File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88playground /*
99.idea
1010.chroma
11- .vscode
11+ .vscode
Original file line number Diff line number Diff line change 22
33declare (strict_types=1 );
44
5- require ' ../vendor/autoload.php ' ;
5+ require __DIR__ . ' / ../vendor/autoload.php ' ;
66
77use Codewithkyrian \ChromaDB \ChromaDB ;
88use Codewithkyrian \ChromaDB \Embeddings \JinaEmbeddingFunction ;
1313 ->withTenant ('test_tenant ' )
1414 ->connect ();
1515
16- $ chroma ->deleteAllCollections ();
17-
1816$ embeddingFunction = new OllamaEmbeddingFunction ();
1917
20- $ collection = $ chroma ->createCollection (
18+ $ collection = $ chroma ->getCollection (
2119 name: 'test_collection ' ,
2220 embeddingFunction: $ embeddingFunction
2321);
2422
23+ $ items = [
24+ ["id " => 1 , "content " => "He seems very happy " ],
25+ ["id " => 2 , "content " => "He was very sad when we last talked " ],
26+ ["id " => 3 , "content " => "She made him angry " ],
27+ ];
28+
2529$ collection ->add (
26- ids: [ ' 1 ' , '2 ' , ' 3 ' ] ,
27- documents: [ ' He seems very happy ' , 'He was very sad when we last talked ' , ' She made him angry ' ]
30+ ids: array_column ( $ items , 'id ' ) ,
31+ documents: array_column ( $ items , 'content ' )
2832);
2933
3034$ queryResponse = $ collection ->query (
You can’t perform that action at this time.
0 commit comments