2828
2929require_once dirname (__DIR__ ).'/bootstrap.php ' ;
3030
31- echo "Make sure you've run the SQL setup from SUPABASE_SETUP.md first! \n\n" ;
32-
3331$ store = new Store (
34- http : http_client (),
32+ httpClient : http_client (),
3533 url: env ('SUPABASE_URL ' ),
3634 apiKey: env ('SUPABASE_API_KEY ' ),
37- table: env ('SUPABASE_TABLE ' ),
38- vectorFieldName: env ('SUPABASE_VECTOR_FIELD ' ),
39- vectorDimension: (int ) env ('SUPABASE_VECTOR_DIMENSION ' ),
40- functionName: env ('SUPABASE_MATCH_FUNCTION ' )
4135);
4236
4337$ documents = [];
@@ -51,49 +45,30 @@ functionName: env('SUPABASE_MATCH_FUNCTION')
5145}
5246
5347$ platform = PlatformFactory::create (
54- env ('OLLAMA_HOST_URL ' ) ?? ' http://localhost:11434 ' ,
48+ env ('OLLAMA_HOST_URL ' ),
5549 http_client ()
5650);
5751
58- $ embeddingModel = new Ollama ('mxbai-embed-large ' );
59- $ vectorizer = new Vectorizer ($ platform , $ embeddingModel );
52+ $ vectorizer = new Vectorizer ($ platform , new Ollama ('mxbai-embed-large ' ));
6053$ loader = new InMemoryLoader ($ documents );
6154$ indexer = new Indexer ($ loader , $ vectorizer , $ store , logger: logger ());
6255$ indexer ->index ();
6356
64- $ chatModel = new Ollama ('llama3.2:3b ' );
65-
6657$ similaritySearch = new SimilaritySearch ($ vectorizer , $ store );
6758$ toolbox = new Toolbox ([$ similaritySearch ], logger: logger ());
6859$ processor = new AgentProcessor ($ toolbox );
69- $ agent = new Agent ($ platform , $ chatModel , [$ processor ], [$ processor ], logger: logger ());
60+ $ agent = new Agent ($ platform , new Ollama ( ' llama3.2:3b ' ) , [$ processor ], [$ processor ], logger: logger ());
7061
7162$ messages = new MessageBag (
7263 Message::forSystem ('Please answer all user questions only using SimilaritySearch function. ' ),
7364 Message::ofUser ('Which movie fits the theme of technology? ' )
7465);
7566
7667echo "Query: Which movie fits the theme of technology? \n" ;
77- echo "Processing... \n" ;
7868
7969try {
8070 $ result = $ agent ->call ($ messages );
8171 echo '✅ Response: ' .$ result ->getContent ()."\n\n" ;
8272} catch (Exception $ e ) {
8373 echo '❌ Error: ' .$ e ->getMessage ()."\n\n" ;
8474}
85-
86- $ messages2 = new MessageBag (
87- Message::forSystem ('Please answer all user questions only using SimilaritySearch function. ' ),
88- Message::ofUser ('What are some good action movies? ' )
89- );
90-
91- echo "Query: What are some good action movies? \n" ;
92- echo "Processing... \n" ;
93-
94- try {
95- $ result2 = $ agent ->call ($ messages2 );
96- echo '✅ Response: ' .$ result2 ->getContent ()."\n\n" ;
97- } catch (Exception $ e ) {
98- echo '❌ Error: ' .$ e ->getMessage ()."\n\n" ;
99- }
0 commit comments