File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <[email protected] >
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ use Symfony \AI \Agent \Agent ;
13
+ use Symfony \AI \Platform \Bridge \Mistral \Mistral ;
14
+ use Symfony \AI \Platform \Bridge \Mistral \PlatformFactory ;
15
+ use Symfony \AI \Platform \Message \Message ;
16
+ use Symfony \AI \Platform \Message \MessageBag ;
17
+
18
+ require_once dirname (__DIR__ ).'/bootstrap.php ' ;
19
+
20
+ $ platform = PlatformFactory::create (env ('MISTRAL_API_KEY ' ), http_client ());
21
+ $ agent = new Agent ($ platform , new Mistral (), logger: logger ());
22
+
23
+ $ messages = new MessageBag (
24
+ Message::forSystem ('Just give short answers. ' ),
25
+ Message::ofUser ('What is your favorite color? ' ),
26
+ );
27
+ $ result = $ agent ->call ($ messages , [
28
+ 'temperature ' => 1.5 ,
29
+ 'n ' => 10 ,
30
+ ]);
31
+
32
+ foreach ($ result ->getContent () as $ key => $ choice ) {
33
+ echo sprintf ('Choice #%d: %s ' , ++$ key , $ choice ->getContent ()).\PHP_EOL ;
34
+ }
You can’t perform that action at this time.
0 commit comments