|
1 | 1 | package apoc.full.it.vectordb; |
2 | 2 |
|
3 | | -import apoc.ml.Prompt; |
4 | | -import apoc.util.TestUtil; |
5 | | -import org.junit.AfterClass; |
6 | | -import org.junit.Before; |
7 | | -import org.junit.BeforeClass; |
8 | | -import org.junit.ClassRule; |
9 | | -import org.junit.Test; |
10 | | -import org.junit.rules.TemporaryFolder; |
11 | | -import org.neo4j.dbms.api.DatabaseManagementService; |
12 | | -import org.neo4j.graphdb.GraphDatabaseService; |
13 | | -import org.neo4j.test.TestDatabaseManagementServiceBuilder; |
14 | | -import org.testcontainers.chromadb.ChromaDBContainer; |
15 | | - |
16 | | -import java.util.List; |
17 | | -import java.util.Map; |
18 | | -import java.util.concurrent.atomic.AtomicReference; |
19 | | - |
20 | | -import static apoc.ml.RestAPIConfig.HEADERS_KEY; |
| 3 | +import static apoc.ml.Prompt.API_KEY_CONF; |
21 | 4 | import static apoc.util.MapUtil.map; |
22 | 5 | import static apoc.util.TestUtil.testCall; |
23 | 6 | import static apoc.util.TestUtil.testResult; |
|
30 | 13 | import static apoc.vectordb.VectorDbTestUtil.dropAndDeleteAll; |
31 | 14 | import static apoc.vectordb.VectorDbTestUtil.ragSetup; |
32 | 15 | import static apoc.vectordb.VectorDbUtil.ERROR_READONLY_MAPPING; |
33 | | -import static apoc.vectordb.VectorDbTestUtil.getAuthHeader; |
34 | | -import static apoc.vectordb.VectorDbTestUtil.ragSetup; |
35 | 16 | import static apoc.vectordb.VectorEmbeddingConfig.ALL_RESULTS_KEY; |
36 | 17 | import static apoc.vectordb.VectorEmbeddingConfig.MAPPING_KEY; |
37 | 18 | import static apoc.vectordb.VectorMappingConfig.*; |
|
42 | 23 | import static org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME; |
43 | 24 | import static org.neo4j.configuration.GraphDatabaseSettings.SYSTEM_DATABASE_NAME; |
44 | 25 |
|
| 26 | +import apoc.ml.Prompt; |
45 | 27 | import apoc.util.TestUtil; |
46 | 28 | import apoc.vectordb.ChromaDb; |
47 | 29 | import apoc.vectordb.VectorDb; |
| 30 | +import apoc.vectordb.VectorDbTestUtil; |
48 | 31 | import java.util.List; |
49 | 32 | import java.util.Map; |
50 | 33 | import java.util.concurrent.atomic.AtomicReference; |
51 | | - |
52 | | -import apoc.vectordb.VectorDbTestUtil; |
53 | 34 | import org.assertj.core.api.Assertions; |
54 | 35 | import org.junit.AfterClass; |
55 | 36 | import org.junit.Before; |
@@ -85,7 +66,7 @@ public static void setUp() throws Exception { |
85 | 66 | CHROMA_CONTAINER.start(); |
86 | 67 |
|
87 | 68 | HOST = CHROMA_CONTAINER.getEndpoint(); |
88 | | - TestUtil.registerProcedure(db, ChromaDb.class, VectorDb.class, Prompt.class)); |
| 69 | + TestUtil.registerProcedure(db, ChromaDb.class, VectorDb.class, Prompt.class); |
89 | 70 |
|
90 | 71 | testCall( |
91 | 72 | db, |
@@ -437,7 +418,7 @@ public void queryVectorsWithCreateRel() { |
437 | 418 | @Test |
438 | 419 | public void queryVectorsWithSystemDbStorage() { |
439 | 420 | String keyConfig = "chroma-config-foo"; |
440 | | - String baseUrl = "http://" + HOST; |
| 421 | + String baseUrl = HOST; |
441 | 422 | Map<String, Object> mapping = |
442 | 423 | map(EMBEDDING_KEY, "vect", NODE_LABEL, "Test", ENTITY_KEY, "myId", METADATA_KEY, "foo"); |
443 | 424 | sysDb.executeTransactionally( |
@@ -480,28 +461,21 @@ public void queryVectorsWithSystemDbStorage() { |
480 | 461 | public void queryVectorsWithRag() { |
481 | 462 | String openAIKey = ragSetup(db); |
482 | 463 |
|
483 | | - Map<String, Object> conf = map(ALL_RESULTS_KEY, true, |
484 | | - HEADERS_KEY, READONLY_AUTHORIZATION, |
485 | | - MAPPING_KEY, map(NODE_LABEL, "Rag", |
486 | | - ENTITY_KEY, "readID", |
487 | | - METADATA_KEY, "foo") |
488 | | - ); |
489 | | - |
490 | | - testResult(db, |
491 | | - """ |
492 | | - CALL apoc.vectordb.chroma.getAndUpdate($host, $collection, ['1', '2'], $conf) YIELD node, metadata, id, vector |
493 | | - WITH collect(node) as paths |
494 | | - CALL apoc.ml.rag(paths, $attributes, "Which city has foo equals to one?", $confPrompt) YIELD value |
495 | | - RETURN value |
496 | | - """ |
497 | | - , |
| 464 | + Map<String, Object> conf = map( |
| 465 | + ALL_RESULTS_KEY, true, MAPPING_KEY, map(NODE_LABEL, "Rag", ENTITY_KEY, "readID", METADATA_KEY, "foo")); |
| 466 | + |
| 467 | + testResult( |
| 468 | + db, |
| 469 | + "CALL apoc.vectordb.chroma.getAndUpdate($host, $collection, ['1', '2'], $conf) YIELD node, metadata, id, vector\n" |
| 470 | + + "WITH collect(node) as paths\n" |
| 471 | + + "CALL apoc.ml.rag(paths, $attributes, \"Which city has foo equals to one?\", $confPrompt) YIELD value\n" |
| 472 | + + "RETURN value", |
498 | 473 | map( |
499 | 474 | "host", HOST, |
500 | 475 | "conf", conf, |
501 | 476 | "collection", COLL_ID.get(), |
502 | 477 | "confPrompt", map(API_KEY_CONF, openAIKey), |
503 | | - "attributes", List.of("city", "foo") |
504 | | - ), |
| 478 | + "attributes", List.of("city", "foo")), |
505 | 479 | VectorDbTestUtil::assertRagWithVectors); |
506 | 480 | } |
507 | 481 | } |
0 commit comments