perf: AI机器人支持多会话

This commit is contained in:
kuaifan
2025-02-10 19:49:30 +09:00
parent f0b5e0c3b9
commit ffe7ebf711
5 changed files with 176 additions and 122 deletions

View File

@@ -66,10 +66,14 @@ class Setting extends AbstractModel
}
$array = [];
$aiList = ['openai', 'claude', 'deepseek', 'gemini', 'zhipu', 'qianwen', 'wenxin'];
$fieldList = ['key', 'model', 'base_url', 'agency', 'system', 'secret'];
$fieldList = ['key', 'model', 'base_url', 'agency', 'temperature', 'system', 'secret'];
foreach ($aiList as $aiName) {
foreach ($fieldList as $fieldName) {
$key = $aiName . '_' . $fieldName;
if ($fieldName == 'temperature' && $value[$key]) {
$array[$key] = floatval(min(1, max(0, floatval($value[$key]) ?: 0.7)));
continue;
}
$array[$key] = $value[$key] ?: match ($key) {
'openai_model' => 'gpt-4o-mini',
'claude_model' => 'claude-3-5-sonnet-latest',