From 6fa236a7c2f6d9a37193c55b5528fd6aab5af0c9 Mon Sep 17 00:00:00 2001 From: Harsh4902 Date: Mon, 18 Dec 2023 10:53:32 +0530 Subject: [PATCH 1/3] Added Java code into ts branch --- .DS_Store | Bin 8196 -> 8196 bytes JS/.DS_Store | Bin 6148 -> 6148 bytes Java/.DS_Store | Bin 0 -> 6148 bytes Java/Examples/.DS_Store | Bin 8196 -> 8196 bytes Java/Examples/airtable/AirtableExample.java | 134 +++ .../code-interpreter/CodeInterpreter.java | 6 +- Java/Examples/htmx-ui-demo/ChatMessage.java | 60 +- Java/Examples/htmx-ui-demo/User.java | 3 +- Java/Examples/json/JsonFormat.java | 10 +- Java/Examples/pinecone/PineconeExample.java | 149 ++-- .../postgresql/PostgreSQLExample.java | 124 +-- .../react-chain/ReactChainApplication.java | 99 ++- Java/Examples/react-chain/react-chain.jsonnet | 23 +- Java/Examples/redis/RedisExample.java | 135 ++- .../SupabaseMiniLMExample.java | 112 +-- Java/Examples/wiki/WikiExample.java | 65 +- .../wiki/{wiki.jsonnet => wiki1.jsonnet} | 2 +- Java/Examples/wiki/wiki2.jsonnet | 23 + Java/Examples/zapier/ZapierExample.java | 266 ++++++ Java/FlySpring/.DS_Store | Bin 0 -> 6148 bytes .../autoroute/dependency-reduced-pom.xml | 320 +++----- Java/FlySpring/autoroute/pom.xml | 166 ++-- Java/FlySpring/edgechain-app/.DS_Store | Bin 0 -> 6148 bytes Java/FlySpring/edgechain-app/.gitignore | 1 + Java/FlySpring/edgechain-app/chat/README.md | 21 + .../edgechain-app/chat/SimpleApp.java | 83 ++ .../edgechain-app/chat/callserver.sh | 5 + Java/FlySpring/edgechain-app/pom.xml | 772 +++++++++--------- .../com/edgechain/EdgeChainApplication.java | 18 +- .../lib/chains/PineconeRetrieval.java | 80 +- .../lib/chains/PostgresRetrieval.java | 197 +++-- .../edgechain/lib/chains/RedisRetrieval.java | 84 +- .../com/edgechain/lib/chains/Retrieval.java | 6 - .../PostgreSQLConfiguration.java | 19 +- .../lib/configuration/RedisConfiguration.java | 6 +- .../lib/configuration/WebConfiguration.java | 23 +- .../impl/PostgreSQLHistoryContextClient.java | 38 +- .../impl/RedisHistoryContextClient.java | 39 +- .../EmbeddingLoggerController.java | 16 +- .../controllers/JsonnetLoggerController.java | 39 + .../PgHistoryContextController.java | 2 +- .../lib/controllers/PostgresController.java | 9 +- .../lib/controllers/RedisController.java | 2 +- .../RedisHistoryContextController.java | 2 +- .../lib/controllers/SupabaseController.java | 2 +- .../lib/embeddings/WordEmbeddings.java | 41 +- .../embeddings/bgeSmall/BgeSmallClient.java | 34 +- .../lib/embeddings/miniLLM/MiniLMClient.java | 30 +- .../request/OpenAiEmbeddingRequest.java | 2 + .../embeddings/response/OpenAiEmbedding.java | 21 +- .../response/OpenAiEmbeddingResponse.java | 25 +- .../lib/embeddings/response/Usage.java | 11 +- .../com/edgechain/lib/endpoint/Endpoint.java | 8 + .../lib/endpoint/impl/BgeSmallEndpoint.java | 118 --- .../lib/endpoint/impl/PineconeEndpoint.java | 90 -- .../lib/endpoint/impl/PostgresEndpoint.java | 135 --- .../lib/endpoint/impl/RedisEndpoint.java | 126 --- .../PostgreSQLHistoryContextEndpoint.java | 2 +- .../RedisHistoryContextEndpoint.java | 2 +- .../impl/embeddings/BgeSmallEndpoint.java | 120 +++ .../impl/embeddings/EmbeddingEndpoint.java | 64 ++ .../impl/{ => embeddings}/MiniLMEndpoint.java | 34 +- .../embeddings/OpenAiEmbeddingEndpoint.java | 71 ++ .../endpoint/impl/index/PineconeEndpoint.java | 162 ++++ .../endpoint/impl/index/PostgresEndpoint.java | 564 +++++++++++++ .../endpoint/impl/index/RedisEndpoint.java | 190 +++++ .../impl/integration/AirtableEndpoint.java | 182 +++++ .../endpoint/impl/llm/LLamaQuickstart.java | 47 ++ .../lib/endpoint/impl/llm/Llama2Endpoint.java | 180 ++++ .../OpenAiChatEndpoint.java} | 238 ++++-- .../impl/{ => supabase}/SupabaseEndpoint.java | 2 +- .../impl/{ => wiki}/WikiEndpoint.java | 11 +- .../flyfly/commands/run/ProjectRunner.java | 70 +- .../commands/run/TestContainersStarter.java | 211 +++-- .../lib/flyfly/utils/ProjectSetup.java | 6 +- .../lib/index/client/impl/PineconeClient.java | 77 +- .../lib/index/client/impl/PostgresClient.java | 515 ++++++++++-- .../lib/index/client/impl/RedisClient.java | 140 ++-- .../index/domain/PostgresWordEmbeddings.java | 126 ++- .../edgechain/lib/index/domain/RRFWeight.java | 45 + .../edgechain/lib/index/enums/BaseWeight.java | 32 + .../edgechain/lib/index/enums/OrderRRFBy.java | 23 + .../lib/index/enums/PostgresLanguage.java | 43 + .../PostgresClientMetadataRepository.java | 208 +++++ .../PostgresClientRepository.java | 396 +++++++-- .../airtable/client/AirtableClient.java | 188 +++++ .../airtable/query/AirtableQueryBuilder.java | 130 +++ .../integration/airtable/query/SortOrder.java | 25 + .../edgechain/lib/jsonnet/JsonnetArgs.java | 4 +- .../edgechain/lib/jsonnet/JsonnetLoader.java | 67 +- .../lib/jsonnet/XtraSonnetCustomFunc.java | 2 +- .../lib/jsonnet/impl/FileJsonnetLoader.java | 69 +- .../com/edgechain/lib/llama2/LLamaClient.java | 57 ++ .../edgechain/lib/llama2/Llama2Client.java | 89 ++ .../request/LLamaCompletionRequest.java | 88 ++ .../request/Llama2ChatCompletionRequest.java | 67 ++ .../Llama2ChatCompletionResponse.java | 18 + .../edgechain/lib/logger/EmbeddingLogger.java | 5 +- .../edgechain/lib/logger/JsonnetLogger.java | 37 + .../logger/entities/ChatCompletionLog.java | 86 +- .../lib/logger/entities/JsonnetLog.java | 122 +++ .../repositories/JsonnetLogRepository.java | 18 + .../services/ChatCompletionLogService.java | 7 +- .../logger/services/EmbeddingLogService.java | 31 +- .../logger/services/JsonnetLogService.java | 54 ++ .../lib/openai/client/OpenAiClient.java | 27 +- .../providers/OpenAiCompletionProvider.java | 6 +- .../openai/request/ChatCompletionRequest.java | 176 +++- .../lib/openai/request/ChatMessage.java | 15 +- .../response/ChatCompletionResponse.java | 30 +- .../com/edgechain/lib/request/ArkRequest.java | 13 +- .../edgechain/lib/response/ArkEmitter.java | 2 +- .../lib/response/ArkEmitterObserver.java | 1 + .../edgechain/lib/response/ArkObservable.java | 2 +- .../lib/retrofit/AirtableService.java | 29 + .../lib/retrofit/BgeSmallService.java | 2 +- .../edgechain/lib/retrofit/Llama2Service.java | 18 + .../edgechain/lib/retrofit/MiniLMService.java | 2 +- .../edgechain/lib/retrofit/OpenAiService.java | 11 +- .../lib/retrofit/PineconeService.java | 5 +- .../retrofit/PostgreSQLContextService.java | 2 +- .../lib/retrofit/PostgresService.java | 37 +- .../lib/retrofit/RedisContextService.java | 2 +- .../edgechain/lib/retrofit/RedisService.java | 11 +- .../edgechain/lib/retrofit/WikiService.java | 2 +- .../retrofit/client/OpenAiStreamService.java | 10 +- .../client/RetrofitClientInstance.java | 83 +- .../retrofit/logger/JsonnetLoggerService.java | 24 + .../observable/AbstractEdgeChain.java | 17 +- .../transformer/observable/EdgeChain.java | 11 +- .../lib/supabase/security/JwtFilter.java | 7 +- .../lib/supabase/security/JwtHelper.java | 30 +- .../lib/supabase/security/WebSecurity.java | 127 +-- .../edgechain/lib/utils/ContextReorder.java | 50 ++ .../edgechain/lib/wiki/client/WikiClient.java | 2 +- .../bgeSmall/BgeSmallController.java | 10 +- .../PostgreSQLHistoryContextController.java | 2 +- .../RedisHistoryContextController.java | 2 +- .../controllers/index/PineconeController.java | 28 +- .../controllers/index/PostgresController.java | 81 +- .../controllers/index/RedisController.java | 39 +- .../integration/AirtableController.java | 44 + .../controllers/llama2/Llama2Controller.java | 30 + .../logging/EmbeddingLogController.java | 11 +- .../logging/JsonnetLogController.java | 36 + .../controllers/miniLM/MiniLMController.java | 10 +- .../controllers/openai/OpenAiController.java | 165 ++-- .../controllers/wiki/WikiController.java | 2 +- .../resources/application-test.properties | 5 + .../src/main/resources/schema.sql | 5 + .../edgechain/EdgeChainApplicationTest.java | 13 + .../com/edgechain/chunker/ChunkerTest.java | 65 +- .../codeInterpreter/CodeInterpreterTest.java | 14 +- .../edgechain/jsonnet/JsonnetLoaderTest.java | 39 +- .../PostgreSQLHistoryContextClientTest.java | 91 +++ ...ostgreSQLHistoryContextRepositoryTest.java | 85 ++ .../endpoint/impl/BgeSmallEndpointTest.java | 60 ++ .../run/TestContainersStarterTest.java | 105 +++ .../index/client/impl/PostgresClientTest.java | 387 +++++++++ .../services/EmbeddingLogServiceTest.java | 67 ++ .../security/WebSecurityConfigFixTest.java | 119 +++ .../security/WebSecurityContextPathTest.java | 79 ++ .../security/WebSecurityJwtNoRoleTest.java | 96 +++ .../security/WebSecurityJwtWithRoleTest.java | 173 ++++ .../edgechain/openai/OpenAiClientTest.java | 14 +- .../pinecone/PineconeClientTest.java | 105 ++- .../PostgresClientMetadataRepositoryTest.java | 185 +++++ .../edgechain/reactChain/ReactChainTest.java | 49 +- .../testutil/PostgresTestContainer.java | 41 + .../edgechain/testutil/TestConfigSupport.java | 77 ++ .../edgechain/testutil/TestJwtCreator.java | 25 + .../com/edgechain/wiki/WikiClientTest.java | 58 +- .../java/resources/ChatCompletionRequest.json | 23 +- .../src/test/resources/logback-test.xml | 18 + .../org.mockito.plugins.MockMaker | 1 + Java/FlySpring/flyfly/.DS_Store | Bin 0 -> 6148 bytes Java/FlySpring/flyfly/pom.xml | 99 ++- Java/FlySpring/pom.xml | 102 +++ Java/FlySpring/readme.md | 20 +- 179 files changed, 9489 insertions(+), 2672 deletions(-) create mode 100644 Java/.DS_Store create mode 100644 Java/Examples/airtable/AirtableExample.java rename Java/Examples/wiki/{wiki.jsonnet => wiki1.jsonnet} (93%) create mode 100644 Java/Examples/wiki/wiki2.jsonnet create mode 100644 Java/Examples/zapier/ZapierExample.java create mode 100644 Java/FlySpring/.DS_Store create mode 100644 Java/FlySpring/edgechain-app/.DS_Store create mode 100644 Java/FlySpring/edgechain-app/chat/README.md create mode 100644 Java/FlySpring/edgechain-app/chat/SimpleApp.java create mode 100755 Java/FlySpring/edgechain-app/chat/callserver.sh delete mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/Retrieval.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/JsonnetLoggerController.java delete mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/BgeSmallEndpoint.java delete mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/PineconeEndpoint.java delete mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/PostgresEndpoint.java delete mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/RedisEndpoint.java rename Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/{ => context}/PostgreSQLHistoryContextEndpoint.java (96%) rename Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/{ => context}/RedisHistoryContextEndpoint.java (96%) create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/embeddings/BgeSmallEndpoint.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/embeddings/EmbeddingEndpoint.java rename Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/{ => embeddings}/MiniLMEndpoint.java (62%) create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/embeddings/OpenAiEmbeddingEndpoint.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/index/PineconeEndpoint.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/index/PostgresEndpoint.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/index/RedisEndpoint.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/integration/AirtableEndpoint.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/llm/LLamaQuickstart.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/llm/Llama2Endpoint.java rename Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/{OpenAiEndpoint.java => llm/OpenAiChatEndpoint.java} (50%) rename Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/{ => supabase}/SupabaseEndpoint.java (96%) rename Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/{ => wiki}/WikiEndpoint.java (78%) create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/domain/RRFWeight.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/enums/BaseWeight.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/enums/OrderRRFBy.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/enums/PostgresLanguage.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/repositories/PostgresClientMetadataRepository.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/integration/airtable/client/AirtableClient.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/integration/airtable/query/AirtableQueryBuilder.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/integration/airtable/query/SortOrder.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/LLamaClient.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/Llama2Client.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/request/LLamaCompletionRequest.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/request/Llama2ChatCompletionRequest.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/response/Llama2ChatCompletionResponse.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/JsonnetLogger.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/entities/JsonnetLog.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/repositories/JsonnetLogRepository.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/services/JsonnetLogService.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/AirtableService.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/Llama2Service.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/logger/JsonnetLoggerService.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/utils/ContextReorder.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/integration/AirtableController.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/llama2/Llama2Controller.java create mode 100644 Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/logging/JsonnetLogController.java create mode 100644 Java/FlySpring/edgechain-app/src/main/resources/application-test.properties create mode 100644 Java/FlySpring/edgechain-app/src/main/resources/schema.sql create mode 100644 Java/FlySpring/edgechain-app/src/test/java/com/edgechain/EdgeChainApplicationTest.java create mode 100644 Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/context/client/impl/PostgreSQLHistoryContextClientTest.java create mode 100644 Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/context/client/repositories/PostgreSQLHistoryContextRepositoryTest.java create mode 100644 Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/endpoint/impl/BgeSmallEndpointTest.java create mode 100644 Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/flyfly/commands/run/TestContainersStarterTest.java create mode 100644 Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/index/client/impl/PostgresClientTest.java create mode 100644 Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/logger/services/EmbeddingLogServiceTest.java create mode 100644 Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/supabase/security/WebSecurityConfigFixTest.java create mode 100644 Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/supabase/security/WebSecurityContextPathTest.java create mode 100644 Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/supabase/security/WebSecurityJwtNoRoleTest.java create mode 100644 Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/supabase/security/WebSecurityJwtWithRoleTest.java create mode 100644 Java/FlySpring/edgechain-app/src/test/java/com/edgechain/postgres/PostgresClientMetadataRepositoryTest.java create mode 100644 Java/FlySpring/edgechain-app/src/test/java/com/edgechain/testutil/PostgresTestContainer.java create mode 100644 Java/FlySpring/edgechain-app/src/test/java/com/edgechain/testutil/TestConfigSupport.java create mode 100644 Java/FlySpring/edgechain-app/src/test/java/com/edgechain/testutil/TestJwtCreator.java create mode 100644 Java/FlySpring/edgechain-app/src/test/resources/logback-test.xml create mode 100644 Java/FlySpring/edgechain-app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker create mode 100644 Java/FlySpring/flyfly/.DS_Store create mode 100644 Java/FlySpring/pom.xml diff --git a/.DS_Store b/.DS_Store index bf4f94f08fc01464eced51e98aea3997ada47a3e..23e40cb48109ed5e051da226dea4dd71714d460e 100644 GIT binary patch delta 63 zcmZp1XmOa}&nUeyU^hRb^kh2$rOkQ*kxZg23|WrFnaDh`foC(j#9wv*J;4%? delta 38 ucmZp1XmOa}&nUGqU^hRb)MPsWrOkQ*kxZNC3!P@%9K^Ggc{97jUv>cULJWrh diff --git a/JS/.DS_Store b/JS/.DS_Store index c3843fb64324de25f7a3deb0ed05110e2af7d937..8b74a4062e85e354820be5d1925058dad9be1e78 100644 GIT binary patch delta 36 scmZoMXfc@J&&aVcU^g=($7BZuSiOni3#~JH+7_u0O8S)wOfH0Mzgh7`f1xV*IQ7oSdIq08+&29`O&K+T8ql7Z<1{9A`7m wv-U(Db;PeBg(UR_83@O)t=j-{6DLCugDZn0gA0Q%kly^0RgQ5pJI7ys0Ie2A6aWAK diff --git a/Java/.DS_Store b/Java/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d2f94edf45605240e20d1d859157a1d77bdbabda GIT binary patch literal 6148 zcmeHKK~BR!4D_Z!q~g*e2M+rJr2HUMDQBceT)33ds#I!703pFGzkrAE1^&Ym7_Z&Z zl7KiNK(^$ajo03FCQ%#{ksIDkQ=$P8B~ZqwkD)_&owX&AT6ocgJ!)FgjBc0nv}k#o z;WsiM4|hcObWSC0Jim*otV6=l^%*ds4?bm;=aXeM;kC!-_+aa6VEA-k2rU3GhB*l4+)HqbSIiU}L99TW zgaRehX^Y_`9CojMnPMX-;pDXWaC)-S4#kDjvA+-Qse281p+SpkzE9`? literal 0 HcmV?d00001 diff --git a/Java/Examples/.DS_Store b/Java/Examples/.DS_Store index 07e27bb6917f6c8eb0aca133d2e3b86f0c83a7a3..e6c911b09daee02c5aee5132471e6d89497aa8db 100644 GIT binary patch literal 8196 zcmeHMzl#$=6n>-e2%eygdX;Q(m3U(Q0dFtHMihi#W0hY^F1nkImjn+*NF&%NSR7nu zVWF*9*x8Byj9_i&_hyFKnak{LY*cgxX5TXJy?NjJW-@bckBCHbK4=ha5K$eS<+*h{ zJdO3-m)Z$Eas^VrpQuYcN-0T)jrNjt7zhjm1_A?tfxtju;BR06cQ&_r$-S?%;TaeR z4E&c2@c9s-vy8P|C@GH)JY)#~S;Mewct;%|eIhMmEf-2kSInuZ2ccbsE-{31hdyF+ z$XLsTlFFTgawnl93tgcI86AF+G$#=&8J>ZGz`!yCT)Wp%w~uI#W_JDF&$Ed#KYz<- zljW^eFU@I^aT!|-ib?hF*Ww*M6Q1#_rq9yUnc=Uf1L7TwEQ-bsD&GFfyZ|+>=v!M5)Wo_UAG?8{fT`2A_9M8)KEN z2j{v(*9Chs?6p32AOGHutm5VzNJ}hjtUq2Gtfkh)3RhdZcw>N|Qxfk07^g0q*FU;i z8`t|ogUj-_ne$t?@jD#Dd)PQ{yfHW{;@H?% z_wwXZqsKu1kVY=@OP_$;=xmI&cLt-SFILs3cjLyGn%3wE_~YL$&TTjLWxi7!y&eDH zgNc8{rod2U3VEZqO< WZwr^ln0a*WZkM%i|1&{j^;?RO3pePq4OI%9{X;p-{gisD#34#NlV8>Q#>Uh)GX+Tk>oZ%n% z1+IJv|H290?7G2r(h@F+iXCZZ*1I#avu`%pj6+1CJ@W1m)rrVLV_91RTR=R|ZH`Lm zNDWfJp6Hl->OBo*&kg6a&459`AYc$M2p9wm0{;R6xU-q8GwyvoYq&wcAn;!zz~2ux z8p~EHr&_A74lq>$K$bDA2z@RG*v3v}E0t3%F#{6X6jGatw8RkF9OHJX*GlD7OKnaf zEj~oLvPdfwp;m`~Td9+1X=%7Yz#uS>0DoL6ae`KiRY= z51Q!jZ10|&RIQEMcOO3M9)|r$e#D+ZBE9J7ihiDPMs^N|6xSBaP>!*6>e+u~QWbCkl3J%QN|FgW9jzQpJA+Vyut#keV no. of records in each request + queryBuilder.sort("speaker_name", SortOrder.fromValue(sortSpeakerName).getValue()); + queryBuilder.offset(offset); // move to next page by passing offset returned in response; + + // Return only those speakers which have rating Greater Than Eq to 3; + queryBuilder.filterByFormula( + LogicalOperator.GTE, + AirtableFormula.Object.field("rating"), + AirtableFormula.Object.value(3)); + + return new EdgeChain<>(airtableEndpoint.findAll("Speakers", queryBuilder)).getArkResponse(); + } + + @GetMapping("/find") + public ArkResponse findById(ArkRequest arkRequest) { + String id = arkRequest.getQueryParam("id"); + return new EdgeChain<>(airtableEndpoint.findById("Speakers", id)).getArkResponse(); + } + + @PostMapping("/create") + public ArkResponse create(ArkRequest arkRequest) { + + JSONObject body = arkRequest.getBody(); + String speakerName = body.getString("name"); + String designation = body.getString("designation"); + int rating = body.getInt("rating"); + String organization = body.getString("organization"); + String biography = body.getString("biography"); + + // Airtable API doesn't allow to upload blob files directly; therefore, you would require to + // upload it + // to some cloud storage i.e, S3 and then set the URL in Airtable. + + AirtableRecord record = new AirtableRecord(); + record.putField("speaker_name", speakerName); + record.putField("designation", designation); + record.putField("rating", rating); + record.putField("organization", organization); + record.putField("biography", biography); + + return new EdgeChain<>(airtableEndpoint.create("Speakers", record)).getArkResponse(); + } + + @PostMapping("/update") + public ArkResponse update(ArkRequest arkRequest) { + + JSONObject body = arkRequest.getBody(); + String id = body.getString("id"); + String speakerName = body.getString("name"); + String designation = body.getString("designation"); + int rating = body.getInt("rating"); + String organization = body.getString("organization"); + String biography = body.getString("biography"); + + // Airtable API doesn't allow to upload blob files directly; therefore, you would require to + // upload it + // to some cloud storage i.e, S3 and then set the URL in Airtable. + + AirtableRecord record = new AirtableRecord(); + record.setId(id); + record.putField("speaker_name", speakerName); + record.putField("designation", designation); + record.putField("rating", rating); + record.putField("organization", organization); + record.putField("biography", biography); + + return new EdgeChain<>(airtableEndpoint.update("Speakers", record)).getArkResponse(); + } + + @DeleteMapping("/delete") + public ArkResponse delete(ArkRequest arkRequest) { + JSONObject body = arkRequest.getBody(); + String id = body.getString("id"); + return new EdgeChain<>(airtableEndpoint.delete("Speakers", id)).getArkResponse(); + } + } +} diff --git a/Java/Examples/code-interpreter/CodeInterpreter.java b/Java/Examples/code-interpreter/CodeInterpreter.java index 084876a39..cce993b95 100644 --- a/Java/Examples/code-interpreter/CodeInterpreter.java +++ b/Java/Examples/code-interpreter/CodeInterpreter.java @@ -4,6 +4,7 @@ import java.util.concurrent.TimeUnit; +import com.edgechain.lib.endpoint.impl.llm.OpenAiChatEndpoint; import org.json.JSONException; import org.json.JSONObject; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -13,7 +14,6 @@ import org.springframework.web.bind.annotation.RestController; import com.edgechain.lib.codeInterpreter.Eval; -import com.edgechain.lib.endpoint.impl.OpenAiEndpoint; import com.edgechain.lib.jsonnet.JsonnetArgs; import com.edgechain.lib.jsonnet.JsonnetLoader; import com.edgechain.lib.jsonnet.enums.DataType; @@ -28,7 +28,7 @@ public class CodeInterpreter { private static final String OPENAI_AUTH_KEY = ""; - private static OpenAiEndpoint userChatEndpoint; + private static OpenAiChatEndpoint userChatEndpoint; private static final ObjectMapper objectMapper = new ObjectMapper(); private static JsonnetLoader loader = new FileJsonnetLoader("./code-interpreter/code-interpreter.jsonnet"); @@ -48,7 +48,7 @@ public double interpret(ArkRequest arkRequest) throws JSONException { JSONObject json = arkRequest.getBody(); userChatEndpoint = - new OpenAiEndpoint( + new OpenAiChatEndpoint( OPENAI_CHAT_COMPLETION_API, OPENAI_AUTH_KEY, "gpt-3.5-turbo", diff --git a/Java/Examples/htmx-ui-demo/ChatMessage.java b/Java/Examples/htmx-ui-demo/ChatMessage.java index 2f77db2c5..8d0c4b71c 100644 --- a/Java/Examples/htmx-ui-demo/ChatMessage.java +++ b/Java/Examples/htmx-ui-demo/ChatMessage.java @@ -1,30 +1,30 @@ -package com.edgechain; - -public class ChatMessage { - String role; - String content; - - public ChatMessage(String role, String content) { - this.role = role; - this.content = content; - } - - public ChatMessage() {} - - public String getRole() { - return role; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - @Override - public String toString() { - return "ChatMessage{" + "role='" + role + '\'' + ", content='" + content + '\'' + '}'; - } -} +package com.edgechain; + +public class ChatMessage { + String role; + String content; + + public ChatMessage(String role, String content) { + this.role = role; + this.content = content; + } + + public ChatMessage() {} + + public String getRole() { + return role; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + @Override + public String toString() { + return "ChatMessage{" + "role='" + role + '\'' + ", content='" + content + '\'' + '}'; + } +} diff --git a/Java/Examples/htmx-ui-demo/User.java b/Java/Examples/htmx-ui-demo/User.java index a0a76a979..d2ea16502 100644 --- a/Java/Examples/htmx-ui-demo/User.java +++ b/Java/Examples/htmx-ui-demo/User.java @@ -1,5 +1,4 @@ -package com.edgechain; -public class User { +class User { public String email; public String password; diff --git a/Java/Examples/json/JsonFormat.java b/Java/Examples/json/JsonFormat.java index d1d7f5aaf..2e2423138 100644 --- a/Java/Examples/json/JsonFormat.java +++ b/Java/Examples/json/JsonFormat.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.concurrent.TimeUnit; +import com.edgechain.lib.endpoint.impl.llm.OpenAiChatEndpoint; import org.json.JSONObject; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; @@ -17,7 +18,6 @@ import org.springframework.web.client.RestTemplate; import com.edgechain.lib.constants.EndpointConstants; -import com.edgechain.lib.endpoint.impl.OpenAiEndpoint; import com.edgechain.lib.jsonFormat.request.FunctionRequest; import com.edgechain.lib.jsonFormat.request.Message; import com.edgechain.lib.jsonFormat.request.OpenApiFunctionRequest; @@ -41,7 +41,7 @@ public class JsonFormat { // need only for situation endpoint private static final String OPENAI_ORG_ID = ""; - private static OpenAiEndpoint userChatEndpoint; + private static OpenAiChatEndpoint userChatEndpoint; private static JsonnetLoader loader = new FileJsonnetLoader("./json/json-format.jsonnet"); private static JsonnetLoader functionLoader = new FileJsonnetLoader("./json/function.jsonnet"); private static final ObjectMapper objectMapper = new ObjectMapper(); @@ -84,7 +84,7 @@ public class ExampleController { public String extract(ArkRequest arkRequest) { userChatEndpoint = - new OpenAiEndpoint( + new OpenAiChatEndpoint( OPENAI_CHAT_COMPLETION_API, OPENAI_AUTH_KEY, "gpt-3.5-turbo", @@ -129,8 +129,8 @@ public String situation(ArkRequest arkRequest) { JSONObject json = arkRequest.getBody(); - OpenAiEndpoint userChat = - new OpenAiEndpoint( + OpenAiChatEndpoint userChat = + new OpenAiChatEndpoint( EndpointConstants.OPENAI_CHAT_COMPLETION_API, OPENAI_AUTH_KEY, OPENAI_ORG_ID, diff --git a/Java/Examples/pinecone/PineconeExample.java b/Java/Examples/pinecone/PineconeExample.java index 8f98764e6..fda4e6163 100644 --- a/Java/Examples/pinecone/PineconeExample.java +++ b/Java/Examples/pinecone/PineconeExample.java @@ -4,12 +4,13 @@ import static com.edgechain.lib.constants.EndpointConstants.OPENAI_EMBEDDINGS_API; import com.edgechain.lib.chains.PineconeRetrieval; -import com.edgechain.lib.chains.Retrieval; import com.edgechain.lib.context.domain.HistoryContext; import com.edgechain.lib.embeddings.WordEmbeddings; -import com.edgechain.lib.endpoint.impl.OpenAiEndpoint; -import com.edgechain.lib.endpoint.impl.PineconeEndpoint; -import com.edgechain.lib.endpoint.impl.RedisHistoryContextEndpoint; + +import com.edgechain.lib.endpoint.impl.context.RedisHistoryContextEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.OpenAiEmbeddingEndpoint; +import com.edgechain.lib.endpoint.impl.index.PineconeEndpoint; +import com.edgechain.lib.endpoint.impl.llm.OpenAiChatEndpoint; import com.edgechain.lib.jsonnet.JsonnetArgs; import com.edgechain.lib.jsonnet.JsonnetLoader; import com.edgechain.lib.jsonnet.enums.DataType; @@ -19,13 +20,11 @@ import com.edgechain.lib.request.ArkRequest; import com.edgechain.lib.response.ArkResponse; import com.edgechain.lib.rxjava.retry.impl.ExponentialDelay; -import com.edgechain.lib.rxjava.retry.impl.FixedDelay; import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; import java.io.IOException; import java.io.InputStream; import java.util.*; import java.util.concurrent.TimeUnit; -import java.util.stream.IntStream; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; @@ -34,22 +33,19 @@ @SpringBootApplication public class PineconeExample { - private static final String OPENAI_AUTH_KEY = ""; - private static final String PINECONE_AUTH_KEY = ""; - private static final String PINECONE_QUERY_API = ""; - private static final String PINECONE_UPSERT_API = ""; - private static final String PINECONE_DELETE = ""; - - private static OpenAiEndpoint ada002Embedding; - private static OpenAiEndpoint gpt3Endpoint; + private static final String OPENAI_AUTH_KEY = ""; // YOUR OPENAI AUTH KEY + private static final String OPENAI_ORG_ID = ""; // YOUR OPENAI ORG ID - private static PineconeEndpoint upsertPineconeEndpoint; - private static PineconeEndpoint queryPineconeEndpoint; + private static final String PINECONE_AUTH_KEY = ""; + private static final String PINECONE_API = ""; // Only API + private static OpenAiChatEndpoint gpt3Endpoint; + private static OpenAiChatEndpoint gpt3StreamEndpoint; - private static PineconeEndpoint deletePineconeEndpoint; + private static PineconeEndpoint pineconeEndpoint; private static RedisHistoryContextEndpoint contextEndpoint; + // It's recommended to perform localized instantiation for thread-safe approach. private JsonnetLoader queryLoader = new FileJsonnetLoader("./pinecone/pinecone-query.jsonnet"); private JsonnetLoader chatLoader = new FileJsonnetLoader("./pinecone/pinecone-chat.jsonnet"); @@ -65,7 +61,7 @@ public static void main(String[] args) { // Redis Configuration properties.setProperty("redis.url", ""); - properties.setProperty("redis.port", "12285"); + properties.setProperty("redis.port", ""); properties.setProperty("redis.username", "default"); properties.setProperty("redis.password", ""); properties.setProperty("redis.ttl", "3600"); @@ -78,36 +74,41 @@ public static void main(String[] args) { new SpringApplicationBuilder(PineconeExample.class).properties(properties).run(args); - // Variables Initialization ==> Endpoints must be intialized in main method... - ada002Embedding = - new OpenAiEndpoint( - OPENAI_EMBEDDINGS_API, + gpt3Endpoint = + new OpenAiChatEndpoint( + OPENAI_CHAT_COMPLETION_API, OPENAI_AUTH_KEY, - "text-embedding-ada-002", - new ExponentialDelay(3, 3, 2, TimeUnit.SECONDS)); + OPENAI_ORG_ID, + "gpt-3.5-turbo", + "user", + 0.85, + new ExponentialDelay(3, 5, 2, TimeUnit.SECONDS)); - gpt3Endpoint = - new OpenAiEndpoint( + gpt3StreamEndpoint = + new OpenAiChatEndpoint( OPENAI_CHAT_COMPLETION_API, OPENAI_AUTH_KEY, + OPENAI_ORG_ID, "gpt-3.5-turbo", "user", 0.7, + true, new ExponentialDelay(3, 5, 2, TimeUnit.SECONDS)); - upsertPineconeEndpoint = - new PineconeEndpoint( - PINECONE_UPSERT_API, - PINECONE_AUTH_KEY, + OpenAiEmbeddingEndpoint ada002 = + new OpenAiEmbeddingEndpoint( + OPENAI_EMBEDDINGS_API, + OPENAI_AUTH_KEY, + OPENAI_ORG_ID, + "text-embedding-ada-002", new ExponentialDelay(3, 3, 2, TimeUnit.SECONDS)); - queryPineconeEndpoint = + pineconeEndpoint = new PineconeEndpoint( - PINECONE_QUERY_API, PINECONE_AUTH_KEY, new ExponentialDelay(3, 3, 2, TimeUnit.SECONDS)); - - deletePineconeEndpoint = - new PineconeEndpoint( - PINECONE_DELETE, PINECONE_AUTH_KEY, new FixedDelay(4, 5, TimeUnit.SECONDS)); + PINECONE_API, + PINECONE_AUTH_KEY, + ada002, + new ExponentialDelay(3, 3, 2, TimeUnit.SECONDS)); contextEndpoint = new RedisHistoryContextEndpoint(new ExponentialDelay(2, 2, 2, TimeUnit.SECONDS)); @@ -157,46 +158,27 @@ public class PineconeController { // Namespace is optional (if not provided, it will be using Empty String "") @PostMapping("/pinecone/upsert") // /v1/examples/openai/upsert?namespace=machine-learning public void upsertPinecone(ArkRequest arkRequest) throws IOException { - String namespace = arkRequest.getQueryParam("namespace"); InputStream file = arkRequest.getMultiPart("file").getInputStream(); - - // Configure Pinecone - upsertPineconeEndpoint.setNamespace(namespace); - String[] arr = pdfReader.readByChunkSize(file, 512); + PineconeRetrieval retrieval = + new PineconeRetrieval(arr, pineconeEndpoint, namespace, arkRequest); - /** - * Retrieval Class is basically used to generate embeddings & upsert it to VectorDB; If OpenAI - * Embedding Endpoint is not provided; then Doc2Vec constructor is used If the model is not - * provided, then it will emit an error - */ - Retrieval retrieval = - new PineconeRetrieval(upsertPineconeEndpoint, ada002Embedding, arkRequest); - - IntStream.range(0, arr.length).parallel().forEach(i -> retrieval.upsert(arr[i])); + retrieval.upsert(); } @PostMapping(value = "/pinecone/query") public ArkResponse query(ArkRequest arkRequest) { - String namespace = arkRequest.getQueryParam("namespace"); String query = arkRequest.getBody().getString("query"); int topK = arkRequest.getIntQueryParam("topK"); + String namespace = arkRequest.getQueryParam("namespace"); - // Configure Pinecone - queryPineconeEndpoint.setNamespace(namespace); - - // Step 1: Chain ==> Get Embeddings From Input & Then Query To Pinecone - EdgeChain embeddingsChain = - new EdgeChain<>(ada002Embedding.embeddings(query, arkRequest)); - - // Step 2: Chain ==> Query Embeddings from Pinecone + // Chain 1 ==> Query Embeddings from Pinecone EdgeChain> queryChain = - new EdgeChain<>(queryPineconeEndpoint.query(embeddingsChain.get(), topK)); + new EdgeChain<>(pineconeEndpoint.query(query, namespace, topK, arkRequest)); - // Chain 3 ===> Our queryFn passes takes list and passes each response with base prompt to - // OpenAI + // Chain ===> Our queryFn passes takes list and passes each response with base prompt EdgeChain> gpt3Chain = queryChain.transform(wordEmbeddings -> queryFn(wordEmbeddings, arkRequest)); @@ -215,14 +197,8 @@ public ArkResponse chatWithPinecone(ArkRequest arkRequest) { String contextId = arkRequest.getQueryParam("id"); String query = arkRequest.getBody().getString("query"); - String namespace = arkRequest.getQueryParam("namespace"); boolean stream = arkRequest.getBooleanHeader("stream"); - - // Configure Pinecone - queryPineconeEndpoint.setNamespace(namespace); - - // Configure GPT3endpoint - gpt3Endpoint.setStream(stream); + String namespace = arkRequest.getQueryParam("namespace"); // Get HistoryContext HistoryContext historyContext = contextEndpoint.get(contextId); @@ -238,22 +214,19 @@ public ArkResponse chatWithPinecone(ArkRequest arkRequest) { // Extract topK value from JsonnetLoader; int topK = chatLoader.getInt("topK"); - // Chain 1 ==> Get Embeddings From Input - EdgeChain embeddingsChain = - new EdgeChain<>(ada002Embedding.embeddings(query, arkRequest)); - - // Chain 2 ==> Query Embeddings from Pinecone & Then concatenate it (preparing for prompt) - // let's say topK=5; then we concatenate List into a string using String.join method + // Chain 1 ==> Query Embeddings from Pinecone & Then concatenate it (preparing for prompt) EdgeChain> pineconeChain = - new EdgeChain<>(queryPineconeEndpoint.query(embeddingsChain.get(), topK)); + new EdgeChain<>(pineconeEndpoint.query(query, namespace, topK, arkRequest)); - // Chain 3 ===> Transform String of Queries into List + // Chain 2 ===> Transform String of Queries into List + // let's say topK=5; then we concatenate List into a string using String.join method EdgeChain queryChain = new EdgeChain<>(pineconeChain) .transform( pineconeResponse -> { + List wordEmbeddings = pineconeResponse.get(); List queryList = new ArrayList<>(); - pineconeResponse.get().forEach(q -> queryList.add(q.getId())); + wordEmbeddings.forEach(q -> queryList.add(q.getId())); return String.join("\n", queryList); }); @@ -261,16 +234,16 @@ public ArkResponse chatWithPinecone(ArkRequest arkRequest) { EdgeChain promptChain = queryChain.transform(queries -> chatFn(historyContext.getResponse(), queries)); - // Chain 5 ==> Pass the Prompt To Gpt3 - EdgeChain gpt3Chain = - new EdgeChain<>( - gpt3Endpoint.chatCompletion(promptChain.get(), "PineconeChatChain", arkRequest)); - // (FOR NON STREAMING) // If it's not stream ==> // Query(What is the collect stage for data maturity) + OpenAiResponse + Prev. ChatHistory if (!stream) { + // Chain 5 ==> Pass the Prompt To Gpt3 + EdgeChain gpt3Chain = + new EdgeChain<>( + gpt3Endpoint.chatCompletion(promptChain.get(), "RedisChatChain", arkRequest)); + // Chain 6 EdgeChain historyUpdatedChain = gpt3Chain.doOnNext( @@ -287,8 +260,13 @@ public ArkResponse chatWithPinecone(ArkRequest arkRequest) { // For STREAMING Version else { + // Chain 5 ==> Pass the Prompt To Gpt3 + EdgeChain gpt3Chain = + new EdgeChain<>( + gpt3StreamEndpoint.chatCompletion(promptChain.get(), "RedisChatChain", arkRequest)); + /* As the response is in stream, so we will use StringBuilder to append the response - and once GPT chain indicates that it is finished, we will save the following into Postgres + and once GPT chain indicates that it is finished, we will save the following into Redis Query(What is the collect stage for data maturity) + OpenAiResponse + Prev. ChatHistory */ @@ -318,8 +296,7 @@ public ArkResponse chatWithPinecone(ArkRequest arkRequest) { @DeleteMapping("/pinecone/deleteAll") public ArkResponse deletePinecone(ArkRequest arkRequest) { String namespace = arkRequest.getQueryParam("namespace"); - deletePineconeEndpoint.setNamespace(namespace); - return new EdgeChain<>(deletePineconeEndpoint.deleteAll()).getArkResponse(); + return new EdgeChain<>(pineconeEndpoint.deleteAll(namespace)).getArkResponse(); } public List queryFn( diff --git a/Java/Examples/postgresql/PostgreSQLExample.java b/Java/Examples/postgresql/PostgreSQLExample.java index 2c5e0b36c..7b1782e3c 100644 --- a/Java/Examples/postgresql/PostgreSQLExample.java +++ b/Java/Examples/postgresql/PostgreSQLExample.java @@ -4,12 +4,14 @@ import static com.edgechain.lib.constants.EndpointConstants.OPENAI_EMBEDDINGS_API; import com.edgechain.lib.chains.PostgresRetrieval; -import com.edgechain.lib.chains.Retrieval; import com.edgechain.lib.context.domain.HistoryContext; -import com.edgechain.lib.embeddings.WordEmbeddings; -import com.edgechain.lib.endpoint.impl.*; +import com.edgechain.lib.endpoint.impl.context.PostgreSQLHistoryContextEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.OpenAiEmbeddingEndpoint; +import com.edgechain.lib.endpoint.impl.index.PostgresEndpoint; +import com.edgechain.lib.endpoint.impl.llm.OpenAiChatEndpoint; import com.edgechain.lib.index.domain.PostgresWordEmbeddings; import com.edgechain.lib.index.enums.PostgresDistanceMetric; +import com.edgechain.lib.index.enums.PostgresLanguage; import com.edgechain.lib.jsonnet.JsonnetArgs; import com.edgechain.lib.jsonnet.JsonnetLoader; import com.edgechain.lib.jsonnet.enums.DataType; @@ -26,7 +28,6 @@ import java.io.InputStream; import java.util.*; import java.util.concurrent.TimeUnit; -import java.util.stream.IntStream; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -36,13 +37,14 @@ @SpringBootApplication public class PostgreSQLExample { - private static final String OPENAI_AUTH_KEY = ""; - - private static OpenAiEndpoint ada002Embedding; - private static OpenAiEndpoint gpt3Endpoint; + private static final String OPENAI_AUTH_KEY = ""; // YOUR OPENAI AUTH KEY + private static final String OPENAI_ORG_ID = ""; // YOUR OPENAI ORG ID + private static OpenAiChatEndpoint gpt3Endpoint; + private static OpenAiChatEndpoint gpt3StreamEndpoint; private static PostgresEndpoint postgresEndpoint; private static PostgreSQLHistoryContextEndpoint contextEndpoint; + // For thread safe, instantitate it in methods... private JsonnetLoader queryLoader = new FileJsonnetLoader("./postgres/postgres-query.jsonnet"); private JsonnetLoader chatLoader = new FileJsonnetLoader("./postgres/postgres-chat.jsonnet"); @@ -62,30 +64,48 @@ public static void main(String[] args) { // If you want to use PostgreSQL only; then just provide dbHost, dbUsername & dbPassword. // If you haven't specified PostgreSQL, then logs won't be stored. properties.setProperty("postgres.db.host", ""); - properties.setProperty("postgres.db.username", "postgres"); + properties.setProperty("postgres.db.username", ""); properties.setProperty("postgres.db.password", ""); new SpringApplicationBuilder(PostgreSQLExample.class).properties(properties).run(args); - // Variables Initialization ==> Endpoints must be intialized in main method... - ada002Embedding = - new OpenAiEndpoint( - OPENAI_EMBEDDINGS_API, + gpt3Endpoint = + new OpenAiChatEndpoint( + OPENAI_CHAT_COMPLETION_API, OPENAI_AUTH_KEY, - "text-embedding-ada-002", - new ExponentialDelay(3, 3, 2, TimeUnit.SECONDS)); + OPENAI_ORG_ID, + "gpt-3.5-turbo", + "user", + 0.85, + new ExponentialDelay(3, 5, 2, TimeUnit.SECONDS)); - gpt3Endpoint = - new OpenAiEndpoint( + gpt3StreamEndpoint = + new OpenAiChatEndpoint( OPENAI_CHAT_COMPLETION_API, OPENAI_AUTH_KEY, + OPENAI_ORG_ID, "gpt-3.5-turbo", "user", - 0.7, + 0.85, + true, new ExponentialDelay(3, 5, 2, TimeUnit.SECONDS)); + OpenAiEmbeddingEndpoint adaEmbedding = + new OpenAiEmbeddingEndpoint( + OPENAI_EMBEDDINGS_API, + OPENAI_AUTH_KEY, + OPENAI_ORG_ID, + "text-embedding-ada-002", + new ExponentialDelay(3, 3, 2, TimeUnit.SECONDS)); + + // Defining tablename and namespace... postgresEndpoint = - new PostgresEndpoint("spring_vectors", new ExponentialDelay(5, 5, 2, TimeUnit.SECONDS)); + new PostgresEndpoint( + "pg_vectors", + "machine-learning", + adaEmbedding, + new ExponentialDelay(5, 5, 2, TimeUnit.SECONDS)); + contextEndpoint = new PostgreSQLHistoryContextEndpoint(new FixedDelay(2, 3, TimeUnit.SECONDS)); } @@ -136,39 +156,36 @@ public class PostgreSQLController { */ @PostMapping("/postgres/upsert") public void upsert(ArkRequest arkRequest) throws IOException { - - String namespace = arkRequest.getQueryParam("namespace"); String filename = arkRequest.getMultiPart("file").getSubmittedFileName(); InputStream file = arkRequest.getMultiPart("file").getInputStream(); - postgresEndpoint.setNamespace(namespace); - String[] arr = pdfReader.readByChunkSize(file, 512); - final Retrieval retrieval = - new PostgresRetrieval(postgresEndpoint, filename, 1536, ada002Embedding, arkRequest); + PostgresRetrieval retrieval = + new PostgresRetrieval( + arr, postgresEndpoint, 1536, filename, PostgresLanguage.ENGLISH, arkRequest); + + // retrieval.setBatchSize(50); // Modifying batchSize....(Default is 30) - IntStream.range(0, arr.length).parallel().forEach(i -> retrieval.upsert(arr[i])); + // Getting ids from upsertion... Internally, it automatically parallelizes the operation... + List ids = retrieval.upsert(); + + ids.forEach(System.out::println); + + System.out.println("Size: " + ids.size()); // Printing the UUIDs } @PostMapping(value = "/postgres/query") public ArkResponse query(ArkRequest arkRequest) { - String namespace = arkRequest.getQueryParam("namespace"); String query = arkRequest.getBody().getString("query"); int topK = arkRequest.getIntQueryParam("topK"); - postgresEndpoint.setNamespace(namespace); - - // Chain 1==> Get Embeddings From Input & Then Query To PostgreSQL - EdgeChain embeddingsChain = - new EdgeChain<>(ada002Embedding.embeddings(query, arkRequest)); - - // Chain 2 ==> Query Embeddings from PostgreSQL + // Chain 1==> Query Embeddings from PostgreSQL EdgeChain> queryChain = new EdgeChain<>( postgresEndpoint.query( - embeddingsChain.get(), PostgresDistanceMetric.IP, topK, 10)); // defining probes + List.of(query), PostgresDistanceMetric.COSINE, topK, topK, 10, arkRequest)); // Chain 3 ===> Our queryFn passes takes list and passes each response with base prompt to // OpenAI @@ -184,15 +201,9 @@ public ArkResponse chat(ArkRequest arkRequest) { String contextId = arkRequest.getQueryParam("id"); String query = arkRequest.getBody().getString("query"); - String namespace = arkRequest.getQueryParam("namespace"); boolean stream = arkRequest.getBooleanHeader("stream"); - // Configure PostgresEndpoint - postgresEndpoint.setNamespace(namespace); - - gpt3Endpoint.setStream(stream); - // Get HistoryContext HistoryContext historyContext = contextEndpoint.get(contextId); @@ -206,24 +217,23 @@ public ArkResponse chat(ArkRequest arkRequest) { // Extract topK value from JsonnetLoader; int topK = chatLoader.getInt("topK"); - - // Chain 1 ==> Get Embeddings From Input - EdgeChain embeddingsChain = - new EdgeChain<>(ada002Embedding.embeddings(query, arkRequest)); - // Chain 2 ==> Query Embeddings from PostgreSQL & Then concatenate it (preparing for prompt) - // let's say topK=5; then we concatenate List into a string using String.join method + EdgeChain> postgresChain = new EdgeChain<>( - postgresEndpoint.query(embeddingsChain.get(), PostgresDistanceMetric.L2, topK)); + postgresEndpoint.query( + List.of(query), PostgresDistanceMetric.COSINE, topK, topK, arkRequest)); // Chain 3 ===> Transform String of Queries into List + // let's say topK=5; then we concatenate List into a string using String.join method EdgeChain queryChain = new EdgeChain<>(postgresChain) .transform( postgresResponse -> { + List postgresWordEmbeddingsList = + postgresResponse.get(); List queryList = new ArrayList<>(); - postgresResponse.get().forEach(q -> queryList.add(q.getRawText())); + postgresWordEmbeddingsList.forEach(q -> queryList.add(q.getRawText())); return String.join("\n", queryList); }); @@ -231,16 +241,16 @@ public ArkResponse chat(ArkRequest arkRequest) { EdgeChain promptChain = queryChain.transform(queries -> chatFn(historyContext.getResponse(), queries)); - // Chain 5 ==> Pass the Prompt To Gpt3 - EdgeChain gpt3Chain = - new EdgeChain<>( - gpt3Endpoint.chatCompletion(promptChain.get(), "PostgresChatChain", arkRequest)); - // (FOR NON STREAMING) // If it's not stream ==> // Query(What is the collect stage for data maturity) + OpenAiResponse + Prev. ChatHistory if (!stream) { + // Chain 5 ==> Pass the Prompt To Gpt3 + EdgeChain gpt3Chain = + new EdgeChain<>( + gpt3Endpoint.chatCompletion(promptChain.get(), "PostgresChatChain", arkRequest)); + // Chain 6 EdgeChain historyUpdatedChain = gpt3Chain.doOnNext( @@ -257,6 +267,12 @@ public ArkResponse chat(ArkRequest arkRequest) { // For STREAMING Version else { + // Chain 5 ==> Pass the Prompt To Gpt3 + EdgeChain gpt3Chain = + new EdgeChain<>( + gpt3StreamEndpoint.chatCompletion( + promptChain.get(), "PostgresChatChain", arkRequest)); + /* As the response is in stream, so we will use StringBuilder to append the response and once GPT chain indicates that it is finished, we will save the following into Postgres Query(What is the collect stage for data maturity) + OpenAiResponse + Prev. ChatHistory diff --git a/Java/Examples/react-chain/ReactChainApplication.java b/Java/Examples/react-chain/ReactChainApplication.java index b8c848f25..d3e612155 100644 --- a/Java/Examples/react-chain/ReactChainApplication.java +++ b/Java/Examples/react-chain/ReactChainApplication.java @@ -1,6 +1,6 @@ package com.edgechain; -import com.edgechain.lib.endpoint.impl.OpenAiEndpoint; +import com.edgechain.lib.endpoint.impl.llm.OpenAiChatEndpoint; import com.edgechain.lib.jsonnet.JsonnetArgs; import com.edgechain.lib.jsonnet.JsonnetLoader; import com.edgechain.lib.jsonnet.enums.DataType; @@ -9,9 +9,10 @@ import com.edgechain.lib.rxjava.retry.impl.ExponentialDelay; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; import java.util.Properties; import java.util.concurrent.TimeUnit; @@ -22,8 +23,9 @@ public class ReactChainApplication { private static final String OPENAI_AUTH_KEY = ""; - - private static OpenAiEndpoint userChatEndpoint; + private static final String OPENAI_ORG_ID = ""; + private static OpenAiChatEndpoint userChatEndpoint; + private static JsonnetLoader loader = new FileJsonnetLoader("./react-chain/react-chain.jsonnet"); public static void main(String[] args) { System.setProperty("server.port", "8080"); @@ -45,64 +47,83 @@ public static void main(String[] args) { new SpringApplicationBuilder(ReactChainApplication.class).properties(properties).run(args); userChatEndpoint = - new OpenAiEndpoint( + new OpenAiChatEndpoint( OPENAI_CHAT_COMPLETION_API, OPENAI_AUTH_KEY, + OPENAI_ORG_ID, "gpt-3.5-turbo", "user", 0.7, + false, new ExponentialDelay(3, 5, 2, TimeUnit.SECONDS)); } @RestController @RequestMapping("/v1/examples") - public class ExampleController { + public class ReactChainController { - @GetMapping(value = "/react-chain") + @PostMapping(value = "/react-chain") public String reactChain(ArkRequest arkRequest) { String prompt = (String) arkRequest.getBody().get("prompt"); - StringBuilder context = new StringBuilder(); - JsonnetLoader loader = - new FileJsonnetLoader("./react-chain.jsonnet") - .put("context", new JsonnetArgs(DataType.STRING, "This is context")) - .put("gptResponse", new JsonnetArgs(DataType.STRING, "")) - .loadOrReload(); - String preset = loader.get("preset"); - - prompt = preset + " \nQuestion: " + prompt; - - String gptResponse = - userChatEndpoint - .chatCompletion(prompt, "React-Chain", arkRequest) - .blockingFirst() - .getChoices() - .get(0) - .getMessage() - .getContent(); - context.append(prompt); - loader.put("context", new JsonnetArgs(DataType.STRING, context.toString())); + + loader.put("context", new JsonnetArgs(DataType.STRING, "This is context")); + loader.put("gptResponse", new JsonnetArgs(DataType.STRING, "")); + loader.put("question", new JsonnetArgs(DataType.STRING, prompt)); + loader.put("text", new JsonnetArgs(DataType.STRING, "")); + + try { + loader.loadOrReload(); + } catch (Exception e) { + e.printStackTrace(); + return "Please broaden the search query!"; + } + prompt = loader.get("initialPrompt"); + + String gptResponse = gptFn(prompt, arkRequest); + + loader.put("context", new JsonnetArgs(DataType.STRING, prompt)); loader.put("gptResponse", new JsonnetArgs(DataType.STRING, gptResponse)); while (!checkIfFinished(gptResponse)) { - loader.loadOrReload(); + try { + loader.loadOrReload(); + } catch (Exception e) { + return "Please broaden the search query or try again!"; + } + + String observation = loader.get("observation"); + if (observation.isEmpty()) + return "No info found on Wiki! Please broaden the search query or try again!"; + prompt = loader.get("prompt"); - gptResponse = - userChatEndpoint - .chatCompletion(prompt, "React-Chain", arkRequest) - .blockingFirst() - .getChoices() - .get(0) - .getMessage() - .getContent(); - context.append("\n" + prompt); - loader.put("context", new JsonnetArgs(DataType.STRING, context.toString())); + gptResponse = gptFn(prompt, arkRequest); + + loader.put("context", new JsonnetArgs(DataType.STRING, prompt)); loader.put("gptResponse", new JsonnetArgs(DataType.STRING, gptResponse)); } - return gptResponse.substring(gptResponse.indexOf("Finish[") + 7, gptResponse.indexOf("]")); + + // Extracting the final answer + loader.put("text", new JsonnetArgs(DataType.STRING, gptResponse)); + + try { + loader.loadOrReload(); + return loader.get("finalAns"); + } catch (Exception e) { + return "Please broaden the search query or try again!"; + } } private boolean checkIfFinished(String gptResponse) { return gptResponse.contains("Finish"); } + + private String gptFn(String prompt, ArkRequest arkRequest) { + return new EdgeChain<>(userChatEndpoint.chatCompletion(prompt, "React-Chain", arkRequest)) + .get() + .getChoices() + .get(0) + .getMessage() + .getContent(); + } } } diff --git a/Java/Examples/react-chain/react-chain.jsonnet b/Java/Examples/react-chain/react-chain.jsonnet index 5f2c25d20..39f3d5da5 100644 --- a/Java/Examples/react-chain/react-chain.jsonnet +++ b/Java/Examples/react-chain/react-chain.jsonnet @@ -45,6 +45,7 @@ local preset = ||| Action 3: Finish[yes] **ALL THE OBSERVATIONS WILL BE PROVIDED BY THE USER, YOU DON'T HAVE TO PROVIDE ANY OBSERVATION** + Question: {} |||; //To extract action from the response @@ -57,14 +58,27 @@ local extractThought(str) = local thought = xtr.strings.substringAfter(xtr.strings.substringBefore(str, "Action"), ":"); thought; +//Replace the {} in the preset with the question +local updateQueryPrompt(question) = + local updatedPrompt = xtr.replace(preset, '{}', question + "\n"); + updatedPrompt; + +//Extract the final answer +local extractFinalAns(text) = + local finalAns = xtr.strings.substringAfter(xtr.strings.substringBeforeLast(xtr.strings.substringAfter(text, "Finish["), "]"), "["); + finalAns; + +local initialPrompt = updateQueryPrompt(payload.question); local gptResponse = payload.gptResponse; //this will be populated from the java code after the prompt is submitted to gpt local action = extractAction(gptResponse); local thought = extractThought(gptResponse); -local searchResponse = std.substr(callFunction("search")(action), 0, 200); //extract action from response and insert here +local searchResponse = std.substr(callFunction("search")(action), 0, 400); //extract action from response and insert here local observation = xtr.join(["Observation:", searchResponse], ''); -local context = payload.context + "\n" + gptResponse + "\n" + observation; -local prompt = xtr.strings.appendIfMissing(context, "\n" + observation); +local context = payload.context; +local prompt = xtr.join([context, gptResponse, observation], '\n'); +local finalAns = extractFinalAns(payload.text); { + initialPrompt: initialPrompt, observation: observation, thought: thought, action: action, @@ -72,6 +86,7 @@ local prompt = xtr.strings.appendIfMissing(context, "\n" + observation); prompt: prompt, context: context, searchResponse: searchResponse, - gptResponse: gptResponse + gptResponse: gptResponse, + finalAns: finalAns } diff --git a/Java/Examples/redis/RedisExample.java b/Java/Examples/redis/RedisExample.java index 603970750..919b4cfa7 100644 --- a/Java/Examples/redis/RedisExample.java +++ b/Java/Examples/redis/RedisExample.java @@ -4,11 +4,13 @@ import static com.edgechain.lib.constants.EndpointConstants.OPENAI_EMBEDDINGS_API; import com.edgechain.lib.chains.RedisRetrieval; -import com.edgechain.lib.chains.Retrieval; import com.edgechain.lib.chunk.enums.LangType; import com.edgechain.lib.context.domain.HistoryContext; import com.edgechain.lib.embeddings.WordEmbeddings; -import com.edgechain.lib.endpoint.impl.*; +import com.edgechain.lib.endpoint.impl.context.RedisHistoryContextEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.OpenAiEmbeddingEndpoint; +import com.edgechain.lib.endpoint.impl.index.RedisEndpoint; +import com.edgechain.lib.endpoint.impl.llm.OpenAiChatEndpoint; import com.edgechain.lib.index.enums.RedisDistanceMetric; import com.edgechain.lib.jsonnet.JsonnetArgs; import com.edgechain.lib.jsonnet.JsonnetLoader; @@ -25,7 +27,6 @@ import java.io.InputStream; import java.util.*; import java.util.concurrent.TimeUnit; -import java.util.stream.IntStream; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -35,9 +36,12 @@ @SpringBootApplication public class RedisExample { - private static final String OPENAI_AUTH_KEY = ""; - private static OpenAiEndpoint ada002Embedding; - private static OpenAiEndpoint gpt3Endpoint; + private static final String OPENAI_AUTH_KEY = ""; // YOUR OPENAI AUTH KEY + private static final String OPENAI_ORG_ID = ""; // YOUR OPENAI ORG ID + private static OpenAiChatEndpoint gpt3Endpoint; + + private static OpenAiChatEndpoint gpt3StreamEndpoint; + private static RedisEndpoint redisEndpoint; private static RedisHistoryContextEndpoint contextEndpoint; @@ -70,25 +74,42 @@ public static void main(String[] args) { new SpringApplicationBuilder(RedisExample.class).properties(properties).run(args); - // Variables Initialization ==> Endpoints must be intialized in main method... - ada002Embedding = - new OpenAiEndpoint( - OPENAI_EMBEDDINGS_API, + gpt3Endpoint = + new OpenAiChatEndpoint( + OPENAI_CHAT_COMPLETION_API, OPENAI_AUTH_KEY, - "text-embedding-ada-002", - new ExponentialDelay(3, 3, 2, TimeUnit.SECONDS)); + OPENAI_ORG_ID, + "gpt-3.5-turbo", + "user", + 0.85, + new ExponentialDelay(3, 5, 2, TimeUnit.SECONDS)); - gpt3Endpoint = - new OpenAiEndpoint( + gpt3StreamEndpoint = + new OpenAiChatEndpoint( OPENAI_CHAT_COMPLETION_API, OPENAI_AUTH_KEY, + OPENAI_ORG_ID, "gpt-3.5-turbo", "user", - 0.7, + 0.85, + true, new ExponentialDelay(3, 5, 2, TimeUnit.SECONDS)); + OpenAiEmbeddingEndpoint ada002Endpoint = + new OpenAiEmbeddingEndpoint( + OPENAI_EMBEDDINGS_API, + OPENAI_AUTH_KEY, + OPENAI_ORG_ID, + "text-embedding-ada-002", + new ExponentialDelay(3, 3, 2, TimeUnit.SECONDS)); + redisEndpoint = - new RedisEndpoint("vector_index", new ExponentialDelay(3, 3, 2, TimeUnit.SECONDS)); + new RedisEndpoint( + "vector_index", + "machine-learning", + ada002Endpoint, + new ExponentialDelay(3, 3, 2, TimeUnit.SECONDS)); + contextEndpoint = new RedisHistoryContextEndpoint(new ExponentialDelay(2, 2, 2, TimeUnit.SECONDS)); } @@ -123,20 +144,15 @@ public class RedisController { /********************** REDIS WITH OPENAI ****************************/ // Namespace is optional (if not provided, it will be using namespace will be "knowledge") + /** + * Both IndexName & namespace are integral for upsert & performing similarity search; If you are + * creating different namespace; recommended to use different index_name because filtering is + * done by index_name * + */ @PostMapping("/redis/upsert") // /v1/examples/openai/upsert?namespace=machine-learning public void upsert(ArkRequest arkRequest) throws IOException { - - String namespace = arkRequest.getQueryParam("namespace"); InputStream file = arkRequest.getMultiPart("file").getInputStream(); - /** - * Both IndexName & namespace are integral for upsert & performing similarity search; If you - * are creating different namespace; recommended to use different index_name because filtering - * is done by index_name * - */ - // Configure RedisEndpoint - redisEndpoint.setNamespace(namespace); - /** * We have two implementation for Read By Sentence: a) readBySentence(LangType, Your File) * EdgeChains sdk has predefined support to chunk by sentences w.r.t to 5 languages (english, @@ -147,14 +163,12 @@ public void upsert(ArkRequest arkRequest) throws IOException { String[] arr = pdfReader.readBySentence(LangType.EN, file); /** - * Retrieval Class is basically used to generate embeddings & upsert it to VectorDB; If OpenAI - * Embedding Endpoint is not provided; then Doc2Vec constructor is used If the model is not - * provided, then it will emit an error + * Retrieval Class is basically used to generate embeddings & upsert it to VectorDB + * asynchronously...; */ - Retrieval retrieval = - new RedisRetrieval( - redisEndpoint, ada002Embedding, 1536, RedisDistanceMetric.COSINE, arkRequest); - IntStream.range(0, arr.length).parallel().forEach(i -> retrieval.upsert(arr[i])); + RedisRetrieval retrieval = + new RedisRetrieval(arr, redisEndpoint, 1536, RedisDistanceMetric.COSINE, arkRequest); + retrieval.upsert(); } /** @@ -166,19 +180,12 @@ public void upsert(ArkRequest arkRequest) throws IOException { @PostMapping(value = "/redis/similarity-search") public ArkResponse similaritySearch(ArkRequest arkRequest) { - String namespace = arkRequest.getQueryParam("namespace"); String query = arkRequest.getBody().getString("query"); int topK = arkRequest.getIntQueryParam("topK"); - redisEndpoint.setNamespace(namespace); - - // Chain 1 ==> Generate Embeddings Using Ada002 - EdgeChain ada002Chain = - new EdgeChain<>(ada002Embedding.embeddings(query, arkRequest)); - - // Chain 2 ==> Pass those embeddings to Redis & Return Score/values (Similarity search) + // Chain 1 ==> Pass those embeddings to Redis & Return Score/values (Similarity search) EdgeChain> redisQueries = - new EdgeChain<>(redisEndpoint.query(ada002Chain.get(), topK)); + new EdgeChain<>(redisEndpoint.query(query, topK, arkRequest)); return redisQueries.getArkResponse(); } @@ -186,19 +193,12 @@ public ArkResponse similaritySearch(ArkRequest arkRequest) { @PostMapping(value = "/redis/query") public ArkResponse queryRedis(ArkRequest arkRequest) { - String namespace = arkRequest.getQueryParam("namespace"); String query = arkRequest.getBody().getString("query"); int topK = arkRequest.getIntQueryParam("topK"); - redisEndpoint.setNamespace(namespace); - - // Chain 1==> Get Embeddings From Input & Then Query To Redis - EdgeChain embeddingsChain = - new EdgeChain<>(ada002Embedding.embeddings(query, arkRequest)); - - // Chain 2 ==> Query Embeddings from Redis + // Chain 1 ==> Query Embeddings from Redis EdgeChain> queryChain = - new EdgeChain<>(redisEndpoint.query(embeddingsChain.get(), topK)); + new EdgeChain<>(redisEndpoint.query(query, topK, arkRequest)); // Chain 3 ===> Our queryFn passes takes list and passes each response with base prompt to // OpenAI @@ -213,14 +213,8 @@ public ArkResponse chatWithRedis(ArkRequest arkRequest) { String contextId = arkRequest.getQueryParam("id"); String query = arkRequest.getBody().getString("query"); - String namespace = arkRequest.getQueryParam("namespace"); boolean stream = arkRequest.getBooleanHeader("stream"); - // configure GPT3Endpoint - gpt3Endpoint.setStream(stream); - - redisEndpoint.setNamespace(namespace); - // Get HistoryContext HistoryContext historyContext = contextEndpoint.get(contextId); @@ -235,22 +229,20 @@ public ArkResponse chatWithRedis(ArkRequest arkRequest) { // Extract topK value from JsonnetLoader; int topK = chatLoader.getInt("topK"); - // Chain 1 ==> Get Embeddings From Input - EdgeChain embeddingsChain = - new EdgeChain<>(ada002Embedding.embeddings(query, arkRequest)); + // Chain 1==> Query Embeddings from Redis & Then concatenate it (preparing for prompt) - // Chain 2 ==> Query Embeddings from Redis & Then concatenate it (preparing for prompt) - // let's say topK=5; then we concatenate List into a string using String.join method EdgeChain> redisChain = - new EdgeChain<>(redisEndpoint.query(embeddingsChain.get(), topK)); + new EdgeChain<>(redisEndpoint.query(query, topK, arkRequest)); // Chain 3 ===> Transform String of Queries into List + // let's say topK=5; then we concatenate List into a string using String.join method EdgeChain queryChain = new EdgeChain<>(redisChain) .transform( redisResponse -> { + List wordEmbeddings = redisResponse.get(); List queryList = new ArrayList<>(); - redisResponse.get().forEach(q -> queryList.add(q.getId())); + wordEmbeddings.forEach(q -> queryList.add(q.getId())); return String.join("\n", queryList); }); @@ -258,16 +250,16 @@ public ArkResponse chatWithRedis(ArkRequest arkRequest) { EdgeChain promptChain = queryChain.transform(queries -> chatFn(historyContext.getResponse(), queries)); - // Chain 5 ==> Pass the Prompt To Gpt3 - EdgeChain gpt3Chain = - new EdgeChain<>( - gpt3Endpoint.chatCompletion(promptChain.get(), "RedisChatChain", arkRequest)); - // (FOR NON STREAMING) // If it's not stream ==> // Query(What is the collect stage for data maturity) + OpenAiResponse + Prev. ChatHistory if (!stream) { + // Chain 5 ==> Pass the Prompt To Gpt3 + EdgeChain gpt3Chain = + new EdgeChain<>( + gpt3Endpoint.chatCompletion(promptChain.get(), "RedisChatChain", arkRequest)); + // Chain 6 EdgeChain historyUpdatedChain = gpt3Chain.doOnNext( @@ -284,6 +276,11 @@ public ArkResponse chatWithRedis(ArkRequest arkRequest) { // For STREAMING Version else { + // Chain 5 ==> Pass the Prompt To Gpt3 + EdgeChain gpt3Chain = + new EdgeChain<>( + gpt3StreamEndpoint.chatCompletion(promptChain.get(), "RedisChatChain", arkRequest)); + /* As the response is in stream, so we will use StringBuilder to append the response and once GPT chain indicates that it is finished, we will save the following into Redis Query(What is the collect stage for data maturity) + OpenAiResponse + Prev. ChatHistory diff --git a/Java/Examples/supabase-miniLM/SupabaseMiniLMExample.java b/Java/Examples/supabase-miniLM/SupabaseMiniLMExample.java index a58cdb94c..dba35663e 100644 --- a/Java/Examples/supabase-miniLM/SupabaseMiniLMExample.java +++ b/Java/Examples/supabase-miniLM/SupabaseMiniLMExample.java @@ -1,13 +1,15 @@ package com.edgechain; import com.edgechain.lib.chains.PostgresRetrieval; -import com.edgechain.lib.chains.Retrieval; import com.edgechain.lib.context.domain.HistoryContext; -import com.edgechain.lib.embeddings.WordEmbeddings; import com.edgechain.lib.embeddings.miniLLM.enums.MiniLMModel; -import com.edgechain.lib.endpoint.impl.*; +import com.edgechain.lib.endpoint.impl.context.PostgreSQLHistoryContextEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.MiniLMEndpoint; +import com.edgechain.lib.endpoint.impl.index.PostgresEndpoint; +import com.edgechain.lib.endpoint.impl.llm.OpenAiChatEndpoint; import com.edgechain.lib.index.domain.PostgresWordEmbeddings; import com.edgechain.lib.index.enums.PostgresDistanceMetric; +import com.edgechain.lib.index.enums.PostgresLanguage; import com.edgechain.lib.jsonnet.JsonnetArgs; import com.edgechain.lib.jsonnet.JsonnetLoader; import com.edgechain.lib.jsonnet.enums.DataType; @@ -33,20 +35,19 @@ import java.util.Objects; import java.util.Properties; import java.util.concurrent.TimeUnit; -import java.util.stream.IntStream; import static com.edgechain.lib.constants.EndpointConstants.OPENAI_CHAT_COMPLETION_API; @SpringBootApplication public class SupabaseMiniLMExample { - private static final String OPENAI_AUTH_KEY = ""; + private static final String OPENAI_AUTH_KEY = ""; // YOUR OPENAI AUTH KEY + private static final String OPENAI_ORG_ID = ""; // YOUR OPENAI ORG ID - private static OpenAiEndpoint gpt3Endpoint; + private static OpenAiChatEndpoint gpt3Endpoint; + private static OpenAiChatEndpoint gpt3StreamEndpoint; private static PostgresEndpoint postgresEndpoint; private static PostgreSQLHistoryContextEndpoint contextEndpoint; - private static MiniLMEndpoint miniLMEndpoint; - private JsonnetLoader queryLoader = new FileJsonnetLoader("./supabase-miniLM/postgres-query.jsonnet"); private JsonnetLoader chatLoader = @@ -61,6 +62,9 @@ public static void main(String[] args) { properties.setProperty("supabase.url", ""); properties.setProperty("supabase.annon.key", ""); + // For JWT decode + properties.setProperty("jwt.secret", ""); + // Adding Cors ==> You can configure multiple cors w.r.t your urls.; properties.setProperty("cors.origins", "http://localhost:4200"); @@ -73,18 +77,27 @@ public static void main(String[] args) { properties.setProperty("postgres.db.username", "postgres"); properties.setProperty("postgres.db.password", ""); - // For JWT decode - properties.setProperty("jwt.secret", ""); - new SpringApplicationBuilder(SupabaseMiniLMExample.class).properties(properties).run(args); gpt3Endpoint = - new OpenAiEndpoint( + new OpenAiChatEndpoint( OPENAI_CHAT_COMPLETION_API, OPENAI_AUTH_KEY, + OPENAI_ORG_ID, "gpt-3.5-turbo", "user", - 0.7, + 0.85, + new ExponentialDelay(3, 5, 2, TimeUnit.SECONDS)); + + gpt3StreamEndpoint = + new OpenAiChatEndpoint( + OPENAI_CHAT_COMPLETION_API, + OPENAI_AUTH_KEY, + OPENAI_ORG_ID, + "gpt-3.5-turbo", + "user", + 0.85, + true, new ExponentialDelay(3, 5, 2, TimeUnit.SECONDS)); // Creating MiniLM Endpoint @@ -92,12 +105,16 @@ public static void main(String[] args) { // download on fly. // All the requests will wait until the model is download & loaded once into the application... // As you can see, the model is not download; so it will download on fly... - miniLMEndpoint = new MiniLMEndpoint(MiniLMModel.ALL_MINILM_L12_V2); + MiniLMEndpoint miniLMEndpoint = new MiniLMEndpoint(MiniLMModel.ALL_MINILM_L12_V2); // Creating PostgresEndpoint ==> We create a new table because miniLM supports 384 dimensional // vectors; postgresEndpoint = - new PostgresEndpoint("minilm_vectors", new ExponentialDelay(2, 3, 2, TimeUnit.SECONDS)); + new PostgresEndpoint( + "minilm_vectors", + "minilm-ns", + miniLMEndpoint, + new ExponentialDelay(2, 3, 2, TimeUnit.SECONDS)); contextEndpoint = new PostgreSQLHistoryContextEndpoint(new FixedDelay(2, 3, TimeUnit.SECONDS)); } @@ -150,39 +167,37 @@ public class SupabaseController { @PostMapping("/miniLM/upsert") @PreAuthorize("hasAnyAuthority('authenticated')") public void upsert(ArkRequest arkRequest) throws IOException { - - String namespace = arkRequest.getQueryParam("namespace"); String filename = arkRequest.getMultiPart("file").getSubmittedFileName(); InputStream file = arkRequest.getMultiPart("file").getInputStream(); - postgresEndpoint.setNamespace(namespace); - String[] arr = pdfReader.readByChunkSize(file, 512); - Retrieval retrieval = - new PostgresRetrieval(postgresEndpoint, filename, 384, miniLMEndpoint, arkRequest); + PostgresRetrieval retrieval = + new PostgresRetrieval( + arr, postgresEndpoint, 384, filename, PostgresLanguage.ENGLISH, arkRequest); - IntStream.range(0, arr.length).parallel().forEach(i -> retrieval.upsert(arr[i])); + // retrieval.setBatchSize(50); // Modifying batchSize.... + + // Getting ids from upsertion... Internally, it automatically parallelizes the operation... + List ids = retrieval.upsert(); + + ids.forEach(System.out::println); + + System.out.println("Size: " + ids.size()); // Printing the UUIDs } @PostMapping(value = "/miniLM/query") @PreAuthorize("hasAnyAuthority('authenticated')") public ArkResponse queryPostgres(ArkRequest arkRequest) { - String namespace = arkRequest.getQueryParam("namespace"); String query = arkRequest.getBody().getString("query"); int topK = arkRequest.getIntQueryParam("topK"); - postgresEndpoint.setNamespace(namespace); - - // Chain 1==> Get Embeddings From Input using MiniLM & Then Query To PostgreSQL - EdgeChain embeddingsChain = - new EdgeChain<>(miniLMEndpoint.embeddings(query, arkRequest)); - // Chain 2 ==> Query Embeddings from PostgreSQL EdgeChain> queryChain = new EdgeChain<>( - postgresEndpoint.query(embeddingsChain.get(), PostgresDistanceMetric.L2, topK)); + postgresEndpoint.query( + List.of(query), PostgresDistanceMetric.L2, topK, topK, arkRequest)); // Chain 3 ===> Our queryFn passes takes list and passes each response with base prompt to // OpenAI @@ -199,15 +214,9 @@ public ArkResponse chatWithPostgres(ArkRequest arkRequest) { String contextId = arkRequest.getQueryParam("id"); String query = arkRequest.getBody().getString("query"); - String namespace = arkRequest.getQueryParam("namespace"); boolean stream = arkRequest.getBooleanHeader("stream"); - // Configure PostgresEndpoint - postgresEndpoint.setNamespace(namespace); - - gpt3Endpoint.setStream(stream); - // Get HistoryContext HistoryContext historyContext = contextEndpoint.get(contextId); @@ -222,23 +231,22 @@ public ArkResponse chatWithPostgres(ArkRequest arkRequest) { // Extract topK value from JsonnetLoader; int topK = chatLoader.getInt("topK"); - // Chain 1 ==> Get Embeddings From Input using MiniLM - EdgeChain embeddingsChain = - new EdgeChain<>(miniLMEndpoint.embeddings(query, arkRequest)); - - // Chain 2 ==> Query Embeddings from PostgreSQL & Then concatenate it (preparing for prompt) + // Chain 1 ==> Query Embeddings from PostgreSQL & Then concatenate it (preparing for prompt) // let's say topK=5; then we concatenate List into a string using String.join method EdgeChain> postgresChain = new EdgeChain<>( - postgresEndpoint.query(embeddingsChain.get(), PostgresDistanceMetric.L2, topK)); + postgresEndpoint.query( + List.of(query), PostgresDistanceMetric.L2, topK, topK, arkRequest)); // Chain 3 ===> Transform String of Queries into List EdgeChain queryChain = new EdgeChain<>(postgresChain) .transform( postgresResponse -> { + List postgresWordEmbeddingsList = + postgresResponse.get(); List queryList = new ArrayList<>(); - postgresResponse.get().forEach(q -> queryList.add(q.getRawText())); + postgresWordEmbeddingsList.forEach(q -> queryList.add(q.getRawText())); return String.join("\n", queryList); }); @@ -246,17 +254,17 @@ public ArkResponse chatWithPostgres(ArkRequest arkRequest) { EdgeChain promptChain = queryChain.transform(queries -> chatFn(historyContext.getResponse(), queries)); - // Chain 5 ==> Pass the Prompt To Gpt3 - EdgeChain gpt3Chain = - new EdgeChain<>( - gpt3Endpoint.chatCompletion( - promptChain.get(), "MiniLMPostgresChatChain", arkRequest)); - // (FOR NON STREAMING) // If it's not stream ==> // Query(What is the collect stage for data maturity) + OpenAiResponse + Prev. ChatHistory if (!stream) { + // Chain 5 ==> Pass the Prompt To Gpt3 + EdgeChain gpt3Chain = + new EdgeChain<>( + gpt3Endpoint.chatCompletion( + promptChain.get(), "MiniLMPostgresChatChain", arkRequest)); + // Chain 6 EdgeChain historyUpdatedChain = gpt3Chain.doOnNext( @@ -273,6 +281,12 @@ public ArkResponse chatWithPostgres(ArkRequest arkRequest) { // For STREAMING Version else { + // Chain 5 ==> Pass the Prompt To Gpt3 + EdgeChain gpt3Chain = + new EdgeChain<>( + gpt3StreamEndpoint.chatCompletion( + promptChain.get(), "MiniLMPostgresChatChain", arkRequest)); + /* As the response is in stream, so we will use StringBuilder to append the response and once GPT chain indicates that it is finished, we will save the following into Postgres Query(What is the collect stage for data maturity) + OpenAiResponse + Prev. ChatHistory diff --git a/Java/Examples/wiki/WikiExample.java b/Java/Examples/wiki/WikiExample.java index 7c3d8cab1..feedb984a 100644 --- a/Java/Examples/wiki/WikiExample.java +++ b/Java/Examples/wiki/WikiExample.java @@ -1,7 +1,7 @@ package com.edgechain; -import com.edgechain.lib.endpoint.impl.OpenAiEndpoint; -import com.edgechain.lib.endpoint.impl.WikiEndpoint; +import com.edgechain.lib.endpoint.impl.llm.OpenAiChatEndpoint; +import com.edgechain.lib.endpoint.impl.wiki.WikiEndpoint; import com.edgechain.lib.jsonnet.JsonnetArgs; import com.edgechain.lib.jsonnet.JsonnetLoader; import com.edgechain.lib.jsonnet.enums.DataType; @@ -27,13 +27,19 @@ @SpringBootApplication public class WikiExample { - private static final String OPENAI_AUTH_KEY = ""; + private static final String OPENAI_AUTH_KEY = ""; // YOUR OPENAI AUTH KEY + private static final String OPENAI_ORG_ID = ""; // YOUR OPENAI ORG ID /* Step 3: Create OpenAiEndpoint to communicate with OpenAiServices; */ - private static OpenAiEndpoint gpt4Endpoint; + private static OpenAiChatEndpoint gpt3Endpoint; + + private static OpenAiChatEndpoint gpt3StreamEndpoint; + private static WikiEndpoint wikiEndpoint; - private final JsonnetLoader loader = new FileJsonnetLoader("./wiki/wiki.jsonnet"); + // There is a 70% chance that file1 is executed; 30% chance file2 is executed.... + private final JsonnetLoader loader = + new FileJsonnetLoader(70, "./wiki/wiki1.jsonnet", "./wiki/wiki2.jsonnet"); public static void main(String[] args) { System.setProperty("server.port", "8080"); @@ -48,20 +54,32 @@ public static void main(String[] args) { properties.setProperty("spring.jpa.properties.hibernate.format_sql", "true"); properties.setProperty("postgres.db.host", ""); - properties.setProperty("postgres.db.username", "postgres"); + properties.setProperty("postgres.db.username", ""); properties.setProperty("postgres.db.password", ""); new SpringApplicationBuilder(WikiExample.class).properties(properties).run(args); wikiEndpoint = new WikiEndpoint(); - gpt4Endpoint = - new OpenAiEndpoint( + gpt3Endpoint = + new OpenAiChatEndpoint( + OPENAI_CHAT_COMPLETION_API, + OPENAI_AUTH_KEY, + OPENAI_ORG_ID, + "gpt-3.5-turbo", + "user", + 0.7, + new ExponentialDelay(3, 5, 2, TimeUnit.SECONDS)); + + gpt3StreamEndpoint = + new OpenAiChatEndpoint( OPENAI_CHAT_COMPLETION_API, OPENAI_AUTH_KEY, - "gpt-4", + OPENAI_ORG_ID, + "gpt-3.5-turbo", "user", 0.7, + true, new ExponentialDelay(3, 5, 2, TimeUnit.SECONDS)); } @@ -80,19 +98,11 @@ public ArkResponse wikiSummary(ArkRequest arkRequest) { String query = arkRequest.getQueryParam("query"); boolean stream = arkRequest.getBooleanHeader("stream"); - // Configure GPT4Endpoint - gpt4Endpoint.setStream(stream); - // Chain 1 ==> WikiChain EdgeChain wikiChain = new EdgeChain<>(wikiEndpoint.getPageContent(query)); // Chain 2 ===> Creating Prompt Chain & Return ChatCompletion EdgeChain promptChain = wikiChain.transform(this::fn); - - // Chain 3 ==> Pass Prompt to ChatCompletion API & Return ArkResponseObservable - EdgeChain openAiChain = - new EdgeChain<>(gpt4Endpoint.chatCompletion(promptChain.get(), "WikiChain", arkRequest)); - /** * The best part is flexibility with just one method EdgeChainsSDK will return response either * in json or stream; The real magic happens here. Streaming happens only if your logic allows @@ -101,8 +111,25 @@ public ArkResponse wikiSummary(ArkRequest arkRequest) { // Note: When you call getArkResponse() or getArkStreamResponse() ==> Only then your streams // are executed... - if (stream) return openAiChain.getArkStreamResponse(); - else return openAiChain.getArkResponse(); + if (stream) { + + // Chain 3 ==> Pass Prompt to ChatCompletion API & Return ArkResponseObservable + EdgeChain openAiChain = + new EdgeChain<>( + gpt3StreamEndpoint.chatCompletion( + promptChain.get(), "WikiChain", loader, arkRequest)); + + return openAiChain.getArkStreamResponse(); + + } else { + + // Chain 3 ==> Pass Prompt to ChatCompletion API & Return ArkResponseObservable + EdgeChain openAiChain = + new EdgeChain<>( + gpt3Endpoint.chatCompletion(promptChain.get(), "WikiChain", loader, arkRequest)); + + return openAiChain.getArkResponse(); + } } private String fn(WikiResponse wiki) { diff --git a/Java/Examples/wiki/wiki.jsonnet b/Java/Examples/wiki/wiki1.jsonnet similarity index 93% rename from Java/Examples/wiki/wiki.jsonnet rename to Java/Examples/wiki/wiki1.jsonnet index 051d088ce..347054fdb 100644 --- a/Java/Examples/wiki/wiki.jsonnet +++ b/Java/Examples/wiki/wiki1.jsonnet @@ -12,7 +12,7 @@ local preset = ||| 2. - ... ``` - Now, given the data, create a 30-bullet point summary of: + Now, given the data, create a 5-bullet point summary of: |||; local keepContext = payload.keepContext; local context = if keepContext == "true" then payload.context else ""; diff --git a/Java/Examples/wiki/wiki2.jsonnet b/Java/Examples/wiki/wiki2.jsonnet new file mode 100644 index 000000000..a0c9e064c --- /dev/null +++ b/Java/Examples/wiki/wiki2.jsonnet @@ -0,0 +1,23 @@ +local keepMaxTokens = payload.keepMaxTokens; +local maxTokens = if keepMaxTokens == "true" then payload.maxTokens else 5120; + +local preset = ||| + Just consider yourself as a summary generator bot. You should detect the language and the characters the user is writing in, and reply in the same character set and language. + You should follow the following template while answering the user: + ``` + 1. - + 2. - + ... + ``` + Now, given the data, create a 15-bullet point summary of: + |||; +local keepContext = payload.keepContext; +local context = if keepContext == "true" then payload.context else ""; +local prompt = std.join("\n", [preset, context]); +{ + "maxTokens": maxTokens, + "typeOfKeepContext": xtr.type(keepContext), + "preset" : preset, + "context": context, + "prompt": if(std.length(prompt) > xtr.parseNum(maxTokens)) then std.substr(prompt, 0, xtr.parseNum(maxTokens)) else prompt +} \ No newline at end of file diff --git a/Java/Examples/zapier/ZapierExample.java b/Java/Examples/zapier/ZapierExample.java new file mode 100644 index 000000000..f50c93f40 --- /dev/null +++ b/Java/Examples/zapier/ZapierExample.java @@ -0,0 +1,266 @@ +package com.edgechain; + +// DEPS com.amazonaws:aws-java-sdk-s3:1.12.554 + +import com.amazonaws.auth.AWSStaticCredentialsProvider; +import com.amazonaws.auth.BasicAWSCredentials; +import com.amazonaws.regions.Regions; +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.s3.AmazonS3ClientBuilder; +import com.amazonaws.services.s3.model.ListObjectsV2Request; +import com.amazonaws.services.s3.model.ListObjectsV2Result; +import com.amazonaws.services.s3.model.S3Object; +import com.amazonaws.services.s3.model.S3ObjectSummary; +import com.edgechain.lib.chains.PineconeRetrieval; +import com.edgechain.lib.chunk.Chunker; +import com.edgechain.lib.endpoint.impl.embeddings.OpenAiEmbeddingEndpoint; +import com.edgechain.lib.endpoint.impl.index.PineconeEndpoint; +import com.edgechain.lib.request.ArkRequest; +import com.edgechain.lib.response.ArkResponse; +import com.edgechain.lib.rxjava.retry.impl.ExponentialDelay; +import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; +import me.xuender.unidecode.Unidecode; +import org.apache.commons.io.IOUtils; +import org.json.JSONArray; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.client.WebClient; +import reactor.util.retry.Retry; +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import java.util.concurrent.TimeUnit; +import java.util.stream.IntStream; + +import static com.edgechain.lib.constants.EndpointConstants.OPENAI_EMBEDDINGS_API; + +/** + * Objective (1): 1. Use Zapier Webhook to pass list of urls (in our example, we have used Wikipedia + * Urls") ==> Trigger 2. Action: Use 'Web Page Parser by Zapier' to extract entire content (which is + * later used to upsert in Pinecone) from url 3. Action: Stringify the JSON 4. Action: Save each + * json (parsed content from each URL) to Amazon S3 (This process is entirely automated by Zapier). + * You would need to create Zap for it. Zapier Hook is used to trigger the ETL process, (Parallelize + * Hook Requests)... ========================================================== 5. Then, we extract + * each file from Amazon S3 6. Upsert the normalized content to Pinecone with a chunkSize of 512... + * You can choose any file storage S3, Dropbox, Google Drive etc.... + */ + +/** + * Objective (2): Extracting PDF via PDF4Me. Create a Zapier by using the following steps: 1. + * Trigger ==> Integrate Google Drive Folder; when new file is added (it's not instant; it's + * scheduled internally by Zapier.) (You can also trigger it by Webhook as well) 2. Action ==> + * Extract text from PDF using PDF4Me (Free plan allows 20 API calls) 3. Action ==> Use ZapierByCode + * to stringify the json response from PDF4Me 4. Action ==> Save it to Amazon S3 Now, from + * EdgeChains SDK we extract the files from S3 & upsert it to Pinecone via Chunk Size 512. + */ +@SpringBootApplication +public class ZapierExample { + + private static final String OPENAI_AUTH_KEY = ""; // YOUR OPENAI AUTH KEY + private static final String OPENAI_ORG_ID = ""; // YOUR OPENAI ORG ID + private static final String ZAPIER_HOOK_URL = + ""; // E.g. https://hooks.zapier.com/hooks/catch/18785910/2ia657b + + private static final String PINECONE_AUTH_KEY = ""; + private static final String PINECONE_API = ""; + + private static PineconeEndpoint pineconeEndpoint; + + public static void main(String[] args) { + + System.setProperty("server.port", "8080"); + + new SpringApplicationBuilder(ZapierExample.class).run(args); + + OpenAiEmbeddingEndpoint adaEmbedding = + new OpenAiEmbeddingEndpoint( + OPENAI_EMBEDDINGS_API, + OPENAI_AUTH_KEY, + OPENAI_ORG_ID, + "text-embedding-ada-002", + new ExponentialDelay(3, 3, 2, TimeUnit.SECONDS)); + + pineconeEndpoint = + new PineconeEndpoint( + PINECONE_API, + PINECONE_AUTH_KEY, + adaEmbedding, + new ExponentialDelay(3, 3, 2, TimeUnit.SECONDS)); + } + + @Bean + public AmazonS3 s3Client() { + + String accessKey = ""; // YOUR_AWS_S3_ACCESS_KEY + String secretKey = ""; // YOUR_AWS_S3_SECRET_KEY + + BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey); + return AmazonS3ClientBuilder.standard() + .withRegion(Regions.fromName("us-east-1")) + .withCredentials(new AWSStaticCredentialsProvider(awsCredentials)) + .build(); + } + + @RestController + public class ZapierController { + + @Autowired private AmazonS3 s3Client; + + // List of wiki urls triggered in parallel via WebHook. They are automatically parsed, + // transformed to JSON and stored in AWS S3. + /* + Examples: + "https://en.wikipedia.org/wiki/The_Weather_Company", + "https://en.wikipedia.org/wiki/Microsoft_Bing", + "https://en.wikipedia.org/wiki/Quora", + "https://en.wikipedia.org/wiki/Steve_Jobs", + "https://en.wikipedia.org/wiki/Michael_Jordan", + */ + @PostMapping("/etl") + public void performETL(ArkRequest arkRequest) { + + JSONObject body = arkRequest.getBody(); + JSONArray jsonArray = body.getJSONArray("urls"); + + IntStream.range(0, jsonArray.length()) + .parallel() + .forEach( + index -> { + String url = jsonArray.getString(index); + // For Logging + System.out.printf("Url %s: %s\n", index, url); + + // Trigger Zapier WebHook + this.zapWebHook(url); + }); + } + + @PostMapping("/upsert-urls") + public void upsertParsedURLs(ArkRequest arkRequest) throws IOException { + String namespace = arkRequest.getQueryParam("namespace"); + JSONObject body = arkRequest.getBody(); + String bucketName = body.getString("bucketName"); + + // Get all the files from S3 bucket + ListObjectsV2Request listObjectsRequest = + new ListObjectsV2Request().withBucketName(bucketName); + + ListObjectsV2Result objectListing = s3Client.listObjectsV2(listObjectsRequest); + + for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) { + String key = objectSummary.getKey(); + + if (key.endsWith(".txt")) { + + S3Object object = s3Client.getObject(bucketName, key); + InputStream objectData = object.getObjectContent(); + String content = IOUtils.toString(objectData, StandardCharsets.UTF_8); + + JSONObject jsonObject = new JSONObject(content); + + // These fields are specified from Zapier Action... + System.out.println("Domain: " + jsonObject.getString("domain")); // en.wikipedia.org + System.out.println("Title: " + jsonObject.getString("title")); // Barack Obama + System.out.println("Author: " + jsonObject.getString("author")); // Wikipedia Contributers + System.out.println("Word Count: " + jsonObject.get("word_count")); // 23077 + System.out.println( + "Date Published: " + jsonObject.getString("date_published")); // Publish date + + // Now, we extract content and Chunk it by 512 size; then upsert it to Pinecone + // Normalize the extracted content.... + + String normalizedText = + Unidecode.decode(jsonObject.getString("content")).replaceAll("[\t\n\r]+", " "); + Chunker chunker = new Chunker(normalizedText); + String[] arr = chunker.byChunkSize(512); + + // Upsert to Pinecone: + PineconeRetrieval retrieval = + new PineconeRetrieval(arr, pineconeEndpoint, namespace, arkRequest); + + retrieval.upsert(); + + System.out.println("File is parsed: " + key); // For Logging + } + } + } + + @PostMapping("/upsert-pdfs") + public void upsertPDFs(ArkRequest arkRequest) throws IOException { + String namespace = arkRequest.getQueryParam("namespace"); + JSONObject body = arkRequest.getBody(); + + String bucketName = body.getString("bucketName"); + + // Get all the files from S3 bucket + ListObjectsV2Request listObjectsRequest = + new ListObjectsV2Request().withBucketName(bucketName); + + ListObjectsV2Result objectListing = s3Client.listObjectsV2(listObjectsRequest); + + for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) { + String key = objectSummary.getKey(); + + if (key.endsWith("-pdf.txt")) { + + S3Object object = s3Client.getObject(bucketName, key); + InputStream objectData = object.getObjectContent(); + String content = IOUtils.toString(objectData, StandardCharsets.UTF_8); + + JSONObject jsonObject = new JSONObject(content); + + // These fields are specified from Zapier Action... + // Now, we extract content and Chunk it by 512 size; then upsert it to Pinecone + // Normalize the extracted content.... + + System.out.println("Filename: " + jsonObject.getString("filename")); // abcd.pdf + System.out.println("Extension: " + jsonObject.getString("file_extension")); // pdf + + String normalizedText = + Unidecode.decode(jsonObject.getString("text")).replaceAll("[\t\n\r]+", " "); + Chunker chunker = new Chunker(normalizedText); + String[] arr = chunker.byChunkSize(512); + + // Upsert to Pinecone: + PineconeRetrieval retrieval = + new PineconeRetrieval(arr, pineconeEndpoint, namespace, arkRequest); + + retrieval.upsert(); + + System.out.println("File is parsed: " + key); // For Logging + } + } + } + + @DeleteMapping("/pinecone/deleteAll") + public ArkResponse deletePinecone(ArkRequest arkRequest) { + String namespace = arkRequest.getQueryParam("namespace"); + return new EdgeChain<>(pineconeEndpoint.deleteAll(namespace)).getArkResponse(); + } + + private void zapWebHook(String url) { + + WebClient webClient = WebClient.builder().baseUrl(ZAPIER_HOOK_URL).build(); + + JSONObject json = new JSONObject(); + json.put("url", url); + + webClient + .post() + .contentType(MediaType.APPLICATION_JSON) + .body(BodyInserters.fromValue(json.toString())) + .retrieve() + .bodyToMono(String.class) + .retryWhen(Retry.fixedDelay(3, Duration.ofSeconds(20))) // Using Fixed Delay.. + .block(); + } + } +} diff --git a/Java/FlySpring/.DS_Store b/Java/FlySpring/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b945340c80d2e5dea86deb66d85d5ce4b496a85f GIT binary patch literal 6148 zcmeHKy-veG4ED8ANd-t989?L(kmw9UsKUz97wAt)TPYhK3PoJ=UFRvAzR$_!NHvcdiTeD(RioTOLEfHLr} z7%*Pcj#_vm*IO4Jj(cqY?Lb*LE*G4oU|?G@V!0LXL9M_a@BkP(%mv|r=#PMa_ literal 0 HcmV?d00001 diff --git a/Java/FlySpring/autoroute/dependency-reduced-pom.xml b/Java/FlySpring/autoroute/dependency-reduced-pom.xml index 8bde02dcf..d186c8cb2 100644 --- a/Java/FlySpring/autoroute/dependency-reduced-pom.xml +++ b/Java/FlySpring/autoroute/dependency-reduced-pom.xml @@ -1,205 +1,115 @@ - - - - spring-boot-starter-parent - org.springframework.boot - 3.0.0 - pom.xml - - 4.0.0 - com.flyspring - autoroute-spring-boot-starter - autoroute - 0.1.1-SNAPSHOT - AutoRoute java functions to routes - - - - maven-shade-plugin - 3.4.1 - - - package - - shade - - - - - - - - - - gofly - - - - maven-antrun-plugin - 3.1.0 - - - package - - run - - - - - - - - - - - - - - - - org.junit.jupiter - junit-jupiter-api - 5.9.2 - test - - - opentest4j - org.opentest4j - - - junit-platform-commons - org.junit.platform - - - apiguardian-api - org.apiguardian - - - - - org.mockito - mockito-junit-jupiter - 5.3.0 - test - - - mockito-core - org.mockito - - - - - junit - junit - 4.4 - test - - - org.springframework - spring-mock - 2.0.8 - test - - - commons-io - commons-io - 2.6 - provided - - - org.springframework.boot - spring-boot-starter-webflux - 3.0.5 - provided - - - org.reflections - reflections - 0.9.12 - provided - - - org.springframework.boot - spring-boot-starter-oauth2-resource-server - 3.0.0 - provided - - - org.springframework.security - spring-security-oauth2-jose - 6.0.0 - provided - - - org.glowroot - glowroot-agent-api - 0.13.6 - provided - - - org.projectlombok - lombok - 1.18.24 - provided - true - - - io.reactivex.rxjava3 - rxjava - 3.1.6 - provided - - - io.reactivex - rxjava-reactive-streams - 1.2.1 - provided - - - io.projectreactor.addons - reactor-adapter - 3.5.1 - provided - - - org.apache.pdfbox - pdfbox - 2.0.28 - provided - - - com.squareup.okhttp3 - okhttp - 4.10.0 - provided - - - commons-fileupload - commons-fileupload - 1.5 - provided - - - me.xuender - unidecode - 0.0.7 - provided - - - org.apache.tika - tika-core - 2.7.0 - provided - - - org.apache.tika - tika-parsers-standard-package - 2.7.0 - provided - - - - 17 - 17 - - + + + + edgechain-parent + com.flyspring + 0.0.1-SNAPSHOT + + 4.0.0 + autoroute + autoroute + 0.1.1-SNAPSHOT + AutoRoute java functions to routes + + clean install + + + maven-shade-plugin + ${maven-shade.version} + + + package + + shade + + + + + + + + + gofly + + + + maven-antrun-plugin + 3.1.0 + + + package + + run + + + + + + + + + + + + + + + + org.junit.jupiter + junit-jupiter-api + 5.9.3 + test + + + opentest4j + org.opentest4j + + + junit-platform-commons + org.junit.platform + + + apiguardian-api + org.apiguardian + + + + + org.mockito + mockito-junit-jupiter + 5.3.1 + test + + + mockito-core + org.mockito + + + + + junit + junit + 4.13.2 + test + + + hamcrest-core + org.hamcrest + + + + + org.springframework + spring-mock + 2.0.8 + test + + + + 1.5 + 2.0.28 + 0.13.6 + 0.9.12 + 2.0.8 + + diff --git a/Java/FlySpring/autoroute/pom.xml b/Java/FlySpring/autoroute/pom.xml index 8612af0e4..5694a6799 100644 --- a/Java/FlySpring/autoroute/pom.xml +++ b/Java/FlySpring/autoroute/pom.xml @@ -1,76 +1,84 @@ - + 4.0.0 - com.flyspring - autoroute-spring-boot-starter + + com.flyspring + edgechain-parent + 0.0.1-SNAPSHOT + + + autoroute 0.1.1-SNAPSHOT autoroute AutoRoute java functions to routes - - org.springframework.boot - spring-boot-starter-parent - 3.0.0 - - - 17 - 17 + 1.5 + 0.13.6 + 0.9.12 + 2.0.28 + 2.0.8 org.junit.jupiter junit-jupiter-api - 5.9.2 test + org.mockito mockito-junit-jupiter - 5.3.0 test + junit junit - 4.4 test + org.springframework spring-mock - 2.0.8 + ${spring-mock.version} test + commons-io commons-io - 2.6 + org.springframework.boot spring-boot-starter-webflux - 3.0.5 + org.reflections - reflections - 0.9.12 + reflections + ${org-reflections.version} + org.springframework.boot spring-boot-starter-oauth2-resource-server + org.springframework.security spring-security-oauth2-jose + org.glowroot glowroot-agent-api - 0.13.6 + ${glowroot.version} @@ -82,104 +90,104 @@ io.reactivex.rxjava3 rxjava - 3.1.6 io.reactivex rxjava-reactive-streams - 1.2.1 + ${rxjava-reactive-streams.version} io.projectreactor.addons reactor-adapter - 3.5.1 org.apache.pdfbox pdfbox - 2.0.28 + ${pdfbox.version} com.squareup.okhttp3 okhttp - 4.10.0 - commons-fileupload - commons-fileupload - 1.5 - + commons-fileupload + commons-fileupload + ${commons-fileupload.version} + me.xuender unidecode - 0.0.7 + ${unidecode.version} org.apache.tika tika-core - 2.7.0 + ${apache-tika.version} org.apache.tika tika-parsers-standard-package - 2.7.0 + ${apache-tika.version} - - + - - gofly - - - - maven-antrun-plugin - 3.1.0 - - - package - - - - - - - run - - - - - - - - + + gofly + + true + + + + + maven-antrun-plugin + ${maven-antrun.version} + + + package + + + + + + + run + + + + + + + + + - - - org.apache.maven.plugins - maven-shade-plugin - 3.4.1 - - - - - - package - - shade - - - - - - - + clean install + + + org.apache.maven.plugins + maven-shade-plugin + ${maven-shade.version} + + + package + + shade + + + + + + + \ No newline at end of file diff --git a/Java/FlySpring/edgechain-app/.DS_Store b/Java/FlySpring/edgechain-app/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b0fd969a017dec4f4a28876beaa4bc4f8cbcc46e GIT binary patch literal 6148 zcmeHKy-ve05I(mN3Id^yj2@VQu81L2;R*Tz&{QHrLn{7ei-$l+Y`hC2FTu=;SozLp zT3acMs6uzr`E%}k`IIkF&L$!=x}6S*21Jy@8GD-;Rv72mJJt)4ZJ^SD%jHs&)& zj``G70aZX1ST_aGv)S@3K^;{ARX`P3D8T;*3ui0>Izj*Iz~GMnzzkt;nESmQ&~gA+ z1ayLkz>JgvrPPEYhLLi_ZCFAw|+U9LQqFlKov+8=*#7R z`~T_B=l`@wuT%k5;9n_VvT|IG@JOMzb{>v messages; + + public Conversation() { + messages = new ArrayList<>(); + messages.add( + new ChatMessage( + "system", + "You are a helpful, polite, old English assistant. Answer the user prompt with a bit" + + " of humor.")); + } + + @PostMapping("/gpt/ask") + public ResponseEntity ask(@RequestBody String prompt) { + updateMessageList("user", prompt); + String model = "gpt-3.5-turbo"; + ChatCompletionRequest chatCompletionRequest = + new ChatCompletionRequest( + model, 0.7, // temperature + messages, false, null, null, null, null, null, null, null); + OpenAiClient openAiClient = new OpenAiClient(); + OpenAiEndpoint chatEndpoint = + new OpenAiEndpoint( + OPENAI_CHAT_COMPLETION_API, + OPENAI_AUTH_KEY, + model, + "user", + 0.7, + false, + new ExponentialDelay(3, 3, 2, TimeUnit.SECONDS)); + openAiClient.setEndpoint(chatEndpoint); + EdgeChain chatCompletion = + openAiClient.createChatCompletion(chatCompletionRequest); + String response = chatCompletion.get().getChoices().get(0).getMessage().getContent(); + System.out.println(response); + updateMessageList("assistant", response); + return new ResponseEntity<>(response, HttpStatus.OK); + } + + private void updateMessageList(String role, String content) { + messages.add(new ChatMessage(role, content)); + + if (messages.size() > 20) { + messages.remove(0); + } + } + } +} diff --git a/Java/FlySpring/edgechain-app/chat/callserver.sh b/Java/FlySpring/edgechain-app/chat/callserver.sh new file mode 100755 index 000000000..ec4d2ffa7 --- /dev/null +++ b/Java/FlySpring/edgechain-app/chat/callserver.sh @@ -0,0 +1,5 @@ +curl --location 'localhost:8080/v1/examples/gpt/ask' \ +--header 'Content-Type: application/json' \ +--data '{ + "prompt": "Who was Nikola Tesla?" +}' diff --git a/Java/FlySpring/edgechain-app/pom.xml b/Java/FlySpring/edgechain-app/pom.xml index 27b8f282b..1d66b78e2 100644 --- a/Java/FlySpring/edgechain-app/pom.xml +++ b/Java/FlySpring/edgechain-app/pom.xml @@ -1,378 +1,402 @@ - - 4.0.0 - com.edgechain - edgechain-app - 1.0.0 - edgechain - EdgeChains SDK. - jar - - 17 - 17 - 17 - 0.23.0 - - - - - org.springframework.boot - spring-boot-starter-data-redis - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-security - - - - org.springframework.boot - spring-boot-starter-webflux - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - - - redis.clients - jedis - 4.3.1 - - - - org.postgresql - postgresql - runtime - - - - javax.validation - validation-api - 2.0.1.Final - - - - com.github.f4b6a3 - uuid-creator - 5.2.0 - - - - org.hibernate.validator - hibernate-validator - 6.1.6.Final - - - - org.modelmapper - modelmapper - 3.1.1 - - - - io.jsonwebtoken - jjwt - 0.9.1 - - - - javax.xml.bind - jaxb-api - 2.3.1 - - - - - com.squareup.retrofit2 - retrofit - 2.9.0 - - - - com.squareup.retrofit2 - adapter-rxjava3 - 2.9.0 - - - - com.squareup.retrofit2 - converter-jackson - 2.9.0 - - - - org.apache.opennlp - opennlp-tools - 2.2.0 - - - - io.reactivex.rxjava3 - rxjava - 3.1.6 - - - - io.reactivex - rxjava-reactive-streams - 1.2.1 - - - - io.projectreactor.addons - reactor-adapter - 3.5.1 - - - - me.xuender - unidecode - 0.0.7 - - - - org.apache.tika - tika-core - 2.7.0 - - - - org.apache.tika - tika-parsers-standard-package - 2.7.0 - - - - ai.djl - api - ${djl.version} - - - - ai.djl - basicdataset - ${djl.version} - - - - ai.djl.huggingface - tokenizers - 0.23.0 - - - - ai.djl - model-zoo - ${djl.version} - - - - - - ai.djl.pytorch - pytorch-engine - ${djl.version} - - - - ai.djl.pytorch - pytorch-model-zoo - ${djl.version} - - - - - io.github.jam01 - xtrasonnet - 0.5.3 - - - - com.knuddels - jtokkit - 0.6.1 - - - - net.objecthunter - exp4j - 0.4.8 - - - - - info.picocli - picocli-spring-boot-starter - 4.7.0 - - - - net.lingala.zip4j - zip4j - 2.11.3 - - - - org.zeroturnaround - zt-exec - 1.12 - - - - org.testcontainers - testcontainers - 1.17.6 - - - - org.testcontainers - postgresql - - - - org.springframework.boot - spring-boot-starter-test - test - - - - ai.djl.onnxruntime - onnxruntime-engine - 0.23.0 - runtime - - - - - - - - - - org.springframework.boot - spring-boot-dependencies - 3.1.0 - pom - import - - - - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - org.apache.maven.plugins - maven-shade-plugin - 3.3.0 - - - org.springframework.boot - spring-boot-maven-plugin - 2.7.0 - - - - false - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - - package - - shade - - - edgechain - - - META-INF/spring.handlers - META-INF/spring.schemas + + 4.0.0 + + com.flyspring + edgechain-parent + 0.0.1-SNAPSHOT + + + edgechain-app + 1.0.0 + edgechain + EdgeChains SDK. + jar + + + 4.4.0 + 0.23.0 + 0.4.8 + 6.0.23.Final + 2.3.1 + 0.9.1 + 0.6.1 + 3.1.1 + 2.2.0 + 2.9.0 + 5.2.0 + 2.0.1.Final + 0.5.3 + + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-security + + + + org.springframework.boot + spring-boot-starter-webflux + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + redis.clients + jedis + + + + org.postgresql + postgresql + compile + + + + dev.fuxing + airtable-api + 0.3.2 + + + + javax.validation + validation-api + ${validation-api.version} + + + + com.github.f4b6a3 + uuid-creator + ${uuid-creator.version} + + + + org.hibernate.validator + hibernate-validator + ${hibernate-validator} + + + + org.modelmapper + modelmapper + ${modelmapper.version} + + + + io.jsonwebtoken + jjwt + ${jsonwebtoken.version} + + + + javax.xml.bind + jaxb-api + ${jaxb-api.version} + + + + com.squareup.retrofit2 + retrofit + ${retrofit2.version} + + + + com.squareup.retrofit2 + adapter-rxjava3 + ${retrofit2.version} + + + + com.squareup.retrofit2 + converter-jackson + ${retrofit2.version} + + + + org.apache.opennlp + opennlp-tools + ${opennlp.version} + + + + io.reactivex.rxjava3 + rxjava + + + + io.reactivex + rxjava-reactive-streams + ${rxjava-reactive-streams.version} + + + + io.projectreactor.addons + reactor-adapter + + + + me.xuender + unidecode + ${unidecode.version} + + + + org.apache.tika + tika-core + ${apache-tika.version} + + + + org.apache.tika + tika-parsers-standard-package + ${apache-tika.version} + + + xml-apis + xml-apis + + + + + + ai.djl + api + ${djl.version} + + + + ai.djl + basicdataset + ${djl.version} + + + + ai.djl.huggingface + tokenizers + ${djl.version} + + + + ai.djl + model-zoo + ${djl.version} + + + + + + ai.djl.pytorch + pytorch-engine + ${djl.version} + + + + ai.djl.pytorch + pytorch-model-zoo + ${djl.version} + + + + + io.github.jam01 + xtrasonnet + ${xtrasonnet.version} + + + + com.knuddels + jtokkit + ${jtokkit.version} + + + + net.objecthunter + exp4j + ${exp4j.version} + + + + + info.picocli + picocli-spring-boot-starter + ${picocli.version} + + + + net.lingala.zip4j + zip4j + ${zip4j.version} + + + + org.zeroturnaround + zt-exec + ${zeroturnaround.version} + + + + org.testcontainers + testcontainers + + + + org.testcontainers + postgresql + + + + org.springframework.boot + spring-boot-starter-test + + + com.vaadin.external.google + android-json + + + test + + + + ai.djl.onnxruntime + onnxruntime-engine + ${djl.version} + runtime + + + + org.testcontainers + junit-jupiter + test + + + + com.auth0 + java-jwt + ${auth0-jwt.version} + test + + + + + + + org.apache.maven.plugins + maven-shade-plugin + ${maven-shade.version} + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + + + + false + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + shade-jar-with-dependencies + package + + shade + + + + edgechain + + + META-INF/spring.handlers + META-INF/spring.schemas - - META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports - - - - - com.edgechain.EdgeChainApplication - - - - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.8 - - - download-and-unpack-jbang - generate-resources - - run - - - - - - - - - - - - - - - - - - - - - - - - - - + + META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports + + + + + com.edgechain.EdgeChainApplication + + + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + ${maven-antrun.version} + + + download-and-unpack-jbang + generate-resources + + run + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/EdgeChainApplication.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/EdgeChainApplication.java index 1e00dfc6c..23714c735 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/EdgeChainApplication.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/EdgeChainApplication.java @@ -1,5 +1,7 @@ package com.edgechain; +import java.net.URL; +import java.nio.file.Paths; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; @@ -7,14 +9,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.annotation.Bean; -import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.web.servlet.handler.HandlerMappingIntrospector; -import java.net.URL; -import java.nio.file.Paths; - @SpringBootApplication -@EnableScheduling public class EdgeChainApplication { private static final Logger logger = LoggerFactory.getLogger(EdgeChainApplication.class); @@ -22,8 +19,9 @@ public class EdgeChainApplication { public static void main(String[] args) { logger.info("Please avoid special symbols such as space in naming the directory."); - System.setProperty("jar.name", getJarFileName(EdgeChainApplication.class)); - logger.info("Executed jar file: " + System.getProperty("jar.name")); + String jarFileName = getJarFileName(EdgeChainApplication.class); + System.setProperty("jar.name", jarFileName); + logger.info("Executed jar file: {}", jarFileName); SpringApplication springApplication = new SpringApplicationBuilder() @@ -35,7 +33,7 @@ public static void main(String[] args) { } @Bean(name = "mvcHandlerMappingIntrospector") - public HandlerMappingIntrospector mvcHandlerMappingIntrospector() { + HandlerMappingIntrospector mvcHandlerMappingIntrospector() { return new HandlerMappingIntrospector(); } @@ -44,13 +42,15 @@ private static String getJarFileName(Class clazz) { if (classResource == null) { throw new RuntimeException("class resource is null"); } + String url = classResource.toString(); + logger.info("class url: {}", url); if (url.startsWith("jar:file:")) { String path = url.replaceAll("^jar:(file:.*[.]jar)!/.*", "$1"); try { return Paths.get(new URL(path).toURI()).toString(); } catch (Exception e) { - throw new RuntimeException("Invalid jar file"); + throw new RuntimeException("Invalid jar file", e); } } throw new RuntimeException("Invalid jar file"); diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/PineconeRetrieval.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/PineconeRetrieval.java index e1091f97b..e2d19d6df 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/PineconeRetrieval.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/PineconeRetrieval.java @@ -1,47 +1,79 @@ package com.edgechain.lib.chains; import com.edgechain.lib.embeddings.WordEmbeddings; -import com.edgechain.lib.endpoint.Endpoint; -import com.edgechain.lib.endpoint.impl.MiniLMEndpoint; -import com.edgechain.lib.endpoint.impl.OpenAiEndpoint; -import com.edgechain.lib.endpoint.impl.PineconeEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.BgeSmallEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.MiniLMEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.OpenAiEmbeddingEndpoint; +import com.edgechain.lib.endpoint.impl.index.PineconeEndpoint; import com.edgechain.lib.request.ArkRequest; +import io.reactivex.rxjava3.core.Completable; +import io.reactivex.rxjava3.core.Observable; +import io.reactivex.rxjava3.schedulers.Schedulers; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PineconeRetrieval extends Retrieval { +import java.util.List; - private final Logger logger = LoggerFactory.getLogger(getClass()); +public class PineconeRetrieval { private final PineconeEndpoint pineconeEndpoint; private final ArkRequest arkRequest; - private final Endpoint endpoint; + private final String[] arr; + private String namespace; + private int batchSize = 30; public PineconeRetrieval( - PineconeEndpoint pineconeEndpoint, Endpoint endpoint, ArkRequest arkRequest) { + String[] arr, PineconeEndpoint pineconeEndpoint, String namespace, ArkRequest arkRequest) { this.pineconeEndpoint = pineconeEndpoint; - this.endpoint = endpoint; this.arkRequest = arkRequest; + this.arr = arr; + this.namespace = namespace; - if (endpoint instanceof OpenAiEndpoint openAiEndpoint) + Logger logger = LoggerFactory.getLogger(getClass()); + if (pineconeEndpoint.getEmbeddingEndpoint() instanceof OpenAiEmbeddingEndpoint openAiEndpoint) logger.info("Using OpenAi Embedding Service: " + openAiEndpoint.getModel()); - else if (endpoint instanceof MiniLMEndpoint miniLMEndpoint) + else if (pineconeEndpoint.getEmbeddingEndpoint() instanceof MiniLMEndpoint miniLMEndpoint) logger.info(String.format("Using %s", miniLMEndpoint.getMiniLMModel().getName())); + else if (pineconeEndpoint.getEmbeddingEndpoint() instanceof BgeSmallEndpoint bgeSmallEndpoint) + logger.info(String.format("Using BgeSmall: " + bgeSmallEndpoint.getModelUrl())); } - @Override - public void upsert(String input) { - if (endpoint instanceof OpenAiEndpoint openAiEndpoint) { - WordEmbeddings embeddings = - openAiEndpoint.embeddings(input, arkRequest).firstOrError().blockingGet(); - this.pineconeEndpoint.upsert(embeddings); - } else if (endpoint instanceof MiniLMEndpoint miniLMEndpoint) { - WordEmbeddings embeddings = - miniLMEndpoint.embeddings(input, arkRequest).firstOrError().blockingGet(); - this.pineconeEndpoint.upsert(embeddings); - } else - throw new RuntimeException( - "Invalid Endpoint; Only OpenAIEndpoint & MiniLMEndpoint are supported"); + public void upsert() { + Observable.fromArray(arr) + .buffer(batchSize) + .concatMapCompletable( + batch -> + Observable.fromIterable(batch) + .flatMap( + input -> + Observable.fromCallable(() -> generateEmbeddings(input)) + .subscribeOn(Schedulers.io())) + .toList() + .flatMapCompletable( + wordEmbeddingsList -> + Completable.fromAction(() -> executeBatchUpsert(wordEmbeddingsList)) + .subscribeOn(Schedulers.io()))) + .blockingAwait(); + } + + private WordEmbeddings generateEmbeddings(String input) { + return pineconeEndpoint + .getEmbeddingEndpoint() + .embeddings(input, arkRequest) + .firstOrError() + .blockingGet(); + } + + private void executeBatchUpsert(List wordEmbeddingsList) { + pineconeEndpoint.batchUpsert(wordEmbeddingsList, this.namespace); + } + + public int getBatchSize() { + return batchSize; + } + + public void setBatchSize(int batchSize) { + this.batchSize = batchSize; } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/PostgresRetrieval.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/PostgresRetrieval.java index c888c03c9..48f82c6fe 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/PostgresRetrieval.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/PostgresRetrieval.java @@ -1,93 +1,186 @@ package com.edgechain.lib.chains; import com.edgechain.lib.embeddings.WordEmbeddings; -import com.edgechain.lib.endpoint.Endpoint; -import com.edgechain.lib.endpoint.impl.BgeSmallEndpoint; -import com.edgechain.lib.endpoint.impl.MiniLMEndpoint; -import com.edgechain.lib.endpoint.impl.OpenAiEndpoint; -import com.edgechain.lib.endpoint.impl.PostgresEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.BgeSmallEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.MiniLMEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.OpenAiEmbeddingEndpoint; +import com.edgechain.lib.endpoint.impl.index.PostgresEndpoint; import com.edgechain.lib.index.enums.PostgresDistanceMetric; +import com.edgechain.lib.index.enums.PostgresLanguage; import com.edgechain.lib.request.ArkRequest; +import com.edgechain.lib.response.StringResponse; +import io.reactivex.rxjava3.core.Completable; +import io.reactivex.rxjava3.core.Observable; +import io.reactivex.rxjava3.schedulers.Schedulers; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PostgresRetrieval extends Retrieval { +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.*; +import java.util.stream.Collectors; - private final Logger logger = LoggerFactory.getLogger(getClass()); +public class PostgresRetrieval { - private final PostgresEndpoint postgresEndpoint; - private final int dimensions; + private final Logger logger = LoggerFactory.getLogger(this.getClass()); - private final PostgresDistanceMetric metric; - private final int lists; + private int batchSize = 30; + + private final String[] arr; private final String filename; + private final PostgresLanguage postgresLanguage; + private final ArkRequest arkRequest; - private final Endpoint endpoint; + private final PostgresEndpoint postgresEndpoint; + private final int dimensions; + private final PostgresDistanceMetric metric; + private final int lists; public PostgresRetrieval( + String[] arr, PostgresEndpoint postgresEndpoint, - String filename, int dimensions, - Endpoint endpoint, + PostgresDistanceMetric metric, + int lists, + String filename, + PostgresLanguage postgresLanguage, ArkRequest arkRequest) { - this.postgresEndpoint = postgresEndpoint; - this.dimensions = dimensions; + this.arr = arr; this.filename = filename; - this.endpoint = endpoint; + this.postgresEndpoint = postgresEndpoint; + this.postgresLanguage = postgresLanguage; this.arkRequest = arkRequest; - this.metric = PostgresDistanceMetric.COSINE; - this.lists = 2000; - if (endpoint instanceof OpenAiEndpoint openAiEndpoint) + this.dimensions = dimensions; + this.metric = metric; + this.lists = lists; + + if (postgresEndpoint.getEmbeddingEndpoint() instanceof OpenAiEmbeddingEndpoint openAiEndpoint) logger.info("Using OpenAi Embedding Service: " + openAiEndpoint.getModel()); - else if (endpoint instanceof MiniLMEndpoint miniLMEndpoint) + else if (postgresEndpoint.getEmbeddingEndpoint() instanceof MiniLMEndpoint miniLMEndpoint) logger.info(String.format("Using %s", miniLMEndpoint.getMiniLMModel().getName())); + else if (postgresEndpoint.getEmbeddingEndpoint() instanceof BgeSmallEndpoint bgeSmallEndpoint) + logger.info(String.format("Using BgeSmall: " + bgeSmallEndpoint.getModelUrl())); } public PostgresRetrieval( + String[] arr, PostgresEndpoint postgresEndpoint, - String filename, int dimensions, - Endpoint endpoint, - ArkRequest arkRequest, - PostgresDistanceMetric metric, - int lists) { + String filename, + PostgresLanguage postgresLanguage, + ArkRequest arkRequest) { + this.arr = arr; + this.filename = filename; + this.postgresLanguage = postgresLanguage; this.postgresEndpoint = postgresEndpoint; this.dimensions = dimensions; - this.filename = filename; - this.endpoint = endpoint; + this.metric = PostgresDistanceMetric.COSINE; + this.lists = 1000; this.arkRequest = arkRequest; - this.metric = metric; - this.lists = lists; - if (endpoint instanceof OpenAiEndpoint openAiEndpoint) + if (postgresEndpoint.getEmbeddingEndpoint() instanceof OpenAiEmbeddingEndpoint openAiEndpoint) logger.info("Using OpenAi Embedding Service: " + openAiEndpoint.getModel()); - else if (endpoint instanceof MiniLMEndpoint miniLMEndpoint) + else if (postgresEndpoint.getEmbeddingEndpoint() instanceof MiniLMEndpoint miniLMEndpoint) logger.info(String.format("Using %s", miniLMEndpoint.getMiniLMModel().getName())); + else if (postgresEndpoint.getEmbeddingEndpoint() instanceof BgeSmallEndpoint bgeSmallEndpoint) + logger.info(String.format("Using BgeSmall: " + bgeSmallEndpoint.getModelUrl())); + } + + public List upsert() { + + // Create Table... + this.postgresEndpoint.createTable(dimensions, metric, lists); + + ConcurrentLinkedQueue uuidQueue = new ConcurrentLinkedQueue<>(); + + Observable.fromArray(arr) + .buffer(batchSize) + .concatMapCompletable( + batch -> + Observable.fromIterable(batch) + .flatMap( + input -> + Observable.fromCallable(() -> generateEmbeddings(input)) + .subscribeOn(Schedulers.io())) + .toList() + .flatMapCompletable( + wordEmbeddingsList -> + Completable.fromAction( + () -> upsertAndCollectIds(wordEmbeddingsList, uuidQueue)) + .subscribeOn(Schedulers.io()))) + .blockingAwait(); + + return new ArrayList<>(uuidQueue); + } + + private WordEmbeddings generateEmbeddings(String input) { + return postgresEndpoint + .getEmbeddingEndpoint() + .embeddings(input, arkRequest) + .firstOrError() + .blockingGet(); + } + + private void upsertAndCollectIds( + List wordEmbeddingsList, ConcurrentLinkedQueue uuidQueue) { + List batchUuidList = executeBatchUpsert(wordEmbeddingsList); + uuidQueue.addAll(batchUuidList); + } + + private List executeBatchUpsert(List wordEmbeddingsList) { + return this.postgresEndpoint.upsert(wordEmbeddingsList, filename, postgresLanguage).stream() + .map(StringResponse::getResponse) + .collect(Collectors.toList()); + } + + public List insertMetadata(String metadataTableName) { + + // Create Table... + this.postgresEndpoint.createMetadataTable(metadataTableName); + + ConcurrentLinkedQueue uuidQueue = new ConcurrentLinkedQueue<>(); + + CountDownLatch latch = new CountDownLatch(1); + + Observable.fromArray(arr) + .map(str -> str.replaceAll("'", "")) + .buffer(batchSize) + .flatMapCompletable( + metadataList -> + Completable.fromAction(() -> insertMetadataAndCollectIds(metadataList, uuidQueue))) + .blockingSubscribe(latch::countDown, error -> latch.countDown()); + + return new ArrayList<>(uuidQueue); + } + + public StringResponse insertOneMetadata( + String metadataTableName, String metadata, String documentDate) { + // Create Table... + this.postgresEndpoint.createMetadataTable(metadataTableName); + return this.postgresEndpoint.insertMetadata(metadataTableName, metadata, documentDate); + } + + private void insertMetadataAndCollectIds( + List metadataList, ConcurrentLinkedQueue uuidQueue) { + List batchUuidList = executeBatchInsertMetadata(metadataList); + uuidQueue.addAll(batchUuidList); + } + + private List executeBatchInsertMetadata(List metadataList) { + return this.postgresEndpoint.batchInsertMetadata(metadataList).stream() + .map(StringResponse::getResponse) + .collect(Collectors.toList()); + } + + public int getBatchSize() { + return batchSize; } - @Override - public void upsert(String input) { - - if (endpoint instanceof OpenAiEndpoint openAiEndpoint) { - WordEmbeddings embeddings = - openAiEndpoint.embeddings(input, arkRequest).firstOrError().blockingGet(); - this.postgresEndpoint.upsert( - embeddings, this.filename, this.dimensions, this.metric, this.lists); - } else if (endpoint instanceof MiniLMEndpoint miniLMEndpoint) { - WordEmbeddings embeddings = - miniLMEndpoint.embeddings(input, arkRequest).firstOrError().blockingGet(); - this.postgresEndpoint.upsert( - embeddings, this.filename, this.dimensions, this.metric, this.lists); - } else if (endpoint instanceof BgeSmallEndpoint bgeSmallEndpoint) { - WordEmbeddings embeddings = bgeSmallEndpoint.embeddings(input, arkRequest); - this.postgresEndpoint.upsert( - embeddings, this.filename, this.dimensions, this.metric, this.lists); - } else - throw new RuntimeException( - "Invalid Endpoint; Only OpenAIEndpoint & MiniLMEndpoint are supported"); + public void setBatchSize(int batchSize) { + this.batchSize = batchSize; } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/RedisRetrieval.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/RedisRetrieval.java index 34d4c3d50..35f5d1732 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/RedisRetrieval.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/RedisRetrieval.java @@ -1,55 +1,87 @@ package com.edgechain.lib.chains; import com.edgechain.lib.embeddings.WordEmbeddings; -import com.edgechain.lib.endpoint.Endpoint; -import com.edgechain.lib.endpoint.impl.MiniLMEndpoint; -import com.edgechain.lib.endpoint.impl.OpenAiEndpoint; -import com.edgechain.lib.endpoint.impl.RedisEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.BgeSmallEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.MiniLMEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.OpenAiEmbeddingEndpoint; +import com.edgechain.lib.endpoint.impl.index.RedisEndpoint; import com.edgechain.lib.index.enums.RedisDistanceMetric; import com.edgechain.lib.request.ArkRequest; +import io.reactivex.rxjava3.core.Completable; +import io.reactivex.rxjava3.core.Observable; +import io.reactivex.rxjava3.schedulers.Schedulers; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class RedisRetrieval extends Retrieval { - - private final Logger logger = LoggerFactory.getLogger(getClass()); +import java.util.List; +public class RedisRetrieval { private final RedisEndpoint redisEndpoint; private final ArkRequest arkRequest; - private final Endpoint endpoint; + private final String[] arr; private final int dimension; private final RedisDistanceMetric metric; + private int batchSize = 30; public RedisRetrieval( + String[] arr, RedisEndpoint redisEndpoint, - Endpoint endpoint, int dimension, RedisDistanceMetric metric, ArkRequest arkRequest) { this.redisEndpoint = redisEndpoint; - this.endpoint = endpoint; this.dimension = dimension; this.metric = metric; this.arkRequest = arkRequest; - if (endpoint instanceof OpenAiEndpoint openAiEndpoint) + this.arr = arr; + + Logger logger = LoggerFactory.getLogger(getClass()); + if (redisEndpoint.getEmbeddingEndpoint() instanceof OpenAiEmbeddingEndpoint openAiEndpoint) logger.info("Using OpenAi Embedding Service: " + openAiEndpoint.getModel()); - else if (endpoint instanceof MiniLMEndpoint miniLMEndpoint) + else if (redisEndpoint.getEmbeddingEndpoint() instanceof MiniLMEndpoint miniLMEndpoint) logger.info(String.format("Using %s", miniLMEndpoint.getMiniLMModel().getName())); + else if (redisEndpoint.getEmbeddingEndpoint() instanceof BgeSmallEndpoint bgeSmallEndpoint) + logger.info(String.format("Using BgeSmall: " + bgeSmallEndpoint.getModelUrl())); + } + + public void upsert() { + + this.redisEndpoint.createIndex(redisEndpoint.getNamespace(), dimension, metric); + + Observable.fromArray(arr) + .buffer(batchSize) + .concatMapCompletable( + batch -> + Observable.fromIterable(batch) + .flatMap( + input -> + Observable.fromCallable(() -> generateEmbeddings(input)) + .subscribeOn(Schedulers.io())) + .toList() + .flatMapCompletable( + wordEmbeddingsList -> + Completable.fromAction(() -> executeBatchUpsert(wordEmbeddingsList)) + .subscribeOn(Schedulers.io()))) + .blockingAwait(); + } + + private WordEmbeddings generateEmbeddings(String input) { + return redisEndpoint + .getEmbeddingEndpoint() + .embeddings(input, arkRequest) + .firstOrError() + .blockingGet(); + } + + private void executeBatchUpsert(List wordEmbeddingsList) { + redisEndpoint.batchUpsert(wordEmbeddingsList); + } + + public void setBatchSize(int batchSize) { + this.batchSize = batchSize; } - @Override - public void upsert(String input) { - - if (endpoint instanceof OpenAiEndpoint openAiEndpoint) { - WordEmbeddings embeddings = - openAiEndpoint.embeddings(input, arkRequest).firstOrError().blockingGet(); - this.redisEndpoint.upsert(embeddings, dimension, metric); - } else if (endpoint instanceof MiniLMEndpoint miniLMEndpoint) { - WordEmbeddings embeddings = - miniLMEndpoint.embeddings(input, arkRequest).firstOrError().blockingGet(); - this.redisEndpoint.upsert(embeddings, dimension, metric); - } else - throw new RuntimeException( - "Invalid Endpoint; Only OpenAIEndpoint & MiniLMEndpoint are supported"); + public int getBatchSize() { + return batchSize; } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/Retrieval.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/Retrieval.java deleted file mode 100644 index 39916b97f..000000000 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/chains/Retrieval.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.edgechain.lib.chains; - -public abstract class Retrieval { - - public abstract void upsert(String input); -} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/configuration/PostgreSQLConfiguration.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/configuration/PostgreSQLConfiguration.java index 60945770b..4a547916e 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/configuration/PostgreSQLConfiguration.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/configuration/PostgreSQLConfiguration.java @@ -1,5 +1,6 @@ package com.edgechain.lib.configuration; +import com.zaxxer.hikari.HikariDataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.context.annotation.Bean; @@ -8,7 +9,6 @@ import org.springframework.jdbc.core.JdbcTemplate; import javax.sql.DataSource; -import java.util.Objects; @Configuration public class PostgreSQLConfiguration { @@ -16,34 +16,23 @@ public class PostgreSQLConfiguration { @Autowired private Environment env; @Bean - public DataSource dataSource() { + DataSource dataSource() { String dbHost = env.getProperty("postgres.db.host"); String dbUsername = env.getProperty("postgres.db.username"); String dbPassword = env.getProperty("postgres.db.password"); return DataSourceBuilder.create() + .type(HikariDataSource.class) .url(dbHost) .driverClassName("org.postgresql.Driver") .username(dbUsername) .password(dbPassword) .build(); - - // return DataSourceBuilder.create() - // .type(HikariDataSource.class) - // .url(dbHost) - // .driverClassName("org.postgresql.Driver") - // .username(dbUsername) - // .password(dbPassword) - // .build(); } @Bean - public JdbcTemplate jdbcTemplate() { + JdbcTemplate jdbcTemplate() { return new JdbcTemplate(dataSource()); } - - private boolean nonNullAndNotEmpty(String val) { - return Objects.nonNull(val) && val.trim().isEmpty(); - } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/configuration/RedisConfiguration.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/configuration/RedisConfiguration.java index 947c37cd9..d5c162cea 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/configuration/RedisConfiguration.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/configuration/RedisConfiguration.java @@ -21,7 +21,7 @@ public class RedisConfiguration { @Bean @Lazy - public JedisPooled jedisPooled() { + JedisPooled jedisPooled() { int port = 6379; String host = "127.0.0.1"; @@ -40,7 +40,7 @@ public JedisPooled jedisPooled() { @Bean @Lazy - public JedisConnectionFactory jedisConnectionFactory() { + JedisConnectionFactory jedisConnectionFactory() { int port = 6379; String host = "127.0.0.1"; @@ -63,7 +63,7 @@ public JedisConnectionFactory jedisConnectionFactory() { } @Bean - public RedisTemplate redisTemplate() { + RedisTemplate redisTemplate() { RedisTemplate redisTemplate = new RedisTemplate<>(); redisTemplate.setConnectionFactory(jedisConnectionFactory()); redisTemplate.setKeySerializer(new StringRedisSerializer()); diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/configuration/WebConfiguration.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/configuration/WebConfiguration.java index 519730dc8..f1f580484 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/configuration/WebConfiguration.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/configuration/WebConfiguration.java @@ -3,6 +3,8 @@ import com.edgechain.lib.configuration.domain.AuthFilter; import com.edgechain.lib.configuration.domain.MethodAuthentication; import com.edgechain.lib.configuration.domain.SecurityUUID; +import java.util.List; +import java.util.UUID; import org.modelmapper.ModelMapper; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -10,9 +12,6 @@ import org.springframework.context.annotation.Primary; import org.springframework.web.client.RestTemplate; -import java.util.List; -import java.util.UUID; - @Configuration("WebConfiguration") @Import(EdgeChainAutoConfiguration.class) public class WebConfiguration { @@ -20,29 +19,29 @@ public class WebConfiguration { public static final String CONTEXT_PATH = "/edgechains"; @Bean - public ModelMapper modelMapper() { + ModelMapper modelMapper() { return new ModelMapper(); } @Bean - public RestTemplate restTemplate() { + RestTemplate restTemplate() { return new RestTemplate(); } @Bean @Primary - public SecurityUUID securityUUID() { + SecurityUUID securityUUID() { return new SecurityUUID(UUID.randomUUID().toString()); } @Bean - public AuthFilter authFilter() { + AuthFilter authFilter() { AuthFilter filter = new AuthFilter(); - filter.setRequestPost(new MethodAuthentication(List.of(""), "")); - filter.setRequestGet(new MethodAuthentication(List.of(""), "")); - filter.setRequestDelete(new MethodAuthentication(List.of(""), "")); - filter.setRequestPatch(new MethodAuthentication(List.of(""), "")); - filter.setRequestPut(new MethodAuthentication(List.of(""), "")); + filter.setRequestPost(new MethodAuthentication(List.of("**"), "")); + filter.setRequestGet(new MethodAuthentication(List.of("**"), "")); + filter.setRequestDelete(new MethodAuthentication(List.of("**"), "")); + filter.setRequestPatch(new MethodAuthentication(List.of("**"), "")); + filter.setRequestPut(new MethodAuthentication(List.of("**"), "")); return filter; } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/context/client/impl/PostgreSQLHistoryContextClient.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/context/client/impl/PostgreSQLHistoryContextClient.java index 08b5e7538..e5ab71034 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/context/client/impl/PostgreSQLHistoryContextClient.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/context/client/impl/PostgreSQLHistoryContextClient.java @@ -3,9 +3,11 @@ import com.edgechain.lib.context.client.HistoryContextClient; import com.edgechain.lib.context.client.repositories.PostgreSQLHistoryContextRepository; import com.edgechain.lib.context.domain.HistoryContext; -import com.edgechain.lib.endpoint.impl.PostgreSQLHistoryContextEndpoint; +import com.edgechain.lib.endpoint.impl.context.PostgreSQLHistoryContextEndpoint; import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; import io.reactivex.rxjava3.core.Observable; +import java.time.LocalDateTime; +import java.util.Objects; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -13,14 +15,11 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDateTime; -import java.util.Objects; - @Service public class PostgreSQLHistoryContextClient implements HistoryContextClient { - private Logger logger = LoggerFactory.getLogger(this.getClass()); + private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired private PostgreSQLHistoryContextRepository historyContextRepository; @@ -28,6 +27,7 @@ public class PostgreSQLHistoryContextClient private static final String PREFIX = "historycontext:"; + @Transactional @Override public EdgeChain create(String id, PostgreSQLHistoryContextEndpoint endpoint) { return new EdgeChain<>( @@ -41,6 +41,11 @@ public EdgeChain create(String id, PostgreSQLHistoryContextEndpo this.createTable(); // Create Table IF NOT EXISTS; HistoryContext context = new HistoryContext(PREFIX + id, "", LocalDateTime.now()); + + if (logger.isInfoEnabled()) { + logger.info("{} is added", context.getId()); + } + emitter.onNext(historyContextRepository.save(context)); emitter.onComplete(); @@ -51,6 +56,7 @@ public EdgeChain create(String id, PostgreSQLHistoryContextEndpo endpoint); } + @Transactional @Override public EdgeChain put( String id, String response, PostgreSQLHistoryContextEndpoint endpoint) { @@ -60,11 +66,14 @@ public EdgeChain put( try { HistoryContext historyContext = this.get(id, null).get(); - String input = response.replaceAll("'", ""); + String input = response.replace("'", ""); historyContext.setResponse(input); HistoryContext returnValue = this.historyContextRepository.save(historyContext); - logger.info(String.format("%s is updated", id)); + + if (logger.isInfoEnabled()) { + logger.info("{} is updated", id); + } emitter.onNext(returnValue); emitter.onComplete(); @@ -76,20 +85,23 @@ public EdgeChain put( endpoint); } + @Transactional(readOnly = true) @Override public EdgeChain get(String id, PostgreSQLHistoryContextEndpoint endpoint) { return new EdgeChain<>( Observable.create( emitter -> { try { - emitter.onNext( + final HistoryContext val = this.historyContextRepository .findById(id) .orElseThrow( () -> - new RuntimeException( - "PostgreSQL history_context id isn't found."))); + new RuntimeException("PostgreSQL history_context id isn't found.")); + + emitter.onNext(val); emitter.onComplete(); + } catch (final Exception e) { emitter.onError(e); } @@ -97,6 +109,7 @@ public EdgeChain get(String id, PostgreSQLHistoryContextEndpoint endpoint); } + @Transactional @Override public EdgeChain delete(String id, PostgreSQLHistoryContextEndpoint endpoint) { return new EdgeChain<>( @@ -107,8 +120,13 @@ public EdgeChain delete(String id, PostgreSQLHistoryContextEndpoint endp HistoryContext historyContext = this.get(id, null).get(); this.historyContextRepository.delete(historyContext); + if (logger.isInfoEnabled()) { + logger.info("{} is deleted", id); + } + emitter.onNext(""); emitter.onComplete(); + } catch (final Exception e) { emitter.onError(e); } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/context/client/impl/RedisHistoryContextClient.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/context/client/impl/RedisHistoryContextClient.java index 962839794..c12006cf2 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/context/client/impl/RedisHistoryContextClient.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/context/client/impl/RedisHistoryContextClient.java @@ -1,10 +1,13 @@ package com.edgechain.lib.context.client.impl; -import com.edgechain.lib.context.domain.HistoryContext; import com.edgechain.lib.context.client.HistoryContextClient; -import com.edgechain.lib.endpoint.impl.RedisHistoryContextEndpoint; +import com.edgechain.lib.context.domain.HistoryContext; +import com.edgechain.lib.endpoint.impl.context.RedisHistoryContextEndpoint; import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; import io.reactivex.rxjava3.core.Observable; +import java.time.LocalDateTime; +import java.util.Objects; +import java.util.concurrent.TimeUnit; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -13,25 +16,20 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Repository; -import java.time.LocalDateTime; -import java.util.Objects; -import java.util.concurrent.TimeUnit; - @Repository public class RedisHistoryContextClient implements HistoryContextClient { - private Logger logger = LoggerFactory.getLogger(this.getClass()); + private final Logger logger = LoggerFactory.getLogger(this.getClass()); private static final String PREFIX = "historycontext:"; - @Autowired private RedisTemplate redisTemplate; + @Autowired private RedisTemplate redisTemplate; @Autowired @Lazy private Environment env; @Override public EdgeChain create(String id, RedisHistoryContextEndpoint endpoint) { - return new EdgeChain<>( Observable.create( emitter -> { @@ -54,6 +52,10 @@ public EdgeChain create(String id, RedisHistoryContextEndpoint e this.redisTemplate.expire( key, Long.parseLong(env.getProperty("redis.ttl")), TimeUnit.SECONDS); + if (logger.isInfoEnabled()) { + logger.info("{} is added", key); + } + emitter.onNext(context); emitter.onComplete(); @@ -71,7 +73,6 @@ public EdgeChain put( Observable.create( emitter -> { try { - HistoryContext historyContext = this.get(key, null).get(); historyContext.setResponse(response); @@ -79,7 +80,9 @@ public EdgeChain put( this.redisTemplate.expire( key, Long.parseLong(env.getProperty("redis.ttl")), TimeUnit.SECONDS); - logger.info(String.format("%s is updated", key)); + if (logger.isInfoEnabled()) { + logger.info("{} is updated", key); + } emitter.onNext(historyContext); emitter.onComplete(); @@ -99,9 +102,11 @@ public EdgeChain get(String key, RedisHistoryContextEndpoint end try { Boolean b = this.redisTemplate.hasKey(key); if (Boolean.TRUE.equals(b)) { - emitter.onNext( - Objects.requireNonNull( - (HistoryContext) this.redisTemplate.opsForValue().get(key))); + + HistoryContext obj = (HistoryContext) this.redisTemplate.opsForValue().get(key); + Objects.requireNonNull(obj, "null value not allowed! key " + key); + + emitter.onNext(obj); emitter.onComplete(); } else { emitter.onError(new RuntimeException("Redis history_context id isn't found.")); @@ -116,13 +121,17 @@ public EdgeChain get(String key, RedisHistoryContextEndpoint end @Override public EdgeChain delete(String key, RedisHistoryContextEndpoint endpoint) { - return new EdgeChain<>( Observable.create( emitter -> { try { this.get(key, null).get(); this.redisTemplate.delete(key); + + if (logger.isInfoEnabled()) { + logger.info("{} is deleted", key); + } + emitter.onNext(""); emitter.onComplete(); diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/EmbeddingLoggerController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/EmbeddingLoggerController.java index 2163bc918..821f27339 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/EmbeddingLoggerController.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/EmbeddingLoggerController.java @@ -1,13 +1,15 @@ package com.edgechain.lib.controllers; -import com.edgechain.lib.logger.EmbeddingLogger; import com.edgechain.lib.logger.EmbeddingLogger; import com.edgechain.lib.logger.entities.EmbeddingLog; import java.util.HashMap; -import java.util.Objects; - import org.springframework.data.domain.Page; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/v1/logs/embeddings") @@ -16,8 +18,10 @@ public class EmbeddingLoggerController { private EmbeddingLogger embeddingLogger; private EmbeddingLogger getInstance() { - if (Objects.isNull(embeddingLogger)) return embeddingLogger = new EmbeddingLogger(); - else return embeddingLogger; + if (embeddingLogger == null) { + embeddingLogger = new EmbeddingLogger(); + } + return embeddingLogger; } @GetMapping("/findAll/{page}/{size}") diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/JsonnetLoggerController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/JsonnetLoggerController.java new file mode 100644 index 000000000..8aab8ec9a --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/JsonnetLoggerController.java @@ -0,0 +1,39 @@ +package com.edgechain.lib.controllers; + +import com.edgechain.lib.logger.JsonnetLogger; +import java.util.HashMap; +import java.util.Objects; + +import com.edgechain.lib.logger.entities.JsonnetLog; +import org.springframework.data.domain.Page; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/v1/logs/jsonnet") +public class JsonnetLoggerController { + + private JsonnetLogger jsonnetLogger; + + private JsonnetLogger getInstance() { + if (Objects.isNull(jsonnetLogger)) return jsonnetLogger = new JsonnetLogger(); + else return jsonnetLogger; + } + + @GetMapping("/findAll/{page}/{size}") + public Page findAll(@PathVariable int page, @PathVariable int size) { + return getInstance().findAll(page, size); + } + + @GetMapping("/findAll/sorted/{page}/{size}") + public Page findAllOrderByCompletedAtDesc( + @PathVariable int page, @PathVariable int size) { + return getInstance().findAllOrderByCreatedAtDesc(page, size); + } + + @PostMapping("/findByName/{page}/{size}") + public Page findAllBySelectedFileOrderByCreatedAtDesc( + @RequestBody HashMap mapper, @PathVariable int page, @PathVariable int size) { + return getInstance() + .findAllBySelectedFileOrderByCreatedAtDesc(mapper.get("filename"), page, size); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/PgHistoryContextController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/PgHistoryContextController.java index 1a44017c9..470ec6de3 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/PgHistoryContextController.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/PgHistoryContextController.java @@ -1,7 +1,7 @@ package com.edgechain.lib.controllers; import com.edgechain.lib.context.domain.HistoryContext; -import com.edgechain.lib.endpoint.impl.PostgreSQLHistoryContextEndpoint; +import com.edgechain.lib.endpoint.impl.context.PostgreSQLHistoryContextEndpoint; import com.edgechain.lib.request.ArkRequest; import com.edgechain.lib.rxjava.retry.impl.FixedDelay; import org.json.JSONObject; diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/PostgresController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/PostgresController.java index 166bc7b6f..0352f04a0 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/PostgresController.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/PostgresController.java @@ -1,6 +1,6 @@ package com.edgechain.lib.controllers; -import com.edgechain.lib.endpoint.impl.PostgresEndpoint; +import com.edgechain.lib.endpoint.impl.index.PostgresEndpoint; import com.edgechain.lib.request.ArkRequest; import com.edgechain.lib.response.StringResponse; import com.edgechain.lib.rxjava.retry.impl.ExponentialDelay; @@ -27,13 +27,8 @@ private PostgresEndpoint getInstance() { @DeleteMapping("/deleteAll") public StringResponse deletePostgres(ArkRequest arkRequest) { - String table = arkRequest.getQueryParam("table"); String namespace = arkRequest.getQueryParam("namespace"); - - getInstance().setTableName(table); - getInstance().setNamespace(namespace); - - return getInstance().deleteAll(); + return getInstance().deleteAll(table, namespace); } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/RedisController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/RedisController.java index 950855fc2..42658fddb 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/RedisController.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/RedisController.java @@ -1,6 +1,6 @@ package com.edgechain.lib.controllers; -import com.edgechain.lib.endpoint.impl.RedisEndpoint; +import com.edgechain.lib.endpoint.impl.index.RedisEndpoint; import com.edgechain.lib.request.ArkRequest; import com.edgechain.lib.rxjava.retry.impl.ExponentialDelay; import org.springframework.web.bind.annotation.DeleteMapping; diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/RedisHistoryContextController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/RedisHistoryContextController.java index 9f956768a..d9cc61f0a 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/RedisHistoryContextController.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/RedisHistoryContextController.java @@ -1,7 +1,7 @@ package com.edgechain.lib.controllers; import com.edgechain.lib.context.domain.HistoryContext; -import com.edgechain.lib.endpoint.impl.RedisHistoryContextEndpoint; +import com.edgechain.lib.endpoint.impl.context.RedisHistoryContextEndpoint; import com.edgechain.lib.request.ArkRequest; import com.edgechain.lib.rxjava.retry.impl.FixedDelay; import org.json.JSONObject; diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/SupabaseController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/SupabaseController.java index 557cdb394..f81cd3d1a 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/SupabaseController.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/controllers/SupabaseController.java @@ -1,6 +1,6 @@ package com.edgechain.lib.controllers; -import com.edgechain.lib.endpoint.impl.SupabaseEndpoint; +import com.edgechain.lib.endpoint.impl.supabase.SupabaseEndpoint; import com.edgechain.lib.request.ArkRequest; import com.edgechain.lib.supabase.response.AuthenticatedResponse; import com.edgechain.lib.supabase.response.SupabaseUser; diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/WordEmbeddings.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/WordEmbeddings.java index e5cb0101b..46b5f32f9 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/WordEmbeddings.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/WordEmbeddings.java @@ -12,7 +12,7 @@ public class WordEmbeddings implements ArkObject, Serializable { private static final long serialVersionUID = 2210956496609994219L; private String id; private List values; - private String score; + private Double score; public WordEmbeddings() {} @@ -26,13 +26,13 @@ public WordEmbeddings(String id, List values) { this.values = values; } - public WordEmbeddings(String id, List values, String score) { + public WordEmbeddings(String id, List values, Double score) { this.id = id; this.values = values; this.score = score; } - public WordEmbeddings(String id, String score) { + public WordEmbeddings(String id, Double score) { this.id = id; this.score = score; } @@ -49,7 +49,7 @@ public void setValues(List values) { this.values = values; } - public String getScore() { + public Double getScore() { return score; } @@ -57,7 +57,7 @@ public void setId(String id) { this.id = id; } - public void setScore(String score) { + public void setScore(Double score) { this.score = score; } @@ -69,9 +69,34 @@ public String toString() { @Override public JSONObject toJson() { JSONObject json = new JSONObject(); - json.put("id", id); - json.put("values", new JSONArray(values)); - json.put("score", score); + + if (id != null) { + json.put("id", id); + } + + if (values != null) { + json.put("values", new JSONArray(values)); + } + + if (score != null) { + json.put("score", score); + } + return json; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + WordEmbeddings that = (WordEmbeddings) o; + + return id.equals(that.id); + } + + @Override + public int hashCode() { + return id.hashCode(); + } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/bgeSmall/BgeSmallClient.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/bgeSmall/BgeSmallClient.java index 905ff134f..6cc92c672 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/bgeSmall/BgeSmallClient.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/bgeSmall/BgeSmallClient.java @@ -16,33 +16,24 @@ import ai.djl.translate.Translator; import ai.djl.translate.TranslatorContext; import com.edgechain.lib.embeddings.bgeSmall.response.BgeSmallResponse; -import com.edgechain.lib.endpoint.impl.BgeSmallEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.BgeSmallEndpoint; import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; import io.reactivex.rxjava3.core.Observable; -import org.springframework.stereotype.Service; - import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.LinkedList; import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; @Service public class BgeSmallClient { - private BgeSmallEndpoint endpoint; - private static volatile ZooModel bgeSmallEn; - public BgeSmallEndpoint getEndpoint() { - return endpoint; - } - - public void setEndpoint(BgeSmallEndpoint endpoint) { - this.endpoint = endpoint; - } - - public EdgeChain createEmbeddings(String input) { + public EdgeChain createEmbeddings(String input, BgeSmallEndpoint endpoint) { return new EdgeChain<>( Observable.create( @@ -69,19 +60,23 @@ private ZooModel loadSmallBgeEn() throws IOException { ZooModel r = bgeSmallEn; if (r == null) { + final Logger logger = LoggerFactory.getLogger(BgeSmallEndpoint.class); synchronized (this) { r = bgeSmallEn; if (r == null) { - Path path = Paths.get("./model"); + logger.info("Creating tokenizer"); + Path path = Paths.get(BgeSmallEndpoint.MODEL_FOLDER); HuggingFaceTokenizer tokenizer = HuggingFaceTokenizer.builder() .optTokenizerPath(path) .optManager(NDManager.newBaseManager("PyTorch")) .build(); + logger.info("Creating translator"); MyTextEmbeddingTranslator translator = new MyTextEmbeddingTranslator(tokenizer, Batchifier.STACK, "cls", true, true); + logger.info("Loading criteria"); Criteria criteria = Criteria.builder() .setTypes(String.class, float[].class) @@ -94,7 +89,7 @@ private ZooModel loadSmallBgeEn() throws IOException { r = criteria.loadModel(); bgeSmallEn = r; } catch (IOException | ModelNotFoundException | MalformedModelException e) { - e.printStackTrace(); + logger.error("Failed to load model", e); throw new RuntimeException(e); } } @@ -162,8 +157,9 @@ static NDArray processEmbedding( embedding = list.head(); } long[] attentionMask = encoding.getAttentionMask(); - try (NDManager ptManager = NDManager.newBaseManager("PyTorch")) { - NDArray inputAttentionMask = ptManager.create(attentionMask).toType(DataType.FLOAT32, true); + try (NDManager ptManager = NDManager.newBaseManager("PyTorch"); + NDArray array = ptManager.create(attentionMask)) { + NDArray inputAttentionMask = array.toType(DataType.FLOAT32, true); switch (pooling) { case "mean": return meanPool(embedding, inputAttentionMask, false); @@ -206,7 +202,7 @@ private static NDArray maxPool(NDArray embeddings, NDArray inputAttentionMask) { private static NDArray weightedMeanPool(NDArray embeddings, NDArray attentionMask) { long[] shape = embeddings.getShape().getShape(); - NDArray weight = embeddings.getManager().arange(1, shape[0] + 1); + NDArray weight = embeddings.getManager().arange(1f, shape[0] + 1f); weight = weight.expandDims(-1).broadcast(shape); attentionMask = attentionMask.expandDims(-1).broadcast(shape).mul(weight); diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/miniLLM/MiniLMClient.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/miniLLM/MiniLMClient.java index b3c958995..b12ec6af0 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/miniLLM/MiniLMClient.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/miniLLM/MiniLMClient.java @@ -9,7 +9,7 @@ import ai.djl.training.util.ProgressBar; import com.edgechain.lib.embeddings.miniLLM.enums.MiniLMModel; import com.edgechain.lib.embeddings.miniLLM.response.MiniLMResponse; -import com.edgechain.lib.endpoint.impl.MiniLMEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.MiniLMEndpoint; import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; import io.reactivex.rxjava3.core.Observable; import org.springframework.stereotype.Service; @@ -21,8 +21,6 @@ @Service public class MiniLMClient { - private MiniLMEndpoint endpoint; - private static volatile ZooModel allMiniL6V2; private static volatile ZooModel allMiniL12V2; @@ -30,25 +28,17 @@ public class MiniLMClient { private static volatile ZooModel multiQAMiniLML6CosV1; - public MiniLMEndpoint getEndpoint() { - return endpoint; - } - - public void setEndpoint(MiniLMEndpoint endpoint) { - this.endpoint = endpoint; - } - - public EdgeChain createEmbeddings(String input) { + public EdgeChain createEmbeddings(String input, MiniLMEndpoint endpoint) { return new EdgeChain<>( Observable.create( emitter -> { try { - if (this.endpoint.getMiniLMModel().equals(MiniLMModel.ALL_MINILM_L6_V2)) { + if (endpoint.getMiniLMModel().equals(MiniLMModel.ALL_MINILM_L6_V2)) { Predictor predictor = - loadAllMiniL6V2(this.endpoint.getMiniLMModel()).newPredictor(); + loadAllMiniL6V2(endpoint.getMiniLMModel()).newPredictor(); float[] predict = predictor.predict(input); @@ -59,10 +49,10 @@ public EdgeChain createEmbeddings(String input) { emitter.onNext(new MiniLMResponse(floatList)); emitter.onComplete(); - } else if (this.endpoint.getMiniLMModel().equals(MiniLMModel.ALL_MINILM_L12_V2)) { + } else if (endpoint.getMiniLMModel().equals(MiniLMModel.ALL_MINILM_L12_V2)) { Predictor predictor = - loadAllMiniL12V2(this.endpoint.getMiniLMModel()).newPredictor(); + loadAllMiniL12V2(endpoint.getMiniLMModel()).newPredictor(); float[] predict = predictor.predict(input); @@ -73,11 +63,9 @@ public EdgeChain createEmbeddings(String input) { emitter.onNext(new MiniLMResponse(floatList)); emitter.onComplete(); - } else if (this.endpoint - .getMiniLMModel() - .equals(MiniLMModel.PARAPHRASE_MINILM_L3_V2)) { + } else if (endpoint.getMiniLMModel().equals(MiniLMModel.PARAPHRASE_MINILM_L3_V2)) { Predictor predictor = - loadParaphraseMiniLML3v2(this.endpoint.getMiniLMModel()).newPredictor(); + loadParaphraseMiniLML3v2(endpoint.getMiniLMModel()).newPredictor(); float[] predict = predictor.predict(input); @@ -92,7 +80,7 @@ public EdgeChain createEmbeddings(String input) { System.out.println("d"); ZooModel zooModel = - loadMultiQAMiniLML6CosV1(this.endpoint.getMiniLMModel()); + loadMultiQAMiniLML6CosV1(endpoint.getMiniLMModel()); Predictor predictor = zooModel.newPredictor(); diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/request/OpenAiEmbeddingRequest.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/request/OpenAiEmbeddingRequest.java index b7143cc25..b460fbfa9 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/request/OpenAiEmbeddingRequest.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/request/OpenAiEmbeddingRequest.java @@ -4,6 +4,8 @@ public class OpenAiEmbeddingRequest { private String input; private String model; + public OpenAiEmbeddingRequest() {} + public OpenAiEmbeddingRequest(String model, String input) { this.model = model; this.input = input; diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/response/OpenAiEmbedding.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/response/OpenAiEmbedding.java index dfcf38cc0..1a946e054 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/response/OpenAiEmbedding.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/response/OpenAiEmbedding.java @@ -1,6 +1,7 @@ package com.edgechain.lib.embeddings.response; import com.edgechain.lib.response.ArkObject; +import org.json.JSONArray; import org.json.JSONObject; import java.util.List; @@ -50,10 +51,20 @@ public String toString() { @Override public JSONObject toJson() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("object", object); - jsonObject.put("embedding", embedding); - jsonObject.put("index", index); - return jsonObject; + JSONObject json = new JSONObject(); + + if (object != null) { + json.put("object", object); + } + + if (embedding != null) { + json.put("embedding", new JSONArray(embedding)); + } + + if (index != null) { + json.put("index", index); + } + + return json; } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/response/OpenAiEmbeddingResponse.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/response/OpenAiEmbeddingResponse.java index ebf52ad5e..0d65ce0f5 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/response/OpenAiEmbeddingResponse.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/response/OpenAiEmbeddingResponse.java @@ -63,11 +63,24 @@ public String toString() { @Override public JSONObject toJson() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("model", model); - jsonObject.put("object", object); - jsonObject.put("data", data.stream().map(OpenAiEmbedding::toJson).collect(Collectors.toList())); - jsonObject.put("usage", usage.toJson()); - return jsonObject; + JSONObject json = new JSONObject(); + + if (model != null) { + json.put("model", model); + } + + if (object != null) { + json.put("object", object); + } + + if (data != null) { + json.put("data", data.stream().map(OpenAiEmbedding::toJson).collect(Collectors.toList())); + } + + if (usage != null) { + json.put("usage", usage.toJson()); // Assuming Usage has a toJson method + } + + return json; } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/response/Usage.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/response/Usage.java index 28b4914b8..c30c10bbc 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/response/Usage.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/embeddings/response/Usage.java @@ -36,8 +36,15 @@ public String toString() { @Override public JSONObject toJson() { JSONObject json = new JSONObject(); - json.put("prompt_tokens", prompt_tokens); - json.put("total_tokens", total_tokens); + + if (prompt_tokens != 0L) { + json.put("prompt_tokens", prompt_tokens); + } + + if (total_tokens != 0L) { + json.put("total_tokens", total_tokens); + } + return json; } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/Endpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/Endpoint.java index 5128f9894..2bdc54901 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/Endpoint.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/Endpoint.java @@ -36,6 +36,14 @@ public Endpoint(String url, String apiKey, RetryPolicy retryPolicy) { this.retryPolicy = retryPolicy; } + public void setUrl(String url) { + this.url = url; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + public String getApiKey() { return this.apiKey; } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/BgeSmallEndpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/BgeSmallEndpoint.java deleted file mode 100644 index 0ab920b58..000000000 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/BgeSmallEndpoint.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.edgechain.lib.endpoint.impl; - -import com.edgechain.lib.embeddings.WordEmbeddings; -import com.edgechain.lib.endpoint.Endpoint; -import com.edgechain.lib.request.ArkRequest; -import com.edgechain.lib.retrofit.BgeSmallService; -import com.edgechain.lib.retrofit.client.RetrofitClientInstance; -import com.edgechain.lib.rxjava.retry.RetryPolicy; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import retrofit2.Retrofit; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.URL; -import java.nio.channels.Channels; -import java.nio.channels.ReadableByteChannel; -import java.util.Objects; - -public class BgeSmallEndpoint extends Endpoint { - - private Logger logger = LoggerFactory.getLogger(BgeSmallEndpoint.class); - - private final Retrofit retrofit = RetrofitClientInstance.getInstance(); - private final BgeSmallService bgeSmallService = retrofit.create(BgeSmallService.class); - - private String input; - - private String modelUrl; - private String tokenizerUrl; - - private String callIdentifier; - private final String MODEL_PATH = "./model/model.onnx"; - private final String TOKENIZER_PATH = "./model/tokenizer.json"; - private final String MODEL_FOLDER = "./model"; - - public BgeSmallEndpoint() {} - - public BgeSmallEndpoint(String modelUrl, String tokenizerUrl) { - this.modelUrl = modelUrl; - this.tokenizerUrl = tokenizerUrl; - - logger.info("Downloading bge-small-en model. Please wait..."); - File modelFile = new File(MODEL_PATH); - File tokenizerFile = new File(TOKENIZER_PATH); - - // check if the file already exists - if (!modelFile.exists()) downloadFile(modelUrl, MODEL_PATH); - if (!tokenizerFile.exists()) downloadFile(tokenizerUrl, TOKENIZER_PATH); - logger.info("Model downloaded successfully!"); - } - - public String getModelUrl() { - return modelUrl; - } - - public String getTokenizerUrl() { - return tokenizerUrl; - } - - public String getInput() { - return input; - } - - public String getCallIdentifier() { - return callIdentifier; - } - - public BgeSmallEndpoint(RetryPolicy retryPolicy, String modelUrl, String tokenizerUrl) { - super(retryPolicy); - this.modelUrl = modelUrl; - this.tokenizerUrl = tokenizerUrl; - } - - public WordEmbeddings embeddings(String input, ArkRequest arkRequest) { - - this.input = input; // set Input - - if (Objects.nonNull(arkRequest)) { - this.callIdentifier = arkRequest.getRequestURI(); - } - - return bgeSmallService - .embeddings(this) - .map(m -> new WordEmbeddings(input, m.getEmbedding())) - .blockingGet(); - } - - private void downloadFile(String urlStr, String path) { - - File modelFolderFile = new File(MODEL_FOLDER); - - if (!modelFolderFile.exists()) { - modelFolderFile.mkdir(); - } - - ReadableByteChannel rbc = null; - FileOutputStream fos = null; - try { - URL url = new URL(urlStr); - rbc = Channels.newChannel(url.openStream()); - fos = new FileOutputStream(path); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - } catch (IOException e) { - logger.info("Error downloading model"); - e.printStackTrace(); - } finally { - assert fos != null; - try { - fos.close(); - rbc.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } -} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/PineconeEndpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/PineconeEndpoint.java deleted file mode 100644 index 5d2938906..000000000 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/PineconeEndpoint.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.edgechain.lib.endpoint.impl; - -import com.edgechain.lib.embeddings.WordEmbeddings; -import com.edgechain.lib.endpoint.Endpoint; -import com.edgechain.lib.retrofit.PineconeService; -import com.edgechain.lib.response.StringResponse; -import com.edgechain.lib.retrofit.client.RetrofitClientInstance; -import com.edgechain.lib.rxjava.retry.RetryPolicy; -import io.reactivex.rxjava3.core.Observable; -import retrofit2.Retrofit; - -import java.util.List; - -public class PineconeEndpoint extends Endpoint { - - private final Retrofit retrofit = RetrofitClientInstance.getInstance(); - private final PineconeService pineconeService = retrofit.create(PineconeService.class); - - private String namespace; - - // Getters; - private WordEmbeddings wordEmbeddings; - - private int topK; - - public PineconeEndpoint() {} - - public PineconeEndpoint(String namespace) { - this.namespace = namespace; - } - - public PineconeEndpoint(String url, String apiKey) { - super(url, apiKey); - } - - public PineconeEndpoint(String url, String apiKey, RetryPolicy retryPolicy) { - super(url, apiKey, retryPolicy); - } - - public PineconeEndpoint(String url, String apiKey, String namespace) { - super(url, apiKey); - this.namespace = namespace; - } - - public PineconeEndpoint(String url, String apiKey, String namespace, RetryPolicy retryPolicy) { - super(url, apiKey, retryPolicy); - this.namespace = namespace; - } - - public String getNamespace() { - return namespace; - } - - public void setNamespace(String namespace) { - this.namespace = namespace; - } - - // Getters - - public WordEmbeddings getWordEmbeddings() { - return wordEmbeddings; - } - - public void setWordEmbeddings(WordEmbeddings wordEmbeddings) { - this.wordEmbeddings = wordEmbeddings; - } - - public int getTopK() { - return topK; - } - - public void setTopK(int topK) { - this.topK = topK; - } - - public StringResponse upsert(WordEmbeddings wordEmbeddings) { - this.wordEmbeddings = wordEmbeddings; - return this.pineconeService.upsert(this).blockingGet(); - } - - public Observable> query(WordEmbeddings wordEmbeddings, int topK) { - this.wordEmbeddings = wordEmbeddings; - this.topK = topK; - return Observable.fromSingle(this.pineconeService.query(this)); - } - - public StringResponse deleteAll() { - return this.pineconeService.deleteAll(this).blockingGet(); - } -} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/PostgresEndpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/PostgresEndpoint.java deleted file mode 100644 index fc8443d28..000000000 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/PostgresEndpoint.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.edgechain.lib.endpoint.impl; - -import com.edgechain.lib.embeddings.WordEmbeddings; -import com.edgechain.lib.endpoint.Endpoint; -import com.edgechain.lib.index.domain.PostgresWordEmbeddings; -import com.edgechain.lib.index.enums.PostgresDistanceMetric; -import com.edgechain.lib.response.StringResponse; -import com.edgechain.lib.retrofit.PostgresService; -import com.edgechain.lib.retrofit.client.RetrofitClientInstance; -import com.edgechain.lib.rxjava.retry.RetryPolicy; -import io.reactivex.rxjava3.core.Observable; -import retrofit2.Retrofit; - -import java.util.List; - -public class PostgresEndpoint extends Endpoint { - - private final Retrofit retrofit = RetrofitClientInstance.getInstance(); - private final PostgresService postgresService = retrofit.create(PostgresService.class); - - private String tableName; - - private int lists; - - private String namespace; - - private String filename; - - // Getters - private WordEmbeddings wordEmbeddings; - private PostgresDistanceMetric metric; - private int dimensions; - private int topK; - - private int probes; - - public PostgresEndpoint() {} - - public PostgresEndpoint(RetryPolicy retryPolicy) { - super(retryPolicy); - } - - public PostgresEndpoint(String tableName) { - this.tableName = tableName; - } - - public PostgresEndpoint(String tableName, RetryPolicy retryPolicy) { - super(retryPolicy); - this.tableName = tableName; - } - - public String getTableName() { - return tableName; - } - - public String getNamespace() { - return namespace; - } - - public void setTableName(String tableName) { - this.tableName = tableName; - } - - public void setNamespace(String namespace) { - this.namespace = namespace; - } - - // Getters - - public WordEmbeddings getWordEmbeddings() { - return wordEmbeddings; - } - - public int getDimensions() { - return dimensions; - } - - public int getTopK() { - return topK; - } - - public String getFilename() { - return filename; - } - - public PostgresDistanceMetric getMetric() { - return metric; - } - - public int getLists() { - return lists; - } - - public int getProbes() { - return probes; - } - - // Convenience Methods - - public StringResponse upsert( - WordEmbeddings wordEmbeddings, - String filename, - int dimension, - PostgresDistanceMetric metric, - int lists) { - this.wordEmbeddings = wordEmbeddings; - this.dimensions = dimension; - this.filename = filename; - this.metric = metric; - this.lists = lists; - return this.postgresService.upsert(this).blockingGet(); - } - - public Observable> query( - WordEmbeddings wordEmbeddings, PostgresDistanceMetric metric, int topK) { - this.wordEmbeddings = wordEmbeddings; - this.topK = topK; - this.metric = metric; - this.probes = 1; - return Observable.fromSingle(this.postgresService.query(this)); - } - - public Observable> query( - WordEmbeddings wordEmbeddings, PostgresDistanceMetric metric, int topK, int probes) { - this.wordEmbeddings = wordEmbeddings; - this.topK = topK; - this.metric = metric; - this.probes = probes; - return Observable.fromSingle(this.postgresService.query(this)); - } - - public StringResponse deleteAll() { - return this.postgresService.deleteAll(this).blockingGet(); - } -} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/RedisEndpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/RedisEndpoint.java deleted file mode 100644 index 1dad38b37..000000000 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/RedisEndpoint.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.edgechain.lib.endpoint.impl; - -import com.edgechain.lib.embeddings.WordEmbeddings; -import com.edgechain.lib.endpoint.Endpoint; -import com.edgechain.lib.retrofit.RedisService; -import com.edgechain.lib.index.enums.RedisDistanceMetric; -import com.edgechain.lib.response.StringResponse; -import com.edgechain.lib.retrofit.client.RetrofitClientInstance; -import com.edgechain.lib.rxjava.retry.RetryPolicy; -import io.reactivex.rxjava3.core.Observable; -import retrofit2.Retrofit; -import java.util.List; - -public class RedisEndpoint extends Endpoint { - - private final Retrofit retrofit = RetrofitClientInstance.getInstance(); - private final RedisService redisService = retrofit.create(RedisService.class); - - private String indexName; - private String namespace; - - // Getters; - private WordEmbeddings wordEmbeddings; - - private int dimensions; - - private RedisDistanceMetric metric; - - private int topK; - - public RedisEndpoint() {} - - public RedisEndpoint(RetryPolicy retryPolicy) { - super(retryPolicy); - } - - public RedisEndpoint(String indexName) { - this.indexName = indexName; - } - - public RedisEndpoint(String indexName, RetryPolicy retryPolicy) { - super(retryPolicy); - this.indexName = indexName; - } - - public RedisEndpoint(String indexName, String namespace) { - this.indexName = indexName; - this.namespace = namespace; - } - - public RedisEndpoint(String indexName, String namespace, RetryPolicy retryPolicy) { - super(retryPolicy); - this.indexName = indexName; - this.namespace = namespace; - } - - public String getIndexName() { - return indexName; - } - - public void setIndexName(String indexName) { - this.indexName = indexName; - } - - public String getNamespace() { - return namespace; - } - - public void setNamespace(String namespace) { - this.namespace = namespace; - } - - // Getters - public WordEmbeddings getWordEmbeddings() { - return wordEmbeddings; - } - - public void setWordEmbeddings(WordEmbeddings wordEmbeddings) { - this.wordEmbeddings = wordEmbeddings; - } - - public int getDimensions() { - return dimensions; - } - - public void setDimensions(int dimensions) { - this.dimensions = dimensions; - } - - public RedisDistanceMetric getMetric() { - return metric; - } - - public void setMetric(RedisDistanceMetric metric) { - this.metric = metric; - } - - public int getTopK() { - return topK; - } - - public void setTopK(int topK) { - this.topK = topK; - } - - // Convenience Methods - public StringResponse upsert( - WordEmbeddings wordEmbeddings, int dimension, RedisDistanceMetric metric) { - - this.wordEmbeddings = wordEmbeddings; - this.dimensions = dimension; - this.metric = metric; - - return this.redisService.upsert(this).blockingGet(); - } - - public Observable> query(WordEmbeddings embeddings, int topK) { - this.topK = topK; - this.wordEmbeddings = embeddings; - return Observable.fromSingle(this.redisService.query(this)); - } - - public void delete(String patternName) { - this.redisService.deleteByPattern(patternName, this).blockingAwait(); - } -} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/PostgreSQLHistoryContextEndpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/context/PostgreSQLHistoryContextEndpoint.java similarity index 96% rename from Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/PostgreSQLHistoryContextEndpoint.java rename to Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/context/PostgreSQLHistoryContextEndpoint.java index 2fb095412..c99a331da 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/PostgreSQLHistoryContextEndpoint.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/context/PostgreSQLHistoryContextEndpoint.java @@ -1,4 +1,4 @@ -package com.edgechain.lib.endpoint.impl; +package com.edgechain.lib.endpoint.impl.context; import com.edgechain.lib.context.domain.ContextPutRequest; import com.edgechain.lib.context.domain.HistoryContext; diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/RedisHistoryContextEndpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/context/RedisHistoryContextEndpoint.java similarity index 96% rename from Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/RedisHistoryContextEndpoint.java rename to Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/context/RedisHistoryContextEndpoint.java index 1a420722c..9dcfcfb75 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/RedisHistoryContextEndpoint.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/context/RedisHistoryContextEndpoint.java @@ -1,4 +1,4 @@ -package com.edgechain.lib.endpoint.impl; +package com.edgechain.lib.endpoint.impl.context; import com.edgechain.lib.context.domain.ContextPutRequest; import com.edgechain.lib.context.domain.HistoryContext; diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/embeddings/BgeSmallEndpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/embeddings/BgeSmallEndpoint.java new file mode 100644 index 000000000..7d115898e --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/embeddings/BgeSmallEndpoint.java @@ -0,0 +1,120 @@ +package com.edgechain.lib.endpoint.impl.embeddings; + +import com.edgechain.lib.embeddings.WordEmbeddings; +import com.edgechain.lib.request.ArkRequest; +import com.edgechain.lib.retrofit.BgeSmallService; +import com.edgechain.lib.retrofit.client.RetrofitClientInstance; +import com.edgechain.lib.rxjava.retry.RetryPolicy; +import io.reactivex.rxjava3.core.Observable; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.util.Objects; + +import org.modelmapper.ModelMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class BgeSmallEndpoint extends EmbeddingEndpoint { + + private static final Logger logger = LoggerFactory.getLogger(BgeSmallEndpoint.class); + + private final BgeSmallService bgeSmallService = + RetrofitClientInstance.getInstance().create(BgeSmallService.class); + + private ModelMapper modelMapper = new ModelMapper(); + + private String modelUrl; + private String tokenizerUrl; + + public static final String MODEL_FOLDER = "./model"; + public static final String MODEL_PATH = MODEL_FOLDER + "/model.onnx"; + public static final String TOKENIZER_PATH = MODEL_FOLDER + "/tokenizer.json"; + + public BgeSmallEndpoint() {} + + public BgeSmallEndpoint(String modelUrl, String tokenizerUrl) { + this.modelUrl = modelUrl; + this.tokenizerUrl = tokenizerUrl; + + File modelFile = new File(MODEL_PATH); + if (!modelFile.exists()) { + logger.info( + "Downloading bge-small-en model from {} to {}. Please wait...", + modelUrl, + modelFile.getAbsolutePath()); + downloadFile(modelUrl, MODEL_PATH); + } + + File tokenizerFile = new File(TOKENIZER_PATH); + if (!tokenizerFile.exists()) { + logger.info( + "Downloading bge-small-en tokenizer from {} to {}. Please wait...", + tokenizerUrl, + tokenizerFile.getAbsolutePath()); + downloadFile(tokenizerUrl, TOKENIZER_PATH); + } + + logger.info("Model downloaded successfully!"); + } + + public String getModelUrl() { + return modelUrl; + } + + public String getTokenizerUrl() { + return tokenizerUrl; + } + + public void setModelUrl(String modelUrl) { + this.modelUrl = modelUrl; + } + + public void setTokenizerUrl(String tokenizerUrl) { + this.tokenizerUrl = tokenizerUrl; + } + + public BgeSmallEndpoint(RetryPolicy retryPolicy, String modelUrl, String tokenizerUrl) { + super(retryPolicy); + this.modelUrl = modelUrl; + this.tokenizerUrl = tokenizerUrl; + } + + @Override + public Observable embeddings(String input, ArkRequest arkRequest) { + BgeSmallEndpoint mapper = modelMapper.map(this, BgeSmallEndpoint.class); + mapper.setRawText(input); + + if (Objects.nonNull(arkRequest)) mapper.setCallIdentifier(arkRequest.getRequestURI()); + else mapper.setCallIdentifier("URI wasn't provided"); + + return Observable.fromSingle( + bgeSmallService.embeddings(mapper).map(m -> new WordEmbeddings(input, m.getEmbedding()))); + } + + private void downloadFile(String urlStr, String path) { + + File modelFolderFile = new File(MODEL_FOLDER); + + if (!modelFolderFile.exists()) { + logger.info("Creating directory {}", MODEL_FOLDER); + modelFolderFile.mkdir(); + } + + try { + URL url = new URL(urlStr); + try (InputStream is = url.openStream(); + ReadableByteChannel rbc = Channels.newChannel(is); + FileOutputStream fos = new FileOutputStream(path)) { + long transferred = fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + logger.info("Downloaded {} bytes", transferred); + } + } catch (IOException e) { + logger.error("Error downloading model", e); + } + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/embeddings/EmbeddingEndpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/embeddings/EmbeddingEndpoint.java new file mode 100644 index 000000000..609332c4b --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/embeddings/EmbeddingEndpoint.java @@ -0,0 +1,64 @@ +package com.edgechain.lib.endpoint.impl.embeddings; + +import com.edgechain.lib.embeddings.WordEmbeddings; +import com.edgechain.lib.endpoint.Endpoint; +import com.edgechain.lib.request.ArkRequest; +import com.edgechain.lib.rxjava.retry.RetryPolicy; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import io.reactivex.rxjava3.core.Observable; + +import java.io.Serializable; + +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = OpenAiEmbeddingEndpoint.class, name = "type1"), + @JsonSubTypes.Type(value = MiniLMEndpoint.class, name = "type2"), + @JsonSubTypes.Type(value = BgeSmallEndpoint.class, name = "type3"), +}) +public abstract class EmbeddingEndpoint extends Endpoint implements Serializable { + + private static final long serialVersionUID = 4201794264326630184L; + private String callIdentifier; + private String rawText; + + public EmbeddingEndpoint() {} + + public EmbeddingEndpoint(RetryPolicy retryPolicy) { + super(retryPolicy); + } + + public EmbeddingEndpoint(String url) { + super(url); + } + + public EmbeddingEndpoint(String url, RetryPolicy retryPolicy) { + super(url, retryPolicy); + } + + public EmbeddingEndpoint(String url, String apiKey) { + super(url, apiKey); + } + + public EmbeddingEndpoint(String url, String apiKey, RetryPolicy retryPolicy) { + super(url, apiKey, retryPolicy); + } + + public abstract Observable embeddings(String input, ArkRequest arkRequest); + + public void setRawText(String rawText) { + this.rawText = rawText; + } + + public void setCallIdentifier(String callIdentifier) { + this.callIdentifier = callIdentifier; + } + + public String getRawText() { + return rawText; + } + + public String getCallIdentifier() { + return callIdentifier; + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/MiniLMEndpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/embeddings/MiniLMEndpoint.java similarity index 62% rename from Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/MiniLMEndpoint.java rename to Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/embeddings/MiniLMEndpoint.java index f50f247d4..840cfac2c 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/MiniLMEndpoint.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/embeddings/MiniLMEndpoint.java @@ -1,8 +1,7 @@ -package com.edgechain.lib.endpoint.impl; +package com.edgechain.lib.endpoint.impl.embeddings; import com.edgechain.lib.embeddings.WordEmbeddings; import com.edgechain.lib.embeddings.miniLLM.enums.MiniLMModel; -import com.edgechain.lib.endpoint.Endpoint; import com.edgechain.lib.request.ArkRequest; import com.edgechain.lib.retrofit.MiniLMService; import com.edgechain.lib.retrofit.client.RetrofitClientInstance; @@ -10,55 +9,46 @@ import java.util.Objects; import io.reactivex.rxjava3.core.Observable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.modelmapper.ModelMapper; import retrofit2.Retrofit; -public class MiniLMEndpoint extends Endpoint { - - private Logger logger = LoggerFactory.getLogger(MiniLMEndpoint.class); +public class MiniLMEndpoint extends EmbeddingEndpoint { private final Retrofit retrofit = RetrofitClientInstance.getInstance(); private final MiniLMService miniLMService = retrofit.create(MiniLMService.class); - - private String input; + private ModelMapper modelMapper = new ModelMapper(); private MiniLMModel miniLMModel; - private String callIdentifier; - public MiniLMEndpoint() {} public MiniLMEndpoint(MiniLMModel miniLMModel) { this.miniLMModel = miniLMModel; } - public String getInput() { - return input; + public void setMiniLMModel(MiniLMModel miniLMModel) { + this.miniLMModel = miniLMModel; } public MiniLMModel getMiniLMModel() { return miniLMModel; } - public String getCallIdentifier() { - return callIdentifier; - } - public MiniLMEndpoint(RetryPolicy retryPolicy, MiniLMModel miniLMModel) { super(retryPolicy); this.miniLMModel = miniLMModel; } + @Override public Observable embeddings(String input, ArkRequest arkRequest) { - this.input = input; // set Input + MiniLMEndpoint mapper = modelMapper.map(this, MiniLMEndpoint.class); + mapper.setRawText(input); - if (Objects.nonNull(arkRequest)) { - this.callIdentifier = arkRequest.getRequestURI(); - } + if (Objects.nonNull(arkRequest)) mapper.setCallIdentifier(arkRequest.getRequestURI()); + else mapper.setCallIdentifier("URI wasn't provided"); return Observable.fromSingle( - miniLMService.embeddings(this).map(m -> new WordEmbeddings(input, m.getEmbedding()))); + miniLMService.embeddings(mapper).map(m -> new WordEmbeddings(input, m.getEmbedding()))); } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/embeddings/OpenAiEmbeddingEndpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/embeddings/OpenAiEmbeddingEndpoint.java new file mode 100644 index 000000000..6dc9dea4f --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/embeddings/OpenAiEmbeddingEndpoint.java @@ -0,0 +1,71 @@ +package com.edgechain.lib.endpoint.impl.embeddings; + +import com.edgechain.lib.embeddings.WordEmbeddings; +import com.edgechain.lib.request.ArkRequest; +import com.edgechain.lib.retrofit.OpenAiService; +import com.edgechain.lib.retrofit.client.RetrofitClientInstance; +import com.edgechain.lib.rxjava.retry.RetryPolicy; +import io.reactivex.rxjava3.core.Observable; +import org.modelmapper.ModelMapper; +import retrofit2.Retrofit; + +import java.util.Objects; + +public class OpenAiEmbeddingEndpoint extends EmbeddingEndpoint { + + private final Retrofit retrofit = RetrofitClientInstance.getInstance(); + private final OpenAiService openAiService = retrofit.create(OpenAiService.class); + + private ModelMapper modelMapper = new ModelMapper(); + + private String orgId; + private String model; + + public OpenAiEmbeddingEndpoint() {} + + public OpenAiEmbeddingEndpoint(String url, String apiKey, String orgId, String model) { + super(url, apiKey); + this.orgId = orgId; + this.model = model; + } + + public OpenAiEmbeddingEndpoint( + String url, String apiKey, String orgId, String model, RetryPolicy retryPolicy) { + super(url, apiKey, retryPolicy); + this.orgId = orgId; + this.model = model; + } + + public String getModel() { + return model; + } + + public String getOrgId() { + return orgId; + } + + public void setOrgId(String orgId) { + this.orgId = orgId; + } + + public void setModel(String model) { + this.model = model; + } + + @Override + public Observable embeddings(String input, ArkRequest arkRequest) { + + OpenAiEmbeddingEndpoint mapper = modelMapper.map(this, OpenAiEmbeddingEndpoint.class); + mapper.setRawText(input); + + if (Objects.nonNull(arkRequest)) mapper.setCallIdentifier(arkRequest.getRequestURI()); + else mapper.setCallIdentifier("URI wasn't provided"); + + return Observable.fromSingle( + openAiService + .embeddings(mapper) + .map( + embeddingResponse -> + new WordEmbeddings(input, embeddingResponse.getData().get(0).getEmbedding()))); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/index/PineconeEndpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/index/PineconeEndpoint.java new file mode 100644 index 000000000..366a06992 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/index/PineconeEndpoint.java @@ -0,0 +1,162 @@ +package com.edgechain.lib.endpoint.impl.index; + +import com.edgechain.lib.embeddings.WordEmbeddings; +import com.edgechain.lib.endpoint.impl.embeddings.EmbeddingEndpoint; +import com.edgechain.lib.endpoint.Endpoint; +import com.edgechain.lib.request.ArkRequest; +import com.edgechain.lib.retrofit.PineconeService; +import com.edgechain.lib.response.StringResponse; +import com.edgechain.lib.retrofit.client.RetrofitClientInstance; +import com.edgechain.lib.rxjava.retry.RetryPolicy; +import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; +import io.reactivex.rxjava3.core.Observable; +import org.modelmapper.ModelMapper; +import retrofit2.Retrofit; + +import java.util.List; + +public class PineconeEndpoint extends Endpoint { + + private static final String QUERY_API = "/query"; + private static final String UPSERT_API = "/vectors/upsert"; + private static final String DELETE_API = "/vectors/delete"; + + private final Retrofit retrofit = RetrofitClientInstance.getInstance(); + private final PineconeService pineconeService = retrofit.create(PineconeService.class); + private ModelMapper modelMapper = new ModelMapper(); + + private String originalUrl; + private String namespace; + + // Getters; + private WordEmbeddings wordEmbedding; + + private List wordEmbeddingsList; + + private int topK; + + private EmbeddingEndpoint embeddingEndpoint; + + public PineconeEndpoint() {} + + public PineconeEndpoint(String url, String apiKey, EmbeddingEndpoint embeddingEndpoint) { + super(url, apiKey); + this.originalUrl = url; + this.embeddingEndpoint = embeddingEndpoint; + } + + public PineconeEndpoint( + String url, String apiKey, EmbeddingEndpoint embeddingEndpoint, RetryPolicy retryPolicy) { + super(url, apiKey, retryPolicy); + this.embeddingEndpoint = embeddingEndpoint; + this.originalUrl = url; + } + + public PineconeEndpoint( + String url, String apiKey, String namespace, EmbeddingEndpoint embeddingEndpoint) { + super(url, apiKey); + this.originalUrl = url; + this.namespace = namespace; + this.embeddingEndpoint = embeddingEndpoint; + } + + public PineconeEndpoint( + String url, + String apiKey, + String namespace, + EmbeddingEndpoint embeddingEndpoint, + RetryPolicy retryPolicy) { + super(url, apiKey, retryPolicy); + this.originalUrl = url; + this.namespace = namespace; + this.embeddingEndpoint = embeddingEndpoint; + } + + public String getNamespace() { + return namespace; + } + + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + // Getters + + public void setOriginalUrl(String originalUrl) { + this.originalUrl = originalUrl; + } + + public void setEmbeddingEndpoint(EmbeddingEndpoint embeddingEndpoint) { + this.embeddingEndpoint = embeddingEndpoint; + } + + public WordEmbeddings getWordEmbedding() { + return wordEmbedding; + } + + public List getWordEmbeddingsList() { + return wordEmbeddingsList; + } + + private void setWordEmbedding(WordEmbeddings wordEmbedding) { + this.wordEmbedding = wordEmbedding; + } + + private void setWordEmbeddingsList(List wordEmbeddingsList) { + this.wordEmbeddingsList = wordEmbeddingsList; + } + + public int getTopK() { + return topK; + } + + public EmbeddingEndpoint getEmbeddingEndpoint() { + return embeddingEndpoint; + } + + public String getOriginalUrl() { + return originalUrl; + } + + private void setTopK(int topK) { + this.topK = topK; + } + + public StringResponse upsert(WordEmbeddings wordEmbedding, String namespace) { + PineconeEndpoint mapper = modelMapper.map(this, PineconeEndpoint.class); + mapper.setWordEmbedding(wordEmbedding); + mapper.setUrl(mapper.getOriginalUrl().concat(UPSERT_API)); + mapper.setNamespace(namespace); + + return this.pineconeService.upsert(mapper).blockingGet(); + } + + public StringResponse batchUpsert(List wordEmbeddingsList, String namespace) { + PineconeEndpoint mapper = modelMapper.map(this, PineconeEndpoint.class); + mapper.setWordEmbeddingsList(wordEmbeddingsList); + mapper.setUrl(mapper.getOriginalUrl().concat(UPSERT_API)); + mapper.setNamespace(namespace); + + return this.pineconeService.batchUpsert(mapper).blockingGet(); + } + + public Observable> query( + String query, String namespace, int topK, ArkRequest arkRequest) { + WordEmbeddings wordEmbeddings = + new EdgeChain<>(getEmbeddingEndpoint().embeddings(query, arkRequest)).get(); + + PineconeEndpoint mapper = modelMapper.map(this, PineconeEndpoint.class); + mapper.setWordEmbedding(wordEmbeddings); + mapper.setUrl(mapper.getOriginalUrl().concat(QUERY_API)); + mapper.setNamespace(namespace); + mapper.setTopK(topK); + return Observable.fromSingle(this.pineconeService.query(mapper)); + } + + public StringResponse deleteAll(String namespace) { + PineconeEndpoint mapper = modelMapper.map(this, PineconeEndpoint.class); + mapper.setUrl(mapper.getOriginalUrl().concat(DELETE_API)); + mapper.setNamespace(namespace); + return this.pineconeService.deleteAll(mapper).blockingGet(); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/index/PostgresEndpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/index/PostgresEndpoint.java new file mode 100644 index 000000000..8fcee3b52 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/index/PostgresEndpoint.java @@ -0,0 +1,564 @@ +package com.edgechain.lib.endpoint.impl.index; + +import com.edgechain.lib.embeddings.WordEmbeddings; +import com.edgechain.lib.endpoint.Endpoint; +import com.edgechain.lib.endpoint.impl.embeddings.EmbeddingEndpoint; +import com.edgechain.lib.index.domain.PostgresWordEmbeddings; +import com.edgechain.lib.index.domain.RRFWeight; +import com.edgechain.lib.index.enums.OrderRRFBy; +import com.edgechain.lib.index.enums.PostgresDistanceMetric; +import com.edgechain.lib.index.enums.PostgresLanguage; +import com.edgechain.lib.request.ArkRequest; +import com.edgechain.lib.response.StringResponse; +import com.edgechain.lib.retrofit.PostgresService; +import com.edgechain.lib.retrofit.client.RetrofitClientInstance; +import com.edgechain.lib.rxjava.retry.RetryPolicy; +import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; +import io.reactivex.rxjava3.core.Observable; +import io.reactivex.rxjava3.schedulers.Schedulers; +import org.modelmapper.ModelMapper; +import retrofit2.Retrofit; + +import java.util.List; + +public class PostgresEndpoint extends Endpoint { + + private final Retrofit retrofit = RetrofitClientInstance.getInstance(); + private final PostgresService postgresService = retrofit.create(PostgresService.class); + private ModelMapper modelMapper = new ModelMapper(); + private String tableName; + private int lists; + + private String id; + private String namespace; + + private String filename; + + // Getters + private WordEmbeddings wordEmbedding; + + private List wordEmbeddingsList; + + private PostgresDistanceMetric metric; + private int dimensions; + private int topK; + private int upperLimit; + + private int probes; + private String embeddingChunk; + + // Fields for metadata table + private List metadataTableNames; + private String metadata; + private String metadataId; + private List metadataList; + private String documentDate; + + /** RRF * */ + private RRFWeight textWeight; + + private RRFWeight similarityWeight; + private RRFWeight dateWeight; + + private OrderRRFBy orderRRFBy; + private String searchQuery; + + private PostgresLanguage postgresLanguage; + + // Join Table + private List idList; + + private EmbeddingEndpoint embeddingEndpoint; + + public PostgresEndpoint() {} + + public PostgresEndpoint(RetryPolicy retryPolicy) { + super(retryPolicy); + } + + public PostgresEndpoint(String tableName, EmbeddingEndpoint embeddingEndpoint) { + this.tableName = tableName; + this.embeddingEndpoint = embeddingEndpoint; + } + + public PostgresEndpoint(String tableName, String namespace, EmbeddingEndpoint embeddingEndpoint) { + this.tableName = tableName; + this.namespace = namespace; + this.embeddingEndpoint = embeddingEndpoint; + } + + public PostgresEndpoint( + String tableName, EmbeddingEndpoint embeddingEndpoint, RetryPolicy retryPolicy) { + super(retryPolicy); + this.tableName = tableName; + this.embeddingEndpoint = embeddingEndpoint; + } + + public PostgresEndpoint( + String tableName, + String namespace, + EmbeddingEndpoint embeddingEndpoint, + RetryPolicy retryPolicy) { + super(retryPolicy); + this.tableName = tableName; + this.namespace = namespace; + this.embeddingEndpoint = embeddingEndpoint; + } + + public String getTableName() { + return tableName; + } + + public String getNamespace() { + return namespace; + } + + public EmbeddingEndpoint getEmbeddingEndpoint() { + return embeddingEndpoint; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + public void setMetadata(String metadata) { + this.metadata = metadata; + } + + public void setId(String id) { + this.id = id; + } + + public void setMetadataId(String metadataId) { + this.metadataId = metadataId; + } + + public void setMetadataList(List metadataList) { + this.metadataList = metadataList; + } + + public void setEmbeddingChunk(String embeddingChunk) { + this.embeddingChunk = embeddingChunk; + } + + public int getUpperLimit() { + return upperLimit; + } + + public void setUpperLimit(int upperLimit) { + this.upperLimit = upperLimit; + } + + private void setLists(int lists) { + this.lists = lists; + } + + private void setFilename(String filename) { + this.filename = filename; + } + + private void setWordEmbedding(WordEmbeddings wordEmbedding) { + this.wordEmbedding = wordEmbedding; + } + + private void setWordEmbeddingsList(List wordEmbeddingsList) { + this.wordEmbeddingsList = wordEmbeddingsList; + } + + private void setMetric(PostgresDistanceMetric metric) { + this.metric = metric; + } + + private void setDimensions(int dimensions) { + this.dimensions = dimensions; + } + + private void setTopK(int topK) { + this.topK = topK; + } + + private void setProbes(int probes) { + this.probes = probes; + } + + private void setMetadataTableNames(List metadataTableNames) { + this.metadataTableNames = metadataTableNames; + } + + private void setDocumentDate(String documentDate) { + this.documentDate = documentDate; + } + + private void setTextWeight(RRFWeight textWeight) { + this.textWeight = textWeight; + } + + private void setSimilarityWeight(RRFWeight similarityWeight) { + this.similarityWeight = similarityWeight; + } + + private void setDateWeight(RRFWeight dateWeight) { + this.dateWeight = dateWeight; + } + + private void setOrderRRFBy(OrderRRFBy orderRRFBy) { + this.orderRRFBy = orderRRFBy; + } + + private void setSearchQuery(String searchQuery) { + this.searchQuery = searchQuery; + } + + private void setPostgresLanguage(PostgresLanguage postgresLanguage) { + this.postgresLanguage = postgresLanguage; + } + + private void setIdList(List idList) { + this.idList = idList; + } + + public void setEmbeddingEndpoint(EmbeddingEndpoint embeddingEndpoint) { + this.embeddingEndpoint = embeddingEndpoint; + } + + // Getters + + public WordEmbeddings getWordEmbedding() { + return wordEmbedding; + } + + public int getDimensions() { + return dimensions; + } + + public int getTopK() { + return topK; + } + + public String getFilename() { + return filename; + } + + public List getWordEmbeddingsList() { + return wordEmbeddingsList; + } + + public PostgresDistanceMetric getMetric() { + return metric; + } + + public int getLists() { + return lists; + } + + public int getProbes() { + return probes; + } + + public List getMetadataTableNames() { + return metadataTableNames; + } + + public String getMetadata() { + return metadata; + } + + public String getMetadataId() { + return metadataId; + } + + public String getId() { + return id; + } + + public List getMetadataList() { + return metadataList; + } + + public String getEmbeddingChunk() { + return embeddingChunk; + } + + public String getDocumentDate() { + return documentDate; + } + + public RRFWeight getTextWeight() { + return textWeight; + } + + public RRFWeight getSimilarityWeight() { + return similarityWeight; + } + + public RRFWeight getDateWeight() { + return dateWeight; + } + + public OrderRRFBy getOrderRRFBy() { + return orderRRFBy; + } + + public String getSearchQuery() { + return searchQuery; + } + + public PostgresLanguage getPostgresLanguage() { + return postgresLanguage; + } + + public List getIdList() { + return idList; + } + + public StringResponse upsert( + WordEmbeddings wordEmbeddings, + String filename, + int dimension, + PostgresDistanceMetric metric) { + + PostgresEndpoint mapper = modelMapper.map(this, PostgresEndpoint.class); + mapper.setWordEmbedding(wordEmbeddings); + mapper.setFilename(filename); + mapper.setDimensions(dimension); + mapper.setMetric(metric); + return this.postgresService.upsert(mapper).blockingGet(); + } + + public StringResponse createTable(int dimensions, PostgresDistanceMetric metric, int lists) { + + PostgresEndpoint mapper = modelMapper.map(this, PostgresEndpoint.class); + mapper.setDimensions(dimensions); + mapper.setMetric(metric); + mapper.setLists(lists); + + return this.postgresService.createTable(mapper).blockingGet(); + } + + public StringResponse createMetadataTable(String metadataTableName) { + PostgresEndpoint mapper = modelMapper.map(this, PostgresEndpoint.class); + mapper.setMetadataTableNames(List.of(metadataTableName)); + return this.postgresService.createMetadataTable(mapper).blockingGet(); + } + + public List upsert( + List wordEmbeddingsList, String filename, PostgresLanguage postgresLanguage) { + + PostgresEndpoint mapper = modelMapper.map(this, PostgresEndpoint.class); + mapper.setWordEmbeddingsList(wordEmbeddingsList); + mapper.setFilename(filename); + mapper.setPostgresLanguage(postgresLanguage); + + return this.postgresService.batchUpsert(mapper).blockingGet(); + } + + public StringResponse insertMetadata( + String metadataTableName, String metadata, String documentDate) { + + PostgresEndpoint mapper = modelMapper.map(this, PostgresEndpoint.class); + mapper.setMetadata(metadata); + mapper.setDocumentDate(documentDate); + mapper.setMetadataTableNames(List.of(metadataTableName)); + return this.postgresService.insertMetadata(mapper).blockingGet(); + } + + public List batchInsertMetadata(List metadataList) { + PostgresEndpoint mapper = modelMapper.map(this, PostgresEndpoint.class); + mapper.setMetadataList(metadataList); + return this.postgresService.batchInsertMetadata(mapper).blockingGet(); + } + + public StringResponse insertIntoJoinTable( + String metadataTableName, String id, String metadataId) { + + PostgresEndpoint mapper = modelMapper.map(this, PostgresEndpoint.class); + mapper.setId(id); + mapper.setMetadataId(metadataId); + mapper.setMetadataTableNames(List.of(metadataTableName)); + + return this.postgresService.insertIntoJoinTable(mapper).blockingGet(); + } + + public StringResponse batchInsertIntoJoinTable( + String metadataTableName, List idList, String metadataId) { + PostgresEndpoint mapper = modelMapper.map(this, PostgresEndpoint.class); + mapper.setIdList(idList); + mapper.setMetadataId(metadataId); + mapper.setMetadataTableNames(List.of(metadataTableName)); + return this.postgresService.batchInsertIntoJoinTable(mapper).blockingGet(); + } + + public Observable> query( + List inputList, + PostgresDistanceMetric metric, + int topK, + int upperLimit, + ArkRequest arkRequest) { + + PostgresEndpoint mapper = modelMapper.map(this, PostgresEndpoint.class); + + List endpointEmbeddingList = + Observable.fromIterable(inputList) + .buffer(inputList.size() > 1 ? inputList.size() / 2 : 1) + .flatMap( + bufferedList -> + Observable.fromIterable(bufferedList) + .flatMap( + res -> + Observable.fromCallable( + () -> + new EdgeChain<>( + embeddingEndpoint.embeddings(res, arkRequest)) + .get()) + .subscribeOn(Schedulers.io()))) + .toList() + .blockingGet(); + + mapper.setWordEmbeddingsList(endpointEmbeddingList); + mapper.setTopK(topK); + mapper.setUpperLimit(upperLimit); + mapper.setMetric(metric); + mapper.setProbes(1); + return Observable.fromSingle(this.postgresService.query(mapper)); + } + + public Observable> query( + List inputList, + PostgresDistanceMetric metric, + int topK, + int upperLimit, + int probes, + ArkRequest arkRequest) { + PostgresEndpoint mapper = modelMapper.map(this, PostgresEndpoint.class); + + List endpointEmbeddingList = + Observable.fromIterable(inputList) + .buffer(inputList.size() > 1 ? inputList.size() / 2 : 1) + .flatMap( + bufferedList -> + Observable.fromIterable(bufferedList) + .flatMap( + res -> + Observable.fromCallable( + () -> + new EdgeChain<>( + embeddingEndpoint.embeddings(res, arkRequest)) + .get()) + .subscribeOn(Schedulers.io()))) + .toList() + .blockingGet(); + + mapper.setWordEmbeddingsList(endpointEmbeddingList); + mapper.setMetric(metric); + mapper.setProbes(probes); + mapper.setTopK(topK); + mapper.setUpperLimit(upperLimit); + return Observable.fromSingle(this.postgresService.query(mapper)); + } + + public Observable> queryRRF( + String metadataTable, + List inputList, + RRFWeight textWeight, + RRFWeight similarityWeight, + RRFWeight dateWeight, + OrderRRFBy orderRRFBy, + String searchQuery, + PostgresLanguage postgresLanguage, + int probes, + PostgresDistanceMetric metric, + int topK, + int upperLimit, + ArkRequest arkRequest) { + PostgresEndpoint mapper = modelMapper.map(this, PostgresEndpoint.class); + mapper.setMetadataTableNames(List.of(metadataTable)); + + List endpointEmbeddingList = + Observable.fromIterable(inputList) + .buffer(inputList.size() > 1 ? inputList.size() / 2 : 1) + .flatMap( + bufferedList -> + Observable.fromIterable(bufferedList) + .flatMap( + res -> + Observable.fromCallable( + () -> + new EdgeChain<>( + embeddingEndpoint.embeddings(res, arkRequest)) + .get()) + .subscribeOn(Schedulers.io()))) + .toList() + .blockingGet(); + + mapper.setWordEmbeddingsList(endpointEmbeddingList); + mapper.setTextWeight(textWeight); + mapper.setSimilarityWeight(similarityWeight); + mapper.setDateWeight(dateWeight); + mapper.setOrderRRFBy(orderRRFBy); + mapper.setSearchQuery(searchQuery); + mapper.setPostgresLanguage(postgresLanguage); + mapper.setProbes(probes); + mapper.setMetric(metric); + mapper.setTopK(topK); + mapper.setUpperLimit(upperLimit); + return Observable.fromSingle(this.postgresService.queryRRF(mapper)); + } + + public Observable> queryWithMetadata( + List metadataTableNames, + WordEmbeddings wordEmbeddings, + PostgresDistanceMetric metric, + int topK) { + PostgresEndpoint mapper = modelMapper.map(this, PostgresEndpoint.class); + mapper.setMetadataTableNames(metadataTableNames); + mapper.setWordEmbedding(wordEmbeddings); + mapper.setTopK(topK); + mapper.setMetric(metric); + mapper.setProbes(1); + return Observable.fromSingle(this.postgresService.queryWithMetadata(mapper)); + } + + public Observable> queryWithMetadata( + List metadataTableNames, + String input, + PostgresDistanceMetric metric, + int topK, + ArkRequest arkRequest) { + PostgresEndpoint mapper = modelMapper.map(this, PostgresEndpoint.class); + + WordEmbeddings wordEmbeddings = + new EdgeChain<>(embeddingEndpoint.embeddings(input, arkRequest)).get(); + + mapper.setMetadataTableNames(metadataTableNames); + mapper.setWordEmbedding(wordEmbeddings); + mapper.setTopK(topK); + mapper.setMetric(metric); + mapper.setProbes(1); + return Observable.fromSingle(this.postgresService.queryWithMetadata(mapper)); + } + + public Observable> getSimilarMetadataChunk(String embeddingChunk) { + PostgresEndpoint mapper = modelMapper.map(this, PostgresEndpoint.class); + mapper.setEmbeddingChunk(embeddingChunk); + return Observable.fromSingle(this.postgresService.getSimilarMetadataChunk(mapper)); + } + + public Observable> getAllChunks(String tableName, String filename) { + PostgresEndpoint mapper = modelMapper.map(this, PostgresEndpoint.class); + mapper.setTableName(tableName); + mapper.setFilename(filename); + + return Observable.fromSingle(this.postgresService.getAllChunks(this)); + } + + public StringResponse deleteAll(String tableName, String namespace) { + PostgresEndpoint mapper = modelMapper.map(this, PostgresEndpoint.class); + mapper.setTableName(tableName); + mapper.setNamespace(namespace); + return this.postgresService.deleteAll(mapper).blockingGet(); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/index/RedisEndpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/index/RedisEndpoint.java new file mode 100644 index 000000000..dbc8941f8 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/index/RedisEndpoint.java @@ -0,0 +1,190 @@ +package com.edgechain.lib.endpoint.impl.index; + +import com.edgechain.lib.embeddings.WordEmbeddings; +import com.edgechain.lib.endpoint.Endpoint; +import com.edgechain.lib.endpoint.impl.embeddings.EmbeddingEndpoint; +import com.edgechain.lib.request.ArkRequest; +import com.edgechain.lib.retrofit.RedisService; +import com.edgechain.lib.index.enums.RedisDistanceMetric; +import com.edgechain.lib.response.StringResponse; +import com.edgechain.lib.retrofit.client.RetrofitClientInstance; +import com.edgechain.lib.rxjava.retry.RetryPolicy; +import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; +import io.reactivex.rxjava3.core.Observable; +import org.modelmapper.ModelMapper; +import retrofit2.Retrofit; +import java.util.List; + +public class RedisEndpoint extends Endpoint { + + private final Retrofit retrofit = RetrofitClientInstance.getInstance(); + private final RedisService redisService = retrofit.create(RedisService.class); + + private ModelMapper modelMapper = new ModelMapper(); + + private String indexName; + private String namespace; + + // Getters; + private WordEmbeddings wordEmbedding; + private List wordEmbeddingsList; + + private int dimensions; + + private RedisDistanceMetric metric; + + private int topK; + + private String pattern; + + private EmbeddingEndpoint embeddingEndpoint; + + public RedisEndpoint() {} + + public RedisEndpoint(RetryPolicy retryPolicy) { + super(retryPolicy); + } + + public RedisEndpoint(String indexName, EmbeddingEndpoint embeddingEndpoint) { + this.indexName = indexName; + this.embeddingEndpoint = embeddingEndpoint; + } + + public RedisEndpoint( + String indexName, EmbeddingEndpoint embeddingEndpoint, RetryPolicy retryPolicy) { + super(retryPolicy); + this.indexName = indexName; + this.embeddingEndpoint = embeddingEndpoint; + } + + public RedisEndpoint(String indexName, String namespace, EmbeddingEndpoint embeddingEndpoint) { + this.indexName = indexName; + this.namespace = namespace; + this.embeddingEndpoint = embeddingEndpoint; + } + + public RedisEndpoint( + String indexName, + String namespace, + EmbeddingEndpoint embeddingEndpoint, + RetryPolicy retryPolicy) { + super(retryPolicy); + this.indexName = indexName; + this.namespace = namespace; + this.embeddingEndpoint = embeddingEndpoint; + } + + public EmbeddingEndpoint getEmbeddingEndpoint() { + return embeddingEndpoint; + } + + public void setEmbeddingEndpoint(EmbeddingEndpoint embeddingEndpoint) { + this.embeddingEndpoint = embeddingEndpoint; + } + + public void setPattern(String pattern) { + this.pattern = pattern; + } + + public String getIndexName() { + return indexName; + } + + public void setIndexName(String indexName) { + this.indexName = indexName; + } + + public String getNamespace() { + return namespace; + } + + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + // Getters + public WordEmbeddings getWordEmbedding() { + return wordEmbedding; + } + + public void setWordEmbedding(WordEmbeddings wordEmbedding) { + this.wordEmbedding = wordEmbedding; + } + + public int getDimensions() { + return dimensions; + } + + public void setDimensions(int dimensions) { + this.dimensions = dimensions; + } + + public void setWordEmbeddingsList(List wordEmbeddingsList) { + this.wordEmbeddingsList = wordEmbeddingsList; + } + + public RedisDistanceMetric getMetric() { + return metric; + } + + public List getWordEmbeddingsList() { + return wordEmbeddingsList; + } + + public void setMetric(RedisDistanceMetric metric) { + this.metric = metric; + } + + public int getTopK() { + return topK; + } + + public void setTopK(int topK) { + this.topK = topK; + } + + public String getPattern() { + return pattern; + } + + // Convenience Methods + public StringResponse createIndex(String namespace, int dimension, RedisDistanceMetric metric) { + RedisEndpoint mapper = modelMapper.map(this, RedisEndpoint.class); + mapper.setDimensions(dimension); + mapper.setMetric(metric); + mapper.setNamespace(namespace); + + return this.redisService.createIndex(mapper).blockingGet(); + } + + public void batchUpsert(List wordEmbeddingsList) { + RedisEndpoint mapper = modelMapper.map(this, RedisEndpoint.class); + mapper.setWordEmbeddingsList(wordEmbeddingsList); + + this.redisService.batchUpsert(mapper).ignoreElement().blockingAwait(); + } + + public StringResponse upsert(WordEmbeddings wordEmbedding) { + RedisEndpoint mapper = modelMapper.map(this, RedisEndpoint.class); + mapper.setWordEmbedding(wordEmbedding); + + return this.redisService.upsert(mapper).blockingGet(); + } + + public Observable> query(String input, int topK, ArkRequest arkRequest) { + + WordEmbeddings wordEmbedding = + new EdgeChain<>(embeddingEndpoint.embeddings(input, arkRequest)).get(); + + RedisEndpoint mapper = modelMapper.map(this, RedisEndpoint.class); + mapper.setTopK(topK); + mapper.setWordEmbedding(wordEmbedding); + return Observable.fromSingle(this.redisService.query(mapper)); + } + + public void delete(String patternName) { + RedisEndpoint mapper = modelMapper.map(this, RedisEndpoint.class); + mapper.setPattern(patternName); + this.redisService.deleteByPattern(mapper).blockingAwait(); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/integration/AirtableEndpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/integration/AirtableEndpoint.java new file mode 100644 index 000000000..1ca7f4943 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/integration/AirtableEndpoint.java @@ -0,0 +1,182 @@ +package com.edgechain.lib.endpoint.impl.integration; + +import com.edgechain.lib.endpoint.Endpoint; +import com.edgechain.lib.integration.airtable.query.AirtableQueryBuilder; +import com.edgechain.lib.retrofit.AirtableService; +import com.edgechain.lib.retrofit.client.RetrofitClientInstance; +import dev.fuxing.airtable.AirtableRecord; +import io.reactivex.rxjava3.core.Observable; +import org.modelmapper.ModelMapper; +import retrofit2.Retrofit; + +import java.util.List; +import java.util.Map; + +public class AirtableEndpoint extends Endpoint { + + private final Retrofit retrofit = RetrofitClientInstance.getInstance(); + private final AirtableService airtableService = retrofit.create(AirtableService.class); + + private ModelMapper modelMapper = new ModelMapper(); + + private String baseId; + private String apiKey; + + private List ids; + private String tableName; + private List airtableRecordList; + private boolean typecast = false; + + private AirtableQueryBuilder airtableQueryBuilder; + + public AirtableEndpoint() {} + + public AirtableEndpoint(String baseId, String apiKey) { + this.baseId = baseId; + this.apiKey = apiKey; + } + + public void setIds(List ids) { + this.ids = ids; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + public void setAirtableRecordList(List airtableRecordList) { + this.airtableRecordList = airtableRecordList; + } + + public void setTypecast(boolean typecast) { + this.typecast = typecast; + } + + public void setAirtableQueryBuilder(AirtableQueryBuilder airtableQueryBuilder) { + this.airtableQueryBuilder = airtableQueryBuilder; + } + + public void setBaseId(String baseId) { + this.baseId = baseId; + } + + @Override + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getBaseId() { + return baseId; + } + + public String getApiKey() { + return apiKey; + } + + public String getTableName() { + return tableName; + } + + public List getIds() { + return ids; + } + + public List getAirtableRecordList() { + return airtableRecordList; + } + + public boolean isTypecast() { + return typecast; + } + + public AirtableQueryBuilder getAirtableQueryBuilder() { + return airtableQueryBuilder; + } + + public Observable> findAll(String tableName, AirtableQueryBuilder builder) { + AirtableEndpoint mapper = modelMapper.map(this, AirtableEndpoint.class); + ; + mapper.setTableName(tableName); + mapper.setAirtableQueryBuilder(builder); + return Observable.fromSingle(this.airtableService.findAll(mapper)); + } + + public Observable> findAll(String tableName) { + AirtableEndpoint mapper = modelMapper.map(this, AirtableEndpoint.class); + mapper.setTableName(tableName); + mapper.setAirtableQueryBuilder(new AirtableQueryBuilder()); + + return Observable.fromSingle(this.airtableService.findAll(mapper)); + } + + public Observable findById(String tableName, String id) { + AirtableEndpoint mapper = modelMapper.map(this, AirtableEndpoint.class); + mapper.setTableName(tableName); + mapper.setIds(List.of(id)); + return Observable.fromSingle(this.airtableService.findById(mapper)); + } + + public Observable> create( + String tableName, List airtableRecordList) { + AirtableEndpoint mapper = modelMapper.map(this, AirtableEndpoint.class); + mapper.setAirtableRecordList(airtableRecordList); + mapper.setTableName(tableName); + return Observable.fromSingle(this.airtableService.create(mapper)); + } + + public Observable> create( + String tableName, List airtableRecordList, boolean typecast) { + AirtableEndpoint mapper = modelMapper.map(this, AirtableEndpoint.class); + mapper.setAirtableRecordList(airtableRecordList); + mapper.setTableName(tableName); + mapper.setTypecast(typecast); + return Observable.fromSingle(this.airtableService.create(mapper)); + } + + public Observable> create(String tableName, AirtableRecord airtableRecord) { + AirtableEndpoint mapper = modelMapper.map(this, AirtableEndpoint.class); + mapper.setAirtableRecordList(List.of(airtableRecord)); + mapper.setTableName(tableName); + return Observable.fromSingle(this.airtableService.create(mapper)); + } + + public Observable> update( + String tableName, List airtableRecordList) { + AirtableEndpoint mapper = modelMapper.map(this, AirtableEndpoint.class); + mapper.setAirtableRecordList(airtableRecordList); + mapper.setTableName(tableName); + + return Observable.fromSingle(this.airtableService.update(mapper)); + } + + public Observable> update( + String tableName, List airtableRecordList, boolean typecast) { + AirtableEndpoint mapper = modelMapper.map(this, AirtableEndpoint.class); + mapper.setAirtableRecordList(airtableRecordList); + mapper.setTableName(tableName); + mapper.setTypecast(typecast); + + return Observable.fromSingle(this.airtableService.update(mapper)); + } + + public Observable> update(String tableName, AirtableRecord airtableRecord) { + AirtableEndpoint mapper = modelMapper.map(this, AirtableEndpoint.class); + mapper.setAirtableRecordList(List.of(airtableRecord)); + mapper.setTableName(tableName); + return Observable.fromSingle(this.airtableService.update(mapper)); + } + + public Observable> delete(String tableName, List ids) { + AirtableEndpoint mapper = modelMapper.map(this, AirtableEndpoint.class); + mapper.setIds(ids); + mapper.setTableName(tableName); + return Observable.fromSingle(this.airtableService.delete(mapper)); + } + + public Observable> delete(String tableName, String id) { + AirtableEndpoint mapper = modelMapper.map(this, AirtableEndpoint.class); + mapper.setIds(List.of(id)); + mapper.setTableName(tableName); + return Observable.fromSingle(this.airtableService.delete(mapper)); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/llm/LLamaQuickstart.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/llm/LLamaQuickstart.java new file mode 100644 index 000000000..03e52f6da --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/llm/LLamaQuickstart.java @@ -0,0 +1,47 @@ +package com.edgechain.lib.endpoint.impl.llm; + +import com.edgechain.lib.endpoint.Endpoint; +import com.edgechain.lib.request.ArkRequest; +import com.edgechain.lib.retrofit.Llama2Service; +import com.edgechain.lib.retrofit.client.RetrofitClientInstance; +import com.edgechain.lib.rxjava.retry.RetryPolicy; +import io.reactivex.rxjava3.core.Observable; +import org.modelmapper.ModelMapper; +import retrofit2.Retrofit; + +public class LLamaQuickstart extends Endpoint { + private final Retrofit retrofit = RetrofitClientInstance.getInstance(); + private final Llama2Service llama2Service = retrofit.create(Llama2Service.class); + private final ModelMapper modelMapper = new ModelMapper(); + private String query; + + public LLamaQuickstart() {} + + public LLamaQuickstart(String url, RetryPolicy retryPolicy) { + super(url, retryPolicy); + } + + public LLamaQuickstart(String url, RetryPolicy retryPolicy, String query) { + super(url, retryPolicy); + this.query = query; + } + + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + public Observable chatCompletion(String query, ArkRequest arkRequest) { + LLamaQuickstart mapper = modelMapper.map(this, LLamaQuickstart.class); + mapper.setQuery(query); + return chatCompletion(mapper, arkRequest); + } + + private Observable chatCompletion( + LLamaQuickstart lLamaQuickstart, ArkRequest arkRequest) { + return Observable.fromSingle(this.llama2Service.llamaCompletion(lLamaQuickstart)); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/llm/Llama2Endpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/llm/Llama2Endpoint.java new file mode 100644 index 000000000..96ba9912d --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/llm/Llama2Endpoint.java @@ -0,0 +1,180 @@ +package com.edgechain.lib.endpoint.impl.llm; + +import com.edgechain.lib.endpoint.Endpoint; +import com.edgechain.lib.llama2.response.Llama2ChatCompletionResponse; +import com.edgechain.lib.request.ArkRequest; +import com.edgechain.lib.retrofit.Llama2Service; +import com.edgechain.lib.retrofit.client.RetrofitClientInstance; +import com.edgechain.lib.rxjava.retry.RetryPolicy; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.reactivex.rxjava3.core.Observable; +import org.json.JSONObject; +import org.modelmapper.ModelMapper; +import retrofit2.Retrofit; + +import java.util.List; +import java.util.Objects; + +public class Llama2Endpoint extends Endpoint { + private final Retrofit retrofit = RetrofitClientInstance.getInstance(); + private final Llama2Service llama2Service = retrofit.create(Llama2Service.class); + + private final ModelMapper modelMapper = new ModelMapper(); + + private String inputs; + private JSONObject parameters; + private Double temperature; + + @JsonProperty("top_k") + private Integer topK; + + @JsonProperty("top_p") + private Double topP; + + @JsonProperty("do_sample") + private Boolean doSample; + + @JsonProperty("max_new_tokens") + private Integer maxNewTokens; + + @JsonProperty("repetition_penalty") + private Double repetitionPenalty; + + private List stop; + private String chainName; + private String callIdentifier; + + public Llama2Endpoint() {} + + public Llama2Endpoint( + String url, + RetryPolicy retryPolicy, + Double temperature, + Integer topK, + Double topP, + Boolean doSample, + Integer maxNewTokens, + Double repetitionPenalty, + List stop) { + super(url, retryPolicy); + this.temperature = temperature; + this.topK = topK; + this.topP = topP; + this.doSample = doSample; + this.maxNewTokens = maxNewTokens; + this.repetitionPenalty = repetitionPenalty; + this.stop = stop; + } + + public Llama2Endpoint(String url, RetryPolicy retryPolicy) { + super(url, retryPolicy); + this.temperature = 0.7; + this.maxNewTokens = 512; + } + + public String getInputs() { + return inputs; + } + + public void setInputs(String inputs) { + this.inputs = inputs; + } + + public JSONObject getParameters() { + return parameters; + } + + public void setParameters(JSONObject parameters) { + this.parameters = parameters; + } + + public Double getTemperature() { + return temperature; + } + + public void setTemperature(Double temperature) { + this.temperature = temperature; + } + + public Integer getTopK() { + return topK; + } + + public void setTopK(Integer topK) { + this.topK = topK; + } + + public Double getTopP() { + return topP; + } + + public void setTopP(Double topP) { + this.topP = topP; + } + + public Boolean getDoSample() { + return doSample; + } + + public void setDoSample(Boolean doSample) { + this.doSample = doSample; + } + + public Integer getMaxNewTokens() { + return maxNewTokens; + } + + public void setMaxNewTokens(Integer maxNewTokens) { + this.maxNewTokens = maxNewTokens; + } + + public Double getRepetitionPenalty() { + return repetitionPenalty; + } + + public void setRepetitionPenalty(Double repetitionPenalty) { + this.repetitionPenalty = repetitionPenalty; + } + + public List getStop() { + return stop; + } + + public void setStop(List stop) { + this.stop = stop; + } + + public String getChainName() { + return chainName; + } + + public void setChainName(String chainName) { + this.chainName = chainName; + } + + public String getCallIdentifier() { + return callIdentifier; + } + + public void setCallIdentifier(String callIdentifier) { + this.callIdentifier = callIdentifier; + } + + public Observable> chatCompletion( + String inputs, String chainName, ArkRequest arkRequest) { + + Llama2Endpoint mapper = modelMapper.map(this, Llama2Endpoint.class); + mapper.setInputs(inputs); + mapper.setChainName(chainName); + return chatCompletion(mapper, arkRequest); + } + + private Observable> chatCompletion( + Llama2Endpoint mapper, ArkRequest arkRequest) { + + if (Objects.nonNull(arkRequest)) mapper.setCallIdentifier(arkRequest.getRequestURI()); + else mapper.setCallIdentifier("URI wasn't provided"); + + return Observable.fromSingle(this.llama2Service.chatCompletion(mapper)); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/OpenAiEndpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/llm/OpenAiChatEndpoint.java similarity index 50% rename from Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/OpenAiEndpoint.java rename to Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/llm/OpenAiChatEndpoint.java index d21685899..19d571ef8 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/OpenAiEndpoint.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/llm/OpenAiChatEndpoint.java @@ -1,22 +1,25 @@ -package com.edgechain.lib.endpoint.impl; +package com.edgechain.lib.endpoint.impl.llm; import com.edgechain.lib.configuration.context.ApplicationContextHolder; -import com.edgechain.lib.embeddings.WordEmbeddings; +import com.edgechain.lib.endpoint.Endpoint; +import com.edgechain.lib.jsonnet.JsonnetLoader; import com.edgechain.lib.openai.request.ChatMessage; +import com.edgechain.lib.openai.response.CompletionResponse; import com.edgechain.lib.request.ArkRequest; import com.edgechain.lib.retrofit.client.OpenAiStreamService; import com.edgechain.lib.retrofit.OpenAiService; -import com.edgechain.lib.endpoint.Endpoint; import com.edgechain.lib.openai.response.ChatCompletionResponse; import com.edgechain.lib.retrofit.client.RetrofitClientInstance; import com.edgechain.lib.rxjava.retry.RetryPolicy; import io.reactivex.rxjava3.core.Observable; +import org.modelmapper.ModelMapper; import retrofit2.Retrofit; import java.util.List; +import java.util.Map; import java.util.Objects; -public class OpenAiEndpoint extends Endpoint { +public class OpenAiChatEndpoint extends Endpoint { private final OpenAiStreamService openAiStreamService = ApplicationContextHolder.getContext().getBean(OpenAiStreamService.class); @@ -24,15 +27,23 @@ public class OpenAiEndpoint extends Endpoint { private final Retrofit retrofit = RetrofitClientInstance.getInstance(); private final OpenAiService openAiService = retrofit.create(OpenAiService.class); + private ModelMapper modelMapper = new ModelMapper(); + private String orgId; private String model; - private String role; - private Double temperature; + private Double temperature; + private List chatMessages; private Boolean stream; + private Double topP; + private Integer n; + private List stop; + private Double presencePenalty; + private Double frequencyPenalty; + private Map logitBias; + private String user; - /** Getter Fields ** */ - private List chatMessages; + private String role; private String input; @@ -41,26 +52,24 @@ public class OpenAiEndpoint extends Endpoint { private String callIdentifier; - public OpenAiEndpoint() {} + private JsonnetLoader jsonnetLoader; - public OpenAiEndpoint(String url, String apiKey, String model) { - super(url, apiKey, null); - this.model = model; - } + public OpenAiChatEndpoint() {} - public OpenAiEndpoint(String url, String apiKey, String model, RetryPolicy retryPolicy) { - super(url, apiKey, retryPolicy); + public OpenAiChatEndpoint(String url, String apiKey, String model) { + super(url, apiKey, null); this.model = model; } - public OpenAiEndpoint( - String url, String apiKey, String model, String role, RetryPolicy retryPolicy) { + // For Embeddings.... + public OpenAiChatEndpoint( + String url, String apiKey, String orgId, String model, RetryPolicy retryPolicy) { super(url, apiKey, retryPolicy); + this.orgId = orgId; this.model = model; - this.role = role; } - public OpenAiEndpoint( + public OpenAiChatEndpoint( String url, String apiKey, String model, @@ -73,7 +82,7 @@ public OpenAiEndpoint( this.temperature = temperature; } - public OpenAiEndpoint( + public OpenAiChatEndpoint( String url, String apiKey, String model, String role, Double temperature, Boolean stream) { super(url, apiKey, null); this.model = model; @@ -82,22 +91,22 @@ public OpenAiEndpoint( this.stream = stream; } - public OpenAiEndpoint( + public OpenAiChatEndpoint( String url, String apiKey, + String orgId, String model, String role, Double temperature, - Boolean stream, RetryPolicy retryPolicy) { super(url, apiKey, retryPolicy); this.model = model; this.role = role; this.temperature = temperature; - this.stream = stream; + this.orgId = orgId; } - public OpenAiEndpoint( + public OpenAiChatEndpoint( String url, String apiKey, String orgId, @@ -113,7 +122,7 @@ public OpenAiEndpoint( this.stream = stream; } - public OpenAiEndpoint( + public OpenAiChatEndpoint( String url, String apiKey, String orgId, @@ -130,14 +139,22 @@ public OpenAiEndpoint( this.stream = stream; } - public String getModel() { - return model; - } - public String getRole() { return role; } + public void setRole(String role) { + this.role = role; + } + + public void setInput(String input) { + this.input = input; + } + + public String getModel() { + return model; + } + public Double getTemperature() { return temperature; } @@ -158,10 +175,6 @@ public void setModel(String model) { this.model = model; } - public void setRole(String role) { - this.role = role; - } - public void setTemperature(Double temperature) { this.temperature = temperature; } @@ -170,14 +183,86 @@ public void setStream(Boolean stream) { this.stream = stream; } - public List getChatMessages() { - return chatMessages; + public Double getTopP() { + return topP; + } + + public void setTopP(Double topP) { + this.topP = topP; + } + + public Integer getN() { + return n; + } + + public void setN(Integer n) { + this.n = n; + } + + public List getStop() { + return stop; } public String getInput() { return input; } + public void setStop(List stop) { + this.stop = stop; + } + + public Double getPresencePenalty() { + return presencePenalty; + } + + public void setPresencePenalty(Double presencePenalty) { + this.presencePenalty = presencePenalty; + } + + public Double getFrequencyPenalty() { + return frequencyPenalty; + } + + public void setFrequencyPenalty(Double frequencyPenalty) { + this.frequencyPenalty = frequencyPenalty; + } + + public Map getLogitBias() { + return logitBias; + } + + public void setLogitBias(Map logitBias) { + this.logitBias = logitBias; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public void setCallIdentifier(String callIdentifier) { + this.callIdentifier = callIdentifier; + } + + public List getChatMessages() { + return chatMessages; + } + + public void setChatMessages(List chatMessages) { + this.chatMessages = chatMessages; + } + + public void setJsonnetLoader(JsonnetLoader jsonnetLoader) { + this.jsonnetLoader = jsonnetLoader; + } + + public JsonnetLoader getJsonnetLoader() { + return jsonnetLoader; + } + public String getChainName() { return chainName; } @@ -193,41 +278,55 @@ public String getCallIdentifier() { public Observable chatCompletion( String input, String chainName, ArkRequest arkRequest) { - this.chatMessages = List.of(new ChatMessage(this.role, input)); - this.chainName = chainName; + OpenAiChatEndpoint mapper = modelMapper.map(this, OpenAiChatEndpoint.class); + mapper.setChatMessages(List.of(new ChatMessage(this.role, input))); + mapper.setChainName(chainName); - if (Objects.nonNull(arkRequest)) { - this.callIdentifier = arkRequest.getRequestURI(); - } + return chatCompletion(mapper, arkRequest); + } - if (Objects.nonNull(this.getStream()) && this.getStream()) - return this.openAiStreamService - .chatCompletion(this) - .map( - chatResponse -> { - if (!Objects.isNull(chatResponse.getChoices().get(0).getFinishReason())) { - chatResponse.getChoices().get(0).getMessage().setContent(""); - return chatResponse; - } else return chatResponse; - }); - else return Observable.fromSingle(this.openAiService.chatCompletion(this)); + public Observable chatCompletion( + String input, String chainName, JsonnetLoader loader, ArkRequest arkRequest) { + + OpenAiChatEndpoint mapper = modelMapper.map(this, OpenAiChatEndpoint.class); + mapper.setChatMessages(List.of(new ChatMessage(this.role, input))); + mapper.setChainName(chainName); + mapper.setJsonnetLoader(loader); + + return chatCompletion(mapper, arkRequest); } public Observable chatCompletion( List chatMessages, String chainName, ArkRequest arkRequest) { + OpenAiChatEndpoint mapper = modelMapper.map(this, OpenAiChatEndpoint.class); + mapper.setChatMessages(chatMessages); + mapper.setChainName(chainName); + return chatCompletion(mapper, arkRequest); + } - this.chainName = chainName; - this.chatMessages = chatMessages; + public Observable chatCompletion( + List chatMessages, + String chainName, + JsonnetLoader loader, + ArkRequest arkRequest) { + + OpenAiChatEndpoint mapper = modelMapper.map(this, OpenAiChatEndpoint.class); + mapper.setChatMessages(chatMessages); + mapper.setChainName(chainName); + mapper.setJsonnetLoader(loader); + + return chatCompletion(mapper, arkRequest); + } + + private Observable chatCompletion( + OpenAiChatEndpoint mapper, ArkRequest arkRequest) { - if (Objects.nonNull(arkRequest)) { - this.callIdentifier = arkRequest.getRequestURI(); - } else { - this.callIdentifier = "URI wasn't provided"; - } + if (Objects.nonNull(arkRequest)) mapper.setCallIdentifier(arkRequest.getRequestURI()); + else mapper.setCallIdentifier("URI wasn't provided"); - if (Objects.nonNull(this.getStream()) && this.getStream()) + if (Objects.nonNull(getStream()) && getStream()) return this.openAiStreamService - .chatCompletion(this) + .chatCompletion(mapper) .map( chatResponse -> { if (!Objects.isNull(chatResponse.getChoices().get(0).getFinishReason())) { @@ -235,21 +334,14 @@ public Observable chatCompletion( return chatResponse; } else return chatResponse; }); - else return Observable.fromSingle(this.openAiService.chatCompletion(this)); + else return Observable.fromSingle(this.openAiService.chatCompletion(mapper)); } - public Observable embeddings(String input, ArkRequest arkRequest) { - this.input = input; // set Input - - if (Objects.nonNull(arkRequest)) { - this.callIdentifier = arkRequest.getRequestURI(); - } + public Observable completion(String input, ArkRequest arkRequest) { + if (Objects.nonNull(arkRequest)) this.callIdentifier = arkRequest.getRequestURI(); + else this.callIdentifier = "URI wasn't provided"; - return Observable.fromSingle( - openAiService - .embeddings(this) - .map( - embeddingResponse -> - new WordEmbeddings(input, embeddingResponse.getData().get(0).getEmbedding()))); + this.input = input; + return Observable.fromSingle(this.openAiService.completion(this)); } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/SupabaseEndpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/supabase/SupabaseEndpoint.java similarity index 96% rename from Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/SupabaseEndpoint.java rename to Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/supabase/SupabaseEndpoint.java index 7ff111733..22acc7921 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/SupabaseEndpoint.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/supabase/SupabaseEndpoint.java @@ -1,4 +1,4 @@ -package com.edgechain.lib.endpoint.impl; +package com.edgechain.lib.endpoint.impl.supabase; import com.edgechain.lib.endpoint.Endpoint; import com.edgechain.lib.retrofit.SupabaseService; diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/WikiEndpoint.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/wiki/WikiEndpoint.java similarity index 78% rename from Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/WikiEndpoint.java rename to Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/wiki/WikiEndpoint.java index cc9e95871..f03cf381d 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/WikiEndpoint.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/endpoint/impl/wiki/WikiEndpoint.java @@ -1,4 +1,4 @@ -package com.edgechain.lib.endpoint.impl; +package com.edgechain.lib.endpoint.impl.wiki; import com.edgechain.lib.endpoint.Endpoint; import com.edgechain.lib.retrofit.WikiService; @@ -6,6 +6,7 @@ import com.edgechain.lib.rxjava.retry.RetryPolicy; import com.edgechain.lib.wiki.response.WikiResponse; import io.reactivex.rxjava3.core.Observable; +import org.modelmapper.ModelMapper; import retrofit2.Retrofit; public class WikiEndpoint extends Endpoint { @@ -13,13 +14,14 @@ public class WikiEndpoint extends Endpoint { private final Retrofit retrofit = RetrofitClientInstance.getInstance(); private final WikiService wikiService = retrofit.create(WikiService.class); + private ModelMapper modelMapper = new ModelMapper(); + private String input; public WikiEndpoint() {} public WikiEndpoint(RetryPolicy retryPolicy) { super(retryPolicy); - this.input = input; } public String getInput() { @@ -31,7 +33,8 @@ public void setInput(String input) { } public Observable getPageContent(String input) { - this.input = input; - return Observable.fromSingle(this.wikiService.getPageContent(this)); + WikiEndpoint mapper = modelMapper.map(this, WikiEndpoint.class); + mapper.setInput(input); + return Observable.fromSingle(this.wikiService.getPageContent(mapper)); } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/flyfly/commands/run/ProjectRunner.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/flyfly/commands/run/ProjectRunner.java index 488460574..f2f8669cd 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/flyfly/commands/run/ProjectRunner.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/flyfly/commands/run/ProjectRunner.java @@ -1,11 +1,19 @@ package com.edgechain.lib.flyfly.commands.run; -import static java.nio.file.StandardWatchEventKinds.*; - import com.edgechain.lib.flyfly.utils.ProjectSetup; import jakarta.annotation.PreDestroy; -import java.io.*; -import java.nio.file.*; +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.nio.file.FileSystems; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.WatchEvent; +import java.nio.file.WatchKey; +import java.nio.file.WatchService; import java.nio.file.attribute.BasicFileAttributes; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -15,11 +23,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.zeroturnaround.exec.ProcessExecutor; +import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE; +import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE; +import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY; @Component public class ProjectRunner { - private final Logger log = LoggerFactory.getLogger(this.getClass()); + private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired TestContainersStarter testContainersStarter; @Autowired ProjectSetup projectSetup; @@ -31,30 +42,35 @@ public class ProjectRunner { public void run() { try { - log.info("Configuring the project"); - log.info("Checking if initscript exists"); + logger.info("Configuring the project"); + logger.info("Checking if initscript exists"); if (!projectSetup.initscriptExists()) { - log.info("Initscript doesn't exist"); - log.info("Adding flyfly.gradle to initscripts"); + logger.info("Initscript doesn't exist"); + logger.info("Adding flyfly.gradle to initscripts"); projectSetup.addInitscript(); } projectSetup.addAutorouteJar(); allowInfrastructureServices = isDockerInstalled(); if (allowInfrastructureServices) checkAndConfigureServices(); - log.debug("registering watcher for src files changes"); + logger.debug("registering watcher for src files changes"); registerFilesWatcher(); - log.debug("registering watcher for build file changes"); + logger.debug("registering watcher for build file changes"); registerBuildFileWatcher(); - log.info("Starting the project"); + logger.info("Starting the project"); runTheProject(); loop(); + + } catch (InterruptedException ie) { + logger.warn("interrupted", ie); + Thread.currentThread().interrupt(); + } catch (Exception e) { - e.printStackTrace(); + logger.error("failed", e); } } boolean isDockerInstalled() throws IOException, InterruptedException { - log.info("Checking if docker is installed to allow infrastructure services"); + logger.info("Checking if docker is installed to allow infrastructure services"); int exitCode; try { String[] command; @@ -62,11 +78,19 @@ boolean isDockerInstalled() throws IOException, InterruptedException { else command = new String[] {"docker", "info"}; exitCode = new ProcessExecutor().command(command).start().getProcess().waitFor(); + + } catch (InterruptedException ie) { + logger.warn("interrupted", ie); + Thread.currentThread().interrupt(); + exitCode = -1; + } catch (Exception e) { + logger.error("failed", e); exitCode = -1; } + if (exitCode != 0) { - log.warn("Couldn't find docker. Disabling infrastructure services."); + logger.warn("Couldn't find docker. Disabling infrastructure services."); return false; } return true; @@ -82,9 +106,9 @@ void runTheProject() throws IOException { } void checkAndConfigureServices() throws IOException { - log.info("Checking if services are needed"); - // Set supportedDBGroupIds = - // Set.of("mysql", "com.mysql", "org.postgresql", "org.mariadb.jdbc"); + logger.info("Checking if services are needed"); + // Set supportedDBGroupIds = + // Set.of("mysql", "com.mysql", "org.postgresql", "org.mariadb.jdbc"); Set supportedDBGroupIds = Set.of("org.postgresql"); BufferedReader reader = new BufferedReader(new FileReader("build.gradle")); String line; @@ -96,12 +120,12 @@ void checkAndConfigureServices() throws IOException { if (start < 0 || end < 0) continue; String groupID = line.substring(start + 1, end); if (supportedDBGroupIds.contains(groupID)) { - if (!testContainersStarter.isServiesNeeded()) break; - log.info("Found : " + groupID); + if (!testContainersStarter.isServiceNeeded()) break; + logger.info("Found : {}", groupID); switch (groupID) { - // case "mysql", "com.mysql" -> testContainersStarter.startMySQL(); + // case "mysql", "com.mysql" -> testContainersStarter.startMySQL(); case "org.postgresql" -> testContainersStarter.startPostgreSQL(); - // case "org.mariadb.jdbc" -> testContainersStarter.startMariaDB(); + // case "org.mariadb.jdbc" -> testContainersStarter.startMariaDB(); } break; } @@ -167,7 +191,7 @@ boolean didBuildFileChange() throws InterruptedException { if (p.endsWith("build.gradle")) found = true; } key.reset(); - if (found) log.info("Detected build file change ..."); + if (found) logger.info("Detected build file change ..."); return found; } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/flyfly/commands/run/TestContainersStarter.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/flyfly/commands/run/TestContainersStarter.java index edea76f91..2ba68603a 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/flyfly/commands/run/TestContainersStarter.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/flyfly/commands/run/TestContainersStarter.java @@ -1,9 +1,12 @@ package com.edgechain.lib.flyfly.commands.run; import jakarta.annotation.PreDestroy; -import java.io.*; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; import java.nio.file.FileSystems; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -14,121 +17,152 @@ public class TestContainersStarter { private final Logger log = LoggerFactory.getLogger(this.getClass()); - private static final String dbName = "test"; - private static final String userName = "test"; - private static final String password = "test"; - // private MySQLContainer mysql; + private static final String DBNAME = "test"; + private static final String USERNAME = "test"; + private static final String PASSWORD = "test"; + // private MySQLContainer mysql; private PostgreSQLContainer postgre; - // private MariaDBContainer mariaDB; - private String flyflyTempTag = "#flyfly_temp_property"; - - // public void startMySQL() throws IOException { - // if (mysql != null && mysql.isRunning()) return; - // log.info("Starting a temporary MySQL database."); - // mysql = - // new MySQLContainer<>(DockerImageName.parse("mysql:5.7")) - // .withDatabaseName(dbName) - // .withUsername(userName) - // .withPassword(password); - // mysql.addParameter("TC_MY_CNF", null); - // mysql.start(); - // log.info("Database started."); - // log.info("DB URL: " + mysql.getJdbcUrl()); - // log.info("DB Username: " + mysql.getUsername()); - // log.info("DB Password: " + mysql.getPassword()); - // addTempProperties(mysql.getJdbcUrl()); - // } + // private MariaDBContainer mariaDB; + static final String FLYFLYTEMPTAG = "#flyfly_temp_property"; + + private String propertiesPath; + + public TestContainersStarter() { + propertiesPath = buildPropertiesPath(); + } + + public String getPropertiesPath() { + return propertiesPath; + } + + public void setPropertiesPath(String propertiesPath) { + this.propertiesPath = propertiesPath; + } + + // public void startMySQL() throws IOException { + // if (mysql != null && mysql.isRunning()) return; + // log.info("Starting a temporary MySQL database."); + // mysql = + // new MySQLContainer<>(DockerImageName.parse("mysql:5.7")) + // .withDatabaseName(dbName) + // .withUsername(userName) + // .withPassword(password); + // mysql.addParameter("TC_MY_CNF", null); + // mysql.start(); + // log.info("Database started."); + // log.info("DB URL: " + mysql.getJdbcUrl()); + // log.info("DB Username: " + mysql.getUsername()); + // log.info("DB Password: " + mysql.getPassword()); + // addTempProperties(mysql.getJdbcUrl()); + // } public void startPostgreSQL() throws IOException { if (postgre != null && postgre.isRunning()) return; log.info("Starting a temporary PostgreSQL database."); postgre = new PostgreSQLContainer<>("postgres:14.5") - .withDatabaseName(dbName) - .withUsername(userName) - .withPassword(password); + .withDatabaseName(DBNAME) + .withUsername(USERNAME) + .withPassword(PASSWORD); postgre.addParameter("TC_MY_CNF", null); postgre.start(); + log.info("Database started."); - log.info("DB URL: " + postgre.getJdbcUrl()); - log.info("DB Username: " + postgre.getUsername()); - log.info("DB Password: " + postgre.getPassword()); + log.info("DB URL: {}", postgre.getJdbcUrl()); + log.info("DB Username: {}", postgre.getUsername()); + log.info("DB Password: {}", postgre.getPassword()); + addTempProperties(postgre.getJdbcUrl()); } - // public void startMariaDB() throws IOException { - // if (postgre != null && postgre.isRunning()) return; - // log.info("Starting a temporary MariaDB database."); - // mariaDB = - // new MariaDBContainer<>("mariadb:10.3.6") - // .withDatabaseName(dbName) - // .withUsername(userName) - // .withPassword(password); - // mariaDB.addParameter("TC_MY_CNF", null); - // mariaDB.start(); - // log.info("Database started."); - // log.info("DB URL: " + mariaDB.getJdbcUrl()); - // log.info("DB Username: " + mariaDB.getUsername()); - // log.info("DB Password: " + mariaDB.getPassword()); - // addTempProperties(mariaDB.getJdbcUrl()); - // } + public void stopPostgreSQL() throws IOException { + try { + removeTempProperties(); + } catch (IOException e) { + } + // if (mysql != null && mysql.isRunning()) mysql.close(); + log.info("Stopping temporary PostgreSQL database."); + if (postgre != null && postgre.isRunning()) postgre.close(); + // if (mariaDB != null && mariaDB.isRunning()) mariaDB.close(); + } + + // public void startMariaDB() throws IOException { + // if (postgre != null && postgre.isRunning()) return; + // log.info("Starting a temporary MariaDB database."); + // mariaDB = + // new MariaDBContainer<>("mariadb:10.3.6") + // .withDatabaseName(dbName) + // .withUsername(userName) + // .withPassword(password); + // mariaDB.addParameter("TC_MY_CNF", null); + // mariaDB.start(); + // log.info("Database started."); + // log.info("DB URL: " + mariaDB.getJdbcUrl()); + // log.info("DB Username: " + mariaDB.getUsername()); + // log.info("DB Password: " + mariaDB.getPassword()); + // addTempProperties(mariaDB.getJdbcUrl()); + // } public void addTempProperties(String url) throws IOException { log.info("Appending temporary DB configuration to application.properties"); - BufferedWriter writer = new BufferedWriter(new FileWriter(getPropertiesPath(), true)); - writer.newLine(); - writer.append(flyflyTempTag); - writer.newLine(); - writer.append("spring.datasource.url=" + url); - writer.newLine(); - writer.append(flyflyTempTag); - writer.newLine(); - writer.append("spring.datasource.username=" + userName); - writer.newLine(); - writer.append(flyflyTempTag); - writer.newLine(); - writer.append("spring.datasource.password=" + password); - writer.flush(); - writer.close(); + try (FileWriter fw = new FileWriter(propertiesPath, true); + BufferedWriter writer = new BufferedWriter(fw)) { + writer.newLine(); + writer.append(FLYFLYTEMPTAG); + writer.newLine(); + writer.append("spring.datasource.url=").append(url); + writer.newLine(); + writer.append(FLYFLYTEMPTAG); + writer.newLine(); + writer.append("spring.datasource.username=").append(USERNAME); + writer.newLine(); + writer.append(FLYFLYTEMPTAG); + writer.newLine(); + writer.append("spring.datasource.password=").append(PASSWORD); + writer.flush(); + } } public void removeTempProperties() throws IOException { - BufferedReader reader = new BufferedReader(new FileReader(getPropertiesPath())); - StringBuilder sb = new StringBuilder(); + log.info("Removing temporary DB configuration from application.properties"); boolean tempNotFound = true; - String line; - while ((line = reader.readLine()) != null) { - if (line.contains(flyflyTempTag)) { - tempNotFound = false; - reader.readLine(); - continue; + StringBuilder sb = new StringBuilder(); + try (FileReader fr = new FileReader(propertiesPath); + BufferedReader reader = new BufferedReader(fr)) { + String line; + while ((line = reader.readLine()) != null) { + if (line.contains(FLYFLYTEMPTAG)) { + tempNotFound = false; + reader.readLine(); // skip next line + continue; + } + sb.append(line).append("\n"); } - sb.append(line + "\n"); } - reader.close(); if (tempNotFound) return; - BufferedWriter writer = new BufferedWriter(new FileWriter(getPropertiesPath())); - writer.write(sb.toString()); - writer.flush(); - writer.close(); + try (FileWriter fw = new FileWriter(propertiesPath); + BufferedWriter writer = new BufferedWriter(fw)) { + writer.write(sb.toString()); + writer.flush(); + } } - public boolean isServiesNeeded() throws IOException { - BufferedReader reader = new BufferedReader(new FileReader(getPropertiesPath())); - String line; - String datafield = "spring.datasource.url"; - while ((line = reader.readLine()) != null) { - if (line.contains(datafield)) { - reader.close(); - return false; + public boolean isServiceNeeded() throws IOException { + final String datafield = "spring.datasource.url"; + try (FileReader fr = new FileReader(propertiesPath); + BufferedReader reader = new BufferedReader(fr)) { + String line; + while ((line = reader.readLine()) != null) { + if (line.contains(datafield)) { + return false; + } } } - reader.close(); return true; } - public String getPropertiesPath() { + private static String buildPropertiesPath() { String separator = FileSystems.getDefault().getSeparator(); return System.getProperty("user.dir") + separator @@ -144,11 +178,8 @@ public String getPropertiesPath() { @PreDestroy public void destroy() { try { - removeTempProperties(); + stopPostgreSQL(); } catch (IOException e) { } - // if (mysql != null && mysql.isRunning()) mysql.close(); - if (postgre != null && postgre.isRunning()) postgre.close(); - // if (mariaDB != null && mariaDB.isRunning()) mariaDB.close(); } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/flyfly/utils/ProjectSetup.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/flyfly/utils/ProjectSetup.java index d6b86789d..cf26a9e7d 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/flyfly/utils/ProjectSetup.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/flyfly/utils/ProjectSetup.java @@ -25,7 +25,7 @@ public class ProjectSetup { private String glowrootDir = flyflyDir + separator + "glowroot"; public boolean initscriptExists() { - log.debug("Checking if flyfly.gradle exists in " + initscriptDir); + log.debug("Checking if flyfly.gradle exists in {}", initscriptDir); return new File(initscriptDir).exists(); } @@ -44,7 +44,7 @@ public void addAutorouteJar() throws IOException { } public boolean formatScriptExists() { - log.debug("Checking if format.gradle exists in " + formatScriptDir); + log.debug("Checking if format.gradle exists in {}", formatScriptDir); return new File(formatScriptDir).exists(); } @@ -55,7 +55,7 @@ public void addFormatScript() throws IOException { } public boolean glowrootAgentExists() { - log.debug("Checking if glowroot folder exists in " + glowrootDir); + log.debug("Checking if glowroot folder exists in {}", glowrootDir); return new File(glowrootDir).exists(); } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/client/impl/PineconeClient.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/client/impl/PineconeClient.java index adcfd1c65..6b5d84f75 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/client/impl/PineconeClient.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/client/impl/PineconeClient.java @@ -1,6 +1,6 @@ package com.edgechain.lib.index.client.impl; -import com.edgechain.lib.endpoint.impl.PineconeEndpoint; +import com.edgechain.lib.endpoint.impl.index.PineconeEndpoint; import com.edgechain.lib.index.request.pinecone.PineconeUpsert; import com.edgechain.lib.embeddings.WordEmbeddings; import com.edgechain.lib.response.StringResponse; @@ -18,36 +18,51 @@ @Service public class PineconeClient { - private PineconeEndpoint endpoint; - private String namespace; + public EdgeChain upsert(PineconeEndpoint endpoint) { + return new EdgeChain<>( + Observable.create( + emitter -> { + try { - public PineconeEndpoint getEndpoint() { - return endpoint; - } + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + headers.setContentType(MediaType.APPLICATION_JSON); + headers.set("Api-Key", endpoint.getApiKey()); + + PineconeUpsert pinecone = new PineconeUpsert(); + pinecone.setVectors(List.of(endpoint.getWordEmbedding())); + pinecone.setNamespace(getNamespace(endpoint)); + + HttpEntity entity = new HttpEntity<>(pinecone, headers); + + ResponseEntity response = + new RestTemplate() + .exchange(endpoint.getUrl(), HttpMethod.POST, entity, String.class); + + emitter.onNext(new StringResponse(response.getBody())); + emitter.onComplete(); - public void setEndpoint(PineconeEndpoint endpoint) { - this.endpoint = endpoint; + } catch (final Exception e) { + emitter.onError(e); + } + }), + endpoint); } - public EdgeChain upsert(WordEmbeddings wordEmbeddings) { + public EdgeChain batchUpsert(PineconeEndpoint endpoint) { return new EdgeChain<>( Observable.create( emitter -> { try { - this.namespace = - (Objects.isNull(endpoint.getNamespace()) || endpoint.getNamespace().isEmpty()) - ? "" - : endpoint.getNamespace(); - HttpHeaders headers = new HttpHeaders(); headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); headers.setContentType(MediaType.APPLICATION_JSON); headers.set("Api-Key", endpoint.getApiKey()); PineconeUpsert pinecone = new PineconeUpsert(); - pinecone.setVectors(List.of(wordEmbeddings)); - pinecone.setNamespace(namespace); + pinecone.setVectors(endpoint.getWordEmbeddingsList()); + pinecone.setNamespace(getNamespace(endpoint)); HttpEntity entity = new HttpEntity<>(pinecone, headers); @@ -65,18 +80,13 @@ public EdgeChain upsert(WordEmbeddings wordEmbeddings) { endpoint); } - public EdgeChain> query(WordEmbeddings wordEmbeddings, int topK) { + public EdgeChain> query(PineconeEndpoint endpoint) { return new EdgeChain<>( Observable.create( emitter -> { try { - this.namespace = - (Objects.isNull(endpoint.getNamespace()) || endpoint.getNamespace().isEmpty()) - ? "" - : endpoint.getNamespace(); - HttpHeaders headers = new HttpHeaders(); headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); headers.setContentType(MediaType.APPLICATION_JSON); @@ -86,9 +96,9 @@ public EdgeChain> query(WordEmbeddings wordEmbeddings, int Map payload = new LinkedHashMap<>(); payload.put("includeValues", true); payload.put("includeMetadata", false); - payload.put("vector", wordEmbeddings.getValues()); - payload.put("top_k", topK); - payload.put("namespace", this.namespace); + payload.put("vector", endpoint.getWordEmbedding().getValues()); + payload.put("top_k", endpoint.getTopK()); + payload.put("namespace", getNamespace(endpoint)); HttpEntity> entity = new HttpEntity<>(payload, headers); @@ -105,18 +115,13 @@ public EdgeChain> query(WordEmbeddings wordEmbeddings, int endpoint); } - public EdgeChain deleteAll() { + public EdgeChain deleteAll(PineconeEndpoint endpoint) { return new EdgeChain<>( Observable.create( emitter -> { try { - this.namespace = - (Objects.isNull(endpoint.getNamespace()) || endpoint.getNamespace().isEmpty()) - ? "" - : endpoint.getNamespace(); - HttpHeaders headers = new HttpHeaders(); headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); headers.setContentType(MediaType.APPLICATION_JSON); @@ -124,7 +129,7 @@ public EdgeChain deleteAll() { Map body = new HashMap<>(); body.put("deleteAll", true); - body.put("namespace", namespace); + body.put("namespace", getNamespace(endpoint)); HttpEntity> entity = new HttpEntity<>(body, headers); @@ -134,7 +139,7 @@ public EdgeChain deleteAll() { emitter.onNext( new StringResponse( "Word embeddings are successfully deleted for namespace:" - + this.namespace)); + + getNamespace(endpoint))); emitter.onComplete(); } catch (final Exception e) { @@ -158,4 +163,10 @@ private List parsePredict(String body) throws IOException { return words2VecList; } + + public String getNamespace(PineconeEndpoint endpoint) { + return (Objects.isNull(endpoint.getNamespace()) || endpoint.getNamespace().isEmpty()) + ? "" + : endpoint.getNamespace(); + } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/client/impl/PostgresClient.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/client/impl/PostgresClient.java index e3652b284..44b3425b4 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/client/impl/PostgresClient.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/client/impl/PostgresClient.java @@ -1,71 +1,214 @@ package com.edgechain.lib.index.client.impl; -import com.edgechain.lib.configuration.context.ApplicationContextHolder; import com.edgechain.lib.embeddings.WordEmbeddings; -import com.edgechain.lib.endpoint.impl.PostgresEndpoint; +import com.edgechain.lib.endpoint.impl.index.PostgresEndpoint; import com.edgechain.lib.index.domain.PostgresWordEmbeddings; -import com.edgechain.lib.index.enums.PostgresDistanceMetric; +import com.edgechain.lib.index.repositories.PostgresClientMetadataRepository; import com.edgechain.lib.index.repositories.PostgresClientRepository; import com.edgechain.lib.response.StringResponse; import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import io.reactivex.rxjava3.core.Observable; -import org.springframework.stereotype.Service; +import java.math.BigDecimal; +import java.sql.Date; import java.sql.Timestamp; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +import org.postgresql.util.PGobject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; @Service public class PostgresClient { - private PostgresEndpoint postgresEndpoint; - private String namespace; + private static final Logger logger = LoggerFactory.getLogger(PostgresClient.class); + + private static final TypeReference> FLOAT_TYPE_REF = new TypeReference<>() {}; - private final PostgresClientRepository repository = - ApplicationContextHolder.getContext().getBean(PostgresClientRepository.class); + @Autowired private PostgresClientRepository repository; - public PostgresEndpoint getPostgresEndpoint() { - return postgresEndpoint; + @Autowired private PostgresClientMetadataRepository metadataRepository; + + private final ObjectMapper objectMapper = new ObjectMapper(); + + public EdgeChain createTable(PostgresEndpoint postgresEndpoint) { + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + this.repository.createTable(postgresEndpoint); + emitter.onNext(new StringResponse("Table: " + postgresEndpoint.getTableName())); + emitter.onComplete(); + } catch (final Exception e) { + emitter.onError(e); + } + })); } - public void setPostgresEndpoint(PostgresEndpoint postgresEndpoint) { - this.postgresEndpoint = postgresEndpoint; + public EdgeChain createMetadataTable(PostgresEndpoint postgresEndpoint) { + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + this.metadataRepository.createTable(postgresEndpoint); + emitter.onNext( + new StringResponse( + "Table: " + postgresEndpoint.getMetadataTableNames().get(0))); + emitter.onComplete(); + } catch (final Exception e) { + emitter.onError(e); + } + })); } - public String getNamespace() { - return namespace; + public EdgeChain> batchUpsert(PostgresEndpoint postgresEndpoint) { + + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + + // Upsert Embeddings + List strings = + this.repository.batchUpsertEmbeddings( + postgresEndpoint.getTableName(), + postgresEndpoint.getWordEmbeddingsList(), + postgresEndpoint.getFilename(), + getNamespace(postgresEndpoint), + postgresEndpoint.getPostgresLanguage()); + + List stringResponseList = + strings.stream().map(StringResponse::new).toList(); + + emitter.onNext(stringResponseList); + emitter.onComplete(); + + } catch (final Exception e) { + emitter.onError(e); + } + }), + postgresEndpoint); } - public void setNamespace(String namespace) { - this.namespace = namespace; + public EdgeChain upsert(PostgresEndpoint postgresEndpoint) { + + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + + // Upsert Embeddings + String embeddingId = + this.repository.upsertEmbeddings( + postgresEndpoint.getTableName(), + postgresEndpoint.getWordEmbedding(), + postgresEndpoint.getFilename(), + getNamespace(postgresEndpoint), + postgresEndpoint.getPostgresLanguage()); + + emitter.onNext(new StringResponse(embeddingId)); + emitter.onComplete(); + + } catch (final Exception e) { + emitter.onError(e); + } + }), + postgresEndpoint); } - public EdgeChain upsert(WordEmbeddings wordEmbeddings) { + public EdgeChain insertMetadata(PostgresEndpoint postgresEndpoint) { return new EdgeChain<>( Observable.create( emitter -> { try { + String metadata = postgresEndpoint.getMetadata(); + String input = metadata.replace("'", ""); - this.namespace = - (Objects.isNull(postgresEndpoint.getNamespace()) - || postgresEndpoint.getNamespace().isEmpty()) - ? "knowledge" - : postgresEndpoint.getNamespace(); + String metadataId = + this.metadataRepository.insertMetadata( + postgresEndpoint.getTableName(), + postgresEndpoint.getMetadataTableNames().get(0), + input, + postgresEndpoint.getDocumentDate()); - // Create Table - this.repository.createTable(postgresEndpoint); + emitter.onNext(new StringResponse(metadataId)); + emitter.onComplete(); - String input = wordEmbeddings.getId().replaceAll("'", ""); + } catch (final Exception e) { + emitter.onError(e); + } + }), + postgresEndpoint); + } - // Upsert Embeddings - this.repository.upsertEmbeddings( + public EdgeChain> batchInsertMetadata(PostgresEndpoint postgresEndpoint) { + + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + + // Insert metadata + List strings = + this.metadataRepository.batchInsertMetadata( + postgresEndpoint.getTableName(), + postgresEndpoint.getMetadataTableNames().get(0), + postgresEndpoint.getMetadataList()); + + List stringResponseList = + strings.stream().map(StringResponse::new).toList(); + + emitter.onNext(stringResponseList); + emitter.onComplete(); + + } catch (final Exception e) { + emitter.onError(e); + } + }), + postgresEndpoint); + } + + public EdgeChain insertIntoJoinTable(PostgresEndpoint postgresEndpoint) { + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + + this.metadataRepository.insertIntoJoinTable(postgresEndpoint); + + emitter.onNext(new StringResponse("Inserted")); + emitter.onComplete(); + + } catch (final Exception e) { + emitter.onError(e); + } + }), + postgresEndpoint); + } + + public EdgeChain batchInsertIntoJoinTable(PostgresEndpoint postgresEndpoint) { + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + this.metadataRepository.batchInsertIntoJoinTable( postgresEndpoint.getTableName(), - input, - postgresEndpoint.getFilename(), - wordEmbeddings, - this.namespace); + postgresEndpoint.getMetadataTableNames().get(0), + postgresEndpoint.getIdList(), + postgresEndpoint.getMetadataId()); - emitter.onNext(new StringResponse("Upserted")); + emitter.onNext(new StringResponse("Inserted")); emitter.onComplete(); } catch (final Exception e) { @@ -75,39 +218,290 @@ public EdgeChain upsert(WordEmbeddings wordEmbeddings) { postgresEndpoint); } - public EdgeChain> query( - WordEmbeddings wordEmbeddings, PostgresDistanceMetric metric, int topK, int probes) { + public EdgeChain> query(PostgresEndpoint postgresEndpoint) { return new EdgeChain<>( Observable.create( emitter -> { try { - this.namespace = - (Objects.isNull(postgresEndpoint.getNamespace()) - || postgresEndpoint.getNamespace().isEmpty()) - ? "knowledge" - : postgresEndpoint.getNamespace(); + List wordEmbeddingsList = new ArrayList<>(); + + List> embeddings = + postgresEndpoint.getWordEmbeddingsList().stream() + .map(WordEmbeddings::getValues) + .toList(); List> rows = this.repository.query( postgresEndpoint.getTableName(), - this.namespace, - probes, - metric, - wordEmbeddings, - topK); + getNamespace(postgresEndpoint), + postgresEndpoint.getProbes(), + postgresEndpoint.getMetric(), + embeddings, + postgresEndpoint.getTopK(), + postgresEndpoint.getUpperLimit()); + + for (Map row : rows) { + + PostgresWordEmbeddings val = new PostgresWordEmbeddings(); + val.setId(Objects.nonNull(row.get("id")) ? row.get("id").toString() : null); + val.setRawText( + Objects.nonNull(row.get("raw_text")) ? (String) row.get("raw_text") : null); + val.setFilename( + Objects.nonNull(row.get("filename")) ? (String) row.get("filename") : null); + val.setTimestamp( + Objects.nonNull(row.get("timestamp")) + ? ((Timestamp) row.get("timestamp")).toLocalDateTime() + : null); + val.setNamespace( + Objects.nonNull(row.get("namespace")) ? (String) row.get("namespace") : null); + + val.setScore( + Objects.nonNull(row.get("score")) ? (Double) row.get("score") : null); + + PGobject pgObject = (PGobject) row.get("embedding"); + String jsonString = pgObject.getValue(); + List values = objectMapper.readerFor(FLOAT_TYPE_REF).readValue(jsonString); + val.setValues(values); + + wordEmbeddingsList.add(val); + } + emitter.onNext(wordEmbeddingsList); + emitter.onComplete(); + } catch (final Exception e) { + emitter.onError(e); + } + }), + postgresEndpoint); + } + + public EdgeChain> queryRRF(PostgresEndpoint postgresEndpoint) { + + return new EdgeChain<>( + Observable.create( + emitter -> { + try { List wordEmbeddingsList = new ArrayList<>(); + List> embeddings = + postgresEndpoint.getWordEmbeddingsList().stream() + .map(WordEmbeddings::getValues) + .toList(); - for (Map row : rows) { + List> rows = + this.repository.queryRRF( + postgresEndpoint.getTableName(), + getNamespace(postgresEndpoint), + postgresEndpoint.getMetadataTableNames().get(0), + embeddings, + postgresEndpoint.getTextWeight(), + postgresEndpoint.getSimilarityWeight(), + postgresEndpoint.getDateWeight(), + postgresEndpoint.getSearchQuery(), + postgresEndpoint.getPostgresLanguage(), + postgresEndpoint.getProbes(), + postgresEndpoint.getMetric(), + postgresEndpoint.getTopK(), + postgresEndpoint.getUpperLimit(), + postgresEndpoint.getOrderRRFBy()); + + for (Map row : rows) { PostgresWordEmbeddings val = new PostgresWordEmbeddings(); - val.setId((String) row.get("id")); + val.setId(Objects.nonNull(row.get("id")) ? row.get("id").toString() : null); + val.setRawText( + Objects.nonNull(row.get("raw_text")) ? (String) row.get("raw_text") : null); + + val.setFilename( + Objects.nonNull(row.get("filename")) ? (String) row.get("filename") : null); + val.setTimestamp( + Objects.nonNull(row.get("timestamp")) + ? ((Timestamp) row.get("timestamp")).toLocalDateTime() + : null); + val.setNamespace( + Objects.nonNull(row.get("namespace")) ? (String) row.get("namespace") : null); + + BigDecimal bigDecimal = + Objects.nonNull(row.get("rrf_score")) + ? (BigDecimal) row.get("rrf_score") + : null; + val.setScore(bigDecimal.doubleValue()); + + if (postgresEndpoint.getMetadataTableNames().get(0).contains("title")) { + val.setTitleMetadata( + Objects.nonNull(row.get("metadata")) ? (String) row.get("metadata") : null); + } else { + val.setMetadata( + Objects.nonNull(row.get("metadata")) ? (String) row.get("metadata") : null); + } + Date documentDate = + Objects.nonNull(row.get("document_date")) + ? (Date) row.get("document_date") + : null; + val.setDocumentDate(documentDate.toString()); + + wordEmbeddingsList.add(val); + } + emitter.onNext(wordEmbeddingsList); + emitter.onComplete(); + + } catch (final Exception e) { + emitter.onError(e); + } + }), + postgresEndpoint); + } + + public EdgeChain> queryWithMetadata( + PostgresEndpoint postgresEndpoint) { + + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + List wordEmbeddingsList = new ArrayList<>(); + if (postgresEndpoint.getMetadataTableNames() != null) { + try { + List metadataTableNames = postgresEndpoint.getMetadataTableNames(); + int numberOfMetadataTables = metadataTableNames.size(); + + /* + * This map will store the pairs + * We need to extract the title info from another metadata table. + * So instead of having extra PostgresWordEmbeddings objects for the title info + * We can store the title info in a map corresponding to the id key of the embeddings table + * Then after the loop is over we can inject the title field in the correct PostgresWordEmbeddings object by using the id key. + */ + Map titleMetadataMap = new HashMap<>(); + Map dateMetadataMap = new HashMap<>(); + for (String metadataTableName : metadataTableNames) { + List> rows = + this.metadataRepository.queryWithMetadata( + postgresEndpoint.getTableName(), + metadataTableName, + getNamespace(postgresEndpoint), + postgresEndpoint.getProbes(), + postgresEndpoint.getMetric(), + postgresEndpoint.getWordEmbedding().getValues(), + postgresEndpoint.getTopK()); + + // To filter out duplicate context chunks + Set contextChunkIds = new HashSet<>(); + for (Map row : rows) { + String metadataId = row.get("metadata_id").toString(); + if (!metadataTableName.contains("title_metadata") + && contextChunkIds.contains(metadataId)) continue; + + PostgresWordEmbeddings val = new PostgresWordEmbeddings(); + final String idStr = + Objects.nonNull(row.get("id")) ? row.get("id").toString() : null; + val.setId(idStr); + val.setRawText( + Objects.nonNull(row.get("raw_text")) + ? (String) row.get("raw_text") + : null); + val.setFilename( + Objects.nonNull(row.get("filename")) + ? (String) row.get("filename") + : null); + val.setTimestamp( + Objects.nonNull(row.get("timestamp")) + ? ((Timestamp) row.get("timestamp")).toLocalDateTime() + : null); + val.setNamespace( + Objects.nonNull(row.get("namespace")) + ? (String) row.get("namespace") + : null); + val.setScore( + Objects.nonNull(row.get("score")) ? (Double) row.get("score") : null); + + // Add metadata fields in response + if (metadataTableName.contains("title_metadata")) { + titleMetadataMap.put(idStr, (String) row.get("metadata")); + dateMetadataMap.put(idStr, (String) row.get("document_date")); + + // For checking if only one metadata table is present which is the title + // table + if (numberOfMetadataTables > 1) continue; + } else { + val.setMetadata((String) row.get("metadata")); + } + contextChunkIds.add(metadataId); + wordEmbeddingsList.add(val); + } + + // Insert the title and date fields into their respective + // PostgresWordEmbeddings + for (PostgresWordEmbeddings wordEmbedding : wordEmbeddingsList) { + String id = wordEmbedding.getId(); + if (titleMetadataMap.containsKey(id)) { + wordEmbedding.setTitleMetadata(titleMetadataMap.get(id)); + } + if (dateMetadataMap.containsKey(id)) { + wordEmbedding.setDocumentDate(dateMetadataMap.get(id)); + } + } + } + } catch (Exception e) { + logger.warn("ignored query error", e); + } + } + + emitter.onNext(wordEmbeddingsList); + emitter.onComplete(); + + } catch (final Exception e) { + emitter.onError(e); + } + }), + postgresEndpoint); + } + + public EdgeChain> getAllChunks(PostgresEndpoint postgresEndpoint) { + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + List wordEmbeddingsList = new ArrayList<>(); + List> rows = this.repository.getAllChunks(postgresEndpoint); + for (Map row : rows) { + PostgresWordEmbeddings val = new PostgresWordEmbeddings(); + val.setId(row.get("id").toString()); val.setRawText((String) row.get("raw_text")); val.setFilename((String) row.get("filename")); - val.setTimestamp(((Timestamp) row.get("timestamp")).toLocalDateTime()); - val.setNamespace((String) row.get("namespace")); - val.setScore((Double) row.get("score")); + PGobject pgObject = (PGobject) row.get("embedding"); + String jsonString = pgObject.getValue(); + List values = objectMapper.readerFor(FLOAT_TYPE_REF).readValue(jsonString); + val.setValues(values); + wordEmbeddingsList.add(val); + } + emitter.onNext(wordEmbeddingsList); + emitter.onComplete(); + } catch (final Exception e) { + emitter.onError(e); + } + }), + postgresEndpoint); + } + + public EdgeChain> getSimilarMetadataChunk( + PostgresEndpoint postgresEndpoint) { + + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + List wordEmbeddingsList = new ArrayList<>(); + List> rows = + this.metadataRepository.getSimilarMetadataChunk( + postgresEndpoint.getTableName(), + postgresEndpoint.getMetadataTableNames().get(0), + postgresEndpoint.getEmbeddingChunk()); + for (Map row : rows) { + + PostgresWordEmbeddings val = new PostgresWordEmbeddings(); + val.setMetadataId(row.get("metadata_id").toString()); + val.setMetadata((String) row.get("metadata")); wordEmbeddingsList.add(val); } @@ -122,23 +516,17 @@ public EdgeChain> query( postgresEndpoint); } - public EdgeChain deleteAll() { + public EdgeChain deleteAll(PostgresEndpoint postgresEndpoint) { return new EdgeChain<>( Observable.create( emitter -> { - this.namespace = - (Objects.isNull(postgresEndpoint.getNamespace()) - || postgresEndpoint.getNamespace().isEmpty()) - ? "knowledge" - : postgresEndpoint.getNamespace(); - + String namespace = getNamespace(postgresEndpoint); try { - this.repository.deleteAll(postgresEndpoint.getTableName(), this.namespace); + this.repository.deleteAll(postgresEndpoint.getTableName(), namespace); emitter.onNext( new StringResponse( - "Word embeddings are successfully deleted for namespace:" - + this.namespace)); + "Word embeddings are successfully deleted for namespace:" + namespace)); emitter.onComplete(); } catch (final Exception e) { emitter.onError(e); @@ -146,4 +534,11 @@ public EdgeChain deleteAll() { }), postgresEndpoint); } + + private String getNamespace(PostgresEndpoint postgresEndpoint) { + return (Objects.isNull(postgresEndpoint.getNamespace()) + || postgresEndpoint.getNamespace().isEmpty()) + ? "knowledge" + : postgresEndpoint.getNamespace(); + } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/client/impl/RedisClient.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/client/impl/RedisClient.java index 7f1c3790b..c436e1033 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/client/impl/RedisClient.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/client/impl/RedisClient.java @@ -1,7 +1,7 @@ package com.edgechain.lib.index.client.impl; import com.edgechain.lib.embeddings.WordEmbeddings; -import com.edgechain.lib.endpoint.impl.RedisEndpoint; +import com.edgechain.lib.endpoint.impl.index.RedisEndpoint; import com.edgechain.lib.index.enums.RedisDistanceMetric; import com.edgechain.lib.index.responses.RedisDocument; import com.edgechain.lib.index.responses.RedisProperty; @@ -16,7 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import redis.clients.jedis.JedisPooled; +import redis.clients.jedis.*; import redis.clients.jedis.search.*; import java.util.*; @@ -30,84 +30,105 @@ public class RedisClient { + " local res = redis.call('del', k)" + " end"; - private RedisEndpoint endpoint; - - private String indexName; - private String namespace; - - public RedisEndpoint getEndpoint() { - return endpoint; - } - - public void setEndpoint(RedisEndpoint endpoint) { - this.endpoint = endpoint; - } - private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired private JedisPooled jedisPooled; - public EdgeChain upsert( - WordEmbeddings words2Vec, int dimension, RedisDistanceMetric metric) { - + public EdgeChain createIndex(RedisEndpoint endpoint) { return new EdgeChain<>( Observable.create( emitter -> { try { + this.createSearchIndex( + getNamespace(endpoint), + endpoint.getIndexName(), + endpoint.getDimensions(), + endpoint.getMetric()); + emitter.onNext(new StringResponse("Created Index ~ ")); + emitter.onComplete(); + } catch (final Exception e) { + emitter.onError(e); + } + })); + } - this.indexName = endpoint.getIndexName(); - this.namespace = - (Objects.isNull(endpoint.getNamespace()) || endpoint.getNamespace().isEmpty()) - ? "knowledge" - : endpoint.getNamespace(); + public EdgeChain upsert(RedisEndpoint endpoint) { - this.createSearchIndex(dimension, RedisDistanceMetric.getDistanceMetric(metric)); + return new EdgeChain<>( + Observable.create( + emitter -> { + try (Jedis jedis = new Jedis(jedisPooled.getPool().getResource())) { Map map = new HashMap<>(); - map.put("id".getBytes(), words2Vec.getId().getBytes()); + map.put("id".getBytes(), endpoint.getWordEmbedding().getId().getBytes()); map.put( "values".getBytes(), - FloatUtils.toByteArray(FloatUtils.toFloatArray(words2Vec.getValues()))); + FloatUtils.toByteArray( + FloatUtils.toFloatArray(endpoint.getWordEmbedding().getValues()))); long v = - jedisPooled.hset((this.namespace + ":" + words2Vec.getId()).getBytes(), map); - - jedisPooled.getPool().returnResource(jedisPooled.getPool().getResource()); + jedis.hset( + (getNamespace(endpoint) + ":" + endpoint.getWordEmbedding().getId()) + .getBytes(), + map); emitter.onNext(new StringResponse("Created ~ " + v)); emitter.onComplete(); } catch (Exception ex) { - jedisPooled.getPool().returnBrokenResource(jedisPooled.getPool().getResource()); emitter.onError(ex); } }), endpoint); } - public EdgeChain> query(WordEmbeddings words2Vec, int topK) { - + public EdgeChain batchUpsert(RedisEndpoint endpoint) { return new EdgeChain<>( Observable.create( emitter -> { - try { + try (Jedis jedis = new Jedis(jedisPooled.getPool().getResource())) { + + Pipeline pipeline = jedis.pipelined(); + + for (WordEmbeddings w : endpoint.getWordEmbeddingsList()) { + Map map = new HashMap<>(); + map.put("id".getBytes(), w.getId().getBytes()); + map.put( + "values".getBytes(), + FloatUtils.toByteArray(FloatUtils.toFloatArray(w.getValues()))); + + pipeline.hmset((getNamespace(endpoint) + ":" + w.getId()).getBytes(), map); + } - this.indexName = endpoint.getIndexName(); - this.namespace = - (Objects.isNull(endpoint.getNamespace()) || endpoint.getNamespace().isEmpty()) - ? "knowledge" - : endpoint.getNamespace(); + pipeline.sync(); + emitter.onNext(new StringResponse("Batch Processing Completed")); + emitter.onComplete(); + } catch (Exception ex) { + + emitter.onError(ex); + } + }), + endpoint); + } + + public EdgeChain> query(RedisEndpoint endpoint) { + + return new EdgeChain<>( + Observable.create( + emitter -> { + try { Query query = new Query("*=>[KNN $k @values $values]") .addParam( "values", - FloatUtils.toByteArray(FloatUtils.toFloatArray(words2Vec.getValues()))) - .addParam("k", topK) + FloatUtils.toByteArray( + FloatUtils.toFloatArray(endpoint.getWordEmbedding().getValues()))) + .addParam("k", endpoint.getTopK()) .returnFields("id", "__values_score") .setSortBy("__values_score", false) .dialect(2); - SearchResult searchResult = jedisPooled.ftSearch(this.indexName, query); + SearchResult searchResult = jedisPooled.ftSearch(endpoint.getIndexName(), query); String body = JsonUtils.convertToString(searchResult); @@ -121,53 +142,46 @@ public EdgeChain> query(WordEmbeddings words2Vec, int topK) ArrayList properties = iterator.next().getProperties(); words2VecList.add( new WordEmbeddings( - properties.get(1).getId(), - String.valueOf(properties.get(0).get__values_score()))); + properties.get(1).getId(), properties.get(0).get__values_score())); } emitter.onNext(words2VecList); emitter.onComplete(); } catch (Exception ex) { + jedisPooled.getPool().returnBrokenResource(jedisPooled.getPool().getResource()); emitter.onError(ex); } }), endpoint); } - public EdgeChain deleteByPattern(String pattern) { + public EdgeChain deleteByPattern(RedisEndpoint endpoint) { return new EdgeChain<>( Observable.create( emitter -> { - try { + try (Jedis jedis = new Jedis(jedisPooled.getPool().getResource())) { - this.indexName = endpoint.getIndexName(); - this.namespace = - (Objects.isNull(endpoint.getNamespace()) || endpoint.getNamespace().isEmpty()) - ? "knowledge" - : endpoint.getNamespace(); - - jedisPooled.eval(String.format(REDIS_DELETE_SCRIPT_IN_LUA, pattern)); - - jedisPooled.getPool().returnResource(jedisPooled.getPool().getResource()); + jedis.eval(String.format(REDIS_DELETE_SCRIPT_IN_LUA, endpoint.getPattern())); emitter.onNext( new StringResponse( - "Word embeddings are successfully deleted for pattern:" + pattern)); + "Word embeddings are successfully deleted for pattern:" + + endpoint.getPattern())); emitter.onComplete(); } catch (Exception ex) { - jedisPooled.getPool().returnBrokenResource(jedisPooled.getPool().getResource()); emitter.onError(ex); } }), endpoint); } - private void createSearchIndex(int dimension, String metric) { + private void createSearchIndex( + String namespace, String indexName, int dimension, RedisDistanceMetric metric) { try { - Map map = jedisPooled.ftInfo(this.indexName); + Map map = jedisPooled.ftInfo(indexName); if (Objects.nonNull(map)) { return; } @@ -184,12 +198,18 @@ private void createSearchIndex(int dimension, String metric) { .addTextField("id", 1) .addVectorField("values", Schema.VectorField.VectorAlgo.HNSW, attributes); - IndexDefinition indexDefinition = new IndexDefinition().setPrefixes(this.namespace); + IndexDefinition indexDefinition = new IndexDefinition().setPrefixes(namespace); String ftCreate = jedisPooled.ftCreate( - this.indexName, IndexOptions.defaultOptions().setDefinition(indexDefinition), schema); + indexName, IndexOptions.defaultOptions().setDefinition(indexDefinition), schema); logger.info("Redis search vector_index created ~ " + ftCreate); } + + private String getNamespace(RedisEndpoint endpoint) { + return (Objects.isNull(endpoint.getNamespace()) || endpoint.getNamespace().isEmpty()) + ? "knowledge" + : endpoint.getNamespace(); + } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/domain/PostgresWordEmbeddings.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/domain/PostgresWordEmbeddings.java index 862c44025..cd2263fe8 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/domain/PostgresWordEmbeddings.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/domain/PostgresWordEmbeddings.java @@ -9,8 +9,9 @@ public class PostgresWordEmbeddings implements ArkObject { - private Long embedding_id; - + // private Long embedding_id; + // + // private Integer embedding_id; private String id; private String rawText; @@ -23,15 +24,20 @@ public class PostgresWordEmbeddings implements ArkObject { private LocalDateTime timestamp; - private Double score; // will be added + private Double score; - public Long getEmbedding_id() { - return embedding_id; - } + private String metadata; + private String metadataId; + private String titleMetadata; + private String documentDate; - public void setEmbedding_id(Long embedding_id) { - this.embedding_id = embedding_id; - } + // public Integer getEmbedding_id() { + // return embedding_id; + // } + // + // public void setEmbedding_id(Integer embedding_id) { + // this.embedding_id = embedding_id; + // } public String getId() { return id; @@ -89,16 +95,104 @@ public void setFilename(String filename) { this.filename = filename; } + public String getMetadata() { + return metadata; + } + + public void setMetadata(String metadata) { + this.metadata = metadata; + } + + public String getMetadataId() { + return metadataId; + } + + public void setMetadataId(String metadataId) { + this.metadataId = metadataId; + } + + public String getTitleMetadata() { + return titleMetadata; + } + + public void setTitleMetadata(String titleMetadata) { + this.titleMetadata = titleMetadata; + } + + public String getDocumentDate() { + return documentDate; + } + + public void setDocumentDate(String documentDate) { + this.documentDate = documentDate; + } + @Override public JSONObject toJson() { JSONObject json = new JSONObject(); - json.put("id", id); - json.put("rawText", rawText); - json.put("namespace", namespace); - json.put("filename", filename); - json.put("values", new JSONArray(values)); - json.put("timestamp", timestamp.toString()); - json.put("score", score); + + // if (embedding_id != null) { + // json.put("embedding_id", embedding_id); + // } + + if (id != null) { + json.put("id", id); + } + + if (rawText != null) { + json.put("rawText", rawText); + } + + if (namespace != null) { + json.put("namespace", namespace); + } + + if (filename != null) { + json.put("filename", filename); + } + + if (values != null) { + json.put("values", new JSONArray(values)); + } + + if (timestamp != null) { + json.put("timestamp", timestamp.toString()); + } + + if (score != null && !Double.isNaN(score)) { + json.put("score", score); + } + + if (titleMetadata != null) { + json.put("titleMetadata", titleMetadata); + } + + if (documentDate != null) { + json.put("documentDate", documentDate); + } + + if (metadata != null) { + json.put("metadata", metadata); + } + if (metadataId != null) { + json.put("metadataId", metadataId); + } + return json; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + PostgresWordEmbeddings that = (PostgresWordEmbeddings) o; + + return id.equals(that.id); + } + + @Override + public int hashCode() { + return id.hashCode(); + } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/domain/RRFWeight.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/domain/RRFWeight.java new file mode 100644 index 000000000..19b6f6974 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/domain/RRFWeight.java @@ -0,0 +1,45 @@ +package com.edgechain.lib.index.domain; + +import com.edgechain.lib.index.enums.BaseWeight; + +import java.util.StringJoiner; + +public class RRFWeight { + + private BaseWeight baseWeight = BaseWeight.W1_0; + private double fineTuneWeight = 0.5; + + public RRFWeight() {} + + public RRFWeight(BaseWeight baseWeight, double fineTuneWeight) { + this.baseWeight = baseWeight; + this.fineTuneWeight = fineTuneWeight; + + if (fineTuneWeight < 0 || fineTuneWeight > 1.0) + throw new IllegalArgumentException("Weights must be between 0 and 1."); + } + + public void setBaseWeight(BaseWeight baseWeight) { + this.baseWeight = baseWeight; + } + + public void setFineTuneWeight(double fineTuneWeight) { + this.fineTuneWeight = fineTuneWeight; + } + + public BaseWeight getBaseWeight() { + return baseWeight; + } + + public double getFineTuneWeight() { + return fineTuneWeight; + } + + @Override + public String toString() { + return new StringJoiner(", ", RRFWeight.class.getSimpleName() + "[", "]") + .add("baseWeight=" + baseWeight) + .add("fineTuneWeight=" + fineTuneWeight) + .toString(); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/enums/BaseWeight.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/enums/BaseWeight.java new file mode 100644 index 000000000..e998f8a09 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/enums/BaseWeight.java @@ -0,0 +1,32 @@ +package com.edgechain.lib.index.enums; + +public enum BaseWeight { + W1_0(1.0), + W1_25(1.25), + W1_5(1.5), + W1_75(1.75), + W2_0(2.0), + W2_25(2.25), + W2_5(2.5), + W2_75(2.75), + W3_0(3.0); + + private final double value; + + BaseWeight(double value) { + this.value = value; + } + + public double getValue() { + return value; + } + + public static BaseWeight fromDouble(double value) { + for (BaseWeight baseWeight : BaseWeight.values()) { + if (baseWeight.getValue() == value) { + return baseWeight; + } + } + throw new IllegalArgumentException("Invalid BaseWeight value: " + value); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/enums/OrderRRFBy.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/enums/OrderRRFBy.java new file mode 100644 index 000000000..db857d0e2 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/enums/OrderRRFBy.java @@ -0,0 +1,23 @@ +package com.edgechain.lib.index.enums; + +public enum OrderRRFBy { + DEFAULT, // Preferred Way; ordered by rrf_score; (relevance over freshness) + TEXT_RANK, // First Ordered By Text_Rank; then ordered by rrf_score (text_rank preferred, then + // relevance) + SIMILARITY, // First Ordered by Similarity; then ordered by rrf_score; (similarity preferred, then + // relevance) + DATE_RANK; // First Ordered by date_rank; then ordered by rrf_score; (freshness preferred, then + + // relevance) + + public static OrderRRFBy fromString(String value) { + if (value != null) { + for (OrderRRFBy orderRRFBy : OrderRRFBy.values()) { + if (orderRRFBy.name().equalsIgnoreCase(value)) { + return orderRRFBy; + } + } + } + throw new IllegalArgumentException("Invalid OrderRRFBy value: " + value); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/enums/PostgresLanguage.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/enums/PostgresLanguage.java new file mode 100644 index 000000000..01f7e82df --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/enums/PostgresLanguage.java @@ -0,0 +1,43 @@ +package com.edgechain.lib.index.enums; + +public enum PostgresLanguage { + SIMPLE("simple"), + ARABIC("arabic"), + ARMENIAN("armenian"), + BASQUE("basque"), + CATALAN("catalan"), + DANISH("danish"), + DUTCH("dutch"), + ENGLISH("english"), + FINNISH("finnish"), + FRENCH("french"), + GERMAN("german"), + GREEK("greek"), + HINDI("hindi"), + HUNGARIAN("hungarian"), + INDONESIAN("indonesian"), + IRISH("irish"), + ITALIAN("italian"), + LITHUANIAN("lithuanian"), + NEPALI("nepali"), + NORWEGIAN("norwegian"), + PORTUGUESE("portuguese"), + ROMANIAN("romanian"), + RUSSIAN("russian"), + SERBIAN("serbian"), + SPANISH("spanish"), + SWEDISH("swedish"), + TAMIL("tamil"), + TURKISH("turkish"), + YIDDISH("yiddish"); + + private final String value; + + PostgresLanguage(String value) { + this.value = value; + } + + public String getValue() { + return value; + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/repositories/PostgresClientMetadataRepository.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/repositories/PostgresClientMetadataRepository.java new file mode 100644 index 000000000..5f340aed3 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/repositories/PostgresClientMetadataRepository.java @@ -0,0 +1,208 @@ +package com.edgechain.lib.index.repositories; + +import com.edgechain.lib.endpoint.impl.index.PostgresEndpoint; +import com.edgechain.lib.index.enums.PostgresDistanceMetric; +import com.edgechain.lib.utils.FloatUtils; +import com.github.f4b6a3.uuid.UuidCreator; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +@Repository +public class PostgresClientMetadataRepository { + + @Autowired private JdbcTemplate jdbcTemplate; + + @Transactional + public void createTable(PostgresEndpoint postgresEndpoint) { + String metadataTable = postgresEndpoint.getMetadataTableNames().get(0); + jdbcTemplate.execute( + String.format( + "CREATE TABLE IF NOT EXISTS %s (metadata_id UUID PRIMARY KEY, metadata TEXT NOT NULL," + + " document_date DATE);", + postgresEndpoint.getTableName() + "_" + metadataTable)); + + // Create a JOIN table + jdbcTemplate.execute( + String.format( + "CREATE TABLE IF NOT EXISTS %s (id UUID UNIQUE NOT NULL, metadata_id UUID NOT NULL, " + + "FOREIGN KEY (id) REFERENCES %s(id) ON DELETE CASCADE, " + + "FOREIGN KEY (metadata_id) REFERENCES %s(metadata_id) ON DELETE CASCADE, " + + "PRIMARY KEY (id, metadata_id));", + postgresEndpoint.getTableName() + "_join_" + metadataTable, + postgresEndpoint.getTableName(), + postgresEndpoint.getTableName() + "_" + metadataTable)); + + jdbcTemplate.execute( + String.format( + "CREATE INDEX IF NOT EXISTS idx_%s ON %s (metadata_id);", + postgresEndpoint.getTableName() + "_join_" + metadataTable, + postgresEndpoint.getTableName() + "_join_" + metadataTable)); + } + + @Transactional + public List batchInsertMetadata( + String table, String metadataTableName, List metadataList) { + + Set uuidSet = new HashSet<>(); + + for (int i = 0; i < metadataList.size(); i++) { + + String metadata = metadataList.get(i).replace("'", ""); + + UUID metadataId = + jdbcTemplate.queryForObject( + String.format( + "INSERT INTO %s (metadata_id, metadata) VALUES ('%s', ?) RETURNING metadata_id;", + table.concat("_").concat(metadataTableName), UuidCreator.getTimeOrderedEpoch()), + UUID.class, + metadata); + + if (metadataId != null) { + uuidSet.add(metadataId.toString()); + } + } + + return new ArrayList<>(uuidSet); + } + + @Transactional + public String insertMetadata( + String table, String metadataTableName, String metadata, String documentDate) { + + metadata = metadata.replace("'", ""); + + UUID metadataId = + jdbcTemplate.queryForObject( + String.format( + "INSERT INTO %s (metadata_id, metadata, document_date) VALUES ('%s', ?," + + " TO_DATE(NULLIF(?, ''), 'Month DD, YYYY')) RETURNING metadata_id;", + table.concat("_").concat(metadataTableName), UuidCreator.getTimeOrderedEpoch()), + UUID.class, + metadata, + documentDate); + + return Objects.requireNonNull(metadataId).toString(); + } + + @Transactional + public void insertIntoJoinTable(PostgresEndpoint postgresEndpoint) { + String joinTableName = + postgresEndpoint.getTableName() + + "_join_" + + postgresEndpoint.getMetadataTableNames().get(0); + jdbcTemplate.execute( + 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(postgresEndpoint.getId()), + 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, + String metadataTableName, + String namespace, + int probes, + PostgresDistanceMetric metric, + List values, + int topK) { + + String embeddings = Arrays.toString(FloatUtils.toFloatArray(values)); + + jdbcTemplate.execute(String.format("SET LOCAL ivfflat.probes = %s;", probes)); + String joinTable = tableName + "_join_" + metadataTableName; + + if (metric.equals(PostgresDistanceMetric.IP)) { + return jdbcTemplate.queryForList( + String.format( + "SELECT e.id, metadata, TO_CHAR(document_date, 'Month DD, YYYY') as document_date," + + " j.metadata_id, raw_text, namespace, filename, timestamp, ( embedding <#>" + + " '%s') * -1 AS score FROM %s e INNER JOIN %s j ON e.id = j.id INNER JOIN %s m" + + " ON j.metadata_id = m.metadata_id WHERE namespace='%s' ORDER BY embedding %s" + + " '%s' LIMIT %s;", + embeddings, + tableName, + joinTable, + tableName.concat("_").concat(metadataTableName), + namespace, + PostgresDistanceMetric.getDistanceMetric(metric), + embeddings, + topK)); + + } else if (metric.equals(PostgresDistanceMetric.COSINE)) { + return jdbcTemplate.queryForList( + String.format( + "SELECT e.id, metadata, TO_CHAR(document_date, 'Month DD, YYYY') as document_date," + + " j.metadata_id, raw_text, namespace, filename, timestamp, 1 - ( embedding <=>" + + " '%s') AS score FROM %s e INNER JOIN %s j ON e.id = j.id INNER JOIN %s m ON" + + " j.metadata_id = m.metadata_id WHERE namespace='%s' ORDER BY embedding %s '%s'" + + " LIMIT %s;", + embeddings, + tableName, + joinTable, + tableName.concat("_").concat(metadataTableName), + namespace, + PostgresDistanceMetric.getDistanceMetric(metric), + embeddings, + topK)); + } else { + return jdbcTemplate.queryForList( + String.format( + "SELECT e.id, metadata, TO_CHAR(document_date, 'Month DD, YYYY') as document_date," + + " j.metadata_id, raw_text, namespace, filename, timestamp, (embedding <-> '%s')" + + " AS score FROM %s e INNER JOIN %s j ON e.id = j.id INNER JOIN %s m ON" + + " j.metadata_id = m.metadata_id WHERE namespace='%s' ORDER BY embedding %s '%s'" + + " ASC LIMIT %s;", + embeddings, + tableName, + joinTable, + tableName.concat("_").concat(metadataTableName), + namespace, + PostgresDistanceMetric.getDistanceMetric(metric), + embeddings, + topK)); + } + } + + // Full-text search + @Transactional(readOnly = true, propagation = Propagation.REQUIRED) + public List> getSimilarMetadataChunk( + String table, String metadataTableName, String embeddingChunk) { + // Remove special characters and replace with a space + String cleanEmbeddingChunk = + embeddingChunk.replaceAll("[^a-zA-Z0-9\\s]", " ").replaceAll("\\s+", " ").trim(); + + String tableName = table.concat("_").concat(metadataTableName); + + // Split the embeddingChunk into words and join them with the '|' (OR) operator + String tsquery = String.join(" | ", cleanEmbeddingChunk.split("\\s+")); + return jdbcTemplate.queryForList( + String.format( + "SELECT *, ts_rank(to_tsvector(%s.metadata), query) as rank_metadata " + + "FROM %s, to_tsvector(%s.metadata) document, to_tsquery('%s') query " + + "WHERE query @@ document ORDER BY rank_metadata DESC", + tableName, tableName, tableName, tsquery)); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/repositories/PostgresClientRepository.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/repositories/PostgresClientRepository.java index ea3e641c7..a626c5741 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/repositories/PostgresClientRepository.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/index/repositories/PostgresClientRepository.java @@ -1,8 +1,11 @@ package com.edgechain.lib.index.repositories; import com.edgechain.lib.embeddings.WordEmbeddings; -import com.edgechain.lib.endpoint.impl.PostgresEndpoint; +import com.edgechain.lib.endpoint.impl.index.PostgresEndpoint; +import com.edgechain.lib.index.domain.RRFWeight; +import com.edgechain.lib.index.enums.OrderRRFBy; import com.edgechain.lib.index.enums.PostgresDistanceMetric; +import com.edgechain.lib.index.enums.PostgresLanguage; import com.edgechain.lib.utils.FloatUtils; import com.github.f4b6a3.uuid.UuidCreator; import org.springframework.beans.factory.annotation.Autowired; @@ -23,60 +26,142 @@ public class PostgresClientRepository { public void createTable(PostgresEndpoint postgresEndpoint) { jdbcTemplate.execute("CREATE EXTENSION IF NOT EXISTS vector;"); - jdbcTemplate.execute( + jdbcTemplate.execute("CREATE EXTENSION IF NOT EXISTS pg_trgm;"); + + String checkTableQuery = String.format( - "CREATE TABLE IF NOT EXISTS %s (embedding_id SERIAL PRIMARY KEY, id VARCHAR(255) NOT" - + " NULL UNIQUE, raw_text TEXT NOT NULL UNIQUE, embedding vector(%s), timestamp" - + " TIMESTAMP NOT NULL, namespace TEXT, filename VARCHAR(255));", - postgresEndpoint.getTableName(), postgresEndpoint.getDimensions())); + "SELECT COUNT(*) FROM information_schema.tables WHERE table_name = '%s'", + postgresEndpoint.getTableName()); + + int tableExists = jdbcTemplate.queryForObject(checkTableQuery, Integer.class); + + String indexName; + String vectorOps; if (PostgresDistanceMetric.L2.equals(postgresEndpoint.getMetric())) { - jdbcTemplate.execute( - String.format( - "CREATE INDEX IF NOT EXISTS %s ON %s USING ivfflat (embedding vector_l2_ops) WITH" - + " (lists = %s);", - postgresEndpoint.getTableName().concat("_").concat("l2_idx"), - postgresEndpoint.getTableName(), - postgresEndpoint.getLists())); + indexName = postgresEndpoint.getTableName().concat("_").concat("l2_idx"); + vectorOps = "vector_l2_ops"; } else if (PostgresDistanceMetric.COSINE.equals(postgresEndpoint.getMetric())) { + indexName = postgresEndpoint.getTableName().concat("_").concat("cosine_idx"); + vectorOps = "vector_cosine_ops"; + } else { + indexName = postgresEndpoint.getTableName().concat("_").concat("ip_idx"); + vectorOps = "vector_ip_ops"; + } + + String indexQuery = + String.format( + "CREATE INDEX IF NOT EXISTS %s ON %s USING ivfflat (embedding %s) WITH" + + " (lists = %s);", + indexName, postgresEndpoint.getTableName(), vectorOps, postgresEndpoint.getLists()); + + String tsvIndexQuery = + String.format( + "CREATE INDEX IF NOT EXISTS %s ON %s USING GIN(tsv);", + postgresEndpoint.getTableName().concat("_tsv_idx"), postgresEndpoint.getTableName()); + + if (tableExists == 0) { + jdbcTemplate.execute( String.format( - "CREATE INDEX IF NOT EXISTS %s ON %s USING ivfflat (embedding vector_cosine_ops) WITH" - + " (lists = %s);", - postgresEndpoint.getTableName().concat("_").concat("cosine_idx"), - postgresEndpoint.getTableName(), - postgresEndpoint.getLists())); + "CREATE TABLE IF NOT EXISTS %s (id UUID PRIMARY KEY, " + + " raw_text TEXT NOT NULL UNIQUE, embedding vector(%s), timestamp" + + " TIMESTAMP NOT NULL, namespace TEXT, filename VARCHAR(255), tsv TSVECTOR);", + postgresEndpoint.getTableName(), postgresEndpoint.getDimensions())); + + jdbcTemplate.execute(indexQuery); + jdbcTemplate.execute(tsvIndexQuery); + } else { - jdbcTemplate.execute( + + String checkIndexQuery = String.format( - "CREATE INDEX IF NOT EXISTS %s ON %s USING ivfflat (embedding vector_ip_ops) WITH" - + " (lists = %s);", - postgresEndpoint.getTableName().concat("_").concat("ip_idx"), - postgresEndpoint.getTableName(), - postgresEndpoint.getLists())); + "SELECT COUNT(*) FROM pg_indexes WHERE tablename = '%s' AND indexname = '%s';", + postgresEndpoint.getTableName(), indexName); + + Integer indexExists = jdbcTemplate.queryForObject(checkIndexQuery, Integer.class); + + if (indexExists != null && indexExists != 1) + throw new RuntimeException( + "No index is specified therefore use the following SQL:\n" + indexQuery); } } @Transactional - public void upsertEmbeddings( + public List batchUpsertEmbeddings( String tableName, - String input, + List wordEmbeddingsList, String filename, + String namespace, + PostgresLanguage language) { + + Set uuidSet = new HashSet<>(); + + for (int i = 0; i < wordEmbeddingsList.size(); i++) { + WordEmbeddings wordEmbeddings = wordEmbeddingsList.get(i); + + if (wordEmbeddings != null && wordEmbeddings.getValues() != null) { + + float[] floatArray = FloatUtils.toFloatArray(wordEmbeddings.getValues()); + String rawText = wordEmbeddings.getId().replace("'", ""); + + UUID id = + jdbcTemplate.queryForObject( + String.format( + "INSERT INTO %s (id, raw_text, embedding, timestamp, namespace, filename, tsv)" + + " VALUES ('%s', ?, '%s', '%s', '%s', '%s', TO_TSVECTOR('%s', '%s')) ON" + + " CONFLICT (raw_text) DO UPDATE SET embedding = EXCLUDED.embedding" + + " RETURNING id;", + tableName, + UuidCreator.getTimeOrderedEpoch(), + Arrays.toString(floatArray), + LocalDateTime.now(), + namespace, + filename, + language.getValue(), + rawText), + UUID.class, + rawText); + + if (id != null) { + uuidSet.add(id.toString()); + } + } + } + + return new ArrayList<>(uuidSet); + } + + @Transactional + public String upsertEmbeddings( + String tableName, WordEmbeddings wordEmbeddings, - String namespace) { + String filename, + String namespace, + PostgresLanguage language) { - jdbcTemplate.execute( - String.format( - "INSERT INTO %s (id, raw_text, embedding, timestamp, namespace, filename) VALUES ('%s'," - + " '%s', '%s', '%s', '%s', '%s') ON CONFLICT (raw_text) DO UPDATE SET embedding =" - + " EXCLUDED.embedding;", - tableName, - UuidCreator.getTimeOrderedEpoch().toString(), - input, - Arrays.toString(FloatUtils.toFloatArray(wordEmbeddings.getValues())), - LocalDateTime.now(), - namespace, - filename)); + float[] floatArray = FloatUtils.toFloatArray(wordEmbeddings.getValues()); + String rawText = wordEmbeddings.getId().replace("'", ""); + + UUID uuid = + jdbcTemplate.queryForObject( + String.format( + "INSERT INTO %s (id, raw_text, embedding, timestamp, namespace, filename, tsv)" + + " VALUES ('%s', ?, '%s', '%s', '%s', '%s', TO_TSVECTOR('%s', '%s')) ON" + + " CONFLICT (raw_text) DO UPDATE SET embedding = EXCLUDED.embedding RETURNING" + + " id;", + tableName, + UuidCreator.getTimeOrderedEpoch(), + Arrays.toString(floatArray), + LocalDateTime.now(), + namespace, + filename, + language.getValue(), + rawText), + UUID.class, + rawText); + + return Objects.requireNonNull(uuid).toString(); } @Transactional(readOnly = true, propagation = Propagation.REQUIRED) @@ -85,51 +170,220 @@ public List> query( String namespace, int probes, PostgresDistanceMetric metric, - WordEmbeddings wordEmbeddings, - int topK) { - - String embeddings = Arrays.toString(FloatUtils.toFloatArray(wordEmbeddings.getValues())); + List> values, + int topK, + int upperLimit) { jdbcTemplate.execute(String.format("SET LOCAL ivfflat.probes = %s;", probes)); - if (metric.equals(PostgresDistanceMetric.IP)) { - return jdbcTemplate.queryForList( - String.format( - "SELECT id, raw_text, namespace, filename, timestamp, ( embedding <#> '%s') * -1 AS" - + " score FROM %s WHERE namespace='%s' ORDER BY embedding %s '%s' LIMIT %s;", - embeddings, - tableName, - namespace, - PostgresDistanceMetric.getDistanceMetric(metric), - Arrays.toString(FloatUtils.toFloatArray(wordEmbeddings.getValues())), - topK)); + StringBuilder query = new StringBuilder(); + + for (int i = 0; i < values.size(); i++) { + + String embeddings = Arrays.toString(FloatUtils.toFloatArray(values.get(i))); - } else if (metric.equals(PostgresDistanceMetric.COSINE)) { + query.append("(").append("SELECT id, raw_text, embedding, namespace, filename, timestamp,"); + switch (metric) { + case COSINE -> query + .append(String.format("1 - (embedding <=> '%s') AS score ", embeddings)) + .append(" FROM ") + .append(tableName) + .append(" WHERE namespace = ") + .append("'") + .append(namespace) + .append("'") + .append(" ORDER BY embedding <=> ") + .append("'") + .append(embeddings) + .append("'") + .append(" LIMIT "); + case IP -> query + .append(String.format("(embedding <#> '%s') * -1 AS score ", embeddings)) + .append(" FROM ") + .append(tableName) + .append(" WHERE namespace = ") + .append("'") + .append(namespace) + .append("'") + .append(" ORDER BY embedding <#> ") + .append("'") + .append(embeddings) + .append("'") + .append(" LIMIT "); + case L2 -> query + .append(String.format("embedding <-> '%s' AS score ", embeddings)) + .append(" FROM ") + .append(tableName) + .append(" WHERE namespace = ") + .append("'") + .append(namespace) + .append("'") + .append(" ORDER BY embedding <-> ") + .append("'") + .append(embeddings) + .append("'") + .append(" LIMIT "); + default -> throw new IllegalArgumentException("Invalid similarity measure: " + metric); + } + query.append(topK).append(")"); + + if (i < values.size() - 1) { + query.append(" UNION ALL ").append("\n"); + } + } + + if (values.size() > 1) { return jdbcTemplate.queryForList( String.format( - "SELECT id, raw_text, namespace, filename, timestamp, 1 - ( embedding <=> '%s') AS" - + " score FROM %s WHERE namespace='%s' ORDER BY embedding %s '%s' LIMIT %s;", - embeddings, - tableName, - namespace, - PostgresDistanceMetric.getDistanceMetric(metric), - Arrays.toString(FloatUtils.toFloatArray(wordEmbeddings.getValues())), - topK)); + "SELECT * FROM (SELECT DISTINCT ON (result.id) * FROM ( %s ) result) subquery ORDER" + + " BY score DESC LIMIT %s;", + query, upperLimit)); } else { + return jdbcTemplate.queryForList(query.toString()); + } + } + + public List> queryRRF( + String tableName, + String namespace, + String metadataTableName, + List> values, + RRFWeight textWeight, + RRFWeight similarityWeight, + RRFWeight dateWeight, + String searchQuery, + PostgresLanguage language, + int probes, + PostgresDistanceMetric metric, + int topK, + int upperLimit, + OrderRRFBy orderRRFBy) { + + jdbcTemplate.execute(String.format("SET LOCAL ivfflat.probes = %s;", probes)); + + StringBuilder query = new StringBuilder(); + + for (int i = 0; i < values.size(); i++) { + String embeddings = Arrays.toString(FloatUtils.toFloatArray(values.get(i))); + + query + .append("(") + .append( + "SELECT id, raw_text, document_date, metadata, namespace, filename, timestamp, \n") + .append( + String.format( + "%s / (ROW_NUMBER() OVER (ORDER BY text_rank DESC) + %s) + \n", + textWeight.getBaseWeight().getValue(), textWeight.getFineTuneWeight())) + .append( + String.format( + "%s / (ROW_NUMBER() OVER (ORDER BY similarity DESC) + %s) + \n", + similarityWeight.getBaseWeight().getValue(), + similarityWeight.getFineTuneWeight())) + .append( + String.format( + "%s / (ROW_NUMBER() OVER (ORDER BY date_rank DESC) + %s) AS rrf_score\n", + dateWeight.getBaseWeight().getValue(), dateWeight.getFineTuneWeight())) + .append("FROM ( ") + .append( + "SELECT sv.id, sv.raw_text, sv.namespace, sv.filename, sv.timestamp," + + " svtm.document_date, svtm.metadata, ") + .append( + String.format( + "ts_rank_cd(sv.tsv, plainto_tsquery('%s', '%s')) AS text_rank, ", + language.getValue(), searchQuery)); + + switch (metric) { + case COSINE -> query.append( + String.format("1 - (sv.embedding <=> '%s') AS similarity, ", embeddings)); + case IP -> query.append( + String.format("(sv.embedding <#> '%s') * -1 AS similarity, ", embeddings)); + case L2 -> query.append(String.format("sv.embedding <-> '%s' AS similarity, ", embeddings)); + default -> throw new IllegalArgumentException("Invalid similarity measure: " + metric); + } + + query + .append("CASE ") + .append("WHEN svtm.document_date IS NULL THEN 0 ") // Null date handling + .append( + "ELSE EXTRACT(YEAR FROM svtm.document_date) * 365 + EXTRACT(DOY FROM" + + " svtm.document_date) ") + .append("END AS date_rank ") + .append("FROM ") + .append( + String.format( + "(SELECT id, raw_text, embedding, tsv, namespace, filename, timestamp from %s" + + " WHERE namespace = '%s'", + tableName, namespace)); + + switch (metric) { + case COSINE -> query + .append(" ORDER BY embedding <=> ") + .append("'") + .append(embeddings) + .append("'") + .append(" LIMIT ") + .append(topK); + case IP -> query + .append(" ORDER BY embedding <#> ") + .append("'") + .append(embeddings) + .append("'") + .append(" LIMIT ") + .append(topK); + case L2 -> query + .append(" ORDER BY embedding <-> ") + .append("'") + .append(embeddings) + .append("'") + .append(" LIMIT ") + .append(topK); + default -> throw new IllegalArgumentException("Invalid metric: " + metric); + } + query + .append(")") + .append(" sv ") + .append("JOIN ") + .append(tableName.concat("_join_").concat(metadataTableName)) + .append(" jtm ON sv.id = jtm.id ") + .append("JOIN ") + .append(tableName.concat("_").concat(metadataTableName)) + .append(" svtm ON jtm.metadata_id = svtm.metadata_id ") + .append(") subquery "); + + switch (orderRRFBy) { + case TEXT_RANK -> query.append("ORDER BY text_rank DESC, rrf_score DESC"); + case SIMILARITY -> query.append("ORDER BY similarity DESC, rrf_score DESC"); + case DATE_RANK -> query.append("ORDER BY date_rank DESC, rrf_score DESC"); + case DEFAULT -> query.append("ORDER BY rrf_score DESC"); + default -> throw new IllegalArgumentException("Invalid orderRRFBy value"); + } + + query.append(" LIMIT ").append(topK).append(")"); + if (i < values.size() - 1) { + query.append(" UNION ALL ").append("\n"); + } + } + + if (values.size() > 1) { return jdbcTemplate.queryForList( String.format( - "SELECT id, raw_text, namespace, filename, timestamp, (embedding <-> '%s') AS score" - + " FROM %s WHERE namespace='%s' ORDER BY embedding %s '%s' ASC LIMIT %s;", - embeddings, - tableName, - namespace, - PostgresDistanceMetric.getDistanceMetric(metric), - Arrays.toString(FloatUtils.toFloatArray(wordEmbeddings.getValues())), - topK)); + "SELECT * FROM (SELECT DISTINCT ON (result.id) * FROM ( %s ) result) subquery ORDER" + + " BY rrf_score DESC LIMIT %s;", + query, upperLimit)); + } else { + return jdbcTemplate.queryForList(query.toString()); } } + @Transactional(readOnly = true) + public List> getAllChunks(PostgresEndpoint endpoint) { + return jdbcTemplate.queryForList( + String.format( + "SELECT id, raw_text, embedding, filename from %s WHERE filename = '%s';", + endpoint.getTableName(), endpoint.getFilename())); + } + @Transactional public void deleteAll(String tableName, String namespace) { jdbcTemplate.execute( diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/integration/airtable/client/AirtableClient.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/integration/airtable/client/AirtableClient.java new file mode 100644 index 000000000..166d7c320 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/integration/airtable/client/AirtableClient.java @@ -0,0 +1,188 @@ +package com.edgechain.lib.integration.airtable.client; + +import com.edgechain.lib.endpoint.impl.integration.AirtableEndpoint; +import com.edgechain.lib.integration.airtable.query.AirtableQueryBuilder; +import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; +import dev.fuxing.airtable.AirtableApi; +import dev.fuxing.airtable.AirtableRecord; +import dev.fuxing.airtable.AirtableTable; +import io.reactivex.rxjava3.core.Observable; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@Service +public class AirtableClient { + + public EdgeChain> findAll(AirtableEndpoint endpoint) { + + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + AirtableApi api = new AirtableApi(endpoint.getApiKey()); + AirtableTable table = api.base(endpoint.getBaseId()).table(endpoint.getTableName()); + + AirtableQueryBuilder airtableQueryBuilder = endpoint.getAirtableQueryBuilder(); + + AirtableTable.PaginationList list = + table.list( + querySpec -> { + int maxRecords = airtableQueryBuilder.getMaxRecords(); + int pageSize = airtableQueryBuilder.getPageSize(); + String sortField = airtableQueryBuilder.getSortField(); + String sortDirection = airtableQueryBuilder.getSortDirection(); + String offset = airtableQueryBuilder.getOffset(); + List fields = airtableQueryBuilder.getFields(); + String filterByFormula = airtableQueryBuilder.getFilterByFormula(); + String view = airtableQueryBuilder.getView(); + String cellFormat = airtableQueryBuilder.getCellFormat(); + String timeZone = airtableQueryBuilder.getTimeZone(); + String userLocale = airtableQueryBuilder.getUserLocale(); + + querySpec.maxRecords(maxRecords); + querySpec.pageSize(pageSize); + + if (sortField != null && sortDirection != null) { + querySpec.sort(sortField, sortDirection); + } + + if (offset != null) { + querySpec.offset(offset); + } + + if (fields != null) { + querySpec.fields(fields); + } + + if (filterByFormula != null) { + querySpec.filterByFormula(filterByFormula); + } + + if (view != null) { + querySpec.view(view); + } + + if (cellFormat != null) { + querySpec.cellFormat(cellFormat); + } + + if (timeZone != null) { + querySpec.timeZone(timeZone); + } + + if (userLocale != null) { + querySpec.userLocale(userLocale); + } + }); + + Map mapper = new HashMap<>(); + mapper.put("data", list); + mapper.put("offset", list.getOffset()); + + emitter.onNext(mapper); + emitter.onComplete(); + + } catch (final Exception e) { + emitter.onError(e); + } + })); + } + + public EdgeChain findById(AirtableEndpoint endpoint) { + + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + + AirtableApi api = new AirtableApi(endpoint.getApiKey()); + AirtableTable table = api.base(endpoint.getBaseId()).table(endpoint.getTableName()); + + String id = endpoint.getIds().get(0); + + if (Objects.isNull(id) || id.isEmpty()) + throw new RuntimeException("Id cannot be null"); + + AirtableRecord record = table.get(id); + + if (Objects.isNull(record)) + throw new RuntimeException("Id: " + id + " does not exist"); + + emitter.onNext(record); + emitter.onComplete(); + + } catch (final Exception e) { + emitter.onError(e); + } + })); + } + + public EdgeChain> create(AirtableEndpoint endpoint) { + + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + + AirtableApi api = new AirtableApi(endpoint.getApiKey()); + AirtableTable table = api.base(endpoint.getBaseId()).table(endpoint.getTableName()); + + List airtableRecordList = + table.post(endpoint.getAirtableRecordList(), endpoint.isTypecast()); + + emitter.onNext(airtableRecordList); + emitter.onComplete(); + + } catch (final Exception e) { + emitter.onError(e); + } + })); + } + + public EdgeChain> update(AirtableEndpoint endpoint) { + + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + + AirtableApi api = new AirtableApi(endpoint.getApiKey()); + AirtableTable table = api.base(endpoint.getBaseId()).table(endpoint.getTableName()); + + List airtableRecordList = + table.put(endpoint.getAirtableRecordList(), endpoint.isTypecast()); + + emitter.onNext(airtableRecordList); + emitter.onComplete(); + + } catch (final Exception e) { + emitter.onError(e); + } + })); + } + + public EdgeChain> delete(AirtableEndpoint endpoint) { + + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + + AirtableApi api = new AirtableApi(endpoint.getApiKey()); + AirtableTable table = api.base(endpoint.getBaseId()).table(endpoint.getTableName()); + + List deleteIdsList = table.delete(endpoint.getIds()); + + emitter.onNext(deleteIdsList); + emitter.onComplete(); + + } catch (final Exception e) { + emitter.onError(e); + } + })); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/integration/airtable/query/AirtableQueryBuilder.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/integration/airtable/query/AirtableQueryBuilder.java new file mode 100644 index 000000000..7e6945568 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/integration/airtable/query/AirtableQueryBuilder.java @@ -0,0 +1,130 @@ +package com.edgechain.lib.integration.airtable.query; + +import dev.fuxing.airtable.formula.AirtableFormula; +import dev.fuxing.airtable.formula.AirtableFunction; +import dev.fuxing.airtable.formula.AirtableOperator; + +import java.time.ZoneId; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; + +public class AirtableQueryBuilder { + private String offset; + private List fields; + private String filterByFormula; + private int maxRecords = 100; + private int pageSize = 100; + private String sortField; + private String sortDirection; + private String view; + private String cellFormat; + private String timeZone; + private String userLocale; + + public void offset(String offset) { + this.offset = offset; + } + + public void fields(String... fields) { + this.fields = Arrays.asList(fields); + } + + public void filterByFormula(String formula) { + this.filterByFormula = formula; + } + + public void filterByFormula(AirtableFunction function, AirtableFormula.Object... objects) { + this.filterByFormula = function.apply(objects); + } + + public void filterByFormula( + AirtableOperator operator, + AirtableFormula.Object left, + AirtableFormula.Object right, + AirtableFormula.Object... others) { + this.filterByFormula = operator.apply(left, right, others); + } + + public void maxRecords(int maxRecords) { + this.maxRecords = maxRecords; + } + + public void pageSize(int pageSize) { + this.pageSize = pageSize; + } + + public void sort(String field, String direction) { + this.sortField = field; + this.sortDirection = direction; + } + + public void view(String view) { + this.view = view; + } + + public void cellFormat(String cellFormat) { + this.cellFormat = cellFormat; + } + + public void timeZone(String timeZone) { + this.timeZone = timeZone; + } + + public void timeZone(ZoneId zoneId) { + this.timeZone = zoneId.getId(); + } + + public void userLocale(String userLocale) { + this.userLocale = userLocale; + } + + public void userLocale(Locale locale) { + this.userLocale = locale.toLanguageTag().toLowerCase(); + } + + // Getters for QuerySpec fields + public String getOffset() { + return offset; + } + + public List getFields() { + return fields; + } + + public String getFilterByFormula() { + return filterByFormula; + } + + public int getMaxRecords() { + return maxRecords; + } + + public int getPageSize() { + return pageSize; + } + + public String getSortField() { + return sortField; + } + + public String getSortDirection() { + return sortDirection; + } + + public String getView() { + return view; + } + + public String getCellFormat() { + return cellFormat; + } + + public String getTimeZone() { + return timeZone; + } + + public String getUserLocale() { + return userLocale; + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/integration/airtable/query/SortOrder.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/integration/airtable/query/SortOrder.java new file mode 100644 index 000000000..9b203f024 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/integration/airtable/query/SortOrder.java @@ -0,0 +1,25 @@ +package com.edgechain.lib.integration.airtable.query; + +public enum SortOrder { + ASC("asc"), + DESC("desc"); + + private final String value; + + SortOrder(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static SortOrder fromValue(String value) { + for (SortOrder sortOrder : SortOrder.values()) { + if (sortOrder.value.equalsIgnoreCase(value)) { + return sortOrder; + } + } + throw new IllegalArgumentException("Invalid SortOrder value: " + value); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/jsonnet/JsonnetArgs.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/jsonnet/JsonnetArgs.java index 8bdbd4a33..945fd1ca0 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/jsonnet/JsonnetArgs.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/jsonnet/JsonnetArgs.java @@ -6,7 +6,9 @@ public class JsonnetArgs { private DataType dataType; - private final String val; + private String val; + + public JsonnetArgs() {} public JsonnetArgs(DataType dataType, String val) { diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/jsonnet/JsonnetLoader.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/jsonnet/JsonnetLoader.java index c3a8a932b..c9fcf20eb 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/jsonnet/JsonnetLoader.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/jsonnet/JsonnetLoader.java @@ -2,6 +2,7 @@ import com.edgechain.lib.jsonnet.enums.DataType; import com.edgechain.lib.jsonnet.exceptions.JsonnetLoaderException; +import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.databind.ObjectMapper; import io.github.jam01.xtrasonnet.Transformer; import org.apache.commons.io.FileUtils; @@ -14,10 +15,21 @@ import java.io.*; import java.util.*; -public abstract class JsonnetLoader { +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS) +public abstract class JsonnetLoader implements Serializable { private final Logger logger = LoggerFactory.getLogger(this.getClass()); + private String f1; + private String f2; + + private String metadata; + private String selectedFile; + + private int threshold = 0; + + private String splitSize; + private Map args = new HashMap<>(); private Map xtraArgsMap = new HashMap<>(); private static final ObjectMapper objectMapper = new ObjectMapper(); @@ -25,6 +37,33 @@ public abstract class JsonnetLoader { public JsonnetLoader() {} + public JsonnetLoader(String f1) { + this.f1 = f1; + } + + public JsonnetLoader(int threshold, String f1, String f2) { + this.f1 = f1; + this.f2 = f2; + if (threshold >= 1 && threshold < 100) { + this.threshold = threshold; + this.splitSize = + String.valueOf(threshold).concat("-").concat(String.valueOf((100 - threshold))); + } else throw new RuntimeException("Threshold has to be b/w 1 and 100"); + } + + public void load(InputStream in1, InputStream in2) { + int randValue = (int) (Math.random() * 101); + if (randValue <= threshold) { + this.selectedFile = getF1(); + logger.info("Using File: " + getF1()); + load(in1); + } else { + this.selectedFile = getF2(); + logger.info("Using File: " + getF2()); + load(in2); + } + } + public void load(InputStream inputStream) { try { preconfigured(); @@ -70,6 +109,8 @@ public void load(InputStream inputStream) { .build() .transform(serializeXtraArgs(xtraArgsMap)); // Get the String Output & Transform it into JsonnetSchema + + this.metadata = res; this.jsonObject = new JSONObject(res); // Delete File @@ -126,4 +167,28 @@ private void preconfigured() { if (Objects.isNull(args.get("keepMaxTokens"))) args.put("keepMaxTokens", new JsonnetArgs(DataType.BOOLEAN, "false")); } + + public String getMetadata() { + return metadata; + } + + public String getSelectedFile() { + return selectedFile; + } + + public String getF1() { + return f1; + } + + public String getF2() { + return f2; + } + + public int getThreshold() { + return threshold; + } + + public String getSplitSize() { + return splitSize; + } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/jsonnet/XtraSonnetCustomFunc.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/jsonnet/XtraSonnetCustomFunc.java index ca3d0665b..33120fc99 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/jsonnet/XtraSonnetCustomFunc.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/jsonnet/XtraSonnetCustomFunc.java @@ -1,6 +1,6 @@ package com.edgechain.lib.jsonnet; -import com.edgechain.lib.endpoint.impl.WikiEndpoint; +import com.edgechain.lib.endpoint.impl.wiki.WikiEndpoint; import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; import io.github.jam01.xtrasonnet.DataFormatService; import io.github.jam01.xtrasonnet.header.Header; diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/jsonnet/impl/FileJsonnetLoader.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/jsonnet/impl/FileJsonnetLoader.java index 0743e402a..529b98902 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/jsonnet/impl/FileJsonnetLoader.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/jsonnet/impl/FileJsonnetLoader.java @@ -2,32 +2,75 @@ import com.edgechain.lib.jsonnet.JsonnetLoader; import com.edgechain.lib.jsonnet.exceptions.JsonnetLoaderException; +import org.apache.commons.io.FilenameUtils; import java.io.*; public class FileJsonnetLoader extends JsonnetLoader { - private String filePath; + private String filePath1; + private String filePath2; + + public String getFilePath1() { + return filePath1; + } + + public void setFilePath1(String filePath1) { + this.filePath1 = filePath1; + } + + public String getFilePath2() { + return filePath2; + } + + public void setFilePath2(String filePath2) { + this.filePath2 = filePath2; + } + + public FileJsonnetLoader() {} public FileJsonnetLoader(String filePath) { - this.filePath = filePath; + super(filePath); + this.filePath1 = filePath; + + if (!new File(filePath).exists()) { + throw new JsonnetLoaderException("File not found - " + filePath); + } } - public FileJsonnetLoader() { - super(); + public FileJsonnetLoader(int threshold, String filePath1, String filePath2) { + super(threshold, FilenameUtils.getName(filePath1), FilenameUtils.getName(filePath2)); + this.filePath1 = filePath1; + this.filePath2 = filePath2; + + if (!new File(filePath1).exists()) { + throw new JsonnetLoaderException("File not found - " + filePath1); + } + + if (!new File(filePath2).exists()) { + throw new JsonnetLoaderException("File not found. " + filePath2); + } } @Override public JsonnetLoader loadOrReload() { - try (InputStream in = new FileInputStream(filePath)) { - this.load(in); - return this; - } catch (final Exception e) { - throw new JsonnetLoaderException(e.getMessage()); - } - } - public String getFilePath() { - return filePath; + if (getThreshold() >= 1 && getThreshold() < 100) { + try (InputStream in1 = new FileInputStream(filePath1); + InputStream in2 = new FileInputStream(filePath2)) { + load(in1, in2); + return this; + } catch (final Exception e) { + throw new JsonnetLoaderException(e.getMessage()); + } + + } else { + try (InputStream in = new FileInputStream(filePath1)) { + load(in); + return this; + } catch (final Exception e) { + throw new JsonnetLoaderException(e.getMessage()); + } + } } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/LLamaClient.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/LLamaClient.java new file mode 100644 index 000000000..ee47fe298 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/LLamaClient.java @@ -0,0 +1,57 @@ +package com.edgechain.lib.llama2; + +import com.edgechain.lib.endpoint.impl.llm.LLamaQuickstart; +import com.edgechain.lib.llama2.request.LLamaCompletionRequest; +import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.reactivex.rxjava3.core.Observable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +import java.util.List; + +@Service +public class LLamaClient { + @Autowired private ObjectMapper objectMapper; + private final Logger logger = LoggerFactory.getLogger(getClass()); + private final RestTemplate restTemplate = new RestTemplate(); + + public EdgeChain> createChatCompletion( + LLamaCompletionRequest request, LLamaQuickstart endpoint) { + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + + logger.info("Logging ChatCompletion...."); + + logger.info("==============REQUEST DATA================"); + logger.info(request.toString()); + + // Create headers + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + HttpEntity entity = new HttpEntity<>(request, headers); + // + String response = + restTemplate.postForObject(endpoint.getUrl(), entity, String.class); + + List chatCompletionResponse = + objectMapper.readValue(response, new TypeReference<>() {}); + emitter.onNext(chatCompletionResponse); + emitter.onComplete(); + + } catch (final Exception e) { + emitter.onError(e); + } + }), + endpoint); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/Llama2Client.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/Llama2Client.java new file mode 100644 index 000000000..481a890f8 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/Llama2Client.java @@ -0,0 +1,89 @@ +package com.edgechain.lib.llama2; + +import com.edgechain.lib.endpoint.impl.llm.LLamaQuickstart; +import com.edgechain.lib.endpoint.impl.llm.Llama2Endpoint; +import com.edgechain.lib.llama2.request.Llama2ChatCompletionRequest; +import com.edgechain.lib.llama2.response.Llama2ChatCompletionResponse; +import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.reactivex.rxjava3.core.Observable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.*; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +@Service +public class Llama2Client { + @Autowired private ObjectMapper objectMapper; + private final Logger logger = LoggerFactory.getLogger(getClass()); + private final RestTemplate restTemplate = new RestTemplate(); + + public EdgeChain> createChatCompletion( + Llama2ChatCompletionRequest request, Llama2Endpoint endpoint) { + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + + logger.info("Logging ChatCompletion...."); + + logger.info("==============REQUEST DATA================"); + logger.info(request.toString()); + + // Create headers + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + HttpEntity entity = new HttpEntity<>(request, headers); + // + String response = + restTemplate.postForObject(endpoint.getUrl(), entity, String.class); + + List chatCompletionResponse = + objectMapper.readValue(response, new TypeReference<>() {}); + emitter.onNext(chatCompletionResponse); + emitter.onComplete(); + + } catch (final Exception e) { + emitter.onError(e); + } + }), + endpoint); + } + + public EdgeChain createGetChatCompletion(LLamaQuickstart endpoint) { + return new EdgeChain<>( + Observable.create( + emitter -> { + try { + + // Create headers + HttpHeaders headers = new HttpHeaders(); + headers.set("User-Agent", "insomnia/8.2.0"); + HttpEntity entity = new HttpEntity<>(headers); + + Map param = Collections.singletonMap("query", endpoint.getQuery()); + + String endpointUrl = endpoint.getUrl() + "?query={query}"; + + ResponseEntity response = + restTemplate.exchange(endpointUrl, HttpMethod.GET, entity, String.class, param); + + logger.info("\nRESPONSE DATA {}\n", response.getBody()); + + emitter.onNext(response.getBody()); + emitter.onComplete(); + + } catch (final Exception e) { + emitter.onError(e); + } + }), + endpoint); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/request/LLamaCompletionRequest.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/request/LLamaCompletionRequest.java new file mode 100644 index 000000000..eea4b0d99 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/request/LLamaCompletionRequest.java @@ -0,0 +1,88 @@ +package com.edgechain.lib.llama2.request; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.StringJoiner; + +public class LLamaCompletionRequest { + @JsonProperty("text_inputs") + private String textInputs; + + @JsonProperty("return_full_text") + private Boolean returnFullText; + + @JsonProperty("top_k") + private Integer topK; + + public LLamaCompletionRequest() {} + + public LLamaCompletionRequest(String textInputs, Boolean returnFullText, Integer topK) { + this.textInputs = textInputs; + this.returnFullText = returnFullText; + this.topK = topK; + } + + @Override + public String toString() { + return new StringJoiner(", ", LLamaCompletionRequest.class.getSimpleName() + "{", "}") + .add("\"text_inputs:\"" + textInputs) + .add("\"return_full_text:\"" + returnFullText) + .add("\"top_k:\"" + topK) + .toString(); + } + + public static LlamaSupportChatCompletionRequestBuilder builder() { + return new LlamaSupportChatCompletionRequestBuilder(); + } + + public String getTextInputs() { + return textInputs; + } + + public void setTextInputs(String textInputs) { + this.textInputs = textInputs; + } + + public Boolean getReturnFullText() { + return returnFullText; + } + + public void setReturnFullText(Boolean returnFullText) { + this.returnFullText = returnFullText; + } + + public Integer getTopK() { + return topK; + } + + public void setTopK(Integer topK) { + this.topK = topK; + } + + public static class LlamaSupportChatCompletionRequestBuilder { + private String textInputs; + private Boolean returnFullText; + private Integer topK; + + private LlamaSupportChatCompletionRequestBuilder() {} + + public LlamaSupportChatCompletionRequestBuilder textInputs(String textInputs) { + this.textInputs = textInputs; + return this; + } + + public LlamaSupportChatCompletionRequestBuilder returnFullText(Boolean returnFullText) { + this.returnFullText = returnFullText; + return this; + } + + public LlamaSupportChatCompletionRequestBuilder topK(Integer topK) { + this.topK = topK; + return this; + } + + public LLamaCompletionRequest build() { + return new LLamaCompletionRequest(textInputs, returnFullText, topK); + } + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/request/Llama2ChatCompletionRequest.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/request/Llama2ChatCompletionRequest.java new file mode 100644 index 000000000..17f190e93 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/request/Llama2ChatCompletionRequest.java @@ -0,0 +1,67 @@ +package com.edgechain.lib.llama2.request; + +import org.json.JSONObject; + +import java.util.StringJoiner; + +public class Llama2ChatCompletionRequest { + + private String inputs; + private JSONObject parameters; + + public Llama2ChatCompletionRequest() {} + + public Llama2ChatCompletionRequest(String inputs, JSONObject parameters) { + this.inputs = inputs; + this.parameters = parameters; + } + + @Override + public String toString() { + return new StringJoiner(", ", Llama2ChatCompletionRequest.class.getSimpleName() + "[{", "}]") + .add("\"inputs:\"" + inputs) + .add("\"parameters:\"" + parameters) + .toString(); + } + + public static Llama2ChatCompletionRequestBuilder builder() { + return new Llama2ChatCompletionRequestBuilder(); + } + + public String getInputs() { + return inputs; + } + + public void setInputs(String inputs) { + this.inputs = inputs; + } + + public JSONObject getParameters() { + return parameters; + } + + public void setParameters(JSONObject parameters) { + this.parameters = parameters; + } + + public static class Llama2ChatCompletionRequestBuilder { + private String inputs; + private JSONObject parameters; + + private Llama2ChatCompletionRequestBuilder() {} + + public Llama2ChatCompletionRequestBuilder inputs(String inputs) { + this.inputs = inputs; + return this; + } + + public Llama2ChatCompletionRequestBuilder parameters(JSONObject parameters) { + this.parameters = parameters; + return this; + } + + public Llama2ChatCompletionRequest build() { + return new Llama2ChatCompletionRequest(inputs, parameters); + } + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/response/Llama2ChatCompletionResponse.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/response/Llama2ChatCompletionResponse.java new file mode 100644 index 000000000..033d78286 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/llama2/response/Llama2ChatCompletionResponse.java @@ -0,0 +1,18 @@ +package com.edgechain.lib.llama2.response; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Llama2ChatCompletionResponse { + @JsonProperty("generated_text") + private String generatedText; + + public Llama2ChatCompletionResponse() {} + + public String getGeneratedText() { + return generatedText; + } + + public void setGeneratedText(String generatedText) { + this.generatedText = generatedText; + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/EmbeddingLogger.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/EmbeddingLogger.java index c1e30b9b5..5fd9129aa 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/EmbeddingLogger.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/EmbeddingLogger.java @@ -1,16 +1,13 @@ package com.edgechain.lib.logger; -import com.edgechain.lib.logger.entities.EmbeddingLog; import com.edgechain.lib.logger.entities.EmbeddingLog; import com.edgechain.lib.retrofit.client.RetrofitClientInstance; import com.edgechain.lib.retrofit.logger.EmbeddingLoggerService; -import com.edgechain.lib.retrofit.logger.EmbeddingLoggerService; +import java.util.HashMap; import org.springframework.data.domain.Page; import org.springframework.web.bind.annotation.PathVariable; import retrofit2.Retrofit; -import java.util.HashMap; - public class EmbeddingLogger { private final Retrofit retrofit = RetrofitClientInstance.getInstance(); diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/JsonnetLogger.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/JsonnetLogger.java new file mode 100644 index 000000000..ab8dbe77c --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/JsonnetLogger.java @@ -0,0 +1,37 @@ +package com.edgechain.lib.logger; + +import com.edgechain.lib.logger.entities.JsonnetLog; +import com.edgechain.lib.retrofit.client.RetrofitClientInstance; +import java.util.HashMap; + +import com.edgechain.lib.retrofit.logger.JsonnetLoggerService; +import org.springframework.data.domain.Page; +import retrofit2.Retrofit; + +public class JsonnetLogger { + + private final Retrofit retrofit = RetrofitClientInstance.getInstance(); + private final JsonnetLoggerService jsonnetLoggerService = + retrofit.create(JsonnetLoggerService.class); + + public JsonnetLogger() {} + + public Page findAll(int page, int size) { + return this.jsonnetLoggerService.findAll(page, size).blockingGet(); + } + + public Page findAllOrderByCreatedAtDesc(int page, int size) { + return this.jsonnetLoggerService.findAllOrderByCreatedAtDesc(page, size).blockingGet(); + } + + public Page findAllBySelectedFileOrderByCreatedAtDesc( + String filename, int page, int size) { + + HashMap mapper = new HashMap<>(); + mapper.put("filename", filename); + + return this.jsonnetLoggerService + .findAllBySelectedFileOrderByCreatedAtDesc(mapper, page, size) + .blockingGet(); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/entities/ChatCompletionLog.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/entities/ChatCompletionLog.java index 5960c5352..74b2e0a11 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/entities/ChatCompletionLog.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/entities/ChatCompletionLog.java @@ -5,6 +5,7 @@ import javax.validation.constraints.NotBlank; import java.time.LocalDateTime; +import java.util.StringJoiner; import java.util.UUID; @Table(name = "chat_completion_logs") @@ -45,6 +46,16 @@ public class ChatCompletionLog { @Column(columnDefinition = "TEXT") private String content; + private Double presencePenalty; + private Double frequencyPenalty; + + @Column(name = "top_p") + private Double topP; + + private Integer n; + + private Double temperature; + private Long latency; private Long promptTokens; @@ -159,23 +170,66 @@ public void setCallIdentifier(String callIdentifier) { this.callIdentifier = callIdentifier; } + public Double getTemperature() { + return temperature; + } + + public void setTemperature(Double temperature) { + this.temperature = temperature; + } + + public Double getPresencePenalty() { + return presencePenalty; + } + + public void setPresencePenalty(Double presencePenalty) { + this.presencePenalty = presencePenalty; + } + + public Double getFrequencyPenalty() { + return frequencyPenalty; + } + + public void setFrequencyPenalty(Double frequencyPenalty) { + this.frequencyPenalty = frequencyPenalty; + } + + public Double getTopP() { + return topP; + } + + public void setTopP(Double topP) { + this.topP = topP; + } + + public Integer getN() { + return n; + } + + public void setN(Integer n) { + this.n = n; + } + @Override public String toString() { - final StringBuilder sb = new StringBuilder("ChatCompletionLog{"); - sb.append("chatCompletionId=").append(chatCompletionId); - sb.append(", id='").append(id).append('\''); - sb.append(", name='").append(name).append('\''); - sb.append(", callIdentifier='").append(callIdentifier).append('\''); - sb.append(", type='").append(type).append('\''); - sb.append(", createdAt=").append(createdAt); - sb.append(", completedAt=").append(completedAt); - sb.append(", model='").append(model).append('\''); - sb.append(", input='").append(input).append('\''); - sb.append(", content='").append(content).append('\''); - sb.append(", latency=").append(latency); - sb.append(", promptTokens=").append(promptTokens); - sb.append(", totalTokens=").append(totalTokens); - sb.append('}'); - return sb.toString(); + return new StringJoiner(", ", ChatCompletionLog.class.getSimpleName() + "[", "]") + .add("id='" + id + "'") + .add("name='" + name + "'") + .add("callIdentifier='" + callIdentifier + "'") + .add("type='" + type + "'") + .add("temperature=" + temperature) + .add("createdAt=" + createdAt) + .add("completedAt=" + completedAt) + .add("model='" + model + "'") + .add("input='" + input + "'") + .add("content='" + content + "'") + .add("presencePenalty=" + presencePenalty) + .add("frequencyPenalty=" + frequencyPenalty) + .add("topP=" + topP) + .add("n=" + n) + .add("latency=" + latency) + .add("promptTokens=" + promptTokens) + .add("totalTokens=" + totalTokens) + .toString(); } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/entities/JsonnetLog.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/entities/JsonnetLog.java new file mode 100644 index 000000000..d9dce0784 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/entities/JsonnetLog.java @@ -0,0 +1,122 @@ +package com.edgechain.lib.logger.entities; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import jakarta.persistence.*; + +import java.time.LocalDateTime; +import java.util.StringJoiner; +import java.util.UUID; + +@Table(name = "jsonnet_logs") +@Entity(name = "JsonnetLog") +public class JsonnetLog { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @JsonIgnore + private Long jsonnetLogId; + + @Column(nullable = false, unique = true) + private String id; + + @Column(nullable = false) + private String splitSize; + + @Column(nullable = false, columnDefinition = "TEXT") + private String metadata; + + @Column(columnDefinition = "TEXT") + private String content; + + private String selectedFile; + + @Column(nullable = false) + private String f1; + + @Column(nullable = false) + private String f2; + + private LocalDateTime createdAt; + + @PrePersist + protected void onCreate() { + setId(UUID.randomUUID().toString()); + } + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + public String getSplitSize() { + return splitSize; + } + + public void setSplitSize(String splitSize) { + this.splitSize = splitSize; + } + + public String getMetadata() { + return metadata; + } + + public void setMetadata(String jsonString) { + this.metadata = jsonString; + } + + public String getF1() { + return f1; + } + + public void setF1(String f1) { + this.f1 = f1; + } + + public String getF2() { + return f2; + } + + public void setF2(String f2) { + this.f2 = f2; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public LocalDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(LocalDateTime createdAt) { + this.createdAt = createdAt; + } + + public String getSelectedFile() { + return selectedFile; + } + + public void setSelectedFile(String selectedFile) { + this.selectedFile = selectedFile; + } + + @Override + public String toString() { + return new StringJoiner(", ", JsonnetLog.class.getSimpleName() + "[", "]") + .add("id='" + id + "'") + .add("splitSize=" + splitSize) + .add("metadata='" + metadata + "'") + .add("content='" + content + "'") + .add("f1='" + f1 + "'") + .add("f2='" + f2 + "'") + .add("createdAt=" + createdAt) + .toString(); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/repositories/JsonnetLogRepository.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/repositories/JsonnetLogRepository.java new file mode 100644 index 000000000..a90955ea8 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/repositories/JsonnetLogRepository.java @@ -0,0 +1,18 @@ +package com.edgechain.lib.logger.repositories; + +import com.edgechain.lib.logger.entities.JsonnetLog; +import org.jetbrains.annotations.NotNull; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface JsonnetLogRepository extends JpaRepository { + + @Override + @NotNull + Page findAll(@NotNull Pageable pageable); + + Page findAllByOrderByCreatedAtDesc(Pageable pageable); + + Page findAllBySelectedFileOrderByCreatedAtDesc(String filename, Pageable pageable); +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/services/ChatCompletionLogService.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/services/ChatCompletionLogService.java index 9871831f6..2e8142ead 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/services/ChatCompletionLogService.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/services/ChatCompletionLogService.java @@ -88,9 +88,14 @@ public void createTable() { + " model VARCHAR(255) NOT NULL,\n" + " input TEXT NOT NULL,\n" + " content TEXT,\n" + + " presence_penalty DOUBLE PRECISION,\n" + + " frequency_penalty DOUBLE PRECISION,\n" + + " top_p DOUBLE PRECISION,\n" + + " n INTEGER,\n" + + " temperature DOUBLE PRECISION,\n" + " latency BIGINT,\n" + " prompt_tokens BIGINT,\n" - + " total_tokens BIGINT\n" + + " total_tokens BIGINT" + ");"); } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/services/EmbeddingLogService.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/services/EmbeddingLogService.java index 8f4ad06e6..986c65a40 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/services/EmbeddingLogService.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/services/EmbeddingLogService.java @@ -1,8 +1,6 @@ package com.edgechain.lib.logger.services; import com.edgechain.lib.logger.entities.EmbeddingLog; -import com.edgechain.lib.logger.entities.EmbeddingLog; -import com.edgechain.lib.logger.repositories.EmbeddingLogRepository; import com.edgechain.lib.logger.repositories.EmbeddingLogRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; @@ -17,6 +15,7 @@ public class EmbeddingLogService { @Autowired private EmbeddingLogRepository embeddingLogRepository; @Autowired private JdbcTemplate jdbcTemplate; + @Transactional public EmbeddingLog saveOrUpdate(EmbeddingLog embeddingLog) { this.createTable(); return this.embeddingLogRepository.save(embeddingLog); @@ -64,19 +63,23 @@ public Page findAllByLatencyGreaterThanEqual(long latency, Pageabl return this.embeddingLogRepository.findAllByLatencyGreaterThanEqual(latency, pageable); } + private static final String SQL_CREATE_TABLE = + """ + CREATE TABLE IF NOT EXISTS embedding_logs ( + embedding_id SERIAL PRIMARY KEY, + id VARCHAR(255) NOT NULL UNIQUE, + call_identifier VARCHAR(255) NOT NULL, + created_at TIMESTAMP, + completed_at TIMESTAMP, + model VARCHAR(255) NOT NULL, + latency BIGINT, + prompt_tokens BIGINT, + total_tokens BIGINT + ); + """; + @Transactional public void createTable() { - jdbcTemplate.execute( - "CREATE TABLE IF NOT EXISTS embedding_logs (\n" - + " embedding_id SERIAL PRIMARY KEY,\n" - + " id VARCHAR(255) NOT NULL UNIQUE,\n" - + " call_identifier VARCHAR(255) NOT NULL,\n" - + " created_at TIMESTAMP,\n" - + " completed_at TIMESTAMP,\n" - + " model VARCHAR(255) NOT NULL,\n" - + " latency BIGINT,\n" - + " prompt_tokens BIGINT,\n" - + " total_tokens BIGINT\n" - + ");;"); + jdbcTemplate.execute(SQL_CREATE_TABLE); } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/services/JsonnetLogService.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/services/JsonnetLogService.java new file mode 100644 index 000000000..df4f91d58 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/logger/services/JsonnetLogService.java @@ -0,0 +1,54 @@ +package com.edgechain.lib.logger.services; + +import com.edgechain.lib.logger.entities.JsonnetLog; +import com.edgechain.lib.logger.repositories.JsonnetLogRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +public class JsonnetLogService { + + @Autowired private JsonnetLogRepository jsonnetLogRepository; + @Autowired private JdbcTemplate jdbcTemplate; + + public JsonnetLog saveOrUpdate(JsonnetLog jsonnetLog) { + this.createTable(); + return jsonnetLogRepository.save(jsonnetLog); + } + + @Transactional(readOnly = true) + public Page findAll(Pageable pageable) { + return this.jsonnetLogRepository.findAll(pageable); + } + + @Transactional(readOnly = true) + public Page findAllOrderByCreatedAtDesc(Pageable pageable) { + return this.jsonnetLogRepository.findAllByOrderByCreatedAtDesc(pageable); + } + + @Transactional(readOnly = true) + public Page findAllBySelectedFileOrderByCreatedAtDesc( + String filename, Pageable pageable) { + return this.jsonnetLogRepository.findAllBySelectedFileOrderByCreatedAtDesc(filename, pageable); + } + + @Transactional + public void createTable() { + jdbcTemplate.execute( + "CREATE TABLE IF NOT EXISTS jsonnet_logs (\n" + + " jsonnet_log_id SERIAL PRIMARY KEY,\n" + + " id VARCHAR(255) NOT NULL UNIQUE,\n" + + " split_size VARCHAR(255) NOT NULL,\n" + + " metadata TEXT NOT NULL,\n" + + " content TEXT,\n" + + " selected_file VARCHAR(255),\n" + + " f1 VARCHAR(255) NOT NULL,\n" + + " f2 VARCHAR(255) NOT NULL,\n" + + " created_at TIMESTAMP\n" + + ");\n"); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/client/OpenAiClient.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/client/OpenAiClient.java index e406cab3f..fffd19dab 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/client/OpenAiClient.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/client/OpenAiClient.java @@ -3,7 +3,8 @@ import com.edgechain.lib.constants.EndpointConstants; import com.edgechain.lib.embeddings.request.OpenAiEmbeddingRequest; import com.edgechain.lib.embeddings.response.OpenAiEmbeddingResponse; -import com.edgechain.lib.endpoint.impl.OpenAiEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.OpenAiEmbeddingEndpoint; +import com.edgechain.lib.endpoint.impl.llm.OpenAiChatEndpoint; import com.edgechain.lib.openai.request.ChatCompletionRequest; import com.edgechain.lib.openai.request.CompletionRequest; import com.edgechain.lib.openai.response.ChatCompletionResponse; @@ -27,17 +28,8 @@ public class OpenAiClient { private final Logger logger = LoggerFactory.getLogger(getClass()); private final RestTemplate restTemplate = new RestTemplate(); - private OpenAiEndpoint endpoint; - - public OpenAiEndpoint getEndpoint() { - return endpoint; - } - - public void setEndpoint(OpenAiEndpoint endpoint) { - this.endpoint = endpoint; - } - - public EdgeChain createChatCompletion(ChatCompletionRequest request) { + public EdgeChain createChatCompletion( + ChatCompletionRequest request, OpenAiChatEndpoint endpoint) { return new EdgeChain<>( Observable.create( @@ -74,9 +66,12 @@ public EdgeChain createChatCompletion(ChatCompletionRequ } public EdgeChain createChatCompletionStream( - ChatCompletionRequest request) { + ChatCompletionRequest request, OpenAiChatEndpoint endpoint) { try { + logger.info("Logging ChatCompletion Stream...."); + logger.info(request.toString()); + return new EdgeChain<>( RxJava3Adapter.fluxToObservable( WebClient.builder() @@ -102,7 +97,8 @@ public EdgeChain createChatCompletionStream( } } - public EdgeChain createCompletion(CompletionRequest request) { + public EdgeChain createCompletion( + CompletionRequest request, OpenAiChatEndpoint endpoint) { return new EdgeChain<>( Observable.create( emitter -> { @@ -128,7 +124,8 @@ public EdgeChain createCompletion(CompletionRequest request) endpoint); } - public EdgeChain createEmbeddings(OpenAiEmbeddingRequest request) { + public EdgeChain createEmbeddings( + OpenAiEmbeddingRequest request, OpenAiEmbeddingEndpoint endpoint) { return new EdgeChain<>( Observable.create( emitter -> { diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/providers/OpenAiCompletionProvider.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/providers/OpenAiCompletionProvider.java index e304a4232..52353f076 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/providers/OpenAiCompletionProvider.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/providers/OpenAiCompletionProvider.java @@ -1,15 +1,15 @@ package com.edgechain.lib.openai.providers; -import com.edgechain.lib.endpoint.impl.OpenAiEndpoint; +import com.edgechain.lib.endpoint.impl.llm.OpenAiChatEndpoint; import com.edgechain.lib.openai.request.CompletionRequest; import com.edgechain.lib.response.StringResponse; import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; /** Going to be removed * */ public class OpenAiCompletionProvider { - private final OpenAiEndpoint endpoint; + private final OpenAiChatEndpoint endpoint; - public OpenAiCompletionProvider(OpenAiEndpoint endpoint) { + public OpenAiCompletionProvider(OpenAiChatEndpoint endpoint) { this.endpoint = endpoint; } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/request/ChatCompletionRequest.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/request/ChatCompletionRequest.java index 952d2e06a..4fe7ce4dd 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/request/ChatCompletionRequest.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/request/ChatCompletionRequest.java @@ -1,22 +1,70 @@ package com.edgechain.lib.openai.request; -import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.*; public class ChatCompletionRequest { + private static final Double DEFAULT_TEMPERATURE = 0.7; + private static final Boolean DEFAULT_STREAM = false; + private static final Double DEFAULT_TOP_P = 1.0; + private static final Integer DEFAULT_N = 1; + private static final List DEFAULT_STOP = Collections.emptyList(); + private static final Double DEFAULT_PRESENCE_PENALTY = 0.0; + private static final Double DEFAULT_FREQUENCY_PENALTY = 0.0; + private static final Map DEFAULT_LOGIT_BIAS = Collections.emptyMap(); + private static final String DEFAULT_USER = ""; + private String model; private Double temperature; private List messages; private Boolean stream; + @JsonProperty("top_p") + private Double topP; + + private Integer n; + + private List stop; + + @JsonProperty("presence_penalty") + private Double presencePenalty; + + @JsonProperty("frequency_penalty") + private Double frequencyPenalty; + + @JsonProperty("logit_bias") + private Map logitBias; + + private String user; + public ChatCompletionRequest() {} public ChatCompletionRequest( - String model, List messages, Double temperature, Boolean stream) { + String model, + Double temperature, + List messages, + Boolean stream, + Double topP, + Integer n, + List stop, + Double presencePenalty, + Double frequencyPenalty, + Map logitBias, + String user) { this.model = model; - this.temperature = temperature; + this.temperature = (temperature != null) ? temperature : DEFAULT_TEMPERATURE; this.messages = messages; - this.stream = stream; + this.stream = (stream != null) ? stream : DEFAULT_STREAM; + this.topP = (topP != null) ? topP : DEFAULT_TOP_P; + this.n = (n != null) ? n : DEFAULT_N; + this.stop = (stop != null) ? stop : DEFAULT_STOP; + this.presencePenalty = (presencePenalty != null) ? presencePenalty : DEFAULT_PRESENCE_PENALTY; + this.frequencyPenalty = + (frequencyPenalty != null) ? frequencyPenalty : DEFAULT_FREQUENCY_PENALTY; + this.logitBias = (logitBias != null) ? logitBias : DEFAULT_LOGIT_BIAS; + this.user = (user != null) ? user : DEFAULT_USER; } public String getModel() { @@ -51,15 +99,49 @@ public void setStream(Boolean stream) { this.stream = stream; } + public Double getTopP() { + return topP; + } + + public Integer getN() { + return n; + } + + public List getStop() { + return stop; + } + + public Double getPresencePenalty() { + return presencePenalty; + } + + public Double getFrequencyPenalty() { + return frequencyPenalty; + } + + public Map getLogitBias() { + return logitBias; + } + + public String getUser() { + return user; + } + @Override public String toString() { - final StringBuilder sb = new StringBuilder("ChatCompletionRequest{"); - sb.append("model='").append(model).append('\''); - sb.append(", temperature=").append(temperature); - sb.append(", messages=").append(messages); - sb.append(", stream=").append(stream); - sb.append('}'); - return sb.toString(); + return new StringJoiner(", ", ChatCompletionRequest.class.getSimpleName() + "[", "]") + .add("model='" + model + "'") + .add("temperature=" + temperature) + .add("messages=" + messages) + .add("stream=" + stream) + .add("topP=" + topP) + .add("n=" + n) + .add("stop=" + stop) + .add("presencePenalty=" + presencePenalty) + .add("frequencyPenalty=" + frequencyPenalty) + .add("logitBias=" + logitBias) + .add("user='" + user + "'") + .toString(); } public static ChatCompletionRequestBuilder builder() { @@ -70,8 +152,26 @@ public static class ChatCompletionRequestBuilder { private String model; private Double temperature; private List messages; + private Boolean stream; + + @JsonProperty("top_p") + private Double topP; - private Boolean stream = Boolean.FALSE; + private Integer n; + private List stop; + + @JsonProperty("presence_penalty") + private Double presencePenalty; + + @JsonProperty("frequency_penalty") + private Double frequencyPenalty; + + @JsonProperty("logit_bias") + private Map logitBias; + + private String user; + + private ChatCompletionRequestBuilder() {} public ChatCompletionRequestBuilder model(String model) { this.model = model; @@ -88,13 +188,59 @@ public ChatCompletionRequestBuilder messages(List messages) { return this; } - public ChatCompletionRequestBuilder stream(Boolean value) { - this.stream = value; + public ChatCompletionRequestBuilder stream(Boolean stream) { + this.stream = stream; + return this; + } + + public ChatCompletionRequestBuilder topP(Double topP) { + this.topP = topP; + return this; + } + + public ChatCompletionRequestBuilder n(Integer n) { + this.n = n; + return this; + } + + public ChatCompletionRequestBuilder stop(List stop) { + this.stop = stop; + return this; + } + + public ChatCompletionRequestBuilder presencePenalty(Double presencePenalty) { + this.presencePenalty = presencePenalty; + return this; + } + + public ChatCompletionRequestBuilder frequencyPenalty(Double frequencyPenalty) { + this.frequencyPenalty = frequencyPenalty; + return this; + } + + public ChatCompletionRequestBuilder logitBias(Map logitBias) { + this.logitBias = logitBias; + return this; + } + + public ChatCompletionRequestBuilder user(String user) { + this.user = user; return this; } public ChatCompletionRequest build() { - return new ChatCompletionRequest(model, messages, temperature, stream); + return new ChatCompletionRequest( + model, + temperature, + messages, + stream, + topP, + n, + stop, + presencePenalty, + frequencyPenalty, + logitBias, + user); } } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/request/ChatMessage.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/request/ChatMessage.java index 6ea6007b6..44642313b 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/request/ChatMessage.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/request/ChatMessage.java @@ -22,6 +22,10 @@ public String getContent() { return content; } + public void setRole(String role) { + this.role = role; + } + public void setContent(String content) { this.content = content; } @@ -33,8 +37,15 @@ public String toString() { public JSONObject toJson() { JSONObject json = new JSONObject(); - json.put("role", role); - json.put("content", content); + + if (role != null) { + json.put("role", role); + } + + if (content != null) { + json.put("content", content); + } + return json; } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/response/ChatCompletionResponse.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/response/ChatCompletionResponse.java index d44acfc67..fd4ced252 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/response/ChatCompletionResponse.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/openai/response/ChatCompletionResponse.java @@ -86,13 +86,31 @@ public String toString() { @Override public JSONObject toJson() { JSONObject json = new JSONObject(); - json.put("id", id); - json.put("object", object); + + if (id != null) { + json.put("id", id); + } + + if (object != null) { + json.put("object", object); + } + json.put("created", created); - json.put("model", model); - json.put( - "choices", choices.stream().map(ChatCompletionChoice::toJson).collect(Collectors.toList())); - json.put("usage", usage.toJson()); + + if (model != null) { + json.put("model", model); + } + + if (choices != null) { + json.put( + "choices", + choices.stream().map(ChatCompletionChoice::toJson).collect(Collectors.toList())); + } + + if (usage != null) { + json.put("usage", usage.toJson()); + } + return json; } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/request/ArkRequest.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/request/ArkRequest.java index dd047758f..875bba38c 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/request/ArkRequest.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/request/ArkRequest.java @@ -9,12 +9,12 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; +import java.io.BufferedReader; import java.io.IOException; import java.security.Principal; import java.util.Collection; import java.util.Enumeration; import java.util.Objects; -import java.util.stream.Collectors; public class ArkRequest { @@ -99,8 +99,15 @@ public int getIntQueryParam(String key) { } public JSONObject getBody() { - try { - return new JSONObject(this.request.getReader().lines().collect(Collectors.joining())); + + StringBuilder jsonContent = new StringBuilder(); + + try (BufferedReader reader = request.getReader()) { + String line; + while ((line = reader.readLine()) != null) { + jsonContent.append(line); + } + return new JSONObject(jsonContent.toString()); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/response/ArkEmitter.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/response/ArkEmitter.java index 97a26403e..b2dda1187 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/response/ArkEmitter.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/response/ArkEmitter.java @@ -12,6 +12,6 @@ public ArkEmitter(EdgeChain edgeChain) { } public ArkEmitter(Observable observable) { - this.observer = new ArkEmitterObserver(observable, this); + this.observer = new ArkEmitterObserver<>(observable, this); } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/response/ArkEmitterObserver.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/response/ArkEmitterObserver.java index fc0f2fbd8..16140aab7 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/response/ArkEmitterObserver.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/response/ArkEmitterObserver.java @@ -39,6 +39,7 @@ public void onError(@NonNull Throwable e) { @Override public void onComplete() { + if (!completed) { completed = true; responseBodyEmitter.complete(); diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/response/ArkObservable.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/response/ArkObservable.java index 88c816f56..8f1f56fdd 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/response/ArkObservable.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/response/ArkObservable.java @@ -9,7 +9,7 @@ public class ArkObservable extends DeferredResult implements ArkResponse { private final ArkObserver observer; public ArkObservable(EdgeChain edgeChain) { - observer = new ArkObserver<>(edgeChain.getScheduledObservable(), this); + observer = new ArkObserver<>(edgeChain.getObservable(), this); } public ArkObservable(Observable observable) { diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/AirtableService.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/AirtableService.java new file mode 100644 index 000000000..dc5744a9d --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/AirtableService.java @@ -0,0 +1,29 @@ +package com.edgechain.lib.retrofit; + +import com.edgechain.lib.endpoint.impl.integration.AirtableEndpoint; +import dev.fuxing.airtable.AirtableRecord; +import io.reactivex.rxjava3.core.Single; +import retrofit2.http.Body; +import retrofit2.http.HTTP; +import retrofit2.http.POST; + +import java.util.List; +import java.util.Map; + +public interface AirtableService { + + @POST("airtable/findAll") + Single> findAll(@Body AirtableEndpoint endpoint); + + @POST("airtable/findById") + Single findById(@Body AirtableEndpoint endpoint); + + @POST("airtable/create") + Single> create(@Body AirtableEndpoint endpoint); + + @POST("airtable/update") + Single> update(@Body AirtableEndpoint endpoint); + + @HTTP(method = "DELETE", path = "airtable/delete", hasBody = true) + Single> delete(@Body AirtableEndpoint endpoint); +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/BgeSmallService.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/BgeSmallService.java index 3f8302378..ad7526fe5 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/BgeSmallService.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/BgeSmallService.java @@ -1,7 +1,7 @@ package com.edgechain.lib.retrofit; import com.edgechain.lib.embeddings.bgeSmall.response.BgeSmallResponse; -import com.edgechain.lib.endpoint.impl.BgeSmallEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.BgeSmallEndpoint; import io.reactivex.rxjava3.core.Single; import retrofit2.http.Body; import retrofit2.http.POST; diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/Llama2Service.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/Llama2Service.java new file mode 100644 index 000000000..5f18ace6c --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/Llama2Service.java @@ -0,0 +1,18 @@ +package com.edgechain.lib.retrofit; + +import com.edgechain.lib.endpoint.impl.llm.LLamaQuickstart; +import com.edgechain.lib.endpoint.impl.llm.Llama2Endpoint; +import com.edgechain.lib.llama2.response.Llama2ChatCompletionResponse; +import io.reactivex.rxjava3.core.Single; +import retrofit2.http.Body; +import retrofit2.http.POST; + +import java.util.List; + +public interface Llama2Service { + @POST(value = "llama/chat-completion") + Single> chatCompletion(@Body Llama2Endpoint llama2Endpoint); + + @POST(value = "llama/chat-completion") + Single llamaCompletion(@Body LLamaQuickstart lLamaQuickstart); +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/MiniLMService.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/MiniLMService.java index a0cfaff77..96e09ba1b 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/MiniLMService.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/MiniLMService.java @@ -2,7 +2,7 @@ import com.edgechain.lib.embeddings.miniLLM.response.MiniLMResponse; -import com.edgechain.lib.endpoint.impl.MiniLMEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.MiniLMEndpoint; import io.reactivex.rxjava3.core.Single; import retrofit2.http.Body; import retrofit2.http.POST; diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/OpenAiService.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/OpenAiService.java index c1bd2e116..814b815a1 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/OpenAiService.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/OpenAiService.java @@ -1,9 +1,10 @@ package com.edgechain.lib.retrofit; import com.edgechain.lib.embeddings.response.OpenAiEmbeddingResponse; -import com.edgechain.lib.endpoint.impl.OpenAiEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.OpenAiEmbeddingEndpoint; +import com.edgechain.lib.endpoint.impl.llm.OpenAiChatEndpoint; import com.edgechain.lib.openai.response.ChatCompletionResponse; -import io.reactivex.rxjava3.core.Completable; +import com.edgechain.lib.openai.response.CompletionResponse; import io.reactivex.rxjava3.core.Single; import retrofit2.http.Body; import retrofit2.http.POST; @@ -11,11 +12,11 @@ public interface OpenAiService { @POST(value = "openai/chat-completion") - Single chatCompletion(@Body OpenAiEndpoint openAiEndpoint); + Single chatCompletion(@Body OpenAiChatEndpoint OpenAiChatEndpoint); @POST(value = "openai/completion") - Single completion(@Body OpenAiEndpoint openAiEndpoint); + Single completion(@Body OpenAiChatEndpoint openAiChatEndpoint); @POST(value = "openai/embeddings") - Single embeddings(@Body OpenAiEndpoint openAiEndpoint); + Single embeddings(@Body OpenAiEmbeddingEndpoint openAiEmbeddingEndpoint); } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/PineconeService.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/PineconeService.java index 9d5282377..0a74c27dc 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/PineconeService.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/PineconeService.java @@ -1,7 +1,7 @@ package com.edgechain.lib.retrofit; import com.edgechain.lib.embeddings.WordEmbeddings; -import com.edgechain.lib.endpoint.impl.PineconeEndpoint; +import com.edgechain.lib.endpoint.impl.index.PineconeEndpoint; import com.edgechain.lib.response.StringResponse; import io.reactivex.rxjava3.core.Single; import retrofit2.http.Body; @@ -15,6 +15,9 @@ public interface PineconeService { @POST(value = "index/pinecone/upsert") Single upsert(@Body PineconeEndpoint pineconeEndpoint); + @POST(value = "index/pinecone/batch-upsert") + Single batchUpsert(@Body PineconeEndpoint pineconeEndpoint); + @POST(value = "index/pinecone/query") Single> query(@Body PineconeEndpoint pineconeEndpoint); diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/PostgreSQLContextService.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/PostgreSQLContextService.java index b1b8325d9..d4b28f3dc 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/PostgreSQLContextService.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/PostgreSQLContextService.java @@ -2,7 +2,7 @@ import com.edgechain.lib.context.domain.ContextPutRequest; import com.edgechain.lib.context.domain.HistoryContext; -import com.edgechain.lib.endpoint.impl.PostgreSQLHistoryContextEndpoint; +import com.edgechain.lib.endpoint.impl.context.PostgreSQLHistoryContextEndpoint; import io.reactivex.rxjava3.core.Completable; import io.reactivex.rxjava3.core.Single; import retrofit2.http.*; diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/PostgresService.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/PostgresService.java index bdbd229b7..a8701d952 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/PostgresService.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/PostgresService.java @@ -1,6 +1,6 @@ package com.edgechain.lib.retrofit; -import com.edgechain.lib.endpoint.impl.PostgresEndpoint; +import com.edgechain.lib.endpoint.impl.index.PostgresEndpoint; import com.edgechain.lib.index.domain.PostgresWordEmbeddings; import com.edgechain.lib.response.StringResponse; import io.reactivex.rxjava3.core.Single; @@ -12,13 +12,46 @@ public interface PostgresService { + @POST(value = "index/postgres/create-table") + Single createTable(@Body PostgresEndpoint postgresEndpoint); + + @POST(value = "index/postgres/metadata/create-table") + Single createMetadataTable(@Body PostgresEndpoint postgresEndpoint); + @POST(value = "index/postgres/upsert") Single upsert(@Body PostgresEndpoint postgresEndpoint); - // + @POST(value = "index/postgres/batch-upsert") + Single> batchUpsert(@Body PostgresEndpoint postgresEndpoint); + + @POST(value = "index/postgres/metadata/insert") + Single insertMetadata(@Body PostgresEndpoint postgresEndpoint); + + @POST(value = "index/postgres/metadata/batch-insert") + Single> batchInsertMetadata(@Body PostgresEndpoint postgresEndpoint); + + @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); + @POST(value = "index/postgres/query-rrf") + Single> queryRRF(@Body PostgresEndpoint postgresEndpoint); + + @POST(value = "index/postgres/metadata/query") + Single> queryWithMetadata(@Body PostgresEndpoint postgresEndpoint); + + @POST(value = "index/postgres/chunks") + Single> getAllChunks(@Body PostgresEndpoint postgresEndpoint); + + @POST(value = "index/postgres/similarity-metadata") + Single> getSimilarMetadataChunk( + @Body PostgresEndpoint postgresEndpoint); + @POST("index/postgres/probes") Single probes(@Body PostgresEndpoint postgresEndpoint); diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/RedisContextService.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/RedisContextService.java index bc327e916..faa4843e0 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/RedisContextService.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/RedisContextService.java @@ -3,7 +3,7 @@ import com.edgechain.lib.context.domain.ContextPutRequest; import com.edgechain.lib.context.domain.HistoryContext; -import com.edgechain.lib.endpoint.impl.RedisHistoryContextEndpoint; +import com.edgechain.lib.endpoint.impl.context.RedisHistoryContextEndpoint; import io.reactivex.rxjava3.core.Completable; import io.reactivex.rxjava3.core.Single; import retrofit2.http.*; diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/RedisService.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/RedisService.java index 513fb5dc5..b29ba59f7 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/RedisService.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/RedisService.java @@ -1,25 +1,30 @@ package com.edgechain.lib.retrofit; import com.edgechain.lib.embeddings.WordEmbeddings; -import com.edgechain.lib.endpoint.impl.RedisEndpoint; +import com.edgechain.lib.endpoint.impl.index.RedisEndpoint; import com.edgechain.lib.response.StringResponse; import io.reactivex.rxjava3.core.Completable; import io.reactivex.rxjava3.core.Single; import retrofit2.http.Body; import retrofit2.http.HTTP; import retrofit2.http.POST; -import retrofit2.http.Query; import java.util.List; public interface RedisService { + @POST(value = "index/redis/create-index") + Single createIndex(@Body RedisEndpoint redisEndpoint); + @POST(value = "index/redis/upsert") Single upsert(@Body RedisEndpoint redisEndpoint); + @POST(value = "index/redis/batch-upsert") + Single batchUpsert(@Body RedisEndpoint redisEndpoint); + @POST(value = "index/redis/query") Single> query(@Body RedisEndpoint redisEndpoint); @HTTP(method = "DELETE", path = "index/redis/delete", hasBody = true) - Completable deleteByPattern(@Query("pattern") String pattern, @Body RedisEndpoint redisEndpoint); + Completable deleteByPattern(@Body RedisEndpoint redisEndpoint); } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/WikiService.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/WikiService.java index d5b2d33bf..6b24c965f 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/WikiService.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/WikiService.java @@ -1,6 +1,6 @@ package com.edgechain.lib.retrofit; -import com.edgechain.lib.endpoint.impl.WikiEndpoint; +import com.edgechain.lib.endpoint.impl.wiki.WikiEndpoint; import com.edgechain.lib.wiki.response.WikiResponse; import io.reactivex.rxjava3.core.Single; import retrofit2.http.Body; diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/client/OpenAiStreamService.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/client/OpenAiStreamService.java index 4bdab038e..4392bb348 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/client/OpenAiStreamService.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/client/OpenAiStreamService.java @@ -2,11 +2,10 @@ import com.edgechain.lib.configuration.WebConfiguration; import com.edgechain.lib.configuration.domain.SecurityUUID; -import com.edgechain.lib.endpoint.impl.OpenAiEndpoint; +import com.edgechain.lib.endpoint.impl.llm.OpenAiChatEndpoint; import com.edgechain.lib.openai.response.ChatCompletionResponse; import com.edgechain.lib.utils.JsonUtils; import io.reactivex.rxjava3.core.Observable; -import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -22,10 +21,7 @@ public class OpenAiStreamService { @Autowired private SecurityUUID securityUUID; - public Observable chatCompletion(OpenAiEndpoint openAiEndpoint) { - - logger.info("Logging Chat Completion Stream...."); - logger.info("Prompt: " + StringUtils.join(openAiEndpoint.getChatMessages())); + public Observable chatCompletion(OpenAiChatEndpoint endpoint) { return RxJava3Adapter.fluxToObservable( WebClient.builder() @@ -43,7 +39,7 @@ public Observable chatCompletion(OpenAiEndpoint openAiEn httpHeaders.set("stream", "true"); httpHeaders.set("Authorization", securityUUID.getAuthKey()); }) - .bodyValue(JsonUtils.convertToString(openAiEndpoint)) + .bodyValue(JsonUtils.convertToString(endpoint)) .retrieve() .bodyToFlux(ChatCompletionResponse.class)); } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/client/RetrofitClientInstance.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/client/RetrofitClientInstance.java index f2b7c6b4b..b0fa2921d 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/client/RetrofitClientInstance.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/client/RetrofitClientInstance.java @@ -13,6 +13,12 @@ import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.TimeUnit; +import okhttp3.ConnectionPool; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; @@ -21,23 +27,25 @@ import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory; import retrofit2.converter.jackson.JacksonConverterFactory; -import java.lang.reflect.Type; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.TimeUnit; - public class RetrofitClientInstance { - private static final String BASE_URL = "http://0.0.0.0"; + private RetrofitClientInstance() { + // no + } - private static SecurityUUID securityUUID = - ApplicationContextHolder.getContext().getBean(SecurityUUID.class); + private static final String BASE_URL = "http://0.0.0.0"; + private static SecurityUUID securityUUID; private static Retrofit retrofit; public static Retrofit getInstance() { if (retrofit == null) { + // tests may set this to a mock - do not overwrite it if present. + if (securityUUID == null) { + securityUUID = ApplicationContextHolder.getContext().getBean(SecurityUUID.class); + } + return retrofit = new Retrofit.Builder() .baseUrl( @@ -46,43 +54,49 @@ public static Retrofit getInstance() { + System.getProperty("server.port") + WebConfiguration.CONTEXT_PATH + "/") - .addConverterFactory(JacksonBuilder()) + .addConverterFactory(createJacksonFactory()) .addCallAdapterFactory(RxJava3CallAdapterFactory.create()) .client( new OkHttpClient.Builder() + .connectionPool(new ConnectionPool(10, 5, TimeUnit.MINUTES)) .addInterceptor( chain -> { - Request original = chain.request(); - Request request = - original - .newBuilder() - .header("Authorization", securityUUID.getAuthKey()) - .build(); - Response response = chain.proceed(request); - String body = response.body().string(); + try { + Request original = chain.request(); + final String authKey = securityUUID.getAuthKey(); + Request request = + original.newBuilder().header("Authorization", authKey).build(); + Response response = chain.proceed(request); + String body = response.body().string(); - String errorMessage = ""; + String errorMessage = ""; - if (!response.isSuccessful()) { - // Create a new Gson object - Gson gson = new Gson(); + if (!response.isSuccessful()) { + // Create a new Gson object + Gson gson = new Gson(); - // Define the type for the map - Type type = new TypeToken>() {}.getType(); + // Define the type for the map + Type type = new TypeToken>() {}.getType(); - // Convert JSON string into a map - Map map = gson.fromJson(body, type); + // Convert JSON string into a map + Map map = gson.fromJson(body, type); - if (Objects.nonNull(map)) { - errorMessage = map.toString(); + if (Objects.nonNull(map)) { + errorMessage = map.toString(); + } } - } - return response - .newBuilder() - .body(ResponseBody.create(body, response.body().contentType())) - .message(errorMessage) - .build(); + return response + .newBuilder() + .body(ResponseBody.create(body, response.body().contentType())) + .message(errorMessage) + .build(); + } catch (Exception e) { + // Interceptor can handle only IOException. Anything else = stall. + // Solution: wrap any exception in an IOException. + // Read more here: https://github.com/square/retrofit/issues/3453 + throw new IOException(e); + } }) .connectTimeout(15, TimeUnit.MINUTES) .readTimeout(20, TimeUnit.MINUTES) @@ -92,7 +106,7 @@ public static Retrofit getInstance() { return retrofit; } - private static JacksonConverterFactory JacksonBuilder() { + private static JacksonConverterFactory createJacksonFactory() { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); objectMapper.registerModule(new JavaTimeModule()); @@ -100,7 +114,6 @@ private static JacksonConverterFactory JacksonBuilder() { objectMapper.registerModule(new Jdk8Module()); objectMapper.registerModule(new PageJacksonModule()); objectMapper.registerModule(new SortJacksonModule()); - objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); return JacksonConverterFactory.create(objectMapper); } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/logger/JsonnetLoggerService.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/logger/JsonnetLoggerService.java new file mode 100644 index 000000000..85bf99e7f --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/retrofit/logger/JsonnetLoggerService.java @@ -0,0 +1,24 @@ +package com.edgechain.lib.retrofit.logger; + +import com.edgechain.lib.logger.entities.JsonnetLog; +import io.reactivex.rxjava3.core.Single; +import java.util.HashMap; +import org.springframework.data.domain.Page; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.POST; +import retrofit2.http.Path; + +public interface JsonnetLoggerService { + + @GET(value = "logs/jsonnet/findAll/{page}/{size}") + Single> findAll(@Path("page") int page, @Path("size") int size); + + @GET(value = "logs/jsonnet/findAll/sorted/{page}/{size}") + Single> findAllOrderByCreatedAtDesc( + @Path("page") int page, @Path("size") int size); + + @POST(value = "logs/jsonnet/findByName/sorted/{page}/{size}") + Single> findAllBySelectedFileOrderByCreatedAtDesc( + @Body HashMap mapper, @Path("page") int page, @Path("size") int size); +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/rxjava/transformer/observable/AbstractEdgeChain.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/rxjava/transformer/observable/AbstractEdgeChain.java index 2546488aa..f4e3cdb99 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/rxjava/transformer/observable/AbstractEdgeChain.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/rxjava/transformer/observable/AbstractEdgeChain.java @@ -2,10 +2,19 @@ import com.edgechain.lib.rxjava.retry.RetryPolicy; import io.reactivex.rxjava3.annotations.NonNull; -import io.reactivex.rxjava3.core.*; +import io.reactivex.rxjava3.core.Completable; +import io.reactivex.rxjava3.core.Notification; +import io.reactivex.rxjava3.core.Observable; +import io.reactivex.rxjava3.core.ObservableSource; +import io.reactivex.rxjava3.core.Scheduler; +import io.reactivex.rxjava3.core.Single; import io.reactivex.rxjava3.disposables.Disposable; -import io.reactivex.rxjava3.functions.*; - +import io.reactivex.rxjava3.functions.Action; +import io.reactivex.rxjava3.functions.BiFunction; +import io.reactivex.rxjava3.functions.BooleanSupplier; +import io.reactivex.rxjava3.functions.Consumer; +import io.reactivex.rxjava3.functions.Function; +import io.reactivex.rxjava3.functions.Predicate; import java.io.Serializable; public abstract class AbstractEdgeChain implements Serializable { @@ -14,7 +23,7 @@ public abstract class AbstractEdgeChain implements Serializable { protected Observable observable; - public AbstractEdgeChain(Observable observable) { + protected AbstractEdgeChain(Observable observable) { this.observable = observable; } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/rxjava/transformer/observable/EdgeChain.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/rxjava/transformer/observable/EdgeChain.java index a030780d5..7e3f42cb6 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/rxjava/transformer/observable/EdgeChain.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/rxjava/transformer/observable/EdgeChain.java @@ -178,6 +178,13 @@ public Single toSingle() { else return this.observable.subscribeOn(Schedulers.io()).firstOrError(); } + public Single toSingleWithoutScheduler() { + + if (RetryUtils.available(endpoint)) + return this.observable.retryWhen(endpoint.getRetryPolicy()).firstOrError(); + else return this.observable.firstOrError(); + } + @Override public T get() { if (RetryUtils.available(endpoint)) @@ -220,10 +227,10 @@ public void completed(Action onComplete, Consumer onError) { } public ArkResponse getArkResponse() { - return new ArkObservable<>(this.observable.subscribeOn(Schedulers.io())); + return new ArkObservable<>(this.observable); } public ArkResponse getArkStreamResponse() { - return new ArkEmitter<>(this.observable.subscribeOn(Schedulers.io())); + return new ArkEmitter<>(this.observable); } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/supabase/security/JwtFilter.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/supabase/security/JwtFilter.java index 9fe5614ca..480b62fc9 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/supabase/security/JwtFilter.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/supabase/security/JwtFilter.java @@ -13,7 +13,6 @@ import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.Objects; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; @@ -60,6 +59,9 @@ protected void doFilterInternal( try { claimsJws = jwtHelper.parseToken(token); } catch (final Exception e) { + // use Spring Security logger here instead of SLF4J + logger.info("JWT not accepted: %s".formatted(e.getMessage())); + ErrorResponse errorResponse = new ErrorResponse(e.getMessage()); response.setContentType(MediaType.APPLICATION_JSON_VALUE); response.getWriter().print(JsonUtils.convertToString(errorResponse)); @@ -70,6 +72,9 @@ protected void doFilterInternal( String email = (String) claimsJws.getBody().get("email"); String role = (String) claimsJws.getBody().get("role"); + // use Spring Security logger here instead of SLF4J + logger.info("JWT email=%s role=%s".formatted(email, role)); + User user = new User(); user.setEmail(email); user.setAccessToken(token); diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/supabase/security/JwtHelper.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/supabase/security/JwtHelper.java index a97d6112b..2ff8fcf58 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/supabase/security/JwtHelper.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/supabase/security/JwtHelper.java @@ -2,6 +2,7 @@ import io.jsonwebtoken.*; import java.security.Key; +import java.util.Objects; import javax.crypto.spec.SecretKeySpec; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; @@ -14,10 +15,10 @@ public class JwtHelper { public Jws parseToken(String accessToken) { try { - Key hmacKey = - new SecretKeySpec( - env.getProperty("jwt.secret").getBytes(), SignatureAlgorithm.HS256.getJcaName()); - + final String secret = env.getProperty("jwt.secret"); + Objects.requireNonNull(secret, "JWT secret not set"); + final byte[] bytes = secret.getBytes(); + final Key hmacKey = new SecretKeySpec(bytes, SignatureAlgorithm.HS256.getJcaName()); return Jwts.parser().setSigningKey(hmacKey).parseClaimsJws(accessToken); } catch (MalformedJwtException e) { @@ -33,27 +34,12 @@ public Jws parseToken(String accessToken) { } } - // validate public boolean validate(String accessToken) { try { - Key hmacKey = - new SecretKeySpec( - env.getProperty("jwt.secret").getBytes(), SignatureAlgorithm.HS256.getJcaName()); - - // String encoded = - // Base64.getEncoder().encodeToString(this.supabaseEnv.getJwtSecret().getBytes()); - Jwts.parser().setSigningKey(hmacKey).parseClaimsJws(accessToken); + parseToken(accessToken); return true; - } catch (MalformedJwtException e) { - throw new JwtException("Token Malformed"); - } catch (UnsupportedJwtException e) { - throw new JwtException("Token Unsupported"); - } catch (ExpiredJwtException e) { - throw new JwtException("Token Expired"); - } catch (IllegalArgumentException e) { - throw new JwtException("Token Empty"); - } catch (SignatureException e) { - throw new JwtException("Token Signature Failed"); + } catch (JwtException e) { + return false; } } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/supabase/security/WebSecurity.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/supabase/security/WebSecurity.java index cd35fabc8..bc6494253 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/supabase/security/WebSecurity.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/supabase/security/WebSecurity.java @@ -2,6 +2,9 @@ import com.edgechain.lib.configuration.WebConfiguration; import com.edgechain.lib.configuration.domain.AuthFilter; +import java.util.Arrays; +import java.util.Objects; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; @@ -15,6 +18,7 @@ import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; @@ -25,9 +29,6 @@ import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import org.springframework.web.filter.CorsFilter; -import java.util.Arrays; -import java.util.Objects; - @EnableWebSecurity @EnableMethodSecurity @Configuration @@ -38,62 +39,94 @@ public class WebSecurity { @Autowired private JwtFilter jwtFilter; @Bean - public AuthenticationManager authenticationManager(AuthenticationConfiguration config) - throws Exception { + AuthenticationManager authenticationManager(AuthenticationConfiguration config) throws Exception { return config.getAuthenticationManager(); } @Bean - public PasswordEncoder passwordEncoder() { + PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } @Bean - public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { - - return http.cors() - .configurationSource(corsConfiguration()) - .and() - .csrf() - .disable() - .authorizeHttpRequests( - (auth) -> { - try { - auth.requestMatchers("" + WebConfiguration.CONTEXT_PATH + "/**") - .permitAll() - .requestMatchers(HttpMethod.POST, authFilter.getRequestPost().getRequests()) - .hasAnyAuthority(authFilter.getRequestPost().getAuthorities()) - // - .requestMatchers(HttpMethod.GET, authFilter.getRequestGet().getRequests()) - .hasAnyAuthority(authFilter.getRequestGet().getAuthorities()) - .requestMatchers(HttpMethod.DELETE, authFilter.getRequestDelete().getRequests()) - .hasAnyAuthority(authFilter.getRequestDelete().getAuthorities()) - .requestMatchers(HttpMethod.PUT, authFilter.getRequestPut().getRequests()) - .hasAnyAuthority(authFilter.getRequestPut().getAuthorities()) - .requestMatchers(HttpMethod.PATCH, authFilter.getRequestPatch().getRequests()) - .hasAnyAuthority(authFilter.getRequestPatch().getAuthorities()) - .anyRequest() - .permitAll(); - - } catch (Exception e) { - throw new RuntimeException(e); - } - }) + SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { + + http.cors(cors -> cors.configurationSource(corsConfiguration())) + .csrf(csrf -> csrf.disable()) + .authorizeHttpRequests(auth -> buildAuth(auth)) .httpBasic(Customizer.withDefaults()) .addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class) - .sessionManagement() - .sessionCreationPolicy(SessionCreationPolicy.STATELESS) - .and() - .exceptionHandling() - .and() + .sessionManagement( + management -> management.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) + .exceptionHandling(Customizer.withDefaults()) .securityContext(c -> c.requireExplicitSave(false)) - .formLogin() - .disable() - .build(); + .formLogin(login -> login.disable()); + return http.build(); + } + + private AuthorizeHttpRequestsConfigurer.AuthorizationManagerRequestMatcherRegistry + buildAuth( + AuthorizeHttpRequestsConfigurer.AuthorizationManagerRequestMatcherRegistry + auth) { + AuthorizeHttpRequestsConfigurer.AuthorizationManagerRequestMatcherRegistry reg = + auth.requestMatchers("" + WebConfiguration.CONTEXT_PATH + "/**").permitAll(); + + reg = + applyAuth( + reg.requestMatchers( + HttpMethod.POST, safeRequests(authFilter.getRequestPost().getRequests(), "POST")), + authFilter.getRequestPost().getAuthorities()); + reg = + applyAuth( + reg.requestMatchers( + HttpMethod.GET, safeRequests(authFilter.getRequestGet().getRequests(), "GET")), + authFilter.getRequestGet().getAuthorities()); + reg = + applyAuth( + reg.requestMatchers( + HttpMethod.DELETE, + safeRequests(authFilter.getRequestDelete().getRequests(), "DELETE")), + authFilter.getRequestDelete().getAuthorities()); + reg = + applyAuth( + reg.requestMatchers( + HttpMethod.PUT, safeRequests(authFilter.getRequestPut().getRequests(), "PUT")), + authFilter.getRequestPut().getAuthorities()); + reg = + applyAuth( + reg.requestMatchers( + HttpMethod.PATCH, + safeRequests(authFilter.getRequestPatch().getRequests(), "PATCH")), + authFilter.getRequestPatch().getAuthorities()); + + reg = reg.anyRequest().permitAll(); + return reg; + } + + private String[] safeRequests(String[] src, String method) { + if (src == null || src.length == 0 || (src.length == 1 && src[0].isEmpty())) { + LoggerFactory.getLogger(getClass()) + .warn( + "Http {} security request patterns outdated. Fixed to a list with one String \"**\" -" + + " please update your configuration", + method); + return new String[] {"**"}; + } else { + return src; + } + } + + private AuthorizeHttpRequestsConfigurer.AuthorizationManagerRequestMatcherRegistry + applyAuth(AuthorizeHttpRequestsConfigurer.AuthorizedUrl url, String[] auths) { + if (auths == null || auths.length == 0 || (auths.length == 1 && auths[0].isEmpty())) { + return url.permitAll(); + } else { + return url.hasAnyAuthority(auths); + } } @Bean - public CorsConfigurationSource corsConfiguration() { + CorsConfigurationSource corsConfiguration() { CorsConfiguration configuration = new CorsConfiguration(); @@ -126,7 +159,7 @@ public CorsConfigurationSource corsConfiguration() { } @Bean - public FilterRegistrationBean corsFilter() { + FilterRegistrationBean corsFilter() { FilterRegistrationBean bean = new FilterRegistrationBean<>(new CorsFilter(corsConfiguration())); bean.setOrder(Ordered.HIGHEST_PRECEDENCE); @@ -134,7 +167,7 @@ public FilterRegistrationBean corsFilter() { } @Bean - public FilterRegistrationBean jwtFilterFilterRegistrationBean(JwtFilter jwtFilter) { + FilterRegistrationBean jwtFilterFilterRegistrationBean(JwtFilter jwtFilter) { FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(jwtFilter); registrationBean.setEnabled(false); return registrationBean; diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/utils/ContextReorder.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/utils/ContextReorder.java new file mode 100644 index 000000000..a3fb83282 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/utils/ContextReorder.java @@ -0,0 +1,50 @@ +package com.edgechain.lib.utils; + +import com.edgechain.lib.embeddings.WordEmbeddings; +import com.edgechain.lib.index.domain.PostgresWordEmbeddings; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +@Component +public class ContextReorder { + + public List reorderWordEmbeddings(List wordEmbeddingsList) { + + wordEmbeddingsList.sort(Comparator.comparingDouble(WordEmbeddings::getScore).reversed()); + + int mid = wordEmbeddingsList.size() / 2; + + List modifiedList = new ArrayList<>(wordEmbeddingsList.subList(0, mid)); + + List secondHalfList = + wordEmbeddingsList.subList(mid, wordEmbeddingsList.size()); + secondHalfList.sort(Comparator.comparingDouble(WordEmbeddings::getScore)); + + modifiedList.addAll(secondHalfList); + + return modifiedList; + } + + public List reorderPostgresWordEmbeddings( + List postgresWordEmbeddings) { + + postgresWordEmbeddings.sort( + Comparator.comparingDouble(PostgresWordEmbeddings::getScore).reversed()); + + int mid = postgresWordEmbeddings.size() / 2; + + List modifiedList = + new ArrayList<>(postgresWordEmbeddings.subList(0, mid)); + + List secondHalfList = + postgresWordEmbeddings.subList(mid, postgresWordEmbeddings.size()); + secondHalfList.sort(Comparator.comparingDouble(PostgresWordEmbeddings::getScore)); + + modifiedList.addAll(secondHalfList); + + return modifiedList; + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/wiki/client/WikiClient.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/wiki/client/WikiClient.java index bd647cd72..677b543c4 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/wiki/client/WikiClient.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/lib/wiki/client/WikiClient.java @@ -1,6 +1,6 @@ package com.edgechain.lib.wiki.client; -import com.edgechain.lib.endpoint.impl.WikiEndpoint; +import com.edgechain.lib.endpoint.impl.wiki.WikiEndpoint; import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; import com.edgechain.lib.wiki.response.WikiResponse; import com.fasterxml.jackson.databind.JsonNode; diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/bgeSmall/BgeSmallController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/bgeSmall/BgeSmallController.java index 41210f1cc..57e23b21a 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/bgeSmall/BgeSmallController.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/bgeSmall/BgeSmallController.java @@ -3,7 +3,7 @@ import com.edgechain.lib.configuration.WebConfiguration; import com.edgechain.lib.embeddings.bgeSmall.BgeSmallClient; import com.edgechain.lib.embeddings.bgeSmall.response.BgeSmallResponse; -import com.edgechain.lib.endpoint.impl.BgeSmallEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.BgeSmallEndpoint; import com.edgechain.lib.logger.entities.EmbeddingLog; import com.edgechain.lib.logger.services.EmbeddingLogService; import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; @@ -32,10 +32,8 @@ public class BgeSmallController { @PostMapping public Single embeddings(@RequestBody BgeSmallEndpoint bgeSmallEndpoint) { - this.bgeSmallClient.setEndpoint(bgeSmallEndpoint); - EdgeChain edgeChain = - this.bgeSmallClient.createEmbeddings(bgeSmallEndpoint.getInput()); + this.bgeSmallClient.createEmbeddings(bgeSmallEndpoint.getRawText(), bgeSmallEndpoint); if (Objects.nonNull(env.getProperty("postgres.db.host"))) { @@ -53,9 +51,9 @@ public Single embeddings(@RequestBody BgeSmallEndpoint bgeSmal embeddingLog.setLatency(duration.toMillis()); embeddingLogService.saveOrUpdate(embeddingLog); }) - .toSingle(); + .toSingleWithoutScheduler(); } - return edgeChain.toSingle(); + return edgeChain.toSingleWithoutScheduler(); } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/context/PostgreSQLHistoryContextController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/context/PostgreSQLHistoryContextController.java index cf5d8d16b..fce8831c0 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/context/PostgreSQLHistoryContextController.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/context/PostgreSQLHistoryContextController.java @@ -4,7 +4,7 @@ import com.edgechain.lib.context.client.impl.PostgreSQLHistoryContextClient; import com.edgechain.lib.context.domain.ContextPutRequest; import com.edgechain.lib.context.domain.HistoryContext; -import com.edgechain.lib.endpoint.impl.PostgreSQLHistoryContextEndpoint; +import com.edgechain.lib.endpoint.impl.context.PostgreSQLHistoryContextEndpoint; import io.reactivex.rxjava3.core.Completable; import io.reactivex.rxjava3.core.Single; import org.springframework.beans.factory.annotation.Autowired; diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/context/RedisHistoryContextController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/context/RedisHistoryContextController.java index ce97d689a..1a4c4a402 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/context/RedisHistoryContextController.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/context/RedisHistoryContextController.java @@ -4,7 +4,7 @@ import com.edgechain.lib.context.client.impl.RedisHistoryContextClient; import com.edgechain.lib.context.domain.ContextPutRequest; import com.edgechain.lib.context.domain.HistoryContext; -import com.edgechain.lib.endpoint.impl.RedisHistoryContextEndpoint; +import com.edgechain.lib.endpoint.impl.context.RedisHistoryContextEndpoint; import io.reactivex.rxjava3.core.Completable; import io.reactivex.rxjava3.core.Single; import org.springframework.beans.factory.annotation.Autowired; diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/index/PineconeController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/index/PineconeController.java index 8a7a8a527..98d3cd9f3 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/index/PineconeController.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/index/PineconeController.java @@ -2,10 +2,9 @@ import com.edgechain.lib.configuration.WebConfiguration; import com.edgechain.lib.embeddings.WordEmbeddings; -import com.edgechain.lib.endpoint.impl.PineconeEndpoint; +import com.edgechain.lib.endpoint.impl.index.PineconeEndpoint; import com.edgechain.lib.index.client.impl.PineconeClient; import com.edgechain.lib.response.StringResponse; -import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; import io.reactivex.rxjava3.core.Single; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -20,32 +19,21 @@ public class PineconeController { @PostMapping("/upsert") public Single upsert(@RequestBody PineconeEndpoint pineconeEndpoint) { + return pineconeClient.upsert(pineconeEndpoint).toSingle(); + } - pineconeClient.setEndpoint(pineconeEndpoint); - - EdgeChain edgeChain = - pineconeClient.upsert(pineconeEndpoint.getWordEmbeddings()); - - return edgeChain.toSingle(); + @PostMapping("/batch-upsert") + public Single batchUpsert(@RequestBody PineconeEndpoint pineconeEndpoint) { + return pineconeClient.batchUpsert(pineconeEndpoint).toSingleWithoutScheduler(); } @PostMapping("/query") public Single> query(@RequestBody PineconeEndpoint pineconeEndpoint) { - - pineconeClient.setEndpoint(pineconeEndpoint); - - EdgeChain> edgeChain = - pineconeClient.query(pineconeEndpoint.getWordEmbeddings(), pineconeEndpoint.getTopK()); - - return edgeChain.toSingle(); + return pineconeClient.query(pineconeEndpoint).toSingle(); } @DeleteMapping("/deleteAll") public Single deleteAll(@RequestBody PineconeEndpoint pineconeEndpoint) { - - pineconeClient.setEndpoint(pineconeEndpoint); - - EdgeChain edgeChain = pineconeClient.deleteAll(); - return edgeChain.toSingle(); + return pineconeClient.deleteAll(pineconeEndpoint).toSingle(); } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/index/PostgresController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/index/PostgresController.java index 58491b687..a83f48db3 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/index/PostgresController.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/index/PostgresController.java @@ -1,7 +1,7 @@ package com.edgechain.service.controllers.index; import com.edgechain.lib.configuration.WebConfiguration; -import com.edgechain.lib.endpoint.impl.PostgresEndpoint; +import com.edgechain.lib.endpoint.impl.index.PostgresEndpoint; import com.edgechain.lib.index.client.impl.PostgresClient; import com.edgechain.lib.index.domain.PostgresWordEmbeddings; import com.edgechain.lib.response.StringResponse; @@ -20,38 +20,85 @@ public class PostgresController { @Autowired @Lazy private PostgresClient postgresClient; + @PostMapping("/create-table") + public Single createTable(@RequestBody PostgresEndpoint postgresEndpoint) { + return this.postgresClient.createTable(postgresEndpoint).toSingle(); + } + + @PostMapping("/metadata/create-table") + public Single createMetadataTable( + @RequestBody PostgresEndpoint postgresEndpoint) { + return this.postgresClient.createMetadataTable(postgresEndpoint).toSingle(); + } + @PostMapping("/upsert") public Single upsert(@RequestBody PostgresEndpoint postgresEndpoint) { + return this.postgresClient.upsert(postgresEndpoint).toSingle(); + } - this.postgresClient.setPostgresEndpoint(postgresEndpoint); - EdgeChain edgeChain = - this.postgresClient.upsert(postgresEndpoint.getWordEmbeddings()); + @PostMapping("/batch-upsert") + public Single> batchUpsert(@RequestBody PostgresEndpoint postgresEndpoint) { + return this.postgresClient.batchUpsert(postgresEndpoint).toSingleWithoutScheduler(); + } + + @PostMapping("/metadata/insert") + public Single insertMetadata(@RequestBody PostgresEndpoint postgresEndpoint) { + return this.postgresClient.insertMetadata(postgresEndpoint).toSingle(); + } + + @PostMapping("/metadata/batch-insert") + public Single> batchInsertMetadata( + @RequestBody PostgresEndpoint postgresEndpoint) { + return this.postgresClient.batchInsertMetadata(postgresEndpoint).toSingle(); + } + + @PostMapping("/join/insert") + public Single insertIntoJoinTable( + @RequestBody PostgresEndpoint postgresEndpoint) { + EdgeChain edgeChain = this.postgresClient.insertIntoJoinTable(postgresEndpoint); + 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) { + return this.postgresClient.query(postgresEndpoint).toSingle(); + } + + @PostMapping("/query-rrf") + public Single> queryRRF( + @RequestBody PostgresEndpoint postgresEndpoint) { + return this.postgresClient.queryRRF(postgresEndpoint).toSingle(); + } - this.postgresClient.setPostgresEndpoint(postgresEndpoint); + @PostMapping("/metadata/query") + public Single> queryWithMetadata( + @RequestBody PostgresEndpoint postgresEndpoint) { + return this.postgresClient.queryWithMetadata(postgresEndpoint).toSingle(); + } - EdgeChain> edgeChain = - this.postgresClient.query( - postgresEndpoint.getWordEmbeddings(), - postgresEndpoint.getMetric(), - postgresEndpoint.getTopK(), - postgresEndpoint.getProbes()); + @PostMapping("/chunks") + public Single> getAllChunks( + @RequestBody PostgresEndpoint postgresEndpoint) { + return this.postgresClient.getAllChunks(postgresEndpoint).toSingle(); + } - return edgeChain.toSingle(); + @PostMapping("/similarity-metadata") + public Single> getSimilarMetadataChunk( + @RequestBody PostgresEndpoint postgresEndpoint) { + return this.postgresClient.getSimilarMetadataChunk(postgresEndpoint).toSingle(); } @DeleteMapping("/deleteAll") public Single deleteAll(@RequestBody PostgresEndpoint postgresEndpoint) { - - this.postgresClient.setPostgresEndpoint(postgresEndpoint); - - EdgeChain edgeChain = this.postgresClient.deleteAll(); - return edgeChain.toSingle(); + return this.postgresClient.deleteAll(postgresEndpoint).toSingle(); } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/index/RedisController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/index/RedisController.java index 6fcd2e566..1d4916f38 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/index/RedisController.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/index/RedisController.java @@ -2,10 +2,9 @@ import com.edgechain.lib.configuration.WebConfiguration; import com.edgechain.lib.embeddings.WordEmbeddings; -import com.edgechain.lib.endpoint.impl.RedisEndpoint; +import com.edgechain.lib.endpoint.impl.index.RedisEndpoint; import com.edgechain.lib.index.client.impl.RedisClient; import com.edgechain.lib.response.StringResponse; -import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; import io.reactivex.rxjava3.core.Completable; import io.reactivex.rxjava3.core.Single; import org.springframework.beans.factory.annotation.Autowired; @@ -20,38 +19,28 @@ public class RedisController { @Autowired @Lazy private RedisClient redisClient; + @PostMapping("/create-index") + public Single createIndex(@RequestBody RedisEndpoint redisEndpoint) { + return this.redisClient.createIndex(redisEndpoint).toSingle(); + } + @PostMapping("/upsert") public Single upsert(@RequestBody RedisEndpoint redisEndpoint) { + return this.redisClient.upsert(redisEndpoint).toSingle(); + } - this.redisClient.setEndpoint(redisEndpoint); - - EdgeChain edgeChain = - this.redisClient.upsert( - redisEndpoint.getWordEmbeddings(), - redisEndpoint.getDimensions(), - redisEndpoint.getMetric()); - - return edgeChain.toSingle(); + @PostMapping("/batch-upsert") + public Single batchUpsert(@RequestBody RedisEndpoint redisEndpoint) { + return this.redisClient.batchUpsert(redisEndpoint).toSingleWithoutScheduler(); } @PostMapping("/query") public Single> query(@RequestBody RedisEndpoint redisEndpoint) { - - this.redisClient.setEndpoint(redisEndpoint); - - EdgeChain> edgeChain = - this.redisClient.query(redisEndpoint.getWordEmbeddings(), redisEndpoint.getTopK()); - - return edgeChain.toSingle(); + return this.redisClient.query(redisEndpoint).toSingle(); } @DeleteMapping("/delete") - public Completable deleteByPattern( - @RequestParam("pattern") String pattern, @RequestBody RedisEndpoint redisEndpoint) { - - this.redisClient.setEndpoint(redisEndpoint); - - EdgeChain edgeChain = this.redisClient.deleteByPattern(pattern); - return edgeChain.await(); + public Completable deleteByPattern(@RequestBody RedisEndpoint redisEndpoint) { + return this.redisClient.deleteByPattern(redisEndpoint).await(); } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/integration/AirtableController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/integration/AirtableController.java new file mode 100644 index 000000000..741fe2362 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/integration/AirtableController.java @@ -0,0 +1,44 @@ +package com.edgechain.service.controllers.integration; + +import com.edgechain.lib.configuration.WebConfiguration; +import com.edgechain.lib.endpoint.impl.integration.AirtableEndpoint; +import com.edgechain.lib.integration.airtable.client.AirtableClient; +import dev.fuxing.airtable.AirtableRecord; +import io.reactivex.rxjava3.core.Single; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +@RestController("Service AirtableController") +@RequestMapping(value = WebConfiguration.CONTEXT_PATH + "/airtable") +public class AirtableController { + + @Autowired private AirtableClient airtableClient; + + @PostMapping("/findAll") + public Single> findAll(@RequestBody AirtableEndpoint endpoint) { + return airtableClient.findAll(endpoint).toSingleWithoutScheduler(); + } + + @PostMapping("/findById") + public Single findById(@RequestBody AirtableEndpoint endpoint) { + return airtableClient.findById(endpoint).toSingleWithoutScheduler(); + } + + @PostMapping("/create") + public Single> create(@RequestBody AirtableEndpoint endpoint) { + return airtableClient.create(endpoint).toSingleWithoutScheduler(); + } + + @PostMapping("/update") + public Single> update(@RequestBody AirtableEndpoint endpoint) { + return airtableClient.update(endpoint).toSingleWithoutScheduler(); + } + + @DeleteMapping("/delete") + public Single> delete(@RequestBody AirtableEndpoint endpoint) { + return airtableClient.delete(endpoint).toSingleWithoutScheduler(); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/llama2/Llama2Controller.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/llama2/Llama2Controller.java new file mode 100644 index 000000000..d998c28bf --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/llama2/Llama2Controller.java @@ -0,0 +1,30 @@ +package com.edgechain.service.controllers.llama2; + +import com.edgechain.lib.configuration.WebConfiguration; +import com.edgechain.lib.endpoint.impl.llm.LLamaQuickstart; +import com.edgechain.lib.llama2.Llama2Client; +import com.edgechain.lib.logger.services.ChatCompletionLogService; +import com.edgechain.lib.logger.services.JsonnetLogService; +import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; +import io.reactivex.rxjava3.core.Single; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.web.bind.annotation.*; + +@RestController("Service Llama2Controller") +@RequestMapping(value = WebConfiguration.CONTEXT_PATH + "/llama") +public class Llama2Controller { + @Autowired private ChatCompletionLogService chatCompletionLogService; + + @Autowired private JsonnetLogService jsonnetLogService; + + @Autowired private Environment env; + @Autowired private Llama2Client llama2Client; + + @PostMapping(value = "/chat-completion") + public Single getChatCompletion(@RequestBody LLamaQuickstart endpoint) { + + EdgeChain edgeChain = llama2Client.createGetChatCompletion(endpoint); + return edgeChain.toSingle(); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/logging/EmbeddingLogController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/logging/EmbeddingLogController.java index d01d214b5..3cad9c5b0 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/logging/EmbeddingLogController.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/logging/EmbeddingLogController.java @@ -3,13 +3,16 @@ import com.edgechain.lib.configuration.WebConfiguration; import com.edgechain.lib.logger.entities.EmbeddingLog; import com.edgechain.lib.logger.services.EmbeddingLogService; -import com.edgechain.lib.logger.services.EmbeddingLogService; +import java.util.HashMap; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; -import org.springframework.web.bind.annotation.*; - -import java.util.HashMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; @RestController("Service EmbeddingLogController") @RequestMapping(value = WebConfiguration.CONTEXT_PATH + "/logs/embeddings") diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/logging/JsonnetLogController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/logging/JsonnetLogController.java new file mode 100644 index 000000000..80da69078 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/logging/JsonnetLogController.java @@ -0,0 +1,36 @@ +package com.edgechain.service.controllers.logging; + +import com.edgechain.lib.configuration.WebConfiguration; +import com.edgechain.lib.logger.entities.JsonnetLog; +import java.util.HashMap; + +import com.edgechain.lib.logger.services.JsonnetLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.web.bind.annotation.*; + +@RestController("Service JsonnetLogControllers") +@RequestMapping(value = WebConfiguration.CONTEXT_PATH + "/logs/jsonnet") +public class JsonnetLogController { + + @Autowired private JsonnetLogService jsonnetLogService; + + @GetMapping("/findAll/{page}/{size}") + public Page findAll(@PathVariable int page, @PathVariable int size) { + return this.jsonnetLogService.findAll(PageRequest.of(page, size)); + } + + @GetMapping("/findAll/sorted/{page}/{size}") + public Page findAllByOrderByCreatedAtDesc( + @PathVariable int page, @PathVariable int size) { + return this.jsonnetLogService.findAllOrderByCreatedAtDesc(PageRequest.of(page, size)); + } + + @PostMapping("/findByName/sorted/{page}/{size}") + public Page findAllBySelectedFileOrderByCreatedAtDesc( + @RequestBody HashMap mapper, @PathVariable int page, @PathVariable int size) { + return this.jsonnetLogService.findAllBySelectedFileOrderByCreatedAtDesc( + mapper.get("filename"), PageRequest.of(page, size)); + } +} diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/miniLM/MiniLMController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/miniLM/MiniLMController.java index 56824fc07..9ab3ea75e 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/miniLM/MiniLMController.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/miniLM/MiniLMController.java @@ -3,7 +3,7 @@ import com.edgechain.lib.configuration.WebConfiguration; import com.edgechain.lib.embeddings.miniLLM.MiniLMClient; import com.edgechain.lib.embeddings.miniLLM.response.MiniLMResponse; -import com.edgechain.lib.endpoint.impl.MiniLMEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.MiniLMEndpoint; import com.edgechain.lib.logger.entities.EmbeddingLog; import com.edgechain.lib.logger.services.EmbeddingLogService; import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; @@ -32,10 +32,8 @@ public class MiniLMController { @PostMapping public Single embeddings(@RequestBody MiniLMEndpoint miniLMEndpoint) { - this.miniLMClient.setEndpoint(miniLMEndpoint); - EdgeChain edgeChain = - this.miniLMClient.createEmbeddings(miniLMEndpoint.getInput()); + this.miniLMClient.createEmbeddings(miniLMEndpoint.getRawText(), miniLMEndpoint); if (Objects.nonNull(env.getProperty("postgres.db.host"))) { @@ -53,9 +51,9 @@ public Single embeddings(@RequestBody MiniLMEndpoint miniLMEndpo embeddingLog.setLatency(duration.toMillis()); embeddingLogService.saveOrUpdate(embeddingLog); }) - .toSingle(); + .toSingleWithoutScheduler(); } - return edgeChain.toSingle(); + return edgeChain.toSingleWithoutScheduler(); } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/openai/OpenAiController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/openai/OpenAiController.java index addb60116..6d3c6f8a1 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/openai/OpenAiController.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/openai/OpenAiController.java @@ -3,11 +3,14 @@ import com.edgechain.lib.configuration.WebConfiguration; import com.edgechain.lib.embeddings.request.OpenAiEmbeddingRequest; import com.edgechain.lib.embeddings.response.OpenAiEmbeddingResponse; -import com.edgechain.lib.endpoint.impl.OpenAiEndpoint; +import com.edgechain.lib.endpoint.impl.embeddings.OpenAiEmbeddingEndpoint; +import com.edgechain.lib.endpoint.impl.llm.OpenAiChatEndpoint; import com.edgechain.lib.logger.entities.ChatCompletionLog; import com.edgechain.lib.logger.entities.EmbeddingLog; +import com.edgechain.lib.logger.entities.JsonnetLog; import com.edgechain.lib.logger.services.ChatCompletionLogService; import com.edgechain.lib.logger.services.EmbeddingLogService; +import com.edgechain.lib.logger.services.JsonnetLogService; import com.edgechain.lib.openai.client.OpenAiClient; import com.edgechain.lib.openai.request.ChatCompletionRequest; import com.edgechain.lib.openai.request.ChatMessage; @@ -32,8 +35,6 @@ import java.sql.SQLException; import java.time.Duration; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; import java.util.Objects; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -44,12 +45,14 @@ public class OpenAiController { @Autowired private ChatCompletionLogService chatCompletionLogService; @Autowired private EmbeddingLogService embeddingLogService; + @Autowired private JsonnetLogService jsonnetLogService; @Autowired private Environment env; @Autowired private OpenAiClient openAiClient; @PostMapping(value = "/chat-completion") - public Single chatCompletion(@RequestBody OpenAiEndpoint openAiEndpoint) { + public Single chatCompletion( + @RequestBody OpenAiChatEndpoint openAiEndpoint) { ChatCompletionRequest chatCompletionRequest = ChatCompletionRequest.builder() @@ -57,38 +60,61 @@ public Single chatCompletion(@RequestBody OpenAiEndpoint .temperature(openAiEndpoint.getTemperature()) .messages(openAiEndpoint.getChatMessages()) .stream(false) + .topP(openAiEndpoint.getTopP()) + .n(openAiEndpoint.getN()) + .stop(openAiEndpoint.getStop()) + .presencePenalty(openAiEndpoint.getPresencePenalty()) + .frequencyPenalty(openAiEndpoint.getFrequencyPenalty()) + .logitBias(openAiEndpoint.getLogitBias()) + .user(openAiEndpoint.getUser()) .build(); - this.openAiClient.setEndpoint(openAiEndpoint); - EdgeChain edgeChain = - openAiClient.createChatCompletion(chatCompletionRequest); + openAiClient.createChatCompletion(chatCompletionRequest, openAiEndpoint); if (Objects.nonNull(env.getProperty("postgres.db.host"))) { - ChatCompletionLog chatCompletionLog = new ChatCompletionLog(); - chatCompletionLog.setName(openAiEndpoint.getChainName()); - chatCompletionLog.setCreatedAt(LocalDateTime.now()); - chatCompletionLog.setCallIdentifier(openAiEndpoint.getCallIdentifier()); - chatCompletionLog.setInput(StringUtils.join(openAiEndpoint.getChatMessages())); - chatCompletionLog.setModel(openAiEndpoint.getModel()); + ChatCompletionLog chatLog = new ChatCompletionLog(); + chatLog.setName(openAiEndpoint.getChainName()); + chatLog.setCreatedAt(LocalDateTime.now()); + chatLog.setCallIdentifier(openAiEndpoint.getCallIdentifier()); + chatLog.setInput(StringUtils.join(chatCompletionRequest.getMessages())); + chatLog.setModel(chatCompletionRequest.getModel()); + + chatLog.setPresencePenalty(chatCompletionRequest.getPresencePenalty()); + chatLog.setFrequencyPenalty(chatCompletionRequest.getFrequencyPenalty()); + chatLog.setTopP(chatCompletionRequest.getTopP()); + chatLog.setN(chatCompletionRequest.getN()); + chatLog.setTemperature(chatCompletionRequest.getTemperature()); return edgeChain .doOnNext( c -> { - chatCompletionLog.setPromptTokens(c.getUsage().getPrompt_tokens()); - chatCompletionLog.setTotalTokens(c.getUsage().getTotal_tokens()); - chatCompletionLog.setContent(c.getChoices().get(0).getMessage().getContent()); - chatCompletionLog.setType(c.getObject()); + chatLog.setPromptTokens(c.getUsage().getPrompt_tokens()); + chatLog.setTotalTokens(c.getUsage().getTotal_tokens()); + chatLog.setContent(c.getChoices().get(0).getMessage().getContent()); + chatLog.setType(c.getObject()); - chatCompletionLog.setCompletedAt(LocalDateTime.now()); + chatLog.setCompletedAt(LocalDateTime.now()); Duration duration = - Duration.between( - chatCompletionLog.getCreatedAt(), chatCompletionLog.getCompletedAt()); - chatCompletionLog.setLatency(duration.toMillis()); - - chatCompletionLogService.saveOrUpdate(chatCompletionLog); + Duration.between(chatLog.getCreatedAt(), chatLog.getCompletedAt()); + chatLog.setLatency(duration.toMillis()); + + chatCompletionLogService.saveOrUpdate(chatLog); + + if (Objects.nonNull(openAiEndpoint.getJsonnetLoader()) + && openAiEndpoint.getJsonnetLoader().getThreshold() >= 1) { + JsonnetLog jsonnetLog = new JsonnetLog(); + jsonnetLog.setMetadata(openAiEndpoint.getJsonnetLoader().getMetadata()); + jsonnetLog.setContent(c.getChoices().get(0).getMessage().getContent()); + jsonnetLog.setF1(openAiEndpoint.getJsonnetLoader().getF1()); + jsonnetLog.setF2(openAiEndpoint.getJsonnetLoader().getF2()); + jsonnetLog.setSplitSize(openAiEndpoint.getJsonnetLoader().getSplitSize()); + jsonnetLog.setCreatedAt(LocalDateTime.now()); + jsonnetLog.setSelectedFile(openAiEndpoint.getJsonnetLoader().getSelectedFile()); + jsonnetLogService.saveOrUpdate(jsonnetLog); + } }) .toSingle(); @@ -98,7 +124,7 @@ public Single chatCompletion(@RequestBody OpenAiEndpoint @PostMapping( value = "/chat-completion-stream", consumes = {MediaType.APPLICATION_JSON_VALUE}) - public SseEmitter chatCompletionStream(@RequestBody OpenAiEndpoint openAiEndpoint) { + public SseEmitter chatCompletionStream(@RequestBody OpenAiChatEndpoint openAiEndpoint) { ChatCompletionRequest chatCompletionRequest = ChatCompletionRequest.builder() @@ -106,10 +132,14 @@ public SseEmitter chatCompletionStream(@RequestBody OpenAiEndpoint openAiEndpoin .temperature(openAiEndpoint.getTemperature()) .messages(openAiEndpoint.getChatMessages()) .stream(true) + .topP(openAiEndpoint.getTopP()) + .n(openAiEndpoint.getN()) + .stop(openAiEndpoint.getStop()) + .presencePenalty(openAiEndpoint.getPresencePenalty()) + .frequencyPenalty(openAiEndpoint.getFrequencyPenalty()) + .logitBias(openAiEndpoint.getLogitBias()) + .user(openAiEndpoint.getUser()) .build(); - - this.openAiClient.setEndpoint(openAiEndpoint); - SseEmitter emitter = new SseEmitter(); ExecutorService executorService = Executors.newSingleThreadExecutor(); @@ -117,18 +147,24 @@ public SseEmitter chatCompletionStream(@RequestBody OpenAiEndpoint openAiEndpoin () -> { try { EdgeChain edgeChain = - openAiClient.createChatCompletionStream(chatCompletionRequest); + openAiClient.createChatCompletionStream(chatCompletionRequest, openAiEndpoint); AtomInteger chunks = AtomInteger.of(0); if (Objects.nonNull(env.getProperty("postgres.db.host"))) { - ChatCompletionLog chatCompletionLog = new ChatCompletionLog(); - chatCompletionLog.setName(openAiEndpoint.getChainName()); - chatCompletionLog.setCallIdentifier(openAiEndpoint.getCallIdentifier()); - chatCompletionLog.setInput(StringUtils.join(openAiEndpoint.getChatMessages())); - chatCompletionLog.setModel(openAiEndpoint.getModel()); - chatCompletionLog.setCreatedAt(LocalDateTime.now()); + ChatCompletionLog chatLog = new ChatCompletionLog(); + chatLog.setName(openAiEndpoint.getChainName()); + chatLog.setCreatedAt(LocalDateTime.now()); + chatLog.setCallIdentifier(openAiEndpoint.getCallIdentifier()); + chatLog.setInput(StringUtils.join(chatCompletionRequest.getMessages())); + chatLog.setModel(chatCompletionRequest.getModel()); + + chatLog.setPresencePenalty(chatCompletionRequest.getPresencePenalty()); + chatLog.setFrequencyPenalty(chatCompletionRequest.getFrequencyPenalty()); + chatLog.setTopP(chatCompletionRequest.getTopP()); + chatLog.setN(chatCompletionRequest.getN()); + chatLog.setTemperature(chatCompletionRequest.getTemperature()); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("<|im_start|>"); @@ -139,12 +175,7 @@ public SseEmitter chatCompletionStream(@RequestBody OpenAiEndpoint openAiEndpoin EncodingRegistry registry = Encodings.newDefaultEncodingRegistry(); Encoding enc = registry.getEncoding(EncodingType.CL100K_BASE); - List strings = new ArrayList<>(); - for (ChatMessage chatMessage : openAiEndpoint.getChatMessages()) { - strings.add(chatMessage.getContent()); - } - - chatCompletionLog.setPromptTokens((long) enc.countTokens(stringBuilder.toString())); + chatLog.setPromptTokens((long) enc.countTokens(stringBuilder.toString())); StringBuilder content = new StringBuilder(); @@ -162,20 +193,30 @@ public SseEmitter chatCompletionStream(@RequestBody OpenAiEndpoint openAiEndpoin if (Objects.nonNull(res.getChoices().get(0).getFinishReason())) { emitter.complete(); - - chatCompletionLog.setType(res.getObject()); - chatCompletionLog.setContent(content.toString()); - chatCompletionLog.setCompletedAt(LocalDateTime.now()); - chatCompletionLog.setTotalTokens( - chunks.get() + chatCompletionLog.getPromptTokens()); + chatLog.setType(res.getObject()); + chatLog.setContent(content.toString()); + chatLog.setCompletedAt(LocalDateTime.now()); + chatLog.setTotalTokens(chunks.get() + chatLog.getPromptTokens()); Duration duration = - Duration.between( - chatCompletionLog.getCreatedAt(), - chatCompletionLog.getCompletedAt()); - chatCompletionLog.setLatency(duration.toMillis()); - - chatCompletionLogService.saveOrUpdate(chatCompletionLog); + Duration.between(chatLog.getCreatedAt(), chatLog.getCompletedAt()); + chatLog.setLatency(duration.toMillis()); + + chatCompletionLogService.saveOrUpdate(chatLog); + + if (Objects.nonNull(openAiEndpoint.getJsonnetLoader()) + && openAiEndpoint.getJsonnetLoader().getThreshold() >= 1) { + JsonnetLog jsonnetLog = new JsonnetLog(); + jsonnetLog.setMetadata(openAiEndpoint.getJsonnetLoader().getMetadata()); + jsonnetLog.setContent(content.toString()); + jsonnetLog.setF1(openAiEndpoint.getJsonnetLoader().getF1()); + jsonnetLog.setF2(openAiEndpoint.getJsonnetLoader().getF2()); + jsonnetLog.setSplitSize(openAiEndpoint.getJsonnetLoader().getSplitSize()); + jsonnetLog.setCreatedAt(LocalDateTime.now()); + jsonnetLog.setSelectedFile( + openAiEndpoint.getJsonnetLoader().getSelectedFile()); + jsonnetLogService.saveOrUpdate(jsonnetLog); + } } } catch (final Exception e) { @@ -209,7 +250,7 @@ public SseEmitter chatCompletionStream(@RequestBody OpenAiEndpoint openAiEndpoin } @PostMapping("/completion") - public Single completion(@RequestBody OpenAiEndpoint openAiEndpoint) { + public Single completion(@RequestBody OpenAiChatEndpoint openAiEndpoint) { CompletionRequest completionRequest = CompletionRequest.builder() @@ -218,22 +259,20 @@ public Single completion(@RequestBody OpenAiEndpoint openAiE .temperature(openAiEndpoint.getTemperature()) .build(); - this.openAiClient.setEndpoint(openAiEndpoint); - - EdgeChain edgeChain = openAiClient.createCompletion(completionRequest); + EdgeChain edgeChain = + openAiClient.createCompletion(completionRequest, openAiEndpoint); return edgeChain.toSingle(); } @PostMapping("/embeddings") - public Single embeddings(@RequestBody OpenAiEndpoint openAiEndpoint) - throws SQLException { - - this.openAiClient.setEndpoint(openAiEndpoint); + public Single embeddings( + @RequestBody OpenAiEmbeddingEndpoint openAiEndpoint) throws SQLException { EdgeChain edgeChain = openAiClient.createEmbeddings( - new OpenAiEmbeddingRequest(openAiEndpoint.getModel(), openAiEndpoint.getInput())); + new OpenAiEmbeddingRequest(openAiEndpoint.getModel(), openAiEndpoint.getRawText()), + openAiEndpoint); if (Objects.nonNull(env.getProperty("postgres.db.host"))) { @@ -255,9 +294,9 @@ public Single embeddings(@RequestBody OpenAiEndpoint op embeddingLogService.saveOrUpdate(embeddingLog); }) - .toSingle(); + .toSingleWithoutScheduler(); } - return edgeChain.toSingle(); + return edgeChain.toSingleWithoutScheduler(); } } diff --git a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/wiki/WikiController.java b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/wiki/WikiController.java index f7ef9660b..f1d394e8b 100644 --- a/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/wiki/WikiController.java +++ b/Java/FlySpring/edgechain-app/src/main/java/com/edgechain/service/controllers/wiki/WikiController.java @@ -1,7 +1,7 @@ package com.edgechain.service.controllers.wiki; import com.edgechain.lib.configuration.WebConfiguration; -import com.edgechain.lib.endpoint.impl.WikiEndpoint; +import com.edgechain.lib.endpoint.impl.wiki.WikiEndpoint; import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; import com.edgechain.lib.wiki.client.WikiClient; import com.edgechain.lib.wiki.response.WikiResponse; diff --git a/Java/FlySpring/edgechain-app/src/main/resources/application-test.properties b/Java/FlySpring/edgechain-app/src/main/resources/application-test.properties new file mode 100644 index 000000000..311c86783 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/resources/application-test.properties @@ -0,0 +1,5 @@ +# this profile will be used only when @ActiveProfiles("test") + +# uncomment these log level lines to follow what Spring is doing for ROLES +# logging.level.org.springframework.security=TRACE +# logging.level.org.springframework.security.web.FilterChainProxy=INFO diff --git a/Java/FlySpring/edgechain-app/src/main/resources/schema.sql b/Java/FlySpring/edgechain-app/src/main/resources/schema.sql new file mode 100644 index 000000000..a4fed6928 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/main/resources/schema.sql @@ -0,0 +1,5 @@ +CREATE TABLE history_context ( + id VARCHAR(255) NOT NULL PRIMARY KEY, + response VARCHAR(1024), + created_at TIMESTAMP +); \ No newline at end of file diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/EdgeChainApplicationTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/EdgeChainApplicationTest.java new file mode 100644 index 000000000..978b58089 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/EdgeChainApplicationTest.java @@ -0,0 +1,13 @@ +package com.edgechain; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class EdgeChainApplicationTest { + + @Test + void test() { + // simply checks server can start + } +} diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/chunker/ChunkerTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/chunker/ChunkerTest.java index e6edef4d7..08f6df3e0 100644 --- a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/chunker/ChunkerTest.java +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/chunker/ChunkerTest.java @@ -1,10 +1,9 @@ package com.edgechain.chunker; -import static org.junit.jupiter.api.Assertions.assertArrayEquals; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.Timeout; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.test.context.SpringBootTest; @@ -12,6 +11,11 @@ import com.edgechain.lib.chunk.Chunker; import com.edgechain.lib.chunk.enums.LangType; +import java.util.Arrays; +import java.util.concurrent.TimeUnit; + +import static org.junit.jupiter.api.Assertions.*; + @SpringBootTest public class ChunkerTest { @@ -82,4 +86,61 @@ public void chunker_BySentenceWithEmptyInput_ReturnEmptyArray(TestInfo testInfo) String[] expected = {"This is a test."}; assertArrayEquals(expected, result); } + + @Test + @DisplayName("Test By Very Small ChunkSize ") + void chunker_ByVerySmallChunkSize_ReturnedExpectedValue() { + String input = "This is Testing"; + Chunker chunker = new Chunker(input); + + String[] result = chunker.byChunkSize(1); + + String[] expected = {"T", "h", "i", "s", "i", "s", "T", "e", "s", "t", "i", "n", "g"}; + assertNotEquals(expected, result); + } + + @Test + @DisplayName("Test By ChunkSize - Input Contains Whitespace") + void chunker_ByChunkSize_InputWhiteSpaceCharacter_ReturnedExpectedValue() { + String input = "\n\t\t"; + Chunker chunker = new Chunker(input); + int chunkSize = 5; + + String[] result = chunker.byChunkSize(chunkSize); + + String[] expected = {""}; + assertArrayEquals(expected, result); + } + + @Test + @DisplayName("Test By Sentence - Contains Only Spaces") + void chunker_BySentence_InputContainsOnlySpaces_ReturnedExpectedValue() { + String input = " "; + Chunker chunker = new Chunker(input); + + String[] result = chunker.bySentence(LangType.EN); + logger.info(Arrays.toString(result)); + String[] expected = {}; + assertArrayEquals(expected, result); + assertEquals(expected.length, result.length); + } + + @Test + @DisplayName("Performance Test With Large String") + @Timeout(value = 5, unit = TimeUnit.SECONDS) + void chunker_Performance_LargeInputString_ReturnedExpectedValue() { + String input = "E".repeat(10000); + Chunker chunker = new Chunker(input); + int chunkSize = 5; + + long startTime = System.currentTimeMillis(); + String[] result = chunker.byChunkSize(chunkSize); + long endTime = System.currentTimeMillis(); + long totalExecutionTime = endTime - startTime; + logger.info(String.valueOf(totalExecutionTime)); + + long maxExecutionTime = 5000; // Execution time in mills + assertEquals(2000, result.length); + assertTrue(totalExecutionTime <= maxExecutionTime); + } } diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/codeInterpreter/CodeInterpreterTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/codeInterpreter/CodeInterpreterTest.java index e4d0527aa..ff6d22dde 100644 --- a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/codeInterpreter/CodeInterpreterTest.java +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/codeInterpreter/CodeInterpreterTest.java @@ -1,9 +1,7 @@ package com.edgechain.codeInterpreter; import static org.junit.Assert.assertFalse; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; import java.io.ByteArrayInputStream; import java.io.InputStream; @@ -65,4 +63,14 @@ public void test_empty_example_extraction() throws Exception { assertNotNull(extractedValue); assertFalse(extractedValue.contains(prompt)); } + + @Test + @DisplayName("Test for empty input") + void test_emptyInput_ReturnedExpectedValue() { + String inputJsonnet = ""; + InputStream inputStream = new ByteArrayInputStream(inputJsonnet.getBytes()); + JsonnetLoader jsonnetLoader = new FileJsonnetLoader(); + + assertThrows(Exception.class, () -> jsonnetLoader.load(inputStream)); + } } diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/jsonnet/JsonnetLoaderTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/jsonnet/JsonnetLoaderTest.java index 5dcdcbfc8..12e6b77fa 100644 --- a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/jsonnet/JsonnetLoaderTest.java +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/jsonnet/JsonnetLoaderTest.java @@ -1,9 +1,5 @@ package com.edgechain.jsonnet; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - import java.io.ByteArrayInputStream; import java.io.InputStream; @@ -20,6 +16,9 @@ import com.edgechain.lib.jsonnet.JsonnetLoader; import com.edgechain.lib.jsonnet.impl.FileJsonnetLoader; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertThrows; + @SpringBootTest public class JsonnetLoaderTest { @@ -106,4 +105,36 @@ public void test_external_variable_xtrasonnet() throws Exception { assertNotNull(externalVar); assertEquals(externalVar, "5"); } + + @Test + void jsonLoader_LoadJsonnet_WithInvalidJsonnet_ThrowsException() { + String inputJsonnet = "This is a test sentence."; + InputStream inputStream = new ByteArrayInputStream(inputJsonnet.getBytes()); + JsonnetLoader jsonnetLoader = new FileJsonnetLoader(); + assertThrows(Exception.class, () -> jsonnetLoader.load(inputStream)); + } + + @Test + void jsonLoader_LoadJsonnet_WithEmptyJsonnet_ThrowsExpcetion() { + String inputJsonnet = "{}"; + InputStream inputStream = new ByteArrayInputStream(inputJsonnet.getBytes()); + JsonnetLoader jsonnetLoader = new FileJsonnetLoader(); + jsonnetLoader.load(inputStream); + assertThrows(Exception.class, () -> jsonnetLoader.get("jsonnet")); + } + + @Test + void jsonLoader_LoadJsonnetWithArrayOfObjects_ReturnExpectedValue(TestInfo testInfo) { + String inputJsonnet = "{ \"objects\": [{ \"key\": \"value1\" }, { \"key\": \"value2\" }] }"; + InputStream inputStream = new ByteArrayInputStream(inputJsonnet.getBytes()); + JsonnetLoader jsonnetLoader = new FileJsonnetLoader(); + + jsonnetLoader.load(inputStream); + JSONArray objects = jsonnetLoader.getArray("objects"); + + assertNotNull(objects); + assertEquals(2, objects.length()); + assertEquals("value1", objects.getJSONObject(0).getString("key")); + assertEquals("value2", objects.getJSONObject(1).getString("key")); + } } diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/context/client/impl/PostgreSQLHistoryContextClientTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/context/client/impl/PostgreSQLHistoryContextClientTest.java new file mode 100644 index 000000000..5e4228e33 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/context/client/impl/PostgreSQLHistoryContextClientTest.java @@ -0,0 +1,91 @@ +package com.edgechain.lib.context.client.impl; + +import com.edgechain.lib.context.domain.HistoryContext; +import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; +import com.edgechain.testutil.PostgresTestContainer; +import com.edgechain.testutil.PostgresTestContainer.PostgresImage; +import com.zaxxer.hikari.HikariConfig; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.annotation.DirtiesContext; +import org.testcontainers.junit.jupiter.Testcontainers; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +@Testcontainers(disabledWithoutDocker = true) +@SpringBootTest(webEnvironment = WebEnvironment.NONE) +@DirtiesContext +class PostgreSQLHistoryContextClientTest { + + private static final Logger LOGGER = + LoggerFactory.getLogger(PostgreSQLHistoryContextClientTest.class); + + private static PostgresTestContainer instance = new PostgresTestContainer(PostgresImage.PLAIN); + + @BeforeAll + static void baseSetupAll() { + instance.start(); + } + + @AfterAll + static void baseTeardownAll() { + instance.stop(); + } + + @Autowired private HikariConfig hikariConfig; + @Autowired private PostgreSQLHistoryContextClient service; + + @Test + void allMethods() { + // hikari has own copy of properties so set these here + hikariConfig.setJdbcUrl(instance.getJdbcUrl()); + hikariConfig.setUsername(instance.getUsername()); + hikariConfig.setPassword(instance.getPassword()); + + final Data data = new Data(); + + final EdgeChain create = service.create("DAVE", null); + create.toSingle().blockingSubscribe(s -> data.id = s.getId(), e -> data.failed = true); + assertFalse(data.failed); + assertNotNull(data.id); + LOGGER.info("create OK id={}", data.id); + + final EdgeChain put = service.put(data.id, "COW", null); + put.toSingle().blockingSubscribe(s -> {}, e -> data.failed = true); + assertFalse(data.failed); + LOGGER.info("put OK"); + + final EdgeChain get = service.get(data.id, null); + get.toSingle().blockingSubscribe(s -> data.val = s.getResponse(), e -> data.failed = true); + assertFalse(data.failed); + assertEquals("COW", data.val); + LOGGER.info("get OK val={}", data.val); + + EdgeChain delete = service.delete(data.id, null); + delete.toSingle().blockingSubscribe(s -> data.val = s, e -> data.failed = true); + assertFalse(data.failed); + assertEquals("", data.val); + LOGGER.info("delete OK val={}", data.val); + + final EdgeChain getMissing = service.get("not_there", null); + getMissing + .toSingle() + .blockingSubscribe(s -> data.failed = true, e -> data.val = e.getMessage()); + assertFalse(data.failed); + assertEquals("PostgreSQL history_context id isn't found.", data.val); + LOGGER.info("get-NotFound OK val={}", data.val); + } + + private static class Data { + public boolean failed; + public String id; + public String val; + } +} diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/context/client/repositories/PostgreSQLHistoryContextRepositoryTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/context/client/repositories/PostgreSQLHistoryContextRepositoryTest.java new file mode 100644 index 000000000..88801627b --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/context/client/repositories/PostgreSQLHistoryContextRepositoryTest.java @@ -0,0 +1,85 @@ +package com.edgechain.lib.context.client.repositories; + +import com.edgechain.lib.context.domain.HistoryContext; +import com.edgechain.testutil.PostgresTestContainer; +import org.junit.jupiter.api.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; +import org.springframework.test.context.jdbc.Sql; + +import java.time.LocalDateTime; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.*; + +@DataJpaTest +@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) +@Sql(scripts = {"classpath:schema.sql"}) +class PostgreSQLHistoryContextRepositoryTest { + + Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired private PostgreSQLHistoryContextRepository repository; + + private static final PostgresTestContainer instance = + new PostgresTestContainer(PostgresTestContainer.PostgresImage.VECTOR); + + @BeforeAll + static void setupAll() { + instance.start(); + } + + @AfterAll + static void tearAll() { + instance.stop(); + } + + @BeforeEach + void setUp() { + repository.deleteAll(); + } + + @DynamicPropertySource + static void setProperties(DynamicPropertyRegistry registry) { + registry.add("spring.datasource.url", instance::getJdbcUrl); + registry.add("spring.datasource.username", instance::getUsername); + registry.add("spring.datasource.password", instance::getPassword); + } + + @Test + void test_Save_And_Retrieve_History_Context() { + HistoryContext historyContext = getHistoryContext(); + repository.save(historyContext); + + Optional result = repository.findById("1"); + logger.info("history context {}", result); + + assertTrue(result.isPresent()); + } + + @Test + void test_Delete_History_Context() { + HistoryContext historyContext = getHistoryContext(); + repository.save(historyContext); + + repository.deleteById("1"); + Optional result = repository.findById("1"); + + assertTrue(result.isEmpty()); + } + + @Test + void test_Find_By_Non_Exist_Context() { + Optional result = repository.findById("10"); + assertTrue(result.isEmpty()); + } + + private HistoryContext getHistoryContext() { + return new HistoryContext("1", "testing history context", LocalDateTime.now()); + } +} diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/endpoint/impl/BgeSmallEndpointTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/endpoint/impl/BgeSmallEndpointTest.java new file mode 100644 index 000000000..b7cae1606 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/endpoint/impl/BgeSmallEndpointTest.java @@ -0,0 +1,60 @@ +package com.edgechain.lib.endpoint.impl; + +import com.edgechain.lib.configuration.domain.SecurityUUID; +import com.edgechain.lib.endpoint.impl.embeddings.BgeSmallEndpoint; +import com.edgechain.lib.retrofit.client.RetrofitClientInstance; +import java.io.File; + +import org.junit.jupiter.api.Test; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.util.ReflectionTestUtils; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.mock; + +class BgeSmallEndpointTest { + + @Test + @DirtiesContext + void downloadFiles() { + // Retrofit needs a port + System.setProperty("server.port", "8888"); + + // give Retrofit a mock securityUUI instance so it goes not call context + SecurityUUID mockSecurityUUID = mock(SecurityUUID.class); + ReflectionTestUtils.setField(RetrofitClientInstance.class, "securityUUID", mockSecurityUUID); + + try { + // GIVEN we have no local files + deleteFiles(); + + // WHEN we create the endpoint instance + // (get tiny JSON files as example download data) + new BgeSmallEndpoint( + "https://jsonplaceholder.typicode.com/posts/1", + "https://jsonplaceholder.typicode.com/posts/2"); + + // THEN the files now exist + File modelFile = new File(BgeSmallEndpoint.MODEL_PATH); + assertTrue(modelFile.exists()); + + File tokenizerFile = new File(BgeSmallEndpoint.TOKENIZER_PATH); + assertTrue(tokenizerFile.exists()); + } finally { + // reset the Retrofit instance + ReflectionTestUtils.setField(RetrofitClientInstance.class, "securityUUID", null); + ReflectionTestUtils.setField(RetrofitClientInstance.class, "retrofit", null); + + deleteFiles(); // make sure we clean up files afterwards + } + } + + // === HELPER METHODS === + + private static void deleteFiles() { + File modelFile = new File(BgeSmallEndpoint.MODEL_PATH); + modelFile.delete(); + + File tokenizerFile = new File(BgeSmallEndpoint.TOKENIZER_PATH); + tokenizerFile.delete(); + } +} diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/flyfly/commands/run/TestContainersStarterTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/flyfly/commands/run/TestContainersStarterTest.java new file mode 100644 index 000000000..b74c11936 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/flyfly/commands/run/TestContainersStarterTest.java @@ -0,0 +1,105 @@ +package com.edgechain.lib.flyfly.commands.run; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testcontainers.DockerClientFactory; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +class TestContainersStarterTest { + + private static final Logger LOGGER = LoggerFactory.getLogger(TestContainersStarterTest.class); + + private TestContainersStarter starter; + + private String tempFilename; + + @BeforeEach + void setup() { + tempFilename = org.assertj.core.util.Files.newTemporaryFile().getAbsolutePath(); + + starter = new TestContainersStarter(); + starter.setPropertiesPath(tempFilename); + } + + @AfterEach + void teardown() { + new File(tempFilename).delete(); + } + + @Test + void addTempProperties() { + try { + starter.addTempProperties("DAVE"); + + List lines = + org.assertj.core.util.Files.linesOf(new File(tempFilename), StandardCharsets.UTF_8); + assertEquals(TestContainersStarter.FLYFLYTEMPTAG, lines.get(1)); + assertTrue(lines.get(2).contains("=DAVE")); + assertEquals(TestContainersStarter.FLYFLYTEMPTAG, lines.get(3)); + assertEquals(TestContainersStarter.FLYFLYTEMPTAG, lines.get(5)); + } catch (IOException e) { + fail("could not finish test", e); + } + } + + @Test + void addTempAndThenRemove() { + try { + Files.writeString(Paths.get(tempFilename), "FIRST LINE\n", StandardCharsets.UTF_8); + + assertTrue(starter.isServiceNeeded()); + + starter.addTempProperties("DAVE"); + assertFalse(starter.isServiceNeeded()); + + starter.removeTempProperties(); + assertTrue(starter.isServiceNeeded()); + + String result = Files.readString(Paths.get(tempFilename), StandardCharsets.UTF_8); + assertEquals("FIRST LINE\n\n", result); // addTemp.. adds a blank line at the start + } catch (IOException e) { + fail("could not finish test", e); + } + } + + @Test + void startAndStopContainer() { + if (!isDockerAvailable()) { + LOGGER.warn("Docker is not running - test skipped"); + return; + } + + try { + starter.startPostgreSQL(); + } catch (IOException e) { + fail("not able to start PostgreSQL", e); + } finally { + try { + starter.stopPostgreSQL(); + } catch (IOException e2) { + fail("failed to stop PostgreSQL", e2); + } + } + } + + boolean isDockerAvailable() { + try { + DockerClientFactory.instance().client(); + return true; + } catch (Throwable ex) { + return false; + } + } +} diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/index/client/impl/PostgresClientTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/index/client/impl/PostgresClientTest.java new file mode 100644 index 000000000..5178bfd63 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/index/client/impl/PostgresClientTest.java @@ -0,0 +1,387 @@ +package com.edgechain.lib.index.client.impl; + +import com.edgechain.lib.embeddings.WordEmbeddings; +import com.edgechain.lib.endpoint.impl.index.PostgresEndpoint; +import com.edgechain.lib.index.domain.PostgresWordEmbeddings; +import com.edgechain.lib.index.enums.PostgresDistanceMetric; +import com.edgechain.lib.index.enums.PostgresLanguage; +import com.edgechain.lib.response.StringResponse; +import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; +import com.edgechain.testutil.PostgresTestContainer; +import com.edgechain.testutil.PostgresTestContainer.PostgresImage; +import com.zaxxer.hikari.HikariConfig; +import java.util.List; +import java.util.stream.Collectors; + +import io.reactivex.rxjava3.observers.TestObserver; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.annotation.DirtiesContext; +import org.testcontainers.junit.jupiter.Testcontainers; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +@Testcontainers(disabledWithoutDocker = true) +@SpringBootTest(webEnvironment = WebEnvironment.NONE) +@DirtiesContext +class PostgresClientTest { + + private static final Logger LOGGER = LoggerFactory.getLogger(PostgresClientTest.class); + + private static final float FLOAT_ERROR_MARGIN = 0.0001f; + + private static PostgresTestContainer instance = new PostgresTestContainer(PostgresImage.VECTOR); + + @BeforeAll + static void setupAll() { + instance.start(); + } + + @AfterAll + static void teardownAll() { + instance.stop(); + } + + @Autowired private HikariConfig hikariConfig; + + @Autowired private PostgresClient service; + + @Test + void allMethods() { + // hikari has own copy of properties so set these here + hikariConfig.setJdbcUrl(instance.getJdbcUrl()); + hikariConfig.setUsername(instance.getUsername()); + hikariConfig.setPassword(instance.getPassword()); + + createTable(); + createMetadataTable(); + + deleteAll(); // check delete before we get foreign keys + + String uuid1 = upsert(); + batchUpsert(); + + query_noMeta(); + + String uuid2 = insertMetadata(); + + batchInsertMetadata(); + insertIntoJoinTable(uuid1, uuid2); + + query_meta(); + getChunks(); + getSimilarChunks(); + } + + private void createTable() { + createTable_metric(PostgresDistanceMetric.COSINE, "t_embedding"); + } + + private void createTable_metric(PostgresDistanceMetric metric, String tableName) { + PostgresEndpoint mockPe = mock(PostgresEndpoint.class); + when(mockPe.getTableName()).thenReturn(tableName); + when(mockPe.getLists()).thenReturn(1); + when(mockPe.getDimensions()).thenReturn(2); + when(mockPe.getMetric()).thenReturn(metric); + + TestObserver test = service.createTable(mockPe).getObservable().test(); + + try { + test.await(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + test.assertNoErrors(); + LOGGER.info("createTable (metric={}) response: '{}'", metric, tableName); + } + + private void createMetadataTable() { + PostgresEndpoint mockPe = mock(PostgresEndpoint.class); + when(mockPe.getTableName()).thenReturn("t_embedding"); + when(mockPe.getMetadataTableNames()).thenReturn(List.of("title_metadata")); + + TestObserver test = service.createMetadataTable(mockPe).getObservable().test(); + try { + test.await(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + LOGGER.info("createMetadataTable response: '{}'", test.values().get(0).getResponse()); + } + + private String upsert() { + WordEmbeddings we = new WordEmbeddings(); + we.setId("WE1"); + we.setScore(0.86914713); + we.setValues(List.of(0.25f, 0.5f)); + + PostgresEndpoint mockPe = mock(PostgresEndpoint.class); + when(mockPe.getTableName()).thenReturn("t_embedding"); + when(mockPe.getWordEmbedding()).thenReturn(we); + when(mockPe.getFilename()).thenReturn("readme.pdf"); + when(mockPe.getNamespace()).thenReturn("testns"); + when(mockPe.getPostgresLanguage()).thenReturn(PostgresLanguage.ENGLISH); + + TestObserver test = service.upsert(mockPe).getObservable().test(); + try { + test.await(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + + test.assertNoErrors(); + + return test.values().get(0).getResponse(); + } + + private String insertMetadata() { + PostgresEndpoint mockPe = mock(PostgresEndpoint.class); + when(mockPe.getTableName()).thenReturn("t_embedding"); + when(mockPe.getMetadataTableNames()).thenReturn(List.of("title_metadata")); + when(mockPe.getMetadata()).thenReturn("This is a sample text"); + when(mockPe.getDocumentDate()).thenReturn("November 11, 2015"); + + TestObserver test = service.insertMetadata(mockPe).getObservable().test(); + try { + test.await(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + test.assertNoErrors(); + return test.values().get(0).getResponse(); + } + + private void batchUpsert() { + WordEmbeddings we1 = new WordEmbeddings(); + we1.setId("WE1"); + we1.setScore(1.05689); + we1.setValues(List.of(0.25f, 0.5f)); + + WordEmbeddings we2 = new WordEmbeddings(); + we2.setId("WE2"); + we2.setScore(2.02689); + we2.setValues(List.of(0.75f, 0.9f)); + + PostgresEndpoint mockPe = mock(PostgresEndpoint.class); + when(mockPe.getTableName()).thenReturn("t_embedding"); + when(mockPe.getWordEmbeddingsList()).thenReturn(List.of(we1, we2)); + when(mockPe.getFilename()).thenReturn("readme.pdf"); + when(mockPe.getNamespace()).thenReturn("testns"); + when(mockPe.getPostgresLanguage()).thenReturn(PostgresLanguage.ENGLISH); + + final Data data = new Data(); + EdgeChain> result = service.batchUpsert(mockPe); + result + .toSingle() + .blockingSubscribe( + s -> data.val = s.stream().map(r -> r.getResponse()).collect(Collectors.joining(",")), + e -> data.error = e); + if (data.error != null) { + fail("batchUpsert failed", data.error); + } + LOGGER.info("batchUpsert response: '{}'", data.val); + } + + private void batchInsertMetadata() { + PostgresEndpoint mockPe = mock(PostgresEndpoint.class); + when(mockPe.getTableName()).thenReturn("t_embedding"); + when(mockPe.getMetadataTableNames()).thenReturn(List.of("title_metadata")); + when(mockPe.getMetadataList()).thenReturn(List.of("text1", "text2")); + + final Data data = new Data(); + EdgeChain> result = service.batchInsertMetadata(mockPe); + result + .toSingle() + .blockingSubscribe( + s -> data.val = s.stream().map(r -> r.getResponse()).collect(Collectors.joining(",")), + e -> data.error = e); + if (data.error != null) { + fail("batchInsertMetadata failed", data.error); + } + LOGGER.info("batchInsertMetadata response: '{}'", data.val); + } + + private void insertIntoJoinTable(String uuid1, String uuid2) { + PostgresEndpoint mockPe = mock(PostgresEndpoint.class); + when(mockPe.getTableName()).thenReturn("t_embedding"); + when(mockPe.getMetadataTableNames()).thenReturn(List.of("title_metadata")); + when(mockPe.getId()).thenReturn(uuid1); + when(mockPe.getMetadataId()).thenReturn(uuid2); + + TestObserver test = service.insertIntoJoinTable(mockPe).getObservable().test(); + + try { + test.await(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + + test.assertNoErrors(); + } + + private void deleteAll() { + deleteAll_namespace(null, "knowledge"); + deleteAll_namespace("", "knowledge"); + deleteAll_namespace("testns", "testns"); + } + + private void deleteAll_namespace(String namespace, String expected) { + PostgresEndpoint mockPe = mock(PostgresEndpoint.class); + when(mockPe.getTableName()).thenReturn("t_embedding"); + when(mockPe.getNamespace()).thenReturn(namespace); + + final Data data = new Data(); + EdgeChain result = service.deleteAll(mockPe); + result.toSingle().blockingSubscribe(s -> data.val = s.getResponse(), e -> data.error = e); + if (data.error != null) { + fail("deleteAll failed", data.error); + } + LOGGER.info("deleteAll (namespace={}) response: '{}'", namespace, data.val); + assertTrue(data.val.endsWith(expected)); + } + + private void query_noMeta() { + query_noMeta_metric(PostgresDistanceMetric.COSINE); + query_noMeta_metric(PostgresDistanceMetric.IP); + query_noMeta_metric(PostgresDistanceMetric.L2); + } + + private void query_noMeta_metric(PostgresDistanceMetric metric) { + WordEmbeddings we1 = new WordEmbeddings(); + we1.setId("WEQUERY"); + we1.setScore(1.05589); + we1.setValues(List.of(0.25f, 0.5f)); + + PostgresEndpoint mockPe = mock(PostgresEndpoint.class); + when(mockPe.getTableName()).thenReturn("t_embedding"); + when(mockPe.getNamespace()).thenReturn("testns"); + when(mockPe.getProbes()).thenReturn(5); + when(mockPe.getMetric()).thenReturn(metric); + when(mockPe.getWordEmbeddingsList()).thenReturn(List.of(we1)); + when(mockPe.getTopK()).thenReturn(5); + when(mockPe.getUpperLimit()).thenReturn(5); + when(mockPe.getMetadataTableNames()).thenReturn(null); + + final Data data = new Data(); + EdgeChain> result = service.query(mockPe); + result + .toSingle() + .blockingSubscribe( + s -> data.val = s.stream().map(r -> r.getRawText()).collect(Collectors.joining(",")), + e -> data.error = e); + if (data.error != null) { + fail("query (no meta) failed", data.error); + } + LOGGER.info("query no meta (metric={}) response: '{}'", metric, data.val); + + // WE1 from single upsert, and WE2 from batch upsert + assertTrue(data.val.contains("WE1") && data.val.contains("WE2")); + } + + private void query_meta() { + query_meta_metric(PostgresDistanceMetric.COSINE); + query_meta_metric(PostgresDistanceMetric.IP); + query_meta_metric(PostgresDistanceMetric.L2); + } + + private void query_meta_metric(PostgresDistanceMetric metric) { + WordEmbeddings we1 = new WordEmbeddings(); + we1.setId("WEQUERY"); + we1.setScore(1.258); + we1.setValues(List.of(0.25f, 0.5f)); + + PostgresEndpoint mockPe = mock(PostgresEndpoint.class); + when(mockPe.getTableName()).thenReturn("t_embedding"); + when(mockPe.getNamespace()).thenReturn("testns"); + when(mockPe.getProbes()).thenReturn(20); + when(mockPe.getMetric()).thenReturn(metric); + when(mockPe.getWordEmbedding()).thenReturn(we1); + when(mockPe.getTopK()).thenReturn(5); + when(mockPe.getUpperLimit()).thenReturn(5); + when(mockPe.getMetadataTableNames()).thenReturn(List.of("title_metadata")); + + final Data data = new Data(); + EdgeChain> result = service.queryWithMetadata(mockPe); + result + .toSingle() + .blockingSubscribe( + s -> data.val = s.stream().map(r -> r.getRawText()).collect(Collectors.joining(",")), + e -> data.error = e); + if (data.error != null) { + fail("query (meta) failed", data.error); + } + LOGGER.info("query with meta (metric={}) response: '{}'", metric, data.val); + + // WE1 from single joined upsert + assertTrue(data.val.contains("WE1")); + } + + private void getChunks() { + PostgresEndpoint mockPe = mock(PostgresEndpoint.class); + when(mockPe.getTableName()).thenReturn("t_embedding"); + when(mockPe.getFilename()).thenReturn("readme.pdf"); + + final Data data = new Data(); + EdgeChain> result = service.getAllChunks(mockPe); + result + .toSingle() + .blockingSubscribe( + s -> { + data.list = s; + data.val = s.stream().map(r -> r.getRawText()).collect(Collectors.joining(",")); + }, + e -> data.error = e); + if (data.error != null) { + fail("getChunks failed", data.error); + } + LOGGER.info("getChunks response: '{}'", data.val); + + // WE1 from single upsert, and WE2 from batch upsert + assertTrue(data.val.contains("WE1") && data.val.contains("WE2")); + + PostgresWordEmbeddings first = data.list.get(0); + assertEquals(0.25f, first.getValues().get(0), FLOAT_ERROR_MARGIN); + assertEquals(0.5f, first.getValues().get(1), FLOAT_ERROR_MARGIN); + + PostgresWordEmbeddings second = data.list.get(1); + assertEquals(0.75f, second.getValues().get(0), FLOAT_ERROR_MARGIN); + assertEquals(0.9f, second.getValues().get(1), FLOAT_ERROR_MARGIN); + } + + private void getSimilarChunks() { + PostgresEndpoint mockPe = mock(PostgresEndpoint.class); + when(mockPe.getTableName()).thenReturn("t_embedding"); + when(mockPe.getMetadataTableNames()).thenReturn(List.of("title_metadata")); + when(mockPe.getEmbeddingChunk()).thenReturn("how to test this"); + + final Data data = new Data(); + EdgeChain> result = service.getSimilarMetadataChunk(mockPe); + result + .toSingle() + .blockingSubscribe( + s -> { + data.list = s; + data.val = s.stream().map(r -> r.getRawText()).collect(Collectors.joining(",")); + }, + e -> data.error = e); + if (data.error != null) { + fail("getSimilarMetadataChunk failed", data.error); + } + LOGGER.info("getSimilarMetadataChunk response: '{}'", data.val); + } + + private static class Data { + public Throwable error; + public String val; + public List list; + } +} diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/logger/services/EmbeddingLogServiceTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/logger/services/EmbeddingLogServiceTest.java new file mode 100644 index 000000000..37054dd1e --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/logger/services/EmbeddingLogServiceTest.java @@ -0,0 +1,67 @@ +package com.edgechain.lib.logger.services; + +import org.junit.jupiter.api.Test; +import org.postgresql.ds.PGSimpleDataSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.test.util.ReflectionTestUtils; +import org.testcontainers.containers.PostgreSQLContainer; +import org.testcontainers.junit.jupiter.Testcontainers; +import static org.junit.jupiter.api.Assertions.fail; + +@Testcontainers(disabledWithoutDocker = true) +class EmbeddingLogServiceTest { + + private static PostgresTestContainer instance = new PostgresTestContainer(); + + @Test + void test() { + instance.start(); + try { + // create datasource and template using Docker properties + final PGSimpleDataSource datasource = new PGSimpleDataSource(); + datasource.setUrl(instance.getJdbcUrl()); + datasource.setUser(instance.getUsername()); + datasource.setPassword(instance.getPassword()); + + final JdbcTemplate template = new JdbcTemplate(datasource); + + // create service using template + final EmbeddingLogService service = new EmbeddingLogService(); + ReflectionTestUtils.setField(service, "jdbcTemplate", template); + + service.createTable(); + + } catch (Exception e) { + fail("could not create table", e); + + } finally { + instance.stop(); + } + } + + public static class PostgresTestContainer extends PostgreSQLContainer { + + private static final Logger LOGGER = LoggerFactory.getLogger(PostgresTestContainer.class); + + private static final String DOCKER_IMAGE = + PostgreSQLContainer.IMAGE + ":" + PostgreSQLContainer.DEFAULT_TAG; + + public PostgresTestContainer() { + super(DOCKER_IMAGE); + } + + @Override + public void start() { + LOGGER.info("starting container"); + super.start(); + } + + @Override + public void stop() { + LOGGER.info("stopping container"); + super.stop(); + } + } +} diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/supabase/security/WebSecurityConfigFixTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/supabase/security/WebSecurityConfigFixTest.java new file mode 100644 index 000000000..01d0ba63d --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/supabase/security/WebSecurityConfigFixTest.java @@ -0,0 +1,119 @@ +package com.edgechain.lib.supabase.security; + +import com.edgechain.lib.configuration.domain.AuthFilter; +import com.edgechain.lib.configuration.domain.MethodAuthentication; +import com.edgechain.testutil.TestJwtCreator; +import java.util.List; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@AutoConfigureMockMvc +@ContextConfiguration(name = "contextWithEmptyPatternsAuthFilter") +class WebSecurityConfigFixTest { + + // ====== TEST JWT-BASED SECURITY WITH NO ROLES (bearer token must be in header) ====== + + private static final String FULL_NONCONTEXT_PATH = "/v0/endpoint/"; + + @BeforeAll + static void setupAll() { + System.setProperty("jwt.secret", "edge-chain-unit-test-jwt-secret"); + } + + @TestConfiguration + public static class AuthFilterTestConfig { + @Bean + AuthFilter authFilter() { + // provide an AuthFilter with an empty string in the patterns list. + // the security class should fix this to ** + AuthFilter auth = new AuthFilter(); + auth.setRequestGet(new MethodAuthentication(List.of(""), "")); + auth.setRequestDelete(new MethodAuthentication(List.of(""), "")); + auth.setRequestPatch(new MethodAuthentication(List.of(""), "")); + auth.setRequestPost(new MethodAuthentication(List.of(""), "")); + auth.setRequestPut(new MethodAuthentication(List.of(""), "")); + return auth; + } + } + + @Autowired private MockMvc mvc; + + @Autowired private JwtHelper jwtHelper; + + @Test + void validateJwt() { + String jwt = TestJwtCreator.generate("ROLE_IGNORED"); + assertTrue(jwtHelper.validate(jwt)); + } + + @Test + void getEndpoint() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_IGNORED"); + mvc.perform( + get(FULL_NONCONTEXT_PATH) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isNotFound()); + } + + @Test + void postEndpoint() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_IGNORED"); + mvc.perform( + post(FULL_NONCONTEXT_PATH) + .content("{}") + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isNotFound()); + } + + @Test + void deleteEndpoint() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_IGNORED"); + mvc.perform( + delete(FULL_NONCONTEXT_PATH) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isNotFound()); + } + + @Test + void patchEndpoint() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_IGNORED"); + mvc.perform( + patch(FULL_NONCONTEXT_PATH) + .content("{}") + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isNotFound()); + } + + @Test + void putEndpoint() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_IGNORED"); + mvc.perform( + put(FULL_NONCONTEXT_PATH) + .content("{}") + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isNotFound()); + } +} diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/supabase/security/WebSecurityContextPathTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/supabase/security/WebSecurityContextPathTest.java new file mode 100644 index 000000000..9b6482670 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/supabase/security/WebSecurityContextPathTest.java @@ -0,0 +1,79 @@ +package com.edgechain.lib.supabase.security; + +import com.edgechain.lib.configuration.WebConfiguration; +import com.edgechain.lib.configuration.domain.SecurityUUID; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@AutoConfigureMockMvc +class WebSecurityContextPathTest { + + // ====== TEST CONTEXT-BASED SECURITY (uuid must be in header) ====== + + private static final String FULL_CONTEXT_PATH = WebConfiguration.CONTEXT_PATH + "/"; + + @Autowired private MockMvc mvc; + + @Autowired private SecurityUUID securityUUID; + + @Test + void getContextEndpoint() throws Exception { + mvc.perform( + get(FULL_CONTEXT_PATH) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", securityUUID.getAuthKey())) + .andExpect(status().isNotFound()); + } + + @Test + void postContextEndpoint() throws Exception { + mvc.perform( + post(FULL_CONTEXT_PATH) + .content("{}") + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", securityUUID.getAuthKey())) + .andExpect(status().isNotFound()); + } + + @Test + void deleteContextEndpoint() throws Exception { + mvc.perform( + delete(FULL_CONTEXT_PATH) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", securityUUID.getAuthKey())) + .andExpect(status().isNotFound()); + } + + @Test + void patchContextEndpoint() throws Exception { + mvc.perform( + patch(FULL_CONTEXT_PATH) + .content("{}") + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", securityUUID.getAuthKey())) + .andExpect(status().isNotFound()); + } + + @Test + void putContextEndpoint() throws Exception { + mvc.perform( + put(FULL_CONTEXT_PATH) + .content("{}") + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", securityUUID.getAuthKey())) + .andExpect(status().isNotFound()); + } +} diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/supabase/security/WebSecurityJwtNoRoleTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/supabase/security/WebSecurityJwtNoRoleTest.java new file mode 100644 index 000000000..6d401409e --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/supabase/security/WebSecurityJwtNoRoleTest.java @@ -0,0 +1,96 @@ +package com.edgechain.lib.supabase.security; + +import com.edgechain.testutil.TestJwtCreator; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@AutoConfigureMockMvc +class WebSecurityJwtNoRoleTest { + + // ====== TEST JWT-BASED SECURITY WITH NO ROLES (bearer token must be in header) ====== + + private static final String FULL_NONCONTEXT_PATH = "/v0/endpoint/"; + + @BeforeAll + static void setupAll() { + System.setProperty("jwt.secret", "edge-chain-unit-test-jwt-secret"); + } + + @Autowired private MockMvc mvc; + + @Autowired private JwtHelper jwtHelper; + + @Test + void validateJwt() { + String jwt = TestJwtCreator.generate("ROLE_IGNORED"); + assertTrue(jwtHelper.validate(jwt)); + } + + @Test + void getEndpoint() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_IGNORED"); + mvc.perform( + get(FULL_NONCONTEXT_PATH) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isNotFound()); + } + + @Test + void postEndpoint() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_IGNORED"); + mvc.perform( + post(FULL_NONCONTEXT_PATH) + .content("{}") + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isNotFound()); + } + + @Test + void deleteEndpoint() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_IGNORED"); + mvc.perform( + delete(FULL_NONCONTEXT_PATH) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isNotFound()); + } + + @Test + void patchEndpoint() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_IGNORED"); + mvc.perform( + patch(FULL_NONCONTEXT_PATH) + .content("{}") + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isNotFound()); + } + + @Test + void putEndpoint() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_IGNORED"); + mvc.perform( + put(FULL_NONCONTEXT_PATH) + .content("{}") + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isNotFound()); + } +} diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/supabase/security/WebSecurityJwtWithRoleTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/supabase/security/WebSecurityJwtWithRoleTest.java new file mode 100644 index 000000000..81da385eb --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/lib/supabase/security/WebSecurityJwtWithRoleTest.java @@ -0,0 +1,173 @@ +package com.edgechain.lib.supabase.security; + +import com.edgechain.lib.configuration.domain.AuthFilter; +import com.edgechain.lib.configuration.domain.MethodAuthentication; +import com.edgechain.testutil.TestJwtCreator; +import java.util.List; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@ActiveProfiles("test") +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@AutoConfigureMockMvc +@ContextConfiguration(name = "contextWithTestRolesAuthFilter") +class WebSecurityJwtWithRoleTest { + + // ====== TEST JWT-BASED SECURITY WITH ROLES (bearer token must be in header) ====== + + private static final String FULL_NONCONTEXT_PATH = "/v0/endpoint/"; + + @TestConfiguration + public static class AuthFilterTestConfig { + @Bean + AuthFilter authFilter() { + // provide an AuthFilter with roles to check we test the correct role for each method + AuthFilter auth = new AuthFilter(); + auth.setRequestGet(new MethodAuthentication(List.of("**"), "ROLE_ADMIN1", "ROLE_AI1")); + auth.setRequestDelete(new MethodAuthentication(List.of("**"), "ROLE_ADMIN2", "ROLE_AI2")); + auth.setRequestPatch(new MethodAuthentication(List.of("**"), "ROLE_ADMIN3", "ROLE_AI3")); + auth.setRequestPost(new MethodAuthentication(List.of("**"), "ROLE_ADMIN4", "ROLE_AI4")); + auth.setRequestPut(new MethodAuthentication(List.of("**"), "ROLE_ADMIN5", "ROLE_AI5")); + return auth; + } + } + + @BeforeAll + static void setupAll() { + System.setProperty("jwt.secret", "edge-chain-unit-test-jwt-secret"); + } + + @Autowired private MockMvc mvc; + + @Autowired private JwtHelper jwtHelper; + + @Test + void validateJwt() { + String jwt = TestJwtCreator.generate("ROLE_TEST"); + assertTrue(jwtHelper.validate(jwt)); + } + + @Test + void getEndpoint() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_ADMIN1"); + mvc.perform( + get(FULL_NONCONTEXT_PATH) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isNotFound()); + } + + @Test + void getEndpoint_notAuth() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_NO_ACCESS"); + mvc.perform( + get(FULL_NONCONTEXT_PATH) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isForbidden()); + } + + @Test + void postEndpoint() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_ADMIN4"); + mvc.perform( + post(FULL_NONCONTEXT_PATH) + .content("{}") + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isNotFound()); + } + + @Test + void postEndpoint_notAuth() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_NO_ACCESS"); + mvc.perform( + post(FULL_NONCONTEXT_PATH) + .content("{}") + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isForbidden()); + } + + @Test + void deleteEndpoint() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_ADMIN2"); + mvc.perform( + delete(FULL_NONCONTEXT_PATH) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isNotFound()); + } + + @Test + void deleteEndpoint_notAuth() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_NO_ACCESS"); + mvc.perform( + delete(FULL_NONCONTEXT_PATH) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isForbidden()); + } + + @Test + void patchEndpoint() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_ADMIN3"); + mvc.perform( + patch(FULL_NONCONTEXT_PATH) + .content("{}") + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isNotFound()); + } + + @Test + void patchEndpoint_notAuth() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_NO_ACCESS"); + mvc.perform( + patch(FULL_NONCONTEXT_PATH) + .content("{}") + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isForbidden()); + } + + @Test + void putEndpoint() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_ADMIN5"); + mvc.perform( + put(FULL_NONCONTEXT_PATH) + .content("{}") + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isNotFound()); + } + + @Test + void putEndpoint_notAuth() throws Exception { + String jwt = TestJwtCreator.generate("ROLE_NO_ACCESS"); + mvc.perform( + put(FULL_NONCONTEXT_PATH) + .content("{}") + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .header("Authorization", "Bearer " + jwt)) + .andExpect(status().isForbidden()); + } +} diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/openai/OpenAiClientTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/openai/OpenAiClientTest.java index cf8c8be36..9b8ac08aa 100644 --- a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/openai/OpenAiClientTest.java +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/openai/OpenAiClientTest.java @@ -1,6 +1,6 @@ package com.edgechain.openai; -import com.edgechain.lib.endpoint.impl.OpenAiEndpoint; +import com.edgechain.lib.endpoint.impl.llm.OpenAiChatEndpoint; import com.edgechain.lib.openai.request.ChatCompletionRequest; import com.edgechain.lib.openai.request.ChatMessage; import com.edgechain.lib.openai.response.ChatCompletionResponse; @@ -88,15 +88,15 @@ public void testOpenAiClient_ChatCompletionResponse_ShouldMappedToPOJO(Class } @Test - @DisplayName("Test OpenAiEndpoint With Retry Mechanism") + @DisplayName("Test OpenAiChatEndpoint With Retry Mechanism") @Order(3) public void testOpenAiClient_WithRetryMechanism_ShouldThrowExceptionWithRetry(TestInfo testInfo) throws InterruptedException { System.out.println("======== " + testInfo.getDisplayName() + " ========"); - OpenAiEndpoint endpoint = - new OpenAiEndpoint( + OpenAiChatEndpoint endpoint = + new OpenAiChatEndpoint( OPENAI_CHAT_COMPLETION_API, "", // apiKey "", // orgId @@ -120,7 +120,7 @@ public void testOpenAiClient_WithRetryMechanism_ShouldThrowExceptionWithRetry(Te } @Test - @DisplayName("Test OpenAiEndpoint With No Retry Mechanism") + @DisplayName("Test OpenAiChatEndpoint With No Retry Mechanism") @Order(4) public void testOpenAiClient_WithNoRetryMechanism_ShouldThrowExceptionWithNoRetry( TestInfo testInfo) throws InterruptedException { @@ -128,8 +128,8 @@ public void testOpenAiClient_WithNoRetryMechanism_ShouldThrowExceptionWithNoRetr System.out.println("======== " + testInfo.getDisplayName() + " ========"); // Step 1 : Create OpenAi Endpoint - OpenAiEndpoint endpoint = - new OpenAiEndpoint( + OpenAiChatEndpoint endpoint = + new OpenAiChatEndpoint( OPENAI_CHAT_COMPLETION_API, "", // apiKey "", // orgId diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/pinecone/PineconeClientTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/pinecone/PineconeClientTest.java index 0f49fb8d6..f300ac6b8 100644 --- a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/pinecone/PineconeClientTest.java +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/pinecone/PineconeClientTest.java @@ -1,6 +1,107 @@ package com.edgechain.pinecone; +import com.edgechain.lib.endpoint.impl.index.PineconeEndpoint; +import com.edgechain.lib.index.client.impl.PineconeClient; +import com.edgechain.lib.response.StringResponse; +import com.edgechain.lib.rxjava.transformer.observable.EdgeChain; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; -@SpringBootTest -public class PineconeClientTest {} +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class PineconeClientTest { + + @LocalServerPort private int port; + + @Autowired private PineconeClient pineconeClient; + + private PineconeEndpoint pineconeEndpoint; + + @BeforeEach + void setUp() { + System.setProperty("server.port", String.valueOf(port)); + pineconeEndpoint = new PineconeEndpoint("https://arakoo.ai", "apiKey", "Pinecone", null); + } + + @Test + @DisplayName("Test Upsert") + public void test_Upsert() { + RestTemplate restTemplate = mock(RestTemplate.class); + ResponseEntity responseEntity = ResponseEntity.ok("some dummy data"); + when(restTemplate.exchange(anyString(), any(), any(), eq(String.class))) + .thenReturn(responseEntity); + + EdgeChain result = pineconeClient.upsert(pineconeEndpoint); + + assertNotNull(result); + } + + @Test + @DisplayName("Test Batch Upsert") + public void test_Batch_Upsert() { + RestTemplate restTemplate = mock(RestTemplate.class); + ResponseEntity responseEntity = ResponseEntity.ok("some dummy data"); + when(restTemplate.exchange(anyString(), any(), any(), eq(String.class))) + .thenReturn(responseEntity); + + EdgeChain result = pineconeClient.batchUpsert(pineconeEndpoint); + + assertNotNull(result); + } + + @Test + @DisplayName("Test Query") + public void test_Query() { + RestTemplate restTemplate = mock(RestTemplate.class); + ResponseEntity responseEntity = ResponseEntity.ok("some dummy data"); + when(restTemplate.exchange(anyString(), any(), any(), eq(String.class))) + .thenReturn(responseEntity); + + EdgeChain queryResult = pineconeClient.batchUpsert(pineconeEndpoint); + + assertNotNull(queryResult); + assertNull(queryResult.get().getResponse()); + } + + @Test + @DisplayName("Test Delete All") + public void test_Delete_All() { + RestTemplate restTemplate = mock(RestTemplate.class); + ResponseEntity responseEntity = ResponseEntity.ok("some dummy data"); + when(restTemplate.exchange(anyString(), any(), any(), eq(String.class))) + .thenReturn(responseEntity); + + EdgeChain deleteResult = pineconeClient.deleteAll(pineconeEndpoint); + + assertNotNull(deleteResult); + assertTrue(deleteResult.get().getResponse().endsWith("Pinecone")); + } + + @Test + @DisplayName("Test Get Namespace") + public void test_GetNamespace() { + // Test for non-empty namespace + String nonEmptyNamespace = pineconeClient.getNamespace(pineconeEndpoint); + assertEquals("Pinecone", nonEmptyNamespace); + + // Test for empty namespace + pineconeEndpoint.setNamespace(""); + String emptyNamespace = pineconeClient.getNamespace(pineconeEndpoint); + assertEquals("", emptyNamespace); + + // Test for null namespace + pineconeEndpoint.setNamespace(null); + String nullNamespace = pineconeClient.getNamespace(pineconeEndpoint); + assertEquals("", nullNamespace); + } +} diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/postgres/PostgresClientMetadataRepositoryTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/postgres/PostgresClientMetadataRepositoryTest.java new file mode 100644 index 000000000..012c7dc16 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/postgres/PostgresClientMetadataRepositoryTest.java @@ -0,0 +1,185 @@ +package com.edgechain.postgres; + +import com.edgechain.lib.embeddings.WordEmbeddings; +import com.edgechain.lib.endpoint.impl.index.PostgresEndpoint; +import com.edgechain.lib.index.enums.PostgresDistanceMetric; +import com.edgechain.lib.index.repositories.PostgresClientMetadataRepository; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.jdbc.core.JdbcTemplate; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +@SpringBootTest +@RunWith(MockitoJUnitRunner.class) +public class PostgresClientMetadataRepositoryTest { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + @Mock private JdbcTemplate jdbcTemplate; + + PostgresEndpoint postgresEndpoint; + @InjectMocks private PostgresClientMetadataRepository repository; + + @Captor private ArgumentCaptor sqlQueryCaptor; + + @BeforeEach + public void setUp() { + postgresEndpoint = mock(PostgresEndpoint.class); + } + + @Test + @DisplayName( + "Test if jdbcTemplate execute method is called twice for createTable() and verifying sql" + + " queries") + public void testCreateTable_NonEmptyMetadataTableNames() { + // Arrange + when(postgresEndpoint.getMetadataTableNames()) + .thenReturn(Collections.singletonList("metadataTestTable")); + + // Act + repository.createTable(postgresEndpoint); + + // Assert + verify(jdbcTemplate, times(3)).execute(sqlQueryCaptor.capture()); + } + + @Test + @DisplayName("createTable() should throw error when the metadata table names list is empty") + public void testCreateTable_EmptyMetadataTableNames() { + // Arrange + when(postgresEndpoint.getMetadataTableNames()).thenReturn(Collections.emptyList()); + + // Act and Assert + assertThrows(IndexOutOfBoundsException.class, () -> repository.createTable(postgresEndpoint)); + verify(jdbcTemplate, times(0)).execute(sqlQueryCaptor.capture()); + } + + @Test + @DisplayName("Insert metadata must throw NullPointerException when metadata ID is null") + public void testInsertMetadata_ThrowsNullPointerException() { + + // Arrange + String tablename = "table"; + String metadataTableName = "metadata_table"; + String metadata = "example_metadata"; + String documentDate = "Aug 01, 2023"; + + // Mock jdbcTemplate.queryForObject to return null + when(jdbcTemplate.queryForObject(anyString(), eq(UUID.class), any(Object[].class))) + .thenReturn(null); + + // Act and Assert + assertThrows( + NullPointerException.class, + () -> { + repository.insertMetadata(tablename, metadataTableName, metadata, documentDate); + }); + + // Verify that jdbcTemplate.queryForObject was called with the correct SQL query and arguments + verify(jdbcTemplate, times(1)) + .queryForObject(sqlQueryCaptor.capture(), eq(UUID.class), any(Object[].class)); + } + + @Test + @DisplayName("Insert entry into the join table") + public void testInsertIntoJoinTable() { + // Arrange + String id = UUID.randomUUID().toString(); + String metadataId = UUID.randomUUID().toString(); + when(postgresEndpoint.getTableName()).thenReturn("embedding_table"); + when(postgresEndpoint.getMetadataTableNames()) + .thenReturn(Collections.singletonList("metadata_table")); + when(postgresEndpoint.getId()).thenReturn(id); + when(postgresEndpoint.getMetadataId()).thenReturn(metadataId); + String joinTable = + postgresEndpoint.getTableName() + + "_join_" + + postgresEndpoint.getMetadataTableNames().get(0); + + // Act + repository.insertIntoJoinTable(postgresEndpoint); + + // Assert + verify(jdbcTemplate, times(1)).execute(sqlQueryCaptor.capture()); + + // Verify the captured query and actual query is same or not + String capturedQuery = sqlQueryCaptor.getValue(); + String expectedQuery = + String.format( + "INSERT INTO %s (id, metadata_id) VALUES ('%s', '%s') ON CONFLICT (id) DO UPDATE SET" + + " metadata_id = EXCLUDED.metadata_id;", + joinTable, postgresEndpoint.getId(), postgresEndpoint.getMetadataId()); + assertEquals(expectedQuery, capturedQuery); + } + + @Test + @DisplayName("Query with metadata") + public void testQueryWithMetadata() { + // Arrange + String tableName = "embedding_table"; + String metadataTableName = "metadata_table"; + String namespace = "example_namespace"; + int probes = 1; + PostgresDistanceMetric metric = PostgresDistanceMetric.L2; + List wordEmbeddingValues = List.of(0.1f, 0.2f, 0.3f); + WordEmbeddings wordEmbeddings = new WordEmbeddings("", wordEmbeddingValues); + int topK = 5; + String metadataId = UUID.randomUUID().toString(); + String id = UUID.randomUUID().toString(); + + // Mock queryForList method to return a dummy result + List> dummyResult = + List.of( + Map.of( + "id", + id, + "metadata", + "example_metadata", + "document_date", + "Aug 01, 2023", + "metadata_id", + metadataId, + "raw_text", + "example_raw_text", + "namespace", + "example_namespace", + "filename", + "example_filename", + "timestamp", + "example_timestamp", + "score", + 0.5)); + when(jdbcTemplate.queryForList(anyString())).thenReturn(dummyResult); + + // Act + List> result = + repository.queryWithMetadata( + tableName, + metadataTableName, + namespace, + probes, + metric, + wordEmbeddings.getValues(), + topK); + + // Assert + verify(jdbcTemplate).queryForList(sqlQueryCaptor.capture()); + assertEquals(dummyResult, result); + } +} diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/reactChain/ReactChainTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/reactChain/ReactChainTest.java index fc8de64ab..9d6ec81be 100644 --- a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/reactChain/ReactChainTest.java +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/reactChain/ReactChainTest.java @@ -1,6 +1,7 @@ package com.edgechain.reactChain; import com.edgechain.lib.jsonnet.JsonnetLoader; +import com.edgechain.lib.jsonnet.exceptions.JsonnetLoaderException; import com.edgechain.lib.jsonnet.impl.FileJsonnetLoader; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -9,8 +10,8 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertThrows; @SpringBootTest public class ReactChainTest { @@ -76,4 +77,48 @@ local callFunction(funcName) = assertNotNull(searchFunction); assertEquals(searchFunction, "udf.fn"); } + + @Test + @DisplayName("Test extractAction with invalid input") + void test_extractAction_WithInvalidJsonnet() throws Exception { + String inputJsonnet = "This is invalid jsonnet."; + InputStream inputStream = new ByteArrayInputStream(inputJsonnet.getBytes()); + JsonnetLoader jsonnetLoader = new FileJsonnetLoader(); + assertThrows(Exception.class, () -> jsonnetLoader.load(inputStream)); + } + + @Test + @DisplayName("Test extractAction with empty input") + void test_extractAction_withEmptyJsonnet() throws Exception { + String inputJsonnet = ""; + InputStream inputStream = new ByteArrayInputStream(inputJsonnet.getBytes()); + JsonnetLoader jsonnetLoader = new FileJsonnetLoader(); + assertThrows(Exception.class, () -> jsonnetLoader.get("action")); + assertThrows(Exception.class, () -> jsonnetLoader.load(inputStream)); + } + + @Test + @DisplayName("Test extractThought - invalid input") + void test_extractThought_WithInvalidInput() { + String inputJsonnet = "This is not a valid jsonnet pattern"; + InputStream inputStream = new ByteArrayInputStream(inputJsonnet.getBytes()); + JsonnetLoader jsonnetLoader = new FileJsonnetLoader(); + assertThrows(Exception.class, () -> jsonnetLoader.load(inputStream)); + } + + @Test + @DisplayName("Test Mapper - Missing function") + public void test_mapper_MissingFunction_ReturnedExpectedResult() { + String inputJsonnet = + """ + local config = { + "edgechains.config": { + "mapper": {}, + }, + }; + """; + InputStream inputStream = new ByteArrayInputStream(inputJsonnet.getBytes()); + JsonnetLoader jsonnetLoader = new FileJsonnetLoader(); + assertThrows(JsonnetLoaderException.class, () -> jsonnetLoader.load(inputStream)); + } } diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/testutil/PostgresTestContainer.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/testutil/PostgresTestContainer.java new file mode 100644 index 000000000..6feab846b --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/testutil/PostgresTestContainer.java @@ -0,0 +1,41 @@ +package com.edgechain.testutil; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testcontainers.containers.PostgreSQLContainer; +import org.testcontainers.utility.DockerImageName; + +public class PostgresTestContainer extends PostgreSQLContainer { + + public enum PostgresImage { + PLAIN, + VECTOR + }; + + private static final Logger LOGGER = LoggerFactory.getLogger(PostgresTestContainer.class); + + // private static final String DOCKER_IMAGE = PostgreSQLContainer.IMAGE + ":" + + // PostgreSQLContainer.DEFAULT_TAG; + + private static final DockerImageName IMAGE = DockerImageName.parse("postgres").withTag("14.5"); + + private static final DockerImageName VECTOR_IMAGE = + DockerImageName.parse("ankane/pgvector").asCompatibleSubstituteFor("postgres"); + + public PostgresTestContainer(PostgresImage img) { + super(img == PostgresImage.VECTOR ? VECTOR_IMAGE : IMAGE); + } + + @Override + public void start() { + LOGGER.info("starting container"); + super.start(); + LOGGER.info("TEST with Docker PostgreSQL url={}", getJdbcUrl()); + } + + @Override + public void stop() { + LOGGER.info("stopping container"); + super.stop(); + } +} diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/testutil/TestConfigSupport.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/testutil/TestConfigSupport.java new file mode 100644 index 000000000..78b605896 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/testutil/TestConfigSupport.java @@ -0,0 +1,77 @@ +package com.edgechain.testutil; + +import com.edgechain.lib.configuration.context.ApplicationContextHolder; +import com.edgechain.lib.retrofit.client.RetrofitClientInstance; +import org.modelmapper.ModelMapper; +import org.springframework.context.ApplicationContext; +import org.springframework.test.util.ReflectionTestUtils; +import retrofit2.Retrofit; +import static org.mockito.Mockito.mock; + +/** Two useful pairs of functions to set private static fields. */ +public final class TestConfigSupport { + + private ApplicationContext prevAppContext; + private String prevServerPort; + + /** + * Creates and forcefully uses a mock application context. Previous value is remembered. Call this + * once in a @BeforeEach setup method. + * + * @return a mock application context + */ + public ApplicationContext setupAppContext() { + prevAppContext = ApplicationContextHolder.getContext(); + + ApplicationContext mockAppContext = mock(ApplicationContext.class); + ReflectionTestUtils.setField(ApplicationContextHolder.class, "context", mockAppContext); + + return mockAppContext; + } + + /** + * Restore a previously saved application context. Call this once in an @AfterEach teardown + * method. + */ + public void tearDownAppContext() { + ReflectionTestUtils.setField(ApplicationContextHolder.class, "context", prevAppContext); + } + + /** + * Creates and forcefully uses a mock Retrofit instance. Call this once in a @BeforeEach setup + * method. + * + * @return a mock Retrofit instance + */ + public Retrofit setupRetrofit() { + Retrofit mockRetrofit = mock(Retrofit.class); + ReflectionTestUtils.setField(RetrofitClientInstance.class, "retrofit", mockRetrofit); + + // Retrofit needs a valid port + prevServerPort = System.getProperty("server.port"); + System.setProperty("server.port", "8888"); + + return mockRetrofit; + } + + private ModelMapper setupModelMapper() { + ModelMapper mockModelMapper = mock(ModelMapper.class); + ReflectionTestUtils.setField(ModelMapper.class, "modelMapper", mockModelMapper); + // Retrofit needs a valid port + prevServerPort = System.getProperty("server.port"); + System.setProperty("server.port", "8888"); + return mockModelMapper; + } + + /** + * Erases the current Retrofit instance so it can be recreated. Call this once in an @AfterEach + * teardown method. + */ + public void tearDownRetrofit() { + ReflectionTestUtils.setField(RetrofitClientInstance.class, "retrofit", null); + + if (prevServerPort != null) { + System.setProperty("server.port", prevServerPort); + } + } +} diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/testutil/TestJwtCreator.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/testutil/TestJwtCreator.java new file mode 100644 index 000000000..07a633fcf --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/testutil/TestJwtCreator.java @@ -0,0 +1,25 @@ +package com.edgechain.testutil; + +import com.auth0.jwt.JWT; +import com.auth0.jwt.algorithms.Algorithm; +import java.util.Date; + +public final class TestJwtCreator { + + private TestJwtCreator() { + // no + } + + public static String generate(String role) { + Algorithm algo = Algorithm.HMAC256(System.getProperty("jwt.secret").getBytes()); + Date d = new Date(); + return JWT.create() + .withSubject("example JWT for testing") + .withClaim("email", "admin@machine.local") + .withClaim("role", role) + .withIssuer("edgechain-tester") + .withIssuedAt(d) + .withExpiresAt(new Date(d.getTime() + 25000)) + .sign(algo); + } +} diff --git a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/wiki/WikiClientTest.java b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/wiki/WikiClientTest.java index 8d8b20a98..ec556317b 100644 --- a/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/wiki/WikiClientTest.java +++ b/Java/FlySpring/edgechain-app/src/test/java/com/edgechain/wiki/WikiClientTest.java @@ -1,19 +1,30 @@ package com.edgechain.wiki; -import com.edgechain.lib.endpoint.impl.WikiEndpoint; +import com.edgechain.lib.configuration.domain.SecurityUUID; +import com.edgechain.lib.endpoint.impl.wiki.WikiEndpoint; +import com.edgechain.lib.retrofit.client.RetrofitClientInstance; +import com.edgechain.lib.wiki.response.WikiResponse; import io.reactivex.rxjava3.observers.TestObserver; -import org.junit.jupiter.api.*; +import java.io.IOException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.TestMethodOrder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.test.context.SpringBootTest; -import static org.junit.jupiter.api.Assertions.*; - -import com.edgechain.lib.wiki.response.WikiResponse; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.util.ReflectionTestUtils; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -public class WikiClientTest { +class WikiClientTest { @LocalServerPort private int port; @@ -21,25 +32,36 @@ public class WikiClientTest { @BeforeEach public void setup() { - System.setProperty("server.port", "" + port); + System.setProperty("server.port", String.valueOf(port)); } @Test - @DisplayName("Test WikiContent Method Returns WikiResponse") - @Order(1) - public void wikiControllerTest_TestWikiContentMethod_ReturnsWikiResponse(TestInfo testInfo) + @DisplayName("Test WikiContent Method Handles Exception") + @DirtiesContext + void wikiControllerTest_TestWikiContentMethod_HandlesException(TestInfo testInfo) throws InterruptedException { + try { + // create a mock instance that will generate a non-IOException in the interceptor + SecurityUUID mockSecurityUUID = mock(SecurityUUID.class); + when(mockSecurityUUID.getAuthKey()).thenThrow(new RuntimeException("FORCED TEST EXCEPTION")); + ReflectionTestUtils.setField(RetrofitClientInstance.class, "securityUUID", mockSecurityUUID); + ReflectionTestUtils.setField(RetrofitClientInstance.class, "retrofit", null); - logger.info("======== " + testInfo.getDisplayName() + " ========"); + logger.info("======== {} ========", testInfo.getDisplayName()); - // Prepare test data - WikiEndpoint wikiEndpoint = new WikiEndpoint(); - TestObserver test = wikiEndpoint.getPageContent("Barack Obama").test(); + // Prepare test data + WikiEndpoint wikiEndpoint = new WikiEndpoint(); + TestObserver test = wikiEndpoint.getPageContent("Barack Obama").test(); - test.await(); + test.await(); - logger.info(test.values().toString()); + logger.info("{}", test.values().toString()); - test.assertNoErrors(); + test.assertError(IOException.class); + } finally { + // reset instance + ReflectionTestUtils.setField(RetrofitClientInstance.class, "securityUUID", null); + ReflectionTestUtils.setField(RetrofitClientInstance.class, "retrofit", null); + } } } diff --git a/Java/FlySpring/edgechain-app/src/test/java/resources/ChatCompletionRequest.json b/Java/FlySpring/edgechain-app/src/test/java/resources/ChatCompletionRequest.json index fe735f847..542a34b86 100644 --- a/Java/FlySpring/edgechain-app/src/test/java/resources/ChatCompletionRequest.json +++ b/Java/FlySpring/edgechain-app/src/test/java/resources/ChatCompletionRequest.json @@ -1,9 +1,18 @@ { - "model" : "gpt-3.5-turbo", - "temperature" : 0.7, - "messages" : [ { - "role" : "user", - "content" : "Can you write two unique sentences on Java Language?" - } ], - "stream" : false + "model": "gpt-3.5-turbo", + "temperature": 0.7, + "messages": [ + { + "role": "user", + "content": "Can you write two unique sentences on Java Language?" + } + ], + "stream": false, + "n": 1, + "stop": [], + "user": "", + "top_p": 1.0, + "presence_penalty": 0.0, + "frequency_penalty": 0.0, + "logit_bias": {} } \ No newline at end of file diff --git a/Java/FlySpring/edgechain-app/src/test/resources/logback-test.xml b/Java/FlySpring/edgechain-app/src/test/resources/logback-test.xml new file mode 100644 index 000000000..c050220c4 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/test/resources/logback-test.xml @@ -0,0 +1,18 @@ + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n + + + + + + + + + + + + + + diff --git a/Java/FlySpring/edgechain-app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/Java/FlySpring/edgechain-app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker new file mode 100644 index 000000000..1f0955d45 --- /dev/null +++ b/Java/FlySpring/edgechain-app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker @@ -0,0 +1 @@ +mock-maker-inline diff --git a/Java/FlySpring/flyfly/.DS_Store b/Java/FlySpring/flyfly/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..2ff3bf83d6059b4e152a28ec96b25e4bb42d42fd GIT binary patch literal 6148 zcmeHKy-EW?5S}rI9N46^P}nCB@&;!(dm*ibBmpgQxu9rawGUw-h_#*1VB>pOS@{rt zvoj&L=CBlz8QA@1=V#~cgWJ6!A|Bt&M?^y+Dlr6ElpYatuWQGG#mTbA;$k$Jwauz$ zlfP<`XD{f88oH%r{`?=OU0>7I^>oorVJqLCA3t{=-i~ws{73)lvcnD7f(+=Iu4vY+ z$_Mv%8&9|9%h}VqrsXy5rsB4@TaOQ4rJjp3;0!ne&VVx@4CpOH<(|{w3^)VMz&8fu zdZTSX^Zo6*ZmMnh&*j@1b?hHfIB})uvoqif-FTW v4H)MbA`%xxfk4lG0wp#KOYLVR)teu056*t$kO literal 0 HcmV?d00001 diff --git a/Java/FlySpring/flyfly/pom.xml b/Java/FlySpring/flyfly/pom.xml index aa917240b..957692182 100644 --- a/Java/FlySpring/flyfly/pom.xml +++ b/Java/FlySpring/flyfly/pom.xml @@ -1,87 +1,85 @@ - + 4.0.0 + - org.springframework.boot - spring-boot-starter-parent - 3.0.0 - + com.flyspring + edgechain-parent + 0.0.1-SNAPSHOT - com.flyspring + flyfly 0.0.1-SNAPSHOT flyfly flyfly CLI + - 17 + 3.3.9 - - - - org.testcontainers - testcontainers-bom - 1.17.6 - pom - import - - - info.picocli picocli-spring-boot-starter - 4.7.0 + ${picocli.version} + org.apache.commons commons-lang3 + commons-io commons-io - 2.11.0 + net.lingala.zip4j zip4j - 2.11.3 + ${zip4j.version} + org.zeroturnaround zt-exec - 1.12 + ${zeroturnaround.version} + org.apache.maven maven-model - 3.3.9 + ${maven-model.version} + org.projectlombok lombok - 1.18.20 - provided + true + org.testcontainers testcontainers - 1.17.6 + org.testcontainers mysql + - mysql - mysql-connector-java + com.mysql + mysql-connector-j org.testcontainers postgresql + org.postgresql postgresql @@ -91,10 +89,12 @@ org.testcontainers mariadb + org.mariadb.jdbc mariadb-java-client + org.springframework.boot spring-boot-starter-test @@ -103,19 +103,21 @@ + clean install org.springframework.boot spring-boot-maven-plugin + ${spring-boot.version} - com.flyspring.flyfly.FlyflyApplication - + com.flyspring.flyfly.FlyflyApplication + org.apache.maven.plugins maven-antrun-plugin - 1.8 + ${maven-antrun.version} download-and-unpack-jbang @@ -126,18 +128,20 @@ - + + dest="${project.build.directory}/jbang" /> - + + file="${project.build.directory}/jbang/jbang/bin/jbang.jar" + tofile="${project.basedir}/src/main/resources/jbang.jar" /> @@ -156,17 +160,21 @@ gofly + + true + maven-antrun-plugin - 3.1.0 + ${maven-antrun.version} package - + @@ -180,13 +188,4 @@ - - - - - - - - - diff --git a/Java/FlySpring/pom.xml b/Java/FlySpring/pom.xml new file mode 100644 index 000000000..46befc706 --- /dev/null +++ b/Java/FlySpring/pom.xml @@ -0,0 +1,102 @@ + + + 4.0.0 + + com.flyspring + edgechain-parent + pom + 0.0.1-SNAPSHOT + EdgeChain parent + Parent POM for EdgeChain + + + 17 + 17 + 17 + + UTF-8 + UTF-8 + + 3.4.1 + 3.1.0 + + 3.1.3 + + 2.7.0 + 2.11.0 + 4.7.0 + 1.2.1 + 1.19.0 + 0.0.7 + 1.12 + 2.11.3 + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + commons-io + commons-io + ${commons-io.version} + + + + org.testcontainers + testcontainers-bom + ${testcontainers.version} + pom + import + + + + org.testcontainers + testcontainers + ${testcontainers.version} + + + + org.testcontainers + junit-jupiter + ${testcontainers.version} + + + + org.testcontainers + mysql + ${testcontainers.version} + + + + org.testcontainers + postgresql + ${testcontainers.version} + + + + org.testcontainers + mariadb + ${testcontainers.version} + + + + + + autoroute + flyfly + edgechain-app + + + + clean install + + diff --git a/Java/FlySpring/readme.md b/Java/FlySpring/readme.md index 891fc9f00..02d5c69bb 100644 --- a/Java/FlySpring/readme.md +++ b/Java/FlySpring/readme.md @@ -1,14 +1,21 @@ # flyfly CLI + ## Installation & Usage + cd to autoroute directory -```console -mvn clean package -P gofly + +```bash +mvn clean package ``` + cd to flyfly directory -```console -mvn clean package -P gofly + +```bash +mvn clean package ``` + Now cd into Examples/starter :- flyfly is ready to roll! + ```bash java -jar flyfly.jar ``` @@ -16,10 +23,13 @@ java -jar flyfly.jar ## Commands ### run + Runs the Spring Boot application. if the project has jpa and a database driver(connector) in the build file and there is not 'spring.datasource.url' in the application.properties. Then the CLI will start a TestContainers database and add temporary values to application.properties to allow the application to run successfully. That's if the driver is supported by the CLI and Docker is installed. -Currently supported DBs are: MySQL, Postgres, and MariaDB. +Currently supported DBs are: MySQL, Postgres, and MariaDB. + ### format + Format the code using Spotless. P.S. - New examples will be added soon! \ No newline at end of file From 07d5e395a417c586b98b8e84c18dc006a50dd7cc Mon Sep 17 00:00:00 2001 From: Harsh4902 Date: Wed, 20 Dec 2023 14:47:21 +0530 Subject: [PATCH 2/3] ReAct example added. --- JS/edgechains/examples/react-chain/.gitignore | 8 + JS/edgechains/examples/react-chain/README.md | 13 + .../examples/react-chain/esbuild.build.js | 45 + .../examples/react-chain/ormconfig.json | 11 + .../examples/react-chain/package-lock.json | 8148 +++++++++++++++++ .../examples/react-chain/package.json | 49 + .../react-chain/src/ReactChain.test.ts | 7 + .../examples/react-chain/src/ReactChain.ts | 122 + .../examples/react-chain/src/index.ts | 13 + .../react-chain/src/react-chain.jsonnet | 87 + .../examples/react-chain/tsconfig.json | 17 + 11 files changed, 8520 insertions(+) create mode 100644 JS/edgechains/examples/react-chain/.gitignore create mode 100644 JS/edgechains/examples/react-chain/README.md create mode 100644 JS/edgechains/examples/react-chain/esbuild.build.js create mode 100644 JS/edgechains/examples/react-chain/ormconfig.json create mode 100644 JS/edgechains/examples/react-chain/package-lock.json create mode 100644 JS/edgechains/examples/react-chain/package.json create mode 100644 JS/edgechains/examples/react-chain/src/ReactChain.test.ts create mode 100644 JS/edgechains/examples/react-chain/src/ReactChain.ts create mode 100644 JS/edgechains/examples/react-chain/src/index.ts create mode 100644 JS/edgechains/examples/react-chain/src/react-chain.jsonnet create mode 100644 JS/edgechains/examples/react-chain/tsconfig.json diff --git a/JS/edgechains/examples/react-chain/.gitignore b/JS/edgechains/examples/react-chain/.gitignore new file mode 100644 index 000000000..03c61f409 --- /dev/null +++ b/JS/edgechains/examples/react-chain/.gitignore @@ -0,0 +1,8 @@ +# standard exclusions +node_modules + +# build artifacts +dist + +# environment files +.env diff --git a/JS/edgechains/examples/react-chain/README.md b/JS/edgechains/examples/react-chain/README.md new file mode 100644 index 000000000..5cd72d778 --- /dev/null +++ b/JS/edgechains/examples/react-chain/README.md @@ -0,0 +1,13 @@ +## How to run ReActChain:- + +- Use the following command in the root directory to run this example: + + `npm i` + + `npm run build` + + `npm start` + +- To use this example make a `POST` request call on `http://localhost:3000/react-chain`. +- Request body: + `{"prompt": "Your Search Topic"}` diff --git a/JS/edgechains/examples/react-chain/esbuild.build.js b/JS/edgechains/examples/react-chain/esbuild.build.js new file mode 100644 index 000000000..8da795c0e --- /dev/null +++ b/JS/edgechains/examples/react-chain/esbuild.build.js @@ -0,0 +1,45 @@ +const esbuild = require("esbuild"); +const path = require("path"); +const fs = require("fs"); +const { execSync } = require("child_process"); + +const outputDir = path.resolve(__dirname, "dist"); + +if (!fs.existsSync(outputDir)) { + fs.mkdirSync(outputDir); +} + +const distPath = path.join(process.cwd(), "dist"); + +fs.promises.mkdir(distPath, { recursive: true }); + +esbuild + .build({ + entryPoints: ["./src/index.ts"], + bundle: true, + minify: true, + platform: "node", + outfile: "./dist/index.js", + tsconfig: "./tsconfig.json", + target: "node21.1.0", + external: [ + "express", + "tsx", + "typescript", + "typeorm", + "react", + "react-dom", + "pg", + "jsdom", + "hono", + "@hanazuki/node-jsonnet", + "readline/promises", + ], + format: "cjs", + loader: { + ".html": "text", + ".css": "css", + ".jsonnet": "text", + }, + }) + .catch(() => process.exit(1)); diff --git a/JS/edgechains/examples/react-chain/ormconfig.json b/JS/edgechains/examples/react-chain/ormconfig.json new file mode 100644 index 000000000..21819c00f --- /dev/null +++ b/JS/edgechains/examples/react-chain/ormconfig.json @@ -0,0 +1,11 @@ +{ + "type": "postgres", + "host": "db.rmzqtepwnzoxgkkzjctt.supabase.co", + "port": 5432, + "username": "postgres", + "password": "xaX0MYcf1YiJlChK", + "database": "postgres", + "entities": ["dist/entities/**/*.js"], + "synchronize": false, + "logging": false +} diff --git a/JS/edgechains/examples/react-chain/package-lock.json b/JS/edgechains/examples/react-chain/package-lock.json new file mode 100644 index 000000000..82ba044ca --- /dev/null +++ b/JS/edgechains/examples/react-chain/package-lock.json @@ -0,0 +1,8148 @@ +{ + "name": "example", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "example", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "@hono/node-server": "^1.2.0", + "@types/dotenv": "^8.2.0", + "hono": "^3.9.2", + "pg": "^8.11.3", + "reflect-metadata": "^0.1.13", + "tsc": "^2.0.4", + "typescript": "^5.3.2" + }, + "devDependencies": { + "@arakoodev/edgechains.js": "0.1.10", + "@hanazuki/node-jsonnet": "^2.1.0", + "@types/jest": "^29.5.8", + "@types/node": "^20.9.4", + "@typescript-eslint/eslint-plugin": "^6.11.0", + "@typescript-eslint/parser": "^6.11.0", + "axios": "^1.6.2", + "dotenv": "^16.3.1", + "dts-bundle-generator": "^8.1.2", + "eslint": "^8.54.0", + "eslint-config-prettier": "^9.0.0", + "eslint-config-standard-with-typescript": "^40.0.0", + "eslint-plugin-import": "^2.29.0", + "eslint-plugin-n": "^16.3.1", + "eslint-plugin-promise": "^6.1.1", + "jest": "^29.7.0", + "prettier": "^3.1.0", + "react": "^18.2.0", + "ts-jest": "^29.1.1", + "tsx": "^3.12.2", + "typeorm": "^0.3.17", + "typescript": "^5.0.2" + } + }, + "node_modules/@aashutoshrathi/word-wrap": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", + "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/@ampproject/remapping": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", + "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@arakoodev/edgechains.js": { + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/@arakoodev/edgechains.js/-/edgechains.js-0.1.10.tgz", + "integrity": "sha512-QUzUpEc+nr+QNFvkD0+lvloo8R/pYWHsC99zY3IaGyL2fTuRi75BnR7RAwXKLKDjG8+Qng7K4+CzSaNrn+kcCw==", + "dev": true, + "dependencies": { + "@hono/node-server": "^1.2.0", + "@types/dotenv": "^8.2.0", + "axios": "^1.6.2", + "dotenv": "^16.3.1", + "hono": "^3.9.2", + "inquirer": "^9.2.12", + "prettier": "^3.1.0" + }, + "bin": { + "create-edgechains": "create-edgechains/scripts/create-edgechains.js" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.23.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.5.tgz", + "integrity": "sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==", + "dev": true, + "dependencies": { + "@babel/highlight": "^7.23.4", + "chalk": "^2.4.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/code-frame/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/code-frame/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "node_modules/@babel/code-frame/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@babel/code-frame/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/code-frame/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.23.5", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.23.5.tgz", + "integrity": "sha512-uU27kfDRlhfKl+w1U6vp16IuvSLtjAxdArVXPa9BvLkrr7CYIsxH5adpHObeAGY/41+syctUWOZ140a2Rvkgjw==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.6.tgz", + "integrity": "sha512-FxpRyGjrMJXh7X3wGLGhNDCRiwpWEF74sKjTLDJSG5Kyvow3QZaG0Adbqzi9ZrVjTWpsX+2cxWXD71NMg93kdw==", + "dev": true, + "dependencies": { + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.23.5", + "@babel/generator": "^7.23.6", + "@babel/helper-compilation-targets": "^7.23.6", + "@babel/helper-module-transforms": "^7.23.3", + "@babel/helpers": "^7.23.6", + "@babel/parser": "^7.23.6", + "@babel/template": "^7.22.15", + "@babel/traverse": "^7.23.6", + "@babel/types": "^7.23.6", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/core/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/generator": { + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.6.tgz", + "integrity": "sha512-qrSfCYxYQB5owCmGLbl8XRpX1ytXlpueOb0N0UmQwA073KZxejgQTzAmJezxvpwQD9uGtK2shHdi55QT+MbjIw==", + "dev": true, + "dependencies": { + "@babel/types": "^7.23.6", + "@jridgewell/gen-mapping": "^0.3.2", + "@jridgewell/trace-mapping": "^0.3.17", + "jsesc": "^2.5.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.23.6.tgz", + "integrity": "sha512-9JB548GZoQVmzrFgp8o7KxdgkTGm6xs9DW0o/Pim72UDjzr5ObUQ6ZzYPqA+g9OTS2bBQoctLJrky0RDCAWRgQ==", + "dev": true, + "dependencies": { + "@babel/compat-data": "^7.23.5", + "@babel/helper-validator-option": "^7.23.5", + "browserslist": "^4.22.2", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/helper-environment-visitor": { + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-function-name": { + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", + "dev": true, + "dependencies": { + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-hoist-variables": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz", + "integrity": "sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.22.15.tgz", + "integrity": "sha512-0pYVBnDKZO2fnSPCrgM/6WMc7eS20Fbok+0r88fp+YtWVLZrp4CkafFGIp+W0VKw4a22sgebPT99y+FDNMdP4w==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.15" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.23.3", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.23.3.tgz", + "integrity": "sha512-7bBs4ED9OmswdfDzpz4MpWgSrV7FXlc3zIagvLFjS5H+Mk7Snr21vQ6QwrsoCGMfNC4e4LQPdoULEt4ykz0SRQ==", + "dev": true, + "dependencies": { + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-module-imports": "^7.22.15", + "@babel/helper-simple-access": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/helper-validator-identifier": "^7.22.20" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz", + "integrity": "sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-simple-access": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz", + "integrity": "sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-split-export-declaration": { + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz", + "integrity": "sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==", + "dev": true, + "dependencies": { + "@babel/types": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz", + "integrity": "sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.23.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.23.5.tgz", + "integrity": "sha512-85ttAOMLsr53VgXkTbkx8oA6YTfT4q7/HzXSLEYmjcSTJPMPQtvq1BD79Byep5xMUYbGRzEpDsjUf3dyp54IKw==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.23.6.tgz", + "integrity": "sha512-wCfsbN4nBidDRhpDhvcKlzHWCTlgJYUUdSJfzXb2NuBssDSIjc3xcb+znA7l+zYsFljAcGM0aFkN40cR3lXiGA==", + "dev": true, + "dependencies": { + "@babel/template": "^7.22.15", + "@babel/traverse": "^7.23.6", + "@babel/types": "^7.23.6" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight": { + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.23.4.tgz", + "integrity": "sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==", + "dev": true, + "dependencies": { + "@babel/helper-validator-identifier": "^7.22.20", + "chalk": "^2.4.2", + "js-tokens": "^4.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/highlight/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "node_modules/@babel/highlight/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@babel/highlight/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/parser": { + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.6.tgz", + "integrity": "sha512-Z2uID7YJ7oNvAI20O9X0bblw7Qqs8Q2hFy0R9tAfnfLkp5MW0UH9eUvnDSnFwKZ0AvgS1ucqR4KzvVHgnke1VQ==", + "dev": true, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-syntax-async-generators": { + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", + "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-bigint": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz", + "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-properties": { + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", + "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.12.13" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-meta": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", + "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-json-strings": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", + "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.23.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.23.3.tgz", + "integrity": "sha512-EB2MELswq55OHUoRZLGg/zC7QWUKfNLpE57m/S2yr1uEneIgsTgrSzXP3NXEsMkVn76OlaVVnzN+ugObuYGwhg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-logical-assignment-operators": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", + "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", + "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-numeric-separator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", + "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-object-rest-spread": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", + "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-catch-binding": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", + "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-chaining": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", + "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-top-level-await": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", + "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-typescript": { + "version": "7.23.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.23.3.tgz", + "integrity": "sha512-9EiNjVJOMwCO+43TqoTrgQ8jMwcAd0sWyXi9RPfIsLTj4R2MADDDQXELhffaUx/uJv2AYcxBgPwH6j4TIA4ytQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.22.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/runtime": { + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.6.tgz", + "integrity": "sha512-zHd0eUrf5GZoOWVCXp6koAKQTfZV07eit6bGPmJgnZdnSAvvZee6zniW2XMF7Cmc4ISOOnPy3QaSiIJGJkVEDQ==", + "dev": true, + "dependencies": { + "regenerator-runtime": "^0.14.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/template": { + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.6.tgz", + "integrity": "sha512-czastdK1e8YByZqezMPFiZ8ahwVMh/ESl9vPgvgdB9AmFMGP5jfpFax74AQgl5zj4XHzqeYAg2l8PuUeRS1MgQ==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.23.5", + "@babel/generator": "^7.23.6", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", + "@babel/helper-hoist-variables": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.23.6", + "@babel/types": "^7.23.6", + "debug": "^4.3.1", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/types": { + "version": "7.23.6", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.6.tgz", + "integrity": "sha512-+uarb83brBzPKN38NX1MkB6vb6+mwvR6amUulqAE7ccQw1pEl+bCia9TbdG1lsnFP7lZySvUn37CHyXQdfTwzg==", + "dev": true, + "dependencies": { + "@babel/helper-string-parser": "^7.23.4", + "@babel/helper-validator-identifier": "^7.22.20", + "to-fast-properties": "^2.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true + }, + "node_modules/@esbuild/android-arm": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.18.20.tgz", + "integrity": "sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.18.20.tgz", + "integrity": "sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.18.20.tgz", + "integrity": "sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.18.20.tgz", + "integrity": "sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.18.20.tgz", + "integrity": "sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.18.20.tgz", + "integrity": "sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.18.20.tgz", + "integrity": "sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.18.20.tgz", + "integrity": "sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.18.20.tgz", + "integrity": "sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.18.20.tgz", + "integrity": "sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.18.20.tgz", + "integrity": "sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.18.20.tgz", + "integrity": "sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==", + "cpu": [ + "mips64el" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.18.20.tgz", + "integrity": "sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.18.20.tgz", + "integrity": "sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.18.20.tgz", + "integrity": "sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.18.20.tgz", + "integrity": "sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.18.20.tgz", + "integrity": "sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.18.20.tgz", + "integrity": "sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.18.20.tgz", + "integrity": "sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.18.20.tgz", + "integrity": "sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.18.20.tgz", + "integrity": "sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.18.20.tgz", + "integrity": "sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", + "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "dev": true, + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.6.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/js": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.56.0.tgz", + "integrity": "sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/@hanazuki/node-jsonnet": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@hanazuki/node-jsonnet/-/node-jsonnet-2.1.0.tgz", + "integrity": "sha512-eAky1kbhBNXeqCoPZbkXa6pASEYXgIY6WwszJiGctUCFaQpQcZlxIvRv+P96GiQ+P8mU1CTfVYqsjTIihG3UkA==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "bindings": "^1.5.0", + "cmake-js": "^7.0.0", + "node-addon-api": "^6.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@hono/node-server": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-1.3.3.tgz", + "integrity": "sha512-zD+TJvSBb5rqx5KSRlpoxNM3ESC8JU3pdecNZc2nK/TJSt88Ae/ko2nKnzYqX2IDegc+4hxLs8CW92B683C2VQ==", + "engines": { + "node": ">=18.14.1" + } + }, + "node_modules/@humanwhocodes/config-array": { + "version": "0.11.13", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.13.tgz", + "integrity": "sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ==", + "dev": true, + "dependencies": { + "@humanwhocodes/object-schema": "^2.0.1", + "debug": "^4.1.1", + "minimatch": "^3.0.5" + }, + "engines": { + "node": ">=10.10.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/object-schema": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz", + "integrity": "sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==", + "dev": true + }, + "node_modules/@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dev": true, + "dependencies": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@jest/console": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.7.0.tgz", + "integrity": "sha512-5Ni4CU7XHQi32IJ398EEP4RrB8eV09sXP2ROqD4bksHrnTree52PsxvX8tpL8LvTZ3pFzXyPbNQReSN41CAhOg==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/core": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.7.0.tgz", + "integrity": "sha512-n7aeXWKMnGtDA48y8TLWJPJmLmmZ642Ceo78cYWEpiD7FzDgmNDV/GCVRorPABdXLJZ/9wzzgZAlHjXjxDHGsg==", + "dev": true, + "dependencies": { + "@jest/console": "^29.7.0", + "@jest/reporters": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "jest-changed-files": "^29.7.0", + "jest-config": "^29.7.0", + "jest-haste-map": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-resolve-dependencies": "^29.7.0", + "jest-runner": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "jest-watcher": "^29.7.0", + "micromatch": "^4.0.4", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/environment": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.7.0.tgz", + "integrity": "sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw==", + "dev": true, + "dependencies": { + "@jest/fake-timers": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-mock": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.7.0.tgz", + "integrity": "sha512-8uMeAMycttpva3P1lBHB8VciS9V0XAr3GymPpipdyQXbBcuhkLQOSe8E/p92RyAdToS6ZD1tFkX+CkhoECE0dQ==", + "dev": true, + "dependencies": { + "expect": "^29.7.0", + "jest-snapshot": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect-utils": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.7.0.tgz", + "integrity": "sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==", + "dev": true, + "dependencies": { + "jest-get-type": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/fake-timers": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.7.0.tgz", + "integrity": "sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@sinonjs/fake-timers": "^10.0.2", + "@types/node": "*", + "jest-message-util": "^29.7.0", + "jest-mock": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/globals": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.7.0.tgz", + "integrity": "sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/expect": "^29.7.0", + "@jest/types": "^29.6.3", + "jest-mock": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/reporters": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-29.7.0.tgz", + "integrity": "sha512-DApq0KJbJOEzAFYjHADNNxAE3KbhxQB1y5Kplb5Waqw6zVbuWatSnMjE5gs8FUgEPmNsnZA3NCWl9NG0ia04Pg==", + "dev": true, + "dependencies": { + "@bcoe/v8-coverage": "^0.2.3", + "@jest/console": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "@types/node": "*", + "chalk": "^4.0.0", + "collect-v8-coverage": "^1.0.0", + "exit": "^0.1.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-instrument": "^6.0.0", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.0", + "istanbul-reports": "^3.1.3", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "slash": "^3.0.0", + "string-length": "^4.0.1", + "strip-ansi": "^6.0.0", + "v8-to-istanbul": "^9.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/source-map": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-29.6.3.tgz", + "integrity": "sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.18", + "callsites": "^3.0.0", + "graceful-fs": "^4.2.9" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-result": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-29.7.0.tgz", + "integrity": "sha512-Fdx+tv6x1zlkJPcWXmMDAG2HBnaR9XPSd5aDWQVsfrZmLVT3lU1cwyxLgRmXR9yrq4NBoEm9BMsfgFzTQAbJYA==", + "dev": true, + "dependencies": { + "@jest/console": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "collect-v8-coverage": "^1.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-sequencer": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-29.7.0.tgz", + "integrity": "sha512-GQwJ5WZVrKnOJuiYiAF52UNUJXgTZx1NHjFSEB0qEMmSZKAkdMoIzw/Cj6x6NF4AvV23AUqDpFzQkN/eYCYTxw==", + "dev": true, + "dependencies": { + "@jest/test-result": "^29.7.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/transform": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.7.0.tgz", + "integrity": "sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==", + "dev": true, + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "babel-plugin-istanbul": "^6.1.1", + "chalk": "^4.0.0", + "convert-source-map": "^2.0.0", + "fast-json-stable-stringify": "^2.1.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "micromatch": "^4.0.4", + "pirates": "^4.0.4", + "slash": "^3.0.0", + "write-file-atomic": "^4.0.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/types": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", + "dev": true, + "dependencies": { + "@jest/schemas": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", + "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", + "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.20", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz", + "integrity": "sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@ljharb/through": { + "version": "2.3.11", + "resolved": "https://registry.npmjs.org/@ljharb/through/-/through-2.3.11.tgz", + "integrity": "sha512-ccfcIDlogiXNq5KcbAwbaO7lMh3Tm1i3khMPYpxlK8hH/W53zN81KM9coerRLOnTGu3nfXIniAmQbRI9OxbC0w==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", + "dev": true + }, + "node_modules/@sinonjs/commons": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.0.tgz", + "integrity": "sha512-jXBtWAF4vmdNmZgD5FoKsVLv3rPgDnLgPbU84LIJ3otV44vJlDRokVng5v8NFJdCf/da9legHcKaRuZs4L7faA==", + "dev": true, + "dependencies": { + "type-detect": "4.0.8" + } + }, + "node_modules/@sinonjs/fake-timers": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", + "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", + "dev": true, + "dependencies": { + "@sinonjs/commons": "^3.0.0" + } + }, + "node_modules/@sqltools/formatter": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@sqltools/formatter/-/formatter-1.2.5.tgz", + "integrity": "sha512-Uy0+khmZqUrUGm5dmMqVlnvufZRSK0FbYzVgp0UMstm+F5+W2/jnEEQyc9vo1ZR/E5ZI/B1WjjoTqBqwJL6Krw==", + "dev": true + }, + "node_modules/@types/babel__core": { + "version": "7.20.5", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", + "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "node_modules/@types/babel__generator": { + "version": "7.6.8", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.8.tgz", + "integrity": "sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==", + "dev": true, + "dependencies": { + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__template": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz", + "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__traverse": { + "version": "7.20.4", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.4.tgz", + "integrity": "sha512-mSM/iKUk5fDDrEV/e83qY+Cr3I1+Q3qqTuEn++HAWYjEa1+NxZr6CNrcJGf2ZTnq4HoFGC3zaTPZTobCzCFukA==", + "dev": true, + "dependencies": { + "@babel/types": "^7.20.7" + } + }, + "node_modules/@types/dotenv": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@types/dotenv/-/dotenv-8.2.0.tgz", + "integrity": "sha512-ylSC9GhfRH7m1EUXBXofhgx4lUWmFeQDINW5oLuS+gxWdfUeW4zJdeVTYVkexEW+e2VUvlZR2kGnGGipAWR7kw==", + "deprecated": "This is a stub types definition. dotenv provides its own type definitions, so you do not need this installed.", + "dependencies": { + "dotenv": "*" + } + }, + "node_modules/@types/graceful-fs": { + "version": "4.1.9", + "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz", + "integrity": "sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/istanbul-lib-coverage": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", + "integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==", + "dev": true + }, + "node_modules/@types/istanbul-lib-report": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.3.tgz", + "integrity": "sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==", + "dev": true, + "dependencies": { + "@types/istanbul-lib-coverage": "*" + } + }, + "node_modules/@types/istanbul-reports": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.4.tgz", + "integrity": "sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==", + "dev": true, + "dependencies": { + "@types/istanbul-lib-report": "*" + } + }, + "node_modules/@types/jest": { + "version": "29.5.11", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.11.tgz", + "integrity": "sha512-S2mHmYIVe13vrm6q4kN6fLYYAka15ALQki/vgDC3mIukEOx8WJlv0kQPM+d4w8Gp6u0uSdKND04IlTXBv0rwnQ==", + "dev": true, + "dependencies": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + } + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true + }, + "node_modules/@types/json5": { + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", + "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", + "dev": true + }, + "node_modules/@types/node": { + "version": "20.10.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.5.tgz", + "integrity": "sha512-nNPsNE65wjMxEKI93yOP+NPGGBJz/PoN3kZsVLee0XMiJolxSekEVD8wRwBUBqkwc7UWop0edW50yrCQW4CyRw==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/semver": { + "version": "7.5.6", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.6.tgz", + "integrity": "sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==", + "dev": true + }, + "node_modules/@types/stack-utils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", + "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==", + "dev": true + }, + "node_modules/@types/yargs": { + "version": "17.0.32", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.32.tgz", + "integrity": "sha512-xQ67Yc/laOG5uMfX/093MRlGGCIBzZMarVa+gfNKJxWAIgykYpVGkBdbqEzGDDfCrVUj6Hiff4mTZ5BA6TmAog==", + "dev": true, + "dependencies": { + "@types/yargs-parser": "*" + } + }, + "node_modules/@types/yargs-parser": { + "version": "21.0.3", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.3.tgz", + "integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==", + "dev": true + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.15.0.tgz", + "integrity": "sha512-j5qoikQqPccq9QoBAupOP+CBu8BaJ8BLjaXSioDISeTZkVO3ig7oSIKh3H+rEpee7xCXtWwSB4KIL5l6hWZzpg==", + "dev": true, + "dependencies": { + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.15.0", + "@typescript-eslint/type-utils": "6.15.0", + "@typescript-eslint/utils": "6.15.0", + "@typescript-eslint/visitor-keys": "6.15.0", + "debug": "^4.3.4", + "graphemer": "^1.4.0", + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha", + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.15.0.tgz", + "integrity": "sha512-MkgKNnsjC6QwcMdlNAel24jjkEO/0hQaMDLqP4S9zq5HBAUJNQB6y+3DwLjX7b3l2b37eNAxMPLwb3/kh8VKdA==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "6.15.0", + "@typescript-eslint/types": "6.15.0", + "@typescript-eslint/typescript-estree": "6.15.0", + "@typescript-eslint/visitor-keys": "6.15.0", + "debug": "^4.3.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.15.0.tgz", + "integrity": "sha512-+BdvxYBltqrmgCNu4Li+fGDIkW9n//NrruzG9X1vBzaNK+ExVXPoGB71kneaVw/Jp+4rH/vaMAGC6JfMbHstVg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.15.0", + "@typescript-eslint/visitor-keys": "6.15.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.15.0.tgz", + "integrity": "sha512-CnmHKTfX6450Bo49hPg2OkIm/D/TVYV7jO1MCfPYGwf6x3GO0VU8YMO5AYMn+u3X05lRRxA4fWCz87GFQV6yVQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "6.15.0", + "@typescript-eslint/utils": "6.15.0", + "debug": "^4.3.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/types": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.15.0.tgz", + "integrity": "sha512-yXjbt//E4T/ee8Ia1b5mGlbNj9fB9lJP4jqLbZualwpP2BCQ5is6BcWwxpIsY4XKAhmdv3hrW92GdtJbatC6dQ==", + "dev": true, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.15.0.tgz", + "integrity": "sha512-7mVZJN7Hd15OmGuWrp2T9UvqR2Ecg+1j/Bp1jXUEY2GZKV6FXlOIoqVDmLpBiEiq3katvj/2n2mR0SDwtloCew==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.15.0", + "@typescript-eslint/visitor-keys": "6.15.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.15.0.tgz", + "integrity": "sha512-eF82p0Wrrlt8fQSRL0bGXzK5nWPRV2dYQZdajcfzOD9+cQz9O7ugifrJxclB+xVOvWvagXfqS4Es7vpLP4augw==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.15.0", + "@typescript-eslint/types": "6.15.0", + "@typescript-eslint/typescript-estree": "6.15.0", + "semver": "^7.5.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.15.0.tgz", + "integrity": "sha512-1zvtdC1a9h5Tb5jU9x3ADNXO9yjP8rXlaoChu0DQX40vf5ACVpYIVIZhIMZ6d5sDXH7vq4dsZBT1fEGj8D2n2w==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.15.0", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@ungap/structured-clone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", + "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", + "dev": true + }, + "node_modules/acorn": { + "version": "8.11.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz", + "integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-escapes": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", + "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.21.3" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ansi-escapes/node_modules/type-fest": { + "version": "0.21.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", + "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", + "dev": true + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/app-root-path": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/app-root-path/-/app-root-path-3.1.0.tgz", + "integrity": "sha512-biN3PwB2gUtjaYy/isrU3aNWI5w+fAfvHkSvCKeQGxhmYpwKFUxudR3Yya+KqVRHBmEDYh+/lTozYCFbmzX4nA==", + "dev": true, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/aproba": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", + "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==", + "dev": true + }, + "node_modules/are-we-there-yet": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-3.0.1.tgz", + "integrity": "sha512-QZW4EDmGwlYur0Yyf/b2uGucHQMa8aFUP7eu9ddR73vvhFyt4V0Vl3QHPcTNJ8l6qYOBdxgXdnBXQrHilfRQBg==", + "dev": true, + "dependencies": { + "delegates": "^1.0.0", + "readable-stream": "^3.6.0" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "node_modules/array-buffer-byte-length": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz", + "integrity": "sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "is-array-buffer": "^3.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array-includes": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.7.tgz", + "integrity": "sha512-dlcsNBIiWhPkHdOEEKnehA+RNUWDc4UqFtnIXU4uuYDPtA4LDkr7qip2p0VvFAEXNDr0yWZ9PJyIRiGjRLQzwQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "get-intrinsic": "^1.2.1", + "is-string": "^1.0.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/array.prototype.findlastindex": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/array.prototype.findlastindex/-/array.prototype.findlastindex-1.2.3.tgz", + "integrity": "sha512-LzLoiOMAxvy+Gd3BAq3B7VeIgPdo+Q8hthvKtXybMvRV0jrXfJM/t8mw7nNlpEcVlVUnCnM2KSX4XU5HmpodOA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "es-shim-unscopables": "^1.0.0", + "get-intrinsic": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.flat": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.2.tgz", + "integrity": "sha512-djYB+Zx2vLewY8RWlNCUdHjDXs2XOgm602S9E7P/UpHgfeHL00cRiIF+IN/G/aUJ7kGPb6yO/ErDI5V2s8iycA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "es-shim-unscopables": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.flatmap": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/array.prototype.flatmap/-/array.prototype.flatmap-1.3.2.tgz", + "integrity": "sha512-Ewyx0c9PmpcsByhSW4r+9zDU7sGjFc86qf/kKtuSCRdhfbk0SNLLkaT5qvcHnRGgc5NP/ly/y+qkXkqONX54CQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "es-shim-unscopables": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/arraybuffer.prototype.slice": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.2.tgz", + "integrity": "sha512-yMBKppFur/fbHu9/6USUe03bZ4knMYiwFBcyiaXB8Go0qNehwX6inYPzK9U0NeQvGxKthcmHcaR8P5MStSRBAw==", + "dev": true, + "dependencies": { + "array-buffer-byte-length": "^1.0.0", + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "get-intrinsic": "^1.2.1", + "is-array-buffer": "^3.0.2", + "is-shared-array-buffer": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true + }, + "node_modules/available-typed-arrays": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", + "integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/axios": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", + "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", + "dev": true, + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/babel-jest": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz", + "integrity": "sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==", + "dev": true, + "dependencies": { + "@jest/transform": "^29.7.0", + "@types/babel__core": "^7.1.14", + "babel-plugin-istanbul": "^6.1.1", + "babel-preset-jest": "^29.6.3", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.8.0" + } + }, + "node_modules/babel-plugin-istanbul": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", + "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0", + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-instrument": "^5.0.4", + "test-exclude": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-istanbul/node_modules/istanbul-lib-instrument": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz", + "integrity": "sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==", + "dev": true, + "dependencies": { + "@babel/core": "^7.12.3", + "@babel/parser": "^7.14.7", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-istanbul/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/babel-plugin-jest-hoist": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.6.3.tgz", + "integrity": "sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg==", + "dev": true, + "dependencies": { + "@babel/template": "^7.3.3", + "@babel/types": "^7.3.3", + "@types/babel__core": "^7.1.14", + "@types/babel__traverse": "^7.0.6" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/babel-preset-current-node-syntax": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz", + "integrity": "sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==", + "dev": true, + "dependencies": { + "@babel/plugin-syntax-async-generators": "^7.8.4", + "@babel/plugin-syntax-bigint": "^7.8.3", + "@babel/plugin-syntax-class-properties": "^7.8.3", + "@babel/plugin-syntax-import-meta": "^7.8.3", + "@babel/plugin-syntax-json-strings": "^7.8.3", + "@babel/plugin-syntax-logical-assignment-operators": "^7.8.3", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", + "@babel/plugin-syntax-numeric-separator": "^7.8.3", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", + "@babel/plugin-syntax-optional-chaining": "^7.8.3", + "@babel/plugin-syntax-top-level-await": "^7.8.3" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/babel-preset-jest": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-29.6.3.tgz", + "integrity": "sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA==", + "dev": true, + "dependencies": { + "babel-plugin-jest-hoist": "^29.6.3", + "babel-preset-current-node-syntax": "^1.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "dev": true, + "dependencies": { + "file-uri-to-path": "1.0.0" + } + }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "dev": true, + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.22.2", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.2.tgz", + "integrity": "sha512-0UgcrvQmBDvZHFGdYUehrCNIazki7/lUP3kkoi/r3YB2amZbFM9J43ZRkJTXBUZK4gmx56+Sqk9+Vs9mwZx9+A==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "caniuse-lite": "^1.0.30001565", + "electron-to-chromium": "^1.4.601", + "node-releases": "^2.0.14", + "update-browserslist-db": "^1.0.13" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/bs-logger": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz", + "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", + "dev": true, + "dependencies": { + "fast-json-stable-stringify": "2.x" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/bser": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", + "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", + "dev": true, + "dependencies": { + "node-int64": "^0.4.0" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, + "node_modules/buffer-writer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz", + "integrity": "sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw==", + "engines": { + "node": ">=4" + } + }, + "node_modules/builtin-modules": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", + "dev": true, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/builtins": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/builtins/-/builtins-5.0.1.tgz", + "integrity": "sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==", + "dev": true, + "dependencies": { + "semver": "^7.0.0" + } + }, + "node_modules/call-bind": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.5.tgz", + "integrity": "sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.1", + "set-function-length": "^1.1.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001570", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001570.tgz", + "integrity": "sha512-+3e0ASu4sw1SWaoCtvPeyXp+5PsjigkSt8OXZbF9StH5pQWbxEjLAZE3n8Aup5udop1uRiKA7a4utUk/uoSpUw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ] + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/char-regex": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", + "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/chardet": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", + "dev": true + }, + "node_modules/chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/ci-info": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", + "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "engines": { + "node": ">=8" + } + }, + "node_modules/cjs-module-lexer": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.3.tgz", + "integrity": "sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ==", + "dev": true + }, + "node_modules/cli-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", + "dev": true, + "dependencies": { + "restore-cursor": "^3.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cli-highlight": { + "version": "2.1.11", + "resolved": "https://registry.npmjs.org/cli-highlight/-/cli-highlight-2.1.11.tgz", + "integrity": "sha512-9KDcoEVwyUXrjcJNvHD0NFc/hiwe/WPVYIleQh2O1N2Zro5gWJZ/K+3DGn8w8P/F6FxOgzyC5bxDyHIgCSPhGg==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "highlight.js": "^10.7.1", + "mz": "^2.4.0", + "parse5": "^5.1.1", + "parse5-htmlparser2-tree-adapter": "^6.0.0", + "yargs": "^16.0.0" + }, + "bin": { + "highlight": "bin/highlight" + }, + "engines": { + "node": ">=8.0.0", + "npm": ">=5.0.0" + } + }, + "node_modules/cli-highlight/node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/cli-highlight/node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/cli-highlight/node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/cli-highlight/node_modules/yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/cli-spinners": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", + "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==", + "dev": true, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/cli-width": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz", + "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==", + "dev": true, + "engines": { + "node": ">= 12" + } + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/cliui/node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/clone": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", + "integrity": "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==", + "dev": true, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/cmake-js": { + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/cmake-js/-/cmake-js-7.2.1.tgz", + "integrity": "sha512-AdPSz9cSIJWdKvm0aJgVu3X8i0U3mNTswJkSHzZISqmYVjZk7Td4oDFg0mCBA383wO+9pG5Ix7pEP1CZH9x2BA==", + "dev": true, + "dependencies": { + "axios": "^1.3.2", + "debug": "^4", + "fs-extra": "^10.1.0", + "lodash.isplainobject": "^4.0.6", + "memory-stream": "^1.0.0", + "node-api-headers": "^0.0.2", + "npmlog": "^6.0.2", + "rc": "^1.2.7", + "semver": "^7.3.8", + "tar": "^6.1.11", + "url-join": "^4.0.1", + "which": "^2.0.2", + "yargs": "^17.6.0" + }, + "bin": { + "cmake-js": "bin/cmake-js" + }, + "engines": { + "node": ">= 14.15.0" + } + }, + "node_modules/co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", + "dev": true, + "engines": { + "iojs": ">= 1.0.0", + "node": ">= 0.12.0" + } + }, + "node_modules/collect-v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz", + "integrity": "sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==", + "dev": true + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/color-support": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", + "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", + "dev": true, + "bin": { + "color-support": "bin.js" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==", + "dev": true + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true + }, + "node_modules/create-jest": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz", + "integrity": "sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "jest-config": "^29.7.0", + "jest-util": "^29.7.0", + "prompts": "^2.0.1" + }, + "bin": { + "create-jest": "bin/create-jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/date-fns": { + "version": "2.30.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz", + "integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.21.0" + }, + "engines": { + "node": ">=0.11" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/date-fns" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/dedent": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.1.tgz", + "integrity": "sha512-+LxW+KLWxu3HW3M2w2ympwtqPrqYRzU8fqi6Fhd18fBALe15blJPI/I4+UHveMVG6lJqB4JNd4UG0S5cnVHwIg==", + "dev": true, + "peerDependencies": { + "babel-plugin-macros": "^3.1.0" + }, + "peerDependenciesMeta": { + "babel-plugin-macros": { + "optional": true + } + } + }, + "node_modules/deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", + "dev": true, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/defaults": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", + "integrity": "sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==", + "dev": true, + "dependencies": { + "clone": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/define-data-property": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz", + "integrity": "sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.2.1", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "dev": true, + "dependencies": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==", + "dev": true + }, + "node_modules/detect-newline": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", + "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/diff-sequences": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", + "integrity": "sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "dependencies": { + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/dotenv": { + "version": "16.3.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/motdotla/dotenv?sponsor=1" + } + }, + "node_modules/dts-bundle-generator": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/dts-bundle-generator/-/dts-bundle-generator-8.1.2.tgz", + "integrity": "sha512-/yvy9Xw0cfFodA8n6jEq8/COZ/WXgJtPabnLBAzIfP/TfxWbD/0a0dvfqNHneNqswQrH0kUcaAfGJC9UNvH97w==", + "dev": true, + "dependencies": { + "typescript": ">=5.0.2", + "yargs": "^17.6.0" + }, + "bin": { + "dts-bundle-generator": "dist/bin/dts-bundle-generator.js" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/electron-to-chromium": { + "version": "1.4.615", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.615.tgz", + "integrity": "sha512-/bKPPcgZVUziECqDc+0HkT87+0zhaWSZHNXqF8FLd2lQcptpmUFwoCSWjCdOng9Gdq+afKArPdEg/0ZW461Eng==", + "dev": true + }, + "node_modules/emittery": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.13.1.tgz", + "integrity": "sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sindresorhus/emittery?sponsor=1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "dependencies": { + "is-arrayish": "^0.2.1" + } + }, + "node_modules/es-abstract": { + "version": "1.22.3", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.22.3.tgz", + "integrity": "sha512-eiiY8HQeYfYH2Con2berK+To6GrK2RxbPawDkGq4UiCQQfZHb6wX9qQqkbpPqaxQFcl8d9QzZqo0tGE0VcrdwA==", + "dev": true, + "dependencies": { + "array-buffer-byte-length": "^1.0.0", + "arraybuffer.prototype.slice": "^1.0.2", + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.5", + "es-set-tostringtag": "^2.0.1", + "es-to-primitive": "^1.2.1", + "function.prototype.name": "^1.1.6", + "get-intrinsic": "^1.2.2", + "get-symbol-description": "^1.0.0", + "globalthis": "^1.0.3", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0", + "internal-slot": "^1.0.5", + "is-array-buffer": "^3.0.2", + "is-callable": "^1.2.7", + "is-negative-zero": "^2.0.2", + "is-regex": "^1.1.4", + "is-shared-array-buffer": "^1.0.2", + "is-string": "^1.0.7", + "is-typed-array": "^1.1.12", + "is-weakref": "^1.0.2", + "object-inspect": "^1.13.1", + "object-keys": "^1.1.1", + "object.assign": "^4.1.4", + "regexp.prototype.flags": "^1.5.1", + "safe-array-concat": "^1.0.1", + "safe-regex-test": "^1.0.0", + "string.prototype.trim": "^1.2.8", + "string.prototype.trimend": "^1.0.7", + "string.prototype.trimstart": "^1.0.7", + "typed-array-buffer": "^1.0.0", + "typed-array-byte-length": "^1.0.0", + "typed-array-byte-offset": "^1.0.0", + "typed-array-length": "^1.0.4", + "unbox-primitive": "^1.0.2", + "which-typed-array": "^1.1.13" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.2.tgz", + "integrity": "sha512-BuDyupZt65P9D2D2vA/zqcI3G5xRsklm5N3xCwuiy+/vKy8i0ifdsQP1sLgO4tZDSCaQUSnmC48khknGMV3D2Q==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.2.2", + "has-tostringtag": "^1.0.0", + "hasown": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-shim-unscopables": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.2.tgz", + "integrity": "sha512-J3yBRXCzDu4ULnQwxyToo/OjdMx6akgVC7K6few0a7F/0wLtmKKN7I73AH5T2836UuXRqN7Qg+IIUw/+YJksRw==", + "dev": true, + "dependencies": { + "hasown": "^2.0.0" + } + }, + "node_modules/es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "dependencies": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/esbuild": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.18.20.tgz", + "integrity": "sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==", + "dev": true, + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/android-arm": "0.18.20", + "@esbuild/android-arm64": "0.18.20", + "@esbuild/android-x64": "0.18.20", + "@esbuild/darwin-arm64": "0.18.20", + "@esbuild/darwin-x64": "0.18.20", + "@esbuild/freebsd-arm64": "0.18.20", + "@esbuild/freebsd-x64": "0.18.20", + "@esbuild/linux-arm": "0.18.20", + "@esbuild/linux-arm64": "0.18.20", + "@esbuild/linux-ia32": "0.18.20", + "@esbuild/linux-loong64": "0.18.20", + "@esbuild/linux-mips64el": "0.18.20", + "@esbuild/linux-ppc64": "0.18.20", + "@esbuild/linux-riscv64": "0.18.20", + "@esbuild/linux-s390x": "0.18.20", + "@esbuild/linux-x64": "0.18.20", + "@esbuild/netbsd-x64": "0.18.20", + "@esbuild/openbsd-x64": "0.18.20", + "@esbuild/sunos-x64": "0.18.20", + "@esbuild/win32-arm64": "0.18.20", + "@esbuild/win32-ia32": "0.18.20", + "@esbuild/win32-x64": "0.18.20" + } + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.56.0.tgz", + "integrity": "sha512-Go19xM6T9puCOWntie1/P997aXxFsOi37JIHRWI514Hc6ZnaHGKY9xFhrU65RT6CcBEzZoGG1e6Nq+DT04ZtZQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.56.0", + "@humanwhocodes/config-array": "^0.11.13", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "@ungap/structured-clone": "^1.2.0", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", + "esquery": "^1.4.2", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "graphemer": "^1.4.0", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-yaml": "^4.1.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "strip-ansi": "^6.0.1", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-compat-utils": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/eslint-compat-utils/-/eslint-compat-utils-0.1.2.tgz", + "integrity": "sha512-Jia4JDldWnFNIru1Ehx1H5s9/yxiRHY/TimCuUc0jNexew3cF1gI6CYZil1ociakfWO3rRqFjl1mskBblB3RYg==", + "dev": true, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "eslint": ">=6.0.0" + } + }, + "node_modules/eslint-config-prettier": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", + "dev": true, + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, + "node_modules/eslint-config-standard": { + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-17.1.0.tgz", + "integrity": "sha512-IwHwmaBNtDK4zDHQukFDW5u/aTb8+meQWZvNFWkiGmbWjD6bqyuSSBxxXKkCftCUzc1zwCH2m/baCNDLGmuO5Q==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "eslint": "^8.0.1", + "eslint-plugin-import": "^2.25.2", + "eslint-plugin-n": "^15.0.0 || ^16.0.0 ", + "eslint-plugin-promise": "^6.0.0" + } + }, + "node_modules/eslint-config-standard-with-typescript": { + "version": "40.0.0", + "resolved": "https://registry.npmjs.org/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-40.0.0.tgz", + "integrity": "sha512-GXUJcwIXiTQaS3H4etv8a1lejVVdZYaxZNz3g7vt6GoJosQqMTurbmSC4FVGyHiGT/d1TjFr3+47A3xsHhsG+Q==", + "dev": true, + "dependencies": { + "@typescript-eslint/parser": "^6.4.0", + "eslint-config-standard": "17.1.0" + }, + "peerDependencies": { + "@typescript-eslint/eslint-plugin": "^6.4.0", + "eslint": "^8.0.1", + "eslint-plugin-import": "^2.25.2", + "eslint-plugin-n": "^15.0.0 || ^16.0.0 ", + "eslint-plugin-promise": "^6.0.0", + "typescript": "*" + } + }, + "node_modules/eslint-import-resolver-node": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", + "integrity": "sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==", + "dev": true, + "dependencies": { + "debug": "^3.2.7", + "is-core-module": "^2.13.0", + "resolve": "^1.22.4" + } + }, + "node_modules/eslint-import-resolver-node/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-module-utils": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.8.0.tgz", + "integrity": "sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==", + "dev": true, + "dependencies": { + "debug": "^3.2.7" + }, + "engines": { + "node": ">=4" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, + "node_modules/eslint-module-utils/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-es-x": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-es-x/-/eslint-plugin-es-x-7.5.0.tgz", + "integrity": "sha512-ODswlDSO0HJDzXU0XvgZ3lF3lS3XAZEossh15Q2UHjwrJggWeBoKqqEsLTZLXl+dh5eOAozG0zRcYtuE35oTuQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.1.2", + "@eslint-community/regexpp": "^4.6.0", + "eslint-compat-utils": "^0.1.2" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ota-meshi" + }, + "peerDependencies": { + "eslint": ">=8" + } + }, + "node_modules/eslint-plugin-import": { + "version": "2.29.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.29.1.tgz", + "integrity": "sha512-BbPC0cuExzhiMo4Ff1BTVwHpjjv28C5R+btTOGaCRC7UEz801up0JadwkeSk5Ued6TG34uaczuVuH6qyy5YUxw==", + "dev": true, + "dependencies": { + "array-includes": "^3.1.7", + "array.prototype.findlastindex": "^1.2.3", + "array.prototype.flat": "^1.3.2", + "array.prototype.flatmap": "^1.3.2", + "debug": "^3.2.7", + "doctrine": "^2.1.0", + "eslint-import-resolver-node": "^0.3.9", + "eslint-module-utils": "^2.8.0", + "hasown": "^2.0.0", + "is-core-module": "^2.13.1", + "is-glob": "^4.0.3", + "minimatch": "^3.1.2", + "object.fromentries": "^2.0.7", + "object.groupby": "^1.0.1", + "object.values": "^1.1.7", + "semver": "^6.3.1", + "tsconfig-paths": "^3.15.0" + }, + "engines": { + "node": ">=4" + }, + "peerDependencies": { + "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" + } + }, + "node_modules/eslint-plugin-import/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-import/node_modules/doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/eslint-plugin-import/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/eslint-plugin-n": { + "version": "16.4.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-16.4.0.tgz", + "integrity": "sha512-IkqJjGoWYGskVaJA7WQuN8PINIxc0N/Pk/jLeYT4ees6Fo5lAhpwGsYek6gS9tCUxgDC4zJ+OwY2bY/6/9OMKQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "builtins": "^5.0.1", + "eslint-plugin-es-x": "^7.5.0", + "get-tsconfig": "^4.7.0", + "ignore": "^5.2.4", + "is-builtin-module": "^3.2.1", + "is-core-module": "^2.12.1", + "minimatch": "^3.1.2", + "resolve": "^1.22.2", + "semver": "^7.5.3" + }, + "engines": { + "node": ">=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, + "node_modules/eslint-plugin-promise": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.1.1.tgz", + "integrity": "sha512-tjqWDwVZQo7UIPMeDReOpUgHCmCiH+ePnVT+5zVapL0uuHnegBUs2smM13CzOs2Xb5+MHMRFTs9v24yjba4Oig==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/eslint-scope": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "dev": true, + "dependencies": { + "acorn": "^8.9.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/esquery": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", + "dev": true, + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/expect": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.7.0.tgz", + "integrity": "sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw==", + "dev": true, + "dependencies": { + "@jest/expect-utils": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/external-editor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", + "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", + "dev": true, + "dependencies": { + "chardet": "^0.7.0", + "iconv-lite": "^0.4.24", + "tmp": "^0.0.33" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "node_modules/fast-glob": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true + }, + "node_modules/fastq": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.16.0.tgz", + "integrity": "sha512-ifCoaXsDrsdkWTtiNJX5uzHDsrck5TzfKKDcuFFTIrrc/BS076qgEIfoIy1VeZqViznfKiysPYTh/QeHtnIsYA==", + "dev": true, + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/fb-watchman": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", + "integrity": "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==", + "dev": true, + "dependencies": { + "bser": "2.1.1" + } + }, + "node_modules/figures": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-5.0.0.tgz", + "integrity": "sha512-ej8ksPF4x6e5wvK9yevct0UCXh8TTFlWGVLlgjZuoBH1HwjIfKE/IdL5mq89sFA7zELi1VhKpmtDnrs7zWyeyg==", + "dev": true, + "dependencies": { + "escape-string-regexp": "^5.0.0", + "is-unicode-supported": "^1.2.0" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/figures/node_modules/escape-string-regexp": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", + "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/file-entry-cache": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "dev": true, + "dependencies": { + "flat-cache": "^3.0.4" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "dev": true + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", + "integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==", + "dev": true, + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.3", + "rimraf": "^3.0.2" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/flatted": { + "version": "3.2.9", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.9.tgz", + "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==", + "dev": true + }, + "node_modules/follow-redirects": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", + "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/for-each": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", + "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", + "dev": true, + "dependencies": { + "is-callable": "^1.1.3" + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/fs-minipass/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fs-minipass/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/function.prototype.name": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.6.tgz", + "integrity": "sha512-Z5kx79swU5P27WEayXM1tBi5Ze/lbIyiNgU3qyXUOf9b2rgXYyF9Dy9Cx+IQv/Lc8WCG6L82zwUPpSS9hGehIg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "functions-have-names": "^1.2.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gauge": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.4.tgz", + "integrity": "sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==", + "dev": true, + "dependencies": { + "aproba": "^1.0.3 || ^2.0.0", + "color-support": "^1.1.3", + "console-control-strings": "^1.1.0", + "has-unicode": "^2.0.1", + "signal-exit": "^3.0.7", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "wide-align": "^1.1.5" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-intrinsic": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz", + "integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/get-symbol-description": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz", + "integrity": "sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-tsconfig": { + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.7.2.tgz", + "integrity": "sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A==", + "dev": true, + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/globals": { + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/globalthis": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz", + "integrity": "sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==", + "dev": true, + "dependencies": { + "define-properties": "^1.1.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/globby": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, + "dependencies": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true + }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, + "node_modules/has-bigints": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", + "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", + "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.2.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", + "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", + "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", + "dev": true, + "dependencies": { + "has-symbols": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==", + "dev": true + }, + "node_modules/hasown": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", + "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/highlight.js": { + "version": "10.7.3", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz", + "integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/hono": { + "version": "3.11.8", + "resolved": "https://registry.npmjs.org/hono/-/hono-3.11.8.tgz", + "integrity": "sha512-s+7FDN0CS0lAvooyj4oQw0PyEec7I+YuVg40gtFHuUrfHBEhKITrLu4dskTdeYn0Xvhbz7s4yRJebJx6gCN/5Q==", + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "dev": true, + "engines": { + "node": ">=10.17.0" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/ignore": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.0.tgz", + "integrity": "sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/import-local": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", + "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", + "dev": true, + "dependencies": { + "pkg-dir": "^4.2.0", + "resolve-cwd": "^3.0.0" + }, + "bin": { + "import-local-fixture": "fixtures/cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", + "dev": true + }, + "node_modules/inquirer": { + "version": "9.2.12", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-9.2.12.tgz", + "integrity": "sha512-mg3Fh9g2zfuVWJn6lhST0O7x4n03k7G8Tx5nvikJkbq8/CK47WDVm+UznF0G6s5Zi0KcyUisr6DU8T67N5U+1Q==", + "dev": true, + "dependencies": { + "@ljharb/through": "^2.3.11", + "ansi-escapes": "^4.3.2", + "chalk": "^5.3.0", + "cli-cursor": "^3.1.0", + "cli-width": "^4.1.0", + "external-editor": "^3.1.0", + "figures": "^5.0.0", + "lodash": "^4.17.21", + "mute-stream": "1.0.0", + "ora": "^5.4.1", + "run-async": "^3.0.0", + "rxjs": "^7.8.1", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^6.2.0" + }, + "engines": { + "node": ">=14.18.0" + } + }, + "node_modules/inquirer/node_modules/chalk": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", + "dev": true, + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/internal-slot": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.6.tgz", + "integrity": "sha512-Xj6dv+PsbtwyPpEflsejS+oIZxmMlV44zAhG479uYu89MsjcYOhCFnNyKrkJrihbsiasQyY0afoCl/9BLR65bg==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.2.2", + "hasown": "^2.0.0", + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-array-buffer": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.2.tgz", + "integrity": "sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.2.0", + "is-typed-array": "^1.1.10" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "dev": true + }, + "node_modules/is-bigint": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", + "integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==", + "dev": true, + "dependencies": { + "has-bigints": "^1.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-boolean-object": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", + "integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-builtin-module": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz", + "integrity": "sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==", + "dev": true, + "dependencies": { + "builtin-modules": "^3.3.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-core-module": { + "version": "2.13.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz", + "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", + "dev": true, + "dependencies": { + "hasown": "^2.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-date-object": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz", + "integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==", + "dev": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-generator-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", + "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-interactive": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", + "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-negative-zero": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz", + "integrity": "sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-number-object": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", + "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", + "dev": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-regex": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", + "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-shared-array-buffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz", + "integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-string": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz", + "integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==", + "dev": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-symbol": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", + "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", + "dev": true, + "dependencies": { + "has-symbols": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-typed-array": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.12.tgz", + "integrity": "sha512-Z14TF2JNG8Lss5/HMqt0//T9JeHXttXy5pH/DBU4vi98ozO2btxzq9MwYDZYnKwU8nRsz/+GVFVRDq3DkVuSPg==", + "dev": true, + "dependencies": { + "which-typed-array": "^1.1.11" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-unicode-supported": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-1.3.0.tgz", + "integrity": "sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-weakref": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", + "integrity": "sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "dev": true + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-instrument": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.1.tgz", + "integrity": "sha512-EAMEJBsYuyyztxMxW3g7ugGPkrZsV57v0Hmv3mm1uQsmB+QnZuepg731CRaIgeUVSdmsTngOkSnauNF8p7FIhA==", + "dev": true, + "dependencies": { + "@babel/core": "^7.12.3", + "@babel/parser": "^7.14.7", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", + "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", + "dev": true, + "dependencies": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.6.tgz", + "integrity": "sha512-TLgnMkKg3iTDsQ9PbPTdpfAK2DzjF9mqUG7RMgcQl8oFjad8ob4laGxv5XV5U9MAfx8D6tSJiUyuAwzLicaxlg==", + "dev": true, + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jest": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", + "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", + "dev": true, + "dependencies": { + "@jest/core": "^29.7.0", + "@jest/types": "^29.6.3", + "import-local": "^3.0.2", + "jest-cli": "^29.7.0" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-changed-files": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-29.7.0.tgz", + "integrity": "sha512-fEArFiwf1BpQ+4bXSprcDc3/x4HSzL4al2tozwVpDFpsxALjLYdyiIK4e5Vz66GQJIbXJ82+35PtysofptNX2w==", + "dev": true, + "dependencies": { + "execa": "^5.0.0", + "jest-util": "^29.7.0", + "p-limit": "^3.1.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-circus": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-29.7.0.tgz", + "integrity": "sha512-3E1nCMgipcTkCocFwM90XXQab9bS+GMsjdpmPrlelaxwD93Ad8iVEjX/vvHPdLPnFf+L40u+5+iutRdA1N9myw==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/expect": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "co": "^4.6.0", + "dedent": "^1.0.0", + "is-generator-fn": "^2.0.0", + "jest-each": "^29.7.0", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "p-limit": "^3.1.0", + "pretty-format": "^29.7.0", + "pure-rand": "^6.0.0", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-cli": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.7.0.tgz", + "integrity": "sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==", + "dev": true, + "dependencies": { + "@jest/core": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "create-jest": "^29.7.0", + "exit": "^0.1.2", + "import-local": "^3.0.2", + "jest-config": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "yargs": "^17.3.1" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-config": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.7.0.tgz", + "integrity": "sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==", + "dev": true, + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/test-sequencer": "^29.7.0", + "@jest/types": "^29.6.3", + "babel-jest": "^29.7.0", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "deepmerge": "^4.2.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-circus": "^29.7.0", + "jest-environment-node": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-runner": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "micromatch": "^4.0.4", + "parse-json": "^5.2.0", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@types/node": "*", + "ts-node": ">=9.0.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "ts-node": { + "optional": true + } + } + }, + "node_modules/jest-diff": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.7.0.tgz", + "integrity": "sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "diff-sequences": "^29.6.3", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-docblock": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-29.7.0.tgz", + "integrity": "sha512-q617Auw3A612guyaFgsbFeYpNP5t2aoUNLwBUbc/0kD1R4t9ixDbyFTHd1nok4epoVFpr7PmeWHrhvuV3XaJ4g==", + "dev": true, + "dependencies": { + "detect-newline": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-each": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-29.7.0.tgz", + "integrity": "sha512-gns+Er14+ZrEoC5fhOfYCY1LOHHr0TI+rQUHZS8Ttw2l7gl+80eHc/gFf2Ktkw0+SIACDTeWvpFcv3B04VembQ==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "jest-get-type": "^29.6.3", + "jest-util": "^29.7.0", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-environment-node": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.7.0.tgz", + "integrity": "sha512-DOSwCRqXirTOyheM+4d5YZOrWcdu0LNZ87ewUoywbcb2XR4wKgqiG8vNeYwhjFMbEkfju7wx2GYH0P2gevGvFw==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/fake-timers": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-mock": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-get-type": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.6.3.tgz", + "integrity": "sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-haste-map": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.7.0.tgz", + "integrity": "sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@types/graceful-fs": "^4.1.3", + "@types/node": "*", + "anymatch": "^3.0.3", + "fb-watchman": "^2.0.0", + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "micromatch": "^4.0.4", + "walker": "^1.0.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "optionalDependencies": { + "fsevents": "^2.3.2" + } + }, + "node_modules/jest-leak-detector": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.7.0.tgz", + "integrity": "sha512-kYA8IJcSYtST2BY9I+SMC32nDpBT3J2NvWJx8+JCuCdl/CR1I4EKUJROiP8XtCcxqgTTBGJNdbB1A8XRKbTetw==", + "dev": true, + "dependencies": { + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-matcher-utils": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.7.0.tgz", + "integrity": "sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "jest-diff": "^29.7.0", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-message-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.7.0.tgz", + "integrity": "sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.12.13", + "@jest/types": "^29.6.3", + "@types/stack-utils": "^2.0.0", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "micromatch": "^4.0.4", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-mock": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.7.0.tgz", + "integrity": "sha512-ITOMZn+UkYS4ZFh83xYAOzWStloNzJFO2s8DWrE4lhtGD+AorgnbkiKERe4wQVBydIGPx059g6riW5Btp6Llnw==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-pnp-resolver": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", + "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", + "dev": true, + "engines": { + "node": ">=6" + }, + "peerDependencies": { + "jest-resolve": "*" + }, + "peerDependenciesMeta": { + "jest-resolve": { + "optional": true + } + } + }, + "node_modules/jest-regex-util": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz", + "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-29.7.0.tgz", + "integrity": "sha512-IOVhZSrg+UvVAshDSDtHyFCCBUl/Q3AAJv8iZ6ZjnZ74xzvwuzLXid9IIIPgTnY62SJjfuupMKZsZQRsCvxEgA==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-pnp-resolver": "^1.2.2", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "resolve": "^1.20.0", + "resolve.exports": "^2.0.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve-dependencies": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-29.7.0.tgz", + "integrity": "sha512-un0zD/6qxJ+S0et7WxeI3H5XSe9lTBBR7bOHCHXkKR6luG5mwDDlIzVQ0V5cZCuoTgEdcdwzTghYkTWfubi+nA==", + "dev": true, + "dependencies": { + "jest-regex-util": "^29.6.3", + "jest-snapshot": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runner": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-29.7.0.tgz", + "integrity": "sha512-fsc4N6cPCAahybGBfTRcq5wFR6fpLznMg47sY5aDpsoejOcVYFb07AHuSnR0liMcPTgBsA3ZJL6kFOjPdoNipQ==", + "dev": true, + "dependencies": { + "@jest/console": "^29.7.0", + "@jest/environment": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "emittery": "^0.13.1", + "graceful-fs": "^4.2.9", + "jest-docblock": "^29.7.0", + "jest-environment-node": "^29.7.0", + "jest-haste-map": "^29.7.0", + "jest-leak-detector": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-resolve": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-util": "^29.7.0", + "jest-watcher": "^29.7.0", + "jest-worker": "^29.7.0", + "p-limit": "^3.1.0", + "source-map-support": "0.5.13" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runtime": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-29.7.0.tgz", + "integrity": "sha512-gUnLjgwdGqW7B4LvOIkbKs9WGbn+QLqRQQ9juC6HndeDiezIwhDP+mhMwHWCEcfQ5RUXa6OPnFF8BJh5xegwwQ==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/fake-timers": "^29.7.0", + "@jest/globals": "^29.7.0", + "@jest/source-map": "^29.6.3", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "cjs-module-lexer": "^1.0.0", + "collect-v8-coverage": "^1.0.0", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-mock": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "slash": "^3.0.0", + "strip-bom": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-snapshot": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.7.0.tgz", + "integrity": "sha512-Rm0BMWtxBcioHr1/OX5YCP8Uov4riHvKPknOGs804Zg9JGZgmIBkbtlxJC/7Z4msKYVbIJtfU+tKb8xlYNfdkw==", + "dev": true, + "dependencies": { + "@babel/core": "^7.11.6", + "@babel/generator": "^7.7.2", + "@babel/plugin-syntax-jsx": "^7.7.2", + "@babel/plugin-syntax-typescript": "^7.7.2", + "@babel/types": "^7.3.3", + "@jest/expect-utils": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "babel-preset-current-node-syntax": "^1.0.0", + "chalk": "^4.0.0", + "expect": "^29.7.0", + "graceful-fs": "^4.2.9", + "jest-diff": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "natural-compare": "^1.4.0", + "pretty-format": "^29.7.0", + "semver": "^7.5.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.7.0.tgz", + "integrity": "sha512-ZB7wHqaRGVw/9hST/OuFUReG7M8vKeq0/J2egIGLdvjHCmYqGARhzXmtgi+gVeZ5uXFF219aOc3Ls2yLg27tkw==", + "dev": true, + "dependencies": { + "@jest/types": "^29.6.3", + "camelcase": "^6.2.0", + "chalk": "^4.0.0", + "jest-get-type": "^29.6.3", + "leven": "^3.1.0", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/jest-watcher": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-29.7.0.tgz", + "integrity": "sha512-49Fg7WXkU3Vl2h6LbLtMQ/HyB6rXSIX7SqvBLQmssRBGN9I0PNvPmAmCWSOY6SOvrjhI/F7/bGAv9RtnsPA03g==", + "dev": true, + "dependencies": { + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "emittery": "^0.13.1", + "jest-util": "^29.7.0", + "string-length": "^4.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.7.0.tgz", + "integrity": "sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==", + "dev": true, + "dependencies": { + "@types/node": "*", + "jest-util": "^29.7.0", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true, + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true + }, + "node_modules/json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/leven": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "dev": true + }, + "node_modules/lodash.memoize": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", + "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", + "dev": true + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true + }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/log-symbols/node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, + "node_modules/makeerror": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", + "integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==", + "dev": true, + "dependencies": { + "tmpl": "1.0.5" + } + }, + "node_modules/memory-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/memory-stream/-/memory-stream-1.0.0.tgz", + "integrity": "sha512-Wm13VcsPIMdG96dzILfij09PvuS3APtcKNh7M28FsCA/w6+1mjR7hhPmfFNoilX9xU7wTdhsH5lJAm6XNzdtww==", + "dev": true, + "dependencies": { + "readable-stream": "^3.4.0" + } + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/minizlib/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/minizlib/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/mute-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-1.0.0.tgz", + "integrity": "sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==", + "dev": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dev": true, + "dependencies": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true + }, + "node_modules/node-addon-api": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-6.1.0.tgz", + "integrity": "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==", + "dev": true + }, + "node_modules/node-api-headers": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/node-api-headers/-/node-api-headers-0.0.2.tgz", + "integrity": "sha512-YsjmaKGPDkmhoNKIpkChtCsPVaRE0a274IdERKnuc/E8K1UJdBZ4/mvI006OijlQZHCfpRNOH3dfHQs92se8gg==", + "dev": true + }, + "node_modules/node-int64": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", + "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", + "dev": true + }, + "node_modules/node-releases": { + "version": "2.0.14", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", + "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==", + "dev": true + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/npmlog": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-6.0.2.tgz", + "integrity": "sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg==", + "dev": true, + "dependencies": { + "are-we-there-yet": "^3.0.0", + "console-control-strings": "^1.1.0", + "gauge": "^4.0.3", + "set-blocking": "^2.0.0" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", + "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.assign": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.5.tgz", + "integrity": "sha512-byy+U7gp+FVwmyzKPYhW2h5l3crpmGsxl7X2s8y43IgxvG4g3QZ6CffDtsNQy1WsmZpQbO+ybo0AlW7TY6DcBQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.5", + "define-properties": "^1.2.1", + "has-symbols": "^1.0.3", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object.fromentries": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.7.tgz", + "integrity": "sha512-UPbPHML6sL8PI/mOqPwsH4G6iyXcCGzLin8KvEPenOZN5lpCNBZZQ+V62vdjB1mQHrmqGQt5/OJzemUA+KJmEA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object.groupby": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object.groupby/-/object.groupby-1.0.1.tgz", + "integrity": "sha512-HqaQtqLnp/8Bn4GL16cj+CUYbnpe1bh0TtEaWvybszDG4tgxCJuRpV8VGuvNaI1fAnI4lUJzDG55MXcOH4JZcQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1", + "get-intrinsic": "^1.2.1" + } + }, + "node_modules/object.values": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.7.tgz", + "integrity": "sha512-aU6xnDFYT3x17e/f0IiiwlGPTy2jzMySGfUB4fq6z7CV8l85CWHDk5ErhyhpfDHhrOMwGFhSQkhMGHaIotA6Ng==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/optionator": { + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", + "integrity": "sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==", + "dev": true, + "dependencies": { + "@aashutoshrathi/word-wrap": "^1.2.3", + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/ora": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", + "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", + "dev": true, + "dependencies": { + "bl": "^4.1.0", + "chalk": "^4.1.0", + "cli-cursor": "^3.1.0", + "cli-spinners": "^2.5.0", + "is-interactive": "^1.0.0", + "is-unicode-supported": "^0.1.0", + "log-symbols": "^4.1.0", + "strip-ansi": "^6.0.0", + "wcwidth": "^1.0.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ora/node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/packet-reader": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-1.0.0.tgz", + "integrity": "sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ==" + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/parse5": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.1.tgz", + "integrity": "sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==", + "dev": true + }, + "node_modules/parse5-htmlparser2-tree-adapter": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz", + "integrity": "sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==", + "dev": true, + "dependencies": { + "parse5": "^6.0.1" + } + }, + "node_modules/parse5-htmlparser2-tree-adapter/node_modules/parse5": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", + "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==", + "dev": true + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/pg": { + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.11.3.tgz", + "integrity": "sha512-+9iuvG8QfaaUrrph+kpF24cXkH1YOOUeArRNYIxq1viYHZagBxrTno7cecY1Fa44tJeZvaoG+Djpkc3JwehN5g==", + "dependencies": { + "buffer-writer": "2.0.0", + "packet-reader": "1.0.0", + "pg-connection-string": "^2.6.2", + "pg-pool": "^3.6.1", + "pg-protocol": "^1.6.0", + "pg-types": "^2.1.0", + "pgpass": "1.x" + }, + "engines": { + "node": ">= 8.0.0" + }, + "optionalDependencies": { + "pg-cloudflare": "^1.1.1" + }, + "peerDependencies": { + "pg-native": ">=3.0.1" + }, + "peerDependenciesMeta": { + "pg-native": { + "optional": true + } + } + }, + "node_modules/pg-cloudflare": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.1.1.tgz", + "integrity": "sha512-xWPagP/4B6BgFO+EKz3JONXv3YDgvkbVrGw2mTo3D6tVDQRh1e7cqVGvyR3BE+eQgAvx1XhW/iEASj4/jCWl3Q==", + "optional": true + }, + "node_modules/pg-connection-string": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.6.2.tgz", + "integrity": "sha512-ch6OwaeaPYcova4kKZ15sbJ2hKb/VP48ZD2gE7i1J+L4MspCtBMAx8nMgz7bksc7IojCIIWuEhHibSMFH8m8oA==" + }, + "node_modules/pg-int8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", + "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/pg-pool": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.6.1.tgz", + "integrity": "sha512-jizsIzhkIitxCGfPRzJn1ZdcosIt3pz9Sh3V01fm1vZnbnCMgmGl5wvGGdNN2EL9Rmb0EcFoCkixH4Pu+sP9Og==", + "peerDependencies": { + "pg": ">=8.0" + } + }, + "node_modules/pg-protocol": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.6.0.tgz", + "integrity": "sha512-M+PDm637OY5WM307051+bsDia5Xej6d9IR4GwJse1qA1DIhiKlksvrneZOYQq42OM+spubpcNYEo2FcKQrDk+Q==" + }, + "node_modules/pg-types": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", + "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==", + "dependencies": { + "pg-int8": "1.0.1", + "postgres-array": "~2.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.4", + "postgres-interval": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pgpass": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz", + "integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==", + "dependencies": { + "split2": "^4.1.0" + } + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pirates": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", + "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "dependencies": { + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pkg-dir/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/postgres-array": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", + "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==", + "engines": { + "node": ">=4" + } + }, + "node_modules/postgres-bytea": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz", + "integrity": "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-date": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz", + "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-interval": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz", + "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==", + "dependencies": { + "xtend": "^4.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/prettier": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.1.tgz", + "integrity": "sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/pretty-format": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", + "integrity": "sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==", + "dev": true, + "dependencies": { + "@jest/schemas": "^29.6.3", + "ansi-styles": "^5.0.0", + "react-is": "^18.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/pretty-format/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/prompts": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", + "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", + "dev": true, + "dependencies": { + "kleur": "^3.0.3", + "sisteransi": "^1.0.5" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "dev": true + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/pure-rand": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.0.4.tgz", + "integrity": "sha512-LA0Y9kxMYv47GIPJy6MI84fqTd2HmYZI83W/kM/SkKfDlajnZYfmXFTxkbY+xSBPkLJxltMa9hIkmdc29eguMA==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/dubzzz" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fast-check" + } + ] + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "dev": true, + "dependencies": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "bin": { + "rc": "cli.js" + } + }, + "node_modules/rc/node_modules/strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", + "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==", + "dev": true, + "dependencies": { + "loose-envify": "^1.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-is": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", + "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", + "dev": true + }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/reflect-metadata": { + "version": "0.1.14", + "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.14.tgz", + "integrity": "sha512-ZhYeb6nRaXCfhnndflDK8qI6ZQ/YcWZCISRAWICW9XYqMUwjZM9Z0DveWX/ABN01oxSHwVxKQmxeYZSsm0jh5A==" + }, + "node_modules/regenerator-runtime": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", + "dev": true + }, + "node_modules/regexp.prototype.flags": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.1.tgz", + "integrity": "sha512-sy6TXMN+hnP/wMy+ISxg3krXx7BAtWVO4UouuCN/ziM9UEne0euamVNafDfvC83bRNr95y0V5iijeDQFUNpvrg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "set-function-name": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve": { + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", + "dev": true, + "dependencies": { + "is-core-module": "^2.13.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-cwd": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", + "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", + "dev": true, + "dependencies": { + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve-cwd/node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, + "node_modules/resolve.exports": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz", + "integrity": "sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/restore-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "dev": true, + "dependencies": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/run-async": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-3.0.0.tgz", + "integrity": "sha512-540WwVDOMxA6dN6We19EcT9sc3hkXPw5mzRNGM3FkdN/vtE9NFvj5lFAPNwUDmJjXidm3v7TC1cTE7t17Ulm1Q==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/rxjs": { + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", + "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", + "dev": true, + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/safe-array-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.0.1.tgz", + "integrity": "sha512-6XbUAseYE2KtOuGueyeobCySj9L4+66Tn6KQMOPQJrAJEowYKW/YR/MGJZl7FdydUdaFu4LYyDZjxf4/Nmo23Q==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.2.1", + "has-symbols": "^1.0.3", + "isarray": "^2.0.5" + }, + "engines": { + "node": ">=0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safe-regex-test": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz", + "integrity": "sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.3", + "is-regex": "^1.1.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/semver/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/semver/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", + "dev": true + }, + "node_modules/set-function-length": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz", + "integrity": "sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==", + "dev": true, + "dependencies": { + "define-data-property": "^1.1.1", + "get-intrinsic": "^1.2.1", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/set-function-name": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.1.tgz", + "integrity": "sha512-tMNCiqYVkXIZgc2Hnoy2IvC/f8ezc5koaRFkCjrpWzGpCd3qbZXPzVy9MAZzK1ch/X0jvSkojys3oqJN0qCmdA==", + "dev": true, + "dependencies": { + "define-data-property": "^1.0.1", + "functions-have-names": "^1.2.3", + "has-property-descriptors": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/sha.js": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", + "dev": true, + "dependencies": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + }, + "bin": { + "sha.js": "bin.js" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true + }, + "node_modules/sisteransi": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", + "dev": true + }, + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.13", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", + "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "engines": { + "node": ">= 10.x" + } + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true + }, + "node_modules/stack-utils": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", + "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", + "dev": true, + "dependencies": { + "escape-string-regexp": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/stack-utils/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string-length": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", + "integrity": "sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==", + "dev": true, + "dependencies": { + "char-regex": "^1.0.2", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string.prototype.trim": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.8.tgz", + "integrity": "sha512-lfjY4HcixfQXOfaqCvcBuOIapyaroTXhbkfJN3gcB1OtyupngWK4sEET9Knd0cXd28kTUqu/kHoV4HKSJdnjiQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimend": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.7.tgz", + "integrity": "sha512-Ni79DqeB72ZFq1uH/L6zJ+DKZTkOtPIHovb3YZHQViE+HDouuU4mBrLOLDn5Dde3RF8qw5qVETEjhu9locMLvA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimstart": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.7.tgz", + "integrity": "sha512-NGhtDFu3jCEm7B4Fy0DpLewdJQOZcQ0rGbwQ/+stjnrp2i+rlKeCvos9hOIeCmqwratM47OBxY7uFZzjxHXmrg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.22.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-bom": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/tar": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.0.tgz", + "integrity": "sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==", + "dev": true, + "dependencies": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^5.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/tar/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true + }, + "node_modules/thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dev": true, + "dependencies": { + "any-promise": "^1.0.0" + } + }, + "node_modules/thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", + "dev": true, + "dependencies": { + "thenify": ">= 3.1.0 < 4" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, + "dependencies": { + "os-tmpdir": "~1.0.2" + }, + "engines": { + "node": ">=0.6.0" + } + }, + "node_modules/tmpl": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", + "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", + "dev": true + }, + "node_modules/to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/ts-api-utils": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.3.tgz", + "integrity": "sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==", + "dev": true, + "engines": { + "node": ">=16.13.0" + }, + "peerDependencies": { + "typescript": ">=4.2.0" + } + }, + "node_modules/ts-jest": { + "version": "29.1.1", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.1.tgz", + "integrity": "sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==", + "dev": true, + "dependencies": { + "bs-logger": "0.x", + "fast-json-stable-stringify": "2.x", + "jest-util": "^29.0.0", + "json5": "^2.2.3", + "lodash.memoize": "4.x", + "make-error": "1.x", + "semver": "^7.5.3", + "yargs-parser": "^21.0.1" + }, + "bin": { + "ts-jest": "cli.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": ">=7.0.0-beta.0 <8", + "@jest/types": "^29.0.0", + "babel-jest": "^29.0.0", + "jest": "^29.0.0", + "typescript": ">=4.3 <6" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "@jest/types": { + "optional": true + }, + "babel-jest": { + "optional": true + }, + "esbuild": { + "optional": true + } + } + }, + "node_modules/tsc": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/tsc/-/tsc-2.0.4.tgz", + "integrity": "sha512-fzoSieZI5KKJVBYGvwbVZs/J5za84f2lSTLPYf6AGiIf43tZ3GNrI1QzTLcjtyDDP4aLxd46RTZq1nQxe7+k5Q==", + "bin": { + "tsc": "bin/tsc" + } + }, + "node_modules/tsconfig-paths": { + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", + "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", + "dev": true, + "dependencies": { + "@types/json5": "^0.0.29", + "json5": "^1.0.2", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + } + }, + "node_modules/tsconfig-paths/node_modules/json5": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", + "dev": true, + "dependencies": { + "minimist": "^1.2.0" + }, + "bin": { + "json5": "lib/cli.js" + } + }, + "node_modules/tsconfig-paths/node_modules/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", + "dev": true + }, + "node_modules/tsx": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-3.14.0.tgz", + "integrity": "sha512-xHtFaKtHxM9LOklMmJdI3BEnQq/D5F73Of2E1GDrITi9sgoVkvIsrQUTY1G8FlmGtA+awCI4EBlTRRYxkL2sRg==", + "dev": true, + "dependencies": { + "esbuild": "~0.18.20", + "get-tsconfig": "^4.7.2", + "source-map-support": "^0.5.21" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, + "node_modules/tsx/node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/typed-array-buffer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.0.tgz", + "integrity": "sha512-Y8KTSIglk9OZEr8zywiIHG/kmQ7KWyjseXs1CbSo8vC42w7hg2HgYTxSWwP0+is7bWDc1H+Fo026CpHFwm8tkw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.2.1", + "is-typed-array": "^1.1.10" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/typed-array-byte-length": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/typed-array-byte-length/-/typed-array-byte-length-1.0.0.tgz", + "integrity": "sha512-Or/+kvLxNpeQ9DtSydonMxCx+9ZXOswtwJn17SNLvhptaXYDJvkFFP5zbfU/uLmvnBJlI4yrnXRxpdWH/M5tNA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "has-proto": "^1.0.1", + "is-typed-array": "^1.1.10" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typed-array-byte-offset": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/typed-array-byte-offset/-/typed-array-byte-offset-1.0.0.tgz", + "integrity": "sha512-RD97prjEt9EL8YgAgpOkf3O4IF9lhJFr9g0htQkm0rchFp/Vx7LW5Q8fSXXub7BXAODyUQohRMyOc3faCPd0hg==", + "dev": true, + "dependencies": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "has-proto": "^1.0.1", + "is-typed-array": "^1.1.10" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typed-array-length": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.4.tgz", + "integrity": "sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "is-typed-array": "^1.1.9" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typeorm": { + "version": "0.3.17", + "resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.3.17.tgz", + "integrity": "sha512-UDjUEwIQalO9tWw9O2A4GU+sT3oyoUXheHJy4ft+RFdnRdQctdQ34L9SqE2p7LdwzafHx1maxT+bqXON+Qnmig==", + "dev": true, + "dependencies": { + "@sqltools/formatter": "^1.2.5", + "app-root-path": "^3.1.0", + "buffer": "^6.0.3", + "chalk": "^4.1.2", + "cli-highlight": "^2.1.11", + "date-fns": "^2.29.3", + "debug": "^4.3.4", + "dotenv": "^16.0.3", + "glob": "^8.1.0", + "mkdirp": "^2.1.3", + "reflect-metadata": "^0.1.13", + "sha.js": "^2.4.11", + "tslib": "^2.5.0", + "uuid": "^9.0.0", + "yargs": "^17.6.2" + }, + "bin": { + "typeorm": "cli.js", + "typeorm-ts-node-commonjs": "cli-ts-node-commonjs.js", + "typeorm-ts-node-esm": "cli-ts-node-esm.js" + }, + "engines": { + "node": ">= 12.9.0" + }, + "funding": { + "url": "https://opencollective.com/typeorm" + }, + "peerDependencies": { + "@google-cloud/spanner": "^5.18.0", + "@sap/hana-client": "^2.12.25", + "better-sqlite3": "^7.1.2 || ^8.0.0", + "hdb-pool": "^0.1.6", + "ioredis": "^5.0.4", + "mongodb": "^5.2.0", + "mssql": "^9.1.1", + "mysql2": "^2.2.5 || ^3.0.1", + "oracledb": "^5.1.0", + "pg": "^8.5.1", + "pg-native": "^3.0.0", + "pg-query-stream": "^4.0.0", + "redis": "^3.1.1 || ^4.0.0", + "sql.js": "^1.4.0", + "sqlite3": "^5.0.3", + "ts-node": "^10.7.0", + "typeorm-aurora-data-api-driver": "^2.0.0" + }, + "peerDependenciesMeta": { + "@google-cloud/spanner": { + "optional": true + }, + "@sap/hana-client": { + "optional": true + }, + "better-sqlite3": { + "optional": true + }, + "hdb-pool": { + "optional": true + }, + "ioredis": { + "optional": true + }, + "mongodb": { + "optional": true + }, + "mssql": { + "optional": true + }, + "mysql2": { + "optional": true + }, + "oracledb": { + "optional": true + }, + "pg": { + "optional": true + }, + "pg-native": { + "optional": true + }, + "pg-query-stream": { + "optional": true + }, + "redis": { + "optional": true + }, + "sql.js": { + "optional": true + }, + "sqlite3": { + "optional": true + }, + "ts-node": { + "optional": true + }, + "typeorm-aurora-data-api-driver": { + "optional": true + } + } + }, + "node_modules/typeorm/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/typeorm/node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/typeorm/node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/typeorm/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/typeorm/node_modules/mkdirp": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-2.1.6.tgz", + "integrity": "sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A==", + "dev": true, + "bin": { + "mkdirp": "dist/cjs/src/bin.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/typescript": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", + "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/unbox-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", + "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "has-bigints": "^1.0.2", + "has-symbols": "^1.0.3", + "which-boxed-primitive": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, + "node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "dev": true, + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.0.13", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", + "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/url-join": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.1.tgz", + "integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==", + "dev": true + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, + "node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "dev": true, + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/v8-to-istanbul": { + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.2.0.tgz", + "integrity": "sha512-/EH/sDgxU2eGxajKdwLCDmQ4FWq+kpi3uCmBGpw1xJtnAxEjlD8j8PEiGWpCIMIs3ciNAgH0d3TTJiUkYzyZjA==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^2.0.0" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/walker": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", + "integrity": "sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==", + "dev": true, + "dependencies": { + "makeerror": "1.0.12" + } + }, + "node_modules/wcwidth": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", + "integrity": "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==", + "dev": true, + "dependencies": { + "defaults": "^1.0.3" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/which-boxed-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", + "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", + "dev": true, + "dependencies": { + "is-bigint": "^1.0.1", + "is-boolean-object": "^1.1.0", + "is-number-object": "^1.0.4", + "is-string": "^1.0.5", + "is-symbol": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-typed-array": { + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.13.tgz", + "integrity": "sha512-P5Nra0qjSncduVPEAr7xhoF5guty49ArDTwzJ/yNuPIbZppyRxFQsRCWrocxIY+CnMVG+qfbU2FmDKyvSGClow==", + "dev": true, + "dependencies": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.4", + "for-each": "^0.3.3", + "gopd": "^1.0.1", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/wide-align": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", + "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", + "dev": true, + "dependencies": { + "string-width": "^1.0.2 || 2 || 3 || 4" + } + }, + "node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/write-file-atomic": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz", + "integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==", + "dev": true, + "dependencies": { + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.7" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "engines": { + "node": ">=0.4" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/JS/edgechains/examples/react-chain/package.json b/JS/edgechains/examples/react-chain/package.json new file mode 100644 index 000000000..342a32a06 --- /dev/null +++ b/JS/edgechains/examples/react-chain/package.json @@ -0,0 +1,49 @@ +{ + "name": "example", + "version": "1.0.0", + "description": "", + "main": "dist/index.js", + "scripts": { + "build": "rm -rf dist && node esbuild.build.js", + "start": "node dist/index.js", + "lint": "eslint --ignore-path .eslintignore --ext .js,.ts", + "format": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\"", + "test": "npx jest" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "@hono/node-server": "^1.2.0", + "@types/dotenv": "^8.2.0", + "hono": "^3.9.2", + "pg": "^8.11.3", + "reflect-metadata": "^0.1.13", + "tsc": "^2.0.4", + "typescript": "^5.3.2" + }, + "devDependencies": { + "@hanazuki/node-jsonnet": "^2.1.0", + "@types/jest": "^29.5.8", + "@types/node": "^20.9.4", + "@typescript-eslint/eslint-plugin": "^6.11.0", + "@typescript-eslint/parser": "^6.11.0", + "axios": "^1.6.2", + "dotenv": "^16.3.1", + "dts-bundle-generator": "^8.1.2", + "eslint": "^8.54.0", + "eslint-config-prettier": "^9.0.0", + "eslint-config-standard-with-typescript": "^40.0.0", + "eslint-plugin-import": "^2.29.0", + "eslint-plugin-n": "^16.3.1", + "eslint-plugin-promise": "^6.1.1", + "jest": "^29.7.0", + "prettier": "^3.1.0", + "react": "^18.2.0", + "@arakoodev/edgechains.js": "0.1.10", + "ts-jest": "^29.1.1", + "tsx": "^3.12.2", + "typeorm": "^0.3.17", + "typescript": "^5.0.2" + } +} diff --git a/JS/edgechains/examples/react-chain/src/ReactChain.test.ts b/JS/edgechains/examples/react-chain/src/ReactChain.test.ts new file mode 100644 index 000000000..e87243d4b --- /dev/null +++ b/JS/edgechains/examples/react-chain/src/ReactChain.test.ts @@ -0,0 +1,7 @@ +const reactChain = require("./ReactChain") + +describe("ReAct Chain", () => { + it("should return a response", async () => { + expect(await reactChain("Author David Chanoff has collaborated with a U.S. Navy admiral who served as the ambassador to the United Kingdom under which President?")).toContain("Bill Clinton"); + }, 30000); +}); \ No newline at end of file diff --git a/JS/edgechains/examples/react-chain/src/ReactChain.ts b/JS/edgechains/examples/react-chain/src/ReactChain.ts new file mode 100644 index 000000000..ccece88e4 --- /dev/null +++ b/JS/edgechains/examples/react-chain/src/ReactChain.ts @@ -0,0 +1,122 @@ +import { Jsonnet } from "@hanazuki/node-jsonnet"; +import { OpenAiEndpoint } from "@arakoodev/edgechains.js"; +import * as path from "path"; +import { Hono } from "hono"; +import axios from "axios"; + +const jsonnet = new Jsonnet(); + +jsonnet.nativeCallback("udf.fn",async (prompt) => { + + const wikiResponse = await axios + .post( + "https://en.wikipedia.org/w/api.php", + {}, + { + params: { + action: "query", + prop: "extracts", + format: "json", + titles: prompt, + explaintext: "", + }, + headers: { + "content-type": "application/x-www-form-urlencoded", + Accept: "application/json", + }, + } + ) + .then(function (response) { + + if(response.data.query == undefined) + return ""; + else + return Object.values(response.data.query.pages); + }) + .catch(function (error) { + if (error.response) { + console.log("Server responded with status code:", error.response.status); + console.log("Response data:", error.response.data); + } else if (error.request) { + console.log("No response received:", error.request); + } else { + console.log("Error creating request:", error.message); + } + }); + + if(wikiResponse == ""){ + return "" + } + else{ + if(wikiResponse[0].extract == undefined){ + return ""; + } + return wikiResponse[0].extract; + } + +},"prompt") + +export const ReactChainRouter = new Hono(); + +const gpt3Endpoint = new OpenAiEndpoint( + "https://api.openai.com/v1/chat/completions", + process.env.OPENAI_API_KEY!, + "", + "gpt-3.5-turbo", + "user", + parseInt("0.7") +); + +const reactChainJsonnetPath = path.join(__dirname, "../src/react-chain.jsonnet"); + +ReactChainRouter.post("/react-chain", async (c) => { + const query = await c.req.json(); + const reactResponse = await reactChain(query.prompt); + + return c.json({ answer : reactResponse }, 200); +}); + +export async function reactChain(query) { + + + var reactJsonnet = await jsonnet + .extString("gptResponse","") + .extString("context","This is contenxt") + .evaluateFile(reactChainJsonnetPath); + + var context = ""; + + var preset = JSON.parse(reactJsonnet).preset; + + query = preset + "\nQuestion: " + query; + + var gptResponse = await gpt3Endpoint.gptFn(query); + + console.log(gptResponse); + + context = context + query; + + jsonnet.extString("context",context).extString("gptResponse",gptResponse); + + while(!checkIfFinished(gptResponse)){ + + reactJsonnet = await jsonnet.evaluateFile(reactChainJsonnetPath); + query = JSON.parse(reactJsonnet).prompt; + + gptResponse = await gpt3Endpoint.gptFn(query); + + console.log(gptResponse); + + context += "\n" + query; + jsonnet.extString("context",context).extString("gptResponse",gptResponse); + } + + console.log(gptResponse); + + var res = gptResponse.substring(gptResponse.indexOf("Finish[")) + return res.substring(res.indexOf("[")+1,res.indexOf("]")); +} + +function checkIfFinished(response:string){ + return response.includes("Finish"); +} \ No newline at end of file diff --git a/JS/edgechains/examples/react-chain/src/index.ts b/JS/edgechains/examples/react-chain/src/index.ts new file mode 100644 index 000000000..b0f2796fb --- /dev/null +++ b/JS/edgechains/examples/react-chain/src/index.ts @@ -0,0 +1,13 @@ +import "dotenv/config"; +import { serve } from "@hono/node-server"; +import { Hono } from "hono"; +import { ReactChainRouter } from "./ReactChain.js"; + +const app = new Hono(); + +app.route("/", ReactChainRouter); + + +serve(app, () => { + console.log("server running on port 3000"); +}); diff --git a/JS/edgechains/examples/react-chain/src/react-chain.jsonnet b/JS/edgechains/examples/react-chain/src/react-chain.jsonnet new file mode 100644 index 000000000..e51205dd8 --- /dev/null +++ b/JS/edgechains/examples/react-chain/src/react-chain.jsonnet @@ -0,0 +1,87 @@ +local config = { + "edgechains.config": { + "mapper": { + "search": std.native("udf.fn"), + }, + }, +}; + +local callFunction(funcName) = + local mapper = config["edgechains.config"].mapper; + mapper[funcName]; +local preset = ||| + You are a Reasoning + Acting (React) Chain Bot. You have to be interactive so ask the queries one by one from the user to reach to the final answer. Please provide a single Thought and single Action to the user so that the user can search the query of the action and provide you with the observation. When you have found the answer to the original prompt then the final response should be Action: Finish[Answer to the original prompt]. + For example the chain would be like this: + + Question: Which magazine was started first Arthur's Magazine or First for Women? + Thought 1: I need to search Arthur's Magazine and First for Women, and find which was + started first. + Action 1: Search[Arthur's Magazine] + Observation 1: Arthur's Magazine (1844-1846) was an American literary periodical published + in Philadelphia in the 19th century. + Thought 2: Arthur's Magazine was started in 1844. I need to search First for Women + next. + Action 2: Search[First for Women] + Observation 2: First for Women is a woman’s magazine published by Bauer Media Group in the + USA.[1] The magazine was started in 1989. + Thought 3: First for Women was started in 1989. 1844 (Arthur's Magazine) < 1989 (First + for Women), so Arthur's Magazine was started first. + Action 3: Finish[Arthur's Magazine] + + Question: Were Pavel Urysohn and Leonid Levin known for the same type of work? + Thought 1: I need to search Pavel Urysohn and Leonid Levin, find their types of work, + then find if they are the same. + Action 1: Search[Pavel Urysohn] + Observation 1: Pavel Samuilovich Urysohn (February 3, 1898 - August 17, 1924) was a Soviet + mathematician who is best known for his contributions in dimension theory. + Thought 2: Pavel Urysohn is a mathematician. I need to search Leonid Levin next and + find its type of work. + Action 2: Search[Leonid Levin] + Observation 2: Leonid Anatolievich Levin is a Soviet-American mathematician and computer + scientist. + Thought 3: Leonid Levin is a mathematician and computer scientist. So Pavel Urysohn + and Leonid Levin have the same type of work. + Action 3: Finish[yes] + + **ALL THE OBSERVATIONS WILL BE PROVIDED BY THE USER, YOU DON'T HAVE TO PROVIDE ANY OBSERVATION** + |||; + +local subStringBefore(str,c) = + local substr = std.split(str,c); + if std.length(substr) == 0 then "" else substr[0]; + +local subStringAfter(str,c) = + local substr = std.split(str,c); + if std.length(substr) == 2 then substr[1] else substr[0]; + +//To extract action from the response +local extractAction(str) = + local action = subStringBefore(subStringAfter(str, "["), "]"); + action; + +//To extract thought from the response +local extractThought(str) = + local thought = subStringAfter(subStringBefore(str, "Action"), ":"); + thought; + +local appendIfMissing(str, c) = + local arr = std.findSubstr(c,str); + if std.length(arr) == 0 then str+c else str; + +local gptResponse = std.extVar("gptResponse"); //this will be populated from the java code after the prompt is submitted to gpt +local action = extractAction(gptResponse); +local thought = extractThought(gptResponse); +local searchResponse = std.substr(callFunction("search")(action), 0, 400); //extract action from response and insert here +local observation = std.join('',["Observation:", searchResponse]); +local context = std.extVar("context") + "\n" + gptResponse + "\n" + observation; +local prompt = appendIfMissing(context, "\n" + observation); +{ + observation: observation, + thought: thought, + action: action, + preset: preset, + prompt: prompt, + context: context, + searchResponse: searchResponse, + gptResponse: gptResponse +} diff --git a/JS/edgechains/examples/react-chain/tsconfig.json b/JS/edgechains/examples/react-chain/tsconfig.json new file mode 100644 index 000000000..fef42cf44 --- /dev/null +++ b/JS/edgechains/examples/react-chain/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "types": ["dotenv/config", "jest", "node"], + "target": "ES2022", + "module": "NodeNext", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "jsx": "react-jsx", + "jsxImportSource": "hono/jsx", + "noImplicitAny": false, + "moduleResolution": "NodeNext", + "declaration": true + }, + "include": ["src/**/*.ts", "dist/**/*.d.ts"] +} From bd039b8084091165aa1b1aae03039c0fec0c5231 Mon Sep 17 00:00:00 2001 From: Harshvardhan Parmar Date: Wed, 20 Dec 2023 15:06:42 +0530 Subject: [PATCH 3/3] Update react-chain.jsonnet --- JS/edgechains/examples/react-chain/src/react-chain.jsonnet | 2 ++ 1 file changed, 2 insertions(+) diff --git a/JS/edgechains/examples/react-chain/src/react-chain.jsonnet b/JS/edgechains/examples/react-chain/src/react-chain.jsonnet index e51205dd8..d7e29208a 100644 --- a/JS/edgechains/examples/react-chain/src/react-chain.jsonnet +++ b/JS/edgechains/examples/react-chain/src/react-chain.jsonnet @@ -1,3 +1,5 @@ +//ReAct-Chain example is taken from https://tsmatz.wordpress.com/2023/03/07/react-with-openai-gpt-and-langchain + local config = { "edgechains.config": { "mapper": {