Skip to content

Instantly share code, notes, and snippets.

@mkurzeja
Created March 31, 2025 06:23
Show Gist options
  • Select an option

  • Save mkurzeja/95655a5fd637e4a76cea8cb0daf7010d to your computer and use it in GitHub Desktop.

Select an option

Save mkurzeja/95655a5fd637e4a76cea8cb0daf7010d to your computer and use it in GitHub Desktop.
PHP at Scale #8
<?php
$config = new OllamaConfig();
$config->model = 'mistral';
$chat = new OllamaChat($config);
echo $chat->generateText('Say hello to `php-at-scale` newsletter subscribers.');
<?php
$chat->setSystemMessage('Answer briefly, using pirrraate language');
echo $chat->generateText('Say hello to `php-at-scale` newsletter subscribers.');
<?php
class MailerExample
{
public function sendMail(string $subject, string $body, string $email): void
{
echo 'The email has been sent to ' . $email . PHP_EOL .
' with the subject "' . $subject . '" and the body: ' . PHP_EOL . $body;
}
}
$tool = FunctionBuilder::buildFunctionInfo(new MailerExample(), 'sendMail');
$chat->addTool($tool);
$response = $chat->generateChat([
Message::system('You are an AI that deliver information using the email system.
When you have enough information to answer the question of the user you send a mail.
User email is example@example.com'),
Message::user('Who is Marie Curie in one line?')
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment