File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ REPLICATE_API_KEY=
17
17
18
18
# For using Ollama
19
19
OLLAMA_HOST_URL =
20
+ OLLAMA_MODEL =
20
21
21
22
# For using GPT on Azure
22
23
AZURE_OPENAI_BASEURL =
Original file line number Diff line number Diff line change 6
6
"require" : {
7
7
"php" : " >=8.2" ,
8
8
"ext-pdo" : " *" ,
9
- "async-aws/bedrock-runtime" : " ^1.1" ,
10
9
"codewithkyrian/chromadb-php" : " ^0.4.0" ,
11
10
"codewithkyrian/transformers" : " ^0.6.1" ,
12
11
"doctrine/dbal" : " ^3.3 || ^4.0" ,
13
12
"google/auth" : " ^1.47" ,
14
- "mongodb/mongodb" : " ^2.1" ,
15
13
"mrmysql/youtube-transcript" : " ^0.0.5" ,
16
14
"php-http/discovery" : " ^1.20" ,
17
15
"probots-io/pinecone-php" : " ^1.0" ,
Original file line number Diff line number Diff line change 18
18
require_once dirname (__DIR__ ).'/bootstrap.php ' ;
19
19
20
20
$ platform = PlatformFactory::create (env ('OLLAMA_HOST_URL ' ), http_client ());
21
- $ model = new Ollama ();
21
+ $ ollamaModel = !empty ($ _SERVER ['OLLAMA_MODEL ' ]) ? $ _SERVER ['OLLAMA_MODEL ' ] : '' ;
22
+ $ model = new Ollama ($ ollamaModel );
22
23
23
24
$ agent = new Agent ($ platform , $ model , logger: logger ());
24
25
$ messages = new MessageBag (
25
26
Message::forSystem ('You are a helpful assistant. ' ),
26
27
Message::ofUser ('Tina has one brother and one sister. How many sisters do Tina \'s siblings have? ' ),
27
28
);
28
- $ result = $ agent ->call ($ messages );
29
29
30
- echo $ result ->getContent ().\PHP_EOL ;
30
+ try {
31
+ $ result = $ agent ->call ($ messages );
32
+ $ response = $ result ->getContent ().\PHP_EOL ;
33
+ } catch (InvalidArgumentException $ e ) {
34
+ $ response = $ e ->getMessage () . "\nMaybe use a different model? \n" ;
35
+ }
36
+
37
+ echo $ response ;
You can’t perform that action at this time.
0 commit comments