-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathLLMConfig.php
46 lines (41 loc) · 1.45 KB
/
LLMConfig.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
<?php
declare(strict_types=1);
namespace AdrienBrault\Instructrice\LLM;
class LLMConfig
{
/**
* @var list<string>|null
*/
public readonly ?array $stopTokens;
/**
* @param callable(mixed, string): string $systemPrompt
* @param array<string, mixed> $headers
* @param list<string> $stopTokens
* @param class-string<LLMInterface> $llmClass
*/
public function __construct(
public readonly string $uri,
public readonly string $model,
public readonly int $contextWindow,
public readonly string $label,
public readonly ?string $provider = null,
public readonly Cost $cost = new Cost(0, 0),
public readonly OpenAiToolStrategy|OpenAiJsonStrategy|null $strategy = null,
public $systemPrompt = null,
public readonly array $headers = [],
public readonly ?int $maxTokens = null,
public readonly ?string $docUrl = null,
array|false|null $stopTokens = null,
public readonly ?string $llmClass = null,
) {
if ($stopTokens !== false) {
$this->stopTokens = $stopTokens ?? ["```\n\n", '<|im_end|>', "\n\n\n", "\t\n\t\n"];
} else {
$this->stopTokens = null;
}
}
public function getLabel(bool $withProvider = true): string
{
return $withProvider && $this->provider !== null ? $this->provider . ' - ' . $this->label : $this->label;
}
}