-
-
Save mkurzeja/95655a5fd637e4a76cea8cb0daf7010d to your computer and use it in GitHub Desktop.
PHP at Scale #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $config = new OllamaConfig(); | |
| $config->model = 'mistral'; | |
| $chat = new OllamaChat($config); | |
| echo $chat->generateText('Say hello to `php-at-scale` newsletter subscribers.'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $chat->setSystemMessage('Answer briefly, using pirrraate language'); | |
| echo $chat->generateText('Say hello to `php-at-scale` newsletter subscribers.'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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