From 69de2ee57589470f343a9436e0bd1fd38f2d699c Mon Sep 17 00:00:00 2001 From: github-actions <> Date: Sun, 30 Jul 2023 15:46:36 +0000 Subject: [PATCH 1/5] Google Java Format --- Examples/postgresql/PostgreSQLExample.java | 2 +- .../client/repositories/PostgreSQLHistoryContextRepository.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Examples/postgresql/PostgreSQLExample.java b/Examples/postgresql/PostgreSQLExample.java index fa5ad9c4e..c399a6d5d 100644 --- a/Examples/postgresql/PostgreSQLExample.java +++ b/Examples/postgresql/PostgreSQLExample.java @@ -187,7 +187,7 @@ public ArkResponse queryPostgres(ArkRequest arkRequest) { new JsonnetArgs( DataType.STRING, pinecone)) // Step 3: Concatenate the Prompt: ${Base Prompt} - - // ${Pinecone Output} + // ${Pinecone Output} .loadOrReload(); // Step 4: Now, pass the prompt to OpenAI ChatCompletion & Add it to the list // which will be returned diff --git a/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/context/client/repositories/PostgreSQLHistoryContextRepository.java b/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/context/client/repositories/PostgreSQLHistoryContextRepository.java index 92437309d..1879eb492 100644 --- a/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/context/client/repositories/PostgreSQLHistoryContextRepository.java +++ b/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/context/client/repositories/PostgreSQLHistoryContextRepository.java @@ -4,6 +4,5 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; - @Repository public interface PostgreSQLHistoryContextRepository extends JpaRepository {} From 19a136888bb0d03765080439bf466c8436a634ac Mon Sep 17 00:00:00 2001 From: github-actions <> Date: Fri, 4 Aug 2023 04:02:47 +0000 Subject: [PATCH 2/5] Google Java Format --- .../main/java/com/edgechain/lib/chains/PineconeRetrieval.java | 1 - .../src/main/java/com/edgechain/lib/chains/RedisRetrieval.java | 1 - 2 files changed, 2 deletions(-) diff --git a/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/PineconeRetrieval.java b/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/PineconeRetrieval.java index d40e657d8..a01f4af71 100644 --- a/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/PineconeRetrieval.java +++ b/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/PineconeRetrieval.java @@ -9,7 +9,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; - public class PineconeRetrieval extends Retrieval { private final Logger logger = LoggerFactory.getLogger(getClass()); diff --git a/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/RedisRetrieval.java b/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/RedisRetrieval.java index 21e56ec63..c01c03f2d 100644 --- a/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/RedisRetrieval.java +++ b/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/RedisRetrieval.java @@ -10,7 +10,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; - public class RedisRetrieval extends Retrieval { private final Logger logger = LoggerFactory.getLogger(getClass()); From d094bc5089d226917afdeb25cd5321b3a5669d0b Mon Sep 17 00:00:00 2001 From: github-actions <> Date: Wed, 9 Aug 2023 09:05:03 +0000 Subject: [PATCH 3/5] Google Java Format --- Examples/json/JsonFormat.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/json/JsonFormat.java b/Examples/json/JsonFormat.java index 1baaba2ac..d1d7f5aaf 100644 --- a/Examples/json/JsonFormat.java +++ b/Examples/json/JsonFormat.java @@ -111,7 +111,7 @@ public String extract(ArkRequest arkRequest) { if (gptResponse == null || gptResponse.isEmpty()) { System.out.println("ChatGptResponse is null. There was an error processing the request."); return ("ChatGptResponse is empty. There was an error processing the request. Please try" - + " again."); + + " again."); } try { @@ -255,7 +255,7 @@ public Object function(ArkRequest arkRequest) { System.out.println( "ChatGptResponse is null or empty. There was an error processing the request."); return "ChatGptResponse is empty. There was an error processing the request. Please try" - + " again."; + + " again."; } else { try { JsonNode jsonNode = From 01d0f4c495c5399cecda544689a20bac4e30b742 Mon Sep 17 00:00:00 2001 From: github-actions <> Date: Mon, 28 Aug 2023 12:23:26 +0000 Subject: [PATCH 4/5] Google Java Format --- .../main/java/com/edgechain/lib/embeddings/response/Usage.java | 1 - 1 file changed, 1 deletion(-) diff --git a/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/response/Usage.java b/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/response/Usage.java index b4109f6f3..c30c10bbc 100644 --- a/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/response/Usage.java +++ b/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/response/Usage.java @@ -3,7 +3,6 @@ import com.edgechain.lib.response.ArkObject; import org.json.JSONObject; - public class Usage implements ArkObject { long prompt_tokens; From e319a0a56eb97253aaddbefaabd3df86fefbc24e Mon Sep 17 00:00:00 2001 From: ArthSrivastava Date: Sat, 16 Sep 2023 13:08:31 +0530 Subject: [PATCH 5/5] batch insertion join table --- .../lib/endpoint/impl/PostgresEndpoint.java | 14 ++++++++++++ .../lib/index/client/impl/PostgresClient.java | 22 +++++++++++++++++++ .../PostgresClientMetadataRepository.java | 20 +++++++++++++++++ .../lib/retrofit/PostgresService.java | 3 +++ .../controllers/index/PostgresController.java | 7 ++++++ 5 files changed, 66 insertions(+) diff --git a/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/PostgresEndpoint.java b/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/PostgresEndpoint.java index 6b1e3c960..82d1fa89c 100644 --- a/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/PostgresEndpoint.java +++ b/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/PostgresEndpoint.java @@ -60,6 +60,9 @@ public class PostgresEndpoint extends Endpoint { private PostgresLanguage postgresLanguage; + //Join Table + private List idList; + public PostgresEndpoint() {} public PostgresEndpoint(RetryPolicy retryPolicy) { @@ -221,6 +224,10 @@ public PostgresLanguage getPostgresLanguage() { return postgresLanguage; } + public List getIdList() { + return idList; + } + public StringResponse upsert( WordEmbeddings wordEmbeddings, String filename, @@ -273,6 +280,13 @@ public StringResponse insertIntoJoinTable( this.metadataTableNames = List.of(metadataTableName); return this.postgresService.insertIntoJoinTable(this).blockingGet(); } + public StringResponse batchInsertIntoJoinTable( + String metadataTableName, List idList, String metadataId) { + this.idList = idList; + this.metadataId = metadataId; + this.metadataTableNames = List.of(metadataTableName); + return this.postgresService.batchInsertIntoJoinTable(this).blockingGet(); + } public Observable> query( WordEmbeddings wordEmbeddings, PostgresDistanceMetric metric, int topK) { diff --git a/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/client/impl/PostgresClient.java b/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/client/impl/PostgresClient.java index 6d714a38d..7a8395a1d 100644 --- a/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/client/impl/PostgresClient.java +++ b/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/client/impl/PostgresClient.java @@ -198,6 +198,28 @@ public EdgeChain insertIntoJoinTable(PostgresEndpoint postgresEn postgresEndpoint); } + public EdgeChain batchInsertIntoJoinTable(PostgresEndpoint postgresEndpoint) { + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + this.metadataRepository.batchInsertIntoJoinTable( + postgresEndpoint.getTableName(), + postgresEndpoint.getMetadataTableNames().get(0), + postgresEndpoint.getIdList(), + postgresEndpoint.getMetadataId() + ); + + emitter.onNext(new StringResponse("Inserted")); + emitter.onComplete(); + + } catch (final Exception e) { + emitter.onError(e); + } + }), + postgresEndpoint); + } + public EdgeChain> query(PostgresEndpoint postgresEndpoint) { return new EdgeChain<>( diff --git a/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/repositories/PostgresClientMetadataRepository.java b/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/repositories/PostgresClientMetadataRepository.java index 215715923..c3dd37f80 100644 --- a/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/repositories/PostgresClientMetadataRepository.java +++ b/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/repositories/PostgresClientMetadataRepository.java @@ -104,6 +104,26 @@ public void insertIntoJoinTable(PostgresEndpoint postgresEndpoint) { UUID.fromString(postgresEndpoint.getMetadataId()))); } + @Transactional + public void batchInsertIntoJoinTable( + String tableName, String metadataTableName, List idList, String metadataId) { + String joinTableName = tableName + "_join_" + metadataTableName; + List sqlStatements = new ArrayList<>(); + for(String id: idList) { + sqlStatements.add( + String.format( + "INSERT INTO %s (id, metadata_id) VALUES ('%s', '%s') ON CONFLICT (id) DO UPDATE SET" + + " metadata_id = EXCLUDED.metadata_id;", + joinTableName, + UUID.fromString(id), + UUID.fromString(metadataId) + ) + ); + } + jdbcTemplate.batchUpdate(sqlStatements.toArray(new String[0])); + } + + @Transactional(readOnly = true, propagation = Propagation.REQUIRED) public List> queryWithMetadata( String tableName, diff --git a/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/PostgresService.java b/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/PostgresService.java index e548e7803..d46a07f67 100644 --- a/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/PostgresService.java +++ b/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/PostgresService.java @@ -33,6 +33,9 @@ public interface PostgresService { @POST(value = "index/postgres/join/insert") Single insertIntoJoinTable(@Body PostgresEndpoint postgresEndpoint); + @POST(value = "index/postgres/join/batch-insert") + Single batchInsertIntoJoinTable(@Body PostgresEndpoint postgresEndpoint); + @POST(value = "index/postgres/query") Single> query(@Body PostgresEndpoint postgresEndpoint); diff --git a/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/index/PostgresController.java b/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/index/PostgresController.java index fdab6cef1..6d2f5bb71 100644 --- a/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/index/PostgresController.java +++ b/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/index/PostgresController.java @@ -59,6 +59,13 @@ public Single insertIntoJoinTable( return edgeChain.toSingle(); } + @PostMapping("/join/batch-insert") + public Single batchInsertIntoJoinTable( + @RequestBody PostgresEndpoint postgresEndpoint) { + EdgeChain edgeChain = this.postgresClient.batchInsertIntoJoinTable(postgresEndpoint); + return edgeChain.toSingle(); + } + @PostMapping("/query") public Single> query( @RequestBody PostgresEndpoint postgresEndpoint) {