diff --git a/examples/.env b/examples/.env index 5c1fdc0b4..234a83fde 100644 --- a/examples/.env +++ b/examples/.env @@ -17,6 +17,7 @@ REPLICATE_API_KEY= # For using Ollama OLLAMA_HOST_URL= +OLLAMA_MODEL= # For using GPT on Azure AZURE_OPENAI_BASEURL= diff --git a/examples/ollama/chat-llama.php b/examples/ollama/chat-llama.php index 394d815c5..265313928 100644 --- a/examples/ollama/chat-llama.php +++ b/examples/ollama/chat-llama.php @@ -18,13 +18,20 @@ require_once dirname(__DIR__).'/bootstrap.php'; $platform = PlatformFactory::create(env('OLLAMA_HOST_URL'), http_client()); -$model = new Ollama(); +$ollamaModel = $_SERVER['OLLAMA_MODEL'] ?? ''; +$model = new Ollama($ollamaModel); $agent = new Agent($platform, $model, logger: logger()); $messages = new MessageBag( Message::forSystem('You are a helpful assistant.'), Message::ofUser('Tina has one brother and one sister. How many sisters do Tina\'s siblings have?'), ); -$result = $agent->call($messages); -echo $result->getContent().\PHP_EOL; +try { + $result = $agent->call($messages); + echo $result->getContent().\PHP_EOL; +} catch(InvalidArgumentException $e) { + echo $e->getMessage() . "\nMaybe use a different model?\n"; +} + +echo $response;