28
28
29
29
require_once dirname (__DIR__ ).'/bootstrap.php ' ;
30
30
31
- echo "Make sure you've run the SQL setup from SUPABASE_SETUP.md first! \n\n" ;
32
-
33
31
$ store = new Store (
34
- http : http_client (),
32
+ httpClient : http_client (),
35
33
url: env ('SUPABASE_URL ' ),
36
34
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 ' )
41
35
);
42
36
43
37
$ documents = [];
@@ -51,49 +45,25 @@ functionName: env('SUPABASE_MATCH_FUNCTION')
51
45
}
52
46
53
47
$ platform = PlatformFactory::create (
54
- env ('OLLAMA_HOST_URL ' ) ?? ' http://localhost:11434 ' ,
48
+ env ('OLLAMA_HOST_URL ' ),
55
49
http_client ()
56
50
);
57
51
58
- $ embeddingModel = new Ollama ('mxbai-embed-large ' );
59
- $ vectorizer = new Vectorizer ($ platform , $ embeddingModel );
52
+ $ vectorizer = new Vectorizer ($ platform , new Ollama ('mxbai-embed-large ' ));
60
53
$ loader = new InMemoryLoader ($ documents );
61
54
$ indexer = new Indexer ($ loader , $ vectorizer , $ store , logger: logger ());
62
55
$ indexer ->index ();
63
56
64
- $ chatModel = new Ollama ('llama3.2:3b ' );
65
-
66
57
$ similaritySearch = new SimilaritySearch ($ vectorizer , $ store );
67
58
$ toolbox = new Toolbox ([$ similaritySearch ], logger: logger ());
68
59
$ 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 ());
70
61
71
62
$ messages = new MessageBag (
72
63
Message::forSystem ('Please answer all user questions only using SimilaritySearch function. ' ),
73
64
Message::ofUser ('Which movie fits the theme of technology? ' )
74
65
);
75
66
76
- echo "Query: Which movie fits the theme of technology? \n" ;
77
- echo "Processing... \n" ;
67
+ $ result = $ agent ->call ($ messages );
78
68
79
- try {
80
- $ result = $ agent ->call ($ messages );
81
- echo '✅ Response: ' .$ result ->getContent ()."\n\n" ;
82
- } catch (Exception $ e ) {
83
- echo '❌ Error: ' .$ e ->getMessage ()."\n\n" ;
84
- }
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
- }
69
+ echo $ result ->getContent ().\PHP_EOL ;
0 commit comments