add multi model
This commit is contained in:
@@ -49,6 +49,7 @@ final readonly class RetriexEffectiveConfigProvider
|
||||
'llm' => [
|
||||
'timeout_seconds' => $this->param('retriex.llm.timeout_seconds'),
|
||||
'num_predict' => $this->param('retriex.llm.num_predict'),
|
||||
'call_models' => $this->param('retriex.llm.call_models'),
|
||||
],
|
||||
'retrieval' => $this->retrievalConfig(),
|
||||
'prompt' => $this->promptConfig(),
|
||||
@@ -85,6 +86,7 @@ final readonly class RetriexEffectiveConfigProvider
|
||||
$this->validateRuntime($config['runtime'], $errors, $warnings);
|
||||
$this->validateIndex($config['index'], $errors, $warnings);
|
||||
$this->validateModel($config['model_generation'], $errors, $warnings);
|
||||
$this->validateLlm($config['llm'], $errors, $warnings);
|
||||
$this->validateRetrieval($config['retrieval'], $errors, $warnings);
|
||||
$this->validatePrompt($config['prompt'], $errors, $warnings);
|
||||
$this->validateAgent($config['agent'], $errors, $warnings);
|
||||
@@ -1714,6 +1716,46 @@ final readonly class RetriexEffectiveConfigProvider
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $llm
|
||||
* @param list<string> $errors
|
||||
* @param list<string> $warnings
|
||||
*/
|
||||
private function validateLlm(array $llm, array &$errors, array &$warnings): void
|
||||
{
|
||||
$callModels = $llm['call_models'] ?? [];
|
||||
if (!is_array($callModels)) {
|
||||
$errors[] = 'llm.call_models must be a map.';
|
||||
return;
|
||||
}
|
||||
|
||||
$knownCalls = [
|
||||
'input_normalization',
|
||||
'shop_query_optimization',
|
||||
'final_answer',
|
||||
];
|
||||
|
||||
foreach ($callModels as $callName => $modelName) {
|
||||
if (!is_string($callName) || trim($callName) === '') {
|
||||
$errors[] = 'llm.call_models contains an invalid call name.';
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!in_array($callName, $knownCalls, true)) {
|
||||
$warnings[] = 'llm.call_models contains an unknown call name: ' . $callName . '.';
|
||||
}
|
||||
|
||||
if ($modelName !== null && !is_string($modelName)) {
|
||||
$errors[] = 'llm.call_models.' . $callName . ' must be null or a string model name.';
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_string($modelName) && trim($modelName) === '') {
|
||||
$warnings[] = 'llm.call_models.' . $callName . ' is empty and will use the default model.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $retrieval
|
||||
* @param list<string> $errors
|
||||
|
||||
Reference in New Issue
Block a user