Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/.env
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ REPLICATE_API_KEY=

# For using Ollama
OLLAMA_HOST_URL=
OLLAMA_MODEL=

# For using GPT on Azure
AZURE_OPENAI_BASEURL=
Expand Down
13 changes: 10 additions & 3 deletions examples/ollama/chat-llama.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Loading