-
Notifications
You must be signed in to change notification settings - Fork 1
/
json_format.php
37 lines (31 loc) · 903 Bytes
/
json_format.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use Partitech\PhpMistral\MistralClient;
use Partitech\PhpMistral\MistralClientException;
use Partitech\PhpMistral\Messages;
// export MISTRAL_API_KEY=your_api_key
$apiKey = getenv('MISTRAL_API_KEY');
$client = new MistralClient($apiKey);
$messages = new Messages();
$messages->addUserMessage('What is the best French cheese? Return the product and produce location in JSON format');
$params = [
'model' => 'mistral-large-latest',
'temperature' => 0.7,
'top_p' => 1,
'max_tokens' => null,
'safe_prompt' => false,
'random_seed' => null,
'response_format' => [
'type' => 'json_object'
]
];
try {
$chatResponse = $client->chat(
$messages,
$params
);
} catch (MistralClientException $e) {
echo $e->getMessage();
exit(1);
}
print_r(json_decode($chatResponse->getMessage()));