-
Notifications
You must be signed in to change notification settings - Fork 4
/
Mistral.php
54 lines (48 loc) · 1.68 KB
/
Mistral.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
declare(strict_types=1);
namespace AdrienBrault\Instructrice\LLM\Provider;
use AdrienBrault\Instructrice\LLM\Cost;
use AdrienBrault\Instructrice\LLM\LLMConfig;
use AdrienBrault\Instructrice\LLM\OpenAiJsonStrategy;
enum Mistral: string implements ProviderModel
{
case MISTRAL_7B = 'open-mistral-7b';
case MIXTRAL_8x7B = 'open-mixtral-8x7b';
case MIXTRAL_8x22B = 'open-mixtral-8x22b';
case MISTRAL_LARGE = 'mistral-large-latest';
public function getApiKeyEnvVar(): ?string
{
return 'MISTRAL_API_KEY';
}
public function createConfig(string $apiKey): LLMConfig
{
return new LLMConfig(
'https://api.mistral.ai/v1/chat/completions',
$this->value,
match ($this) {
self::MISTRAL_7B => 32000,
self::MIXTRAL_8x7B => 32000,
self::MIXTRAL_8x22B => 64000,
self::MISTRAL_LARGE => 32000,
},
match ($this) {
self::MISTRAL_7B => 'Mistral 7B',
self::MIXTRAL_8x7B => 'Mixtral 8x7B',
self::MIXTRAL_8x22B => 'Mixtral 8x22B',
self::MISTRAL_LARGE => 'Mistral Large',
},
'Mistral',
match ($this) {
self::MISTRAL_7B => Cost::create(0.25),
self::MIXTRAL_8x7B => Cost::create(0.7),
self::MIXTRAL_8x22B => new Cost(2, 6),
self::MISTRAL_LARGE => new Cost(8, 24),
},
OpenAiJsonStrategy::JSON,
headers: [
'Authorization' => 'Bearer ' . $apiKey,
],
docUrl: 'https://docs.mistral.ai/getting-started/models/'
);
}
}