fix: AI 请求加 170 秒超时保护,防止服务端无响应时无限挂起
This commit is contained in:
parent
a4cccbc858
commit
6f008ed8c0
@ -19,6 +19,7 @@ export async function chatCompletion(messages: ChatMessage[], options: { tempera
|
||||
const config = requireAiConfig();
|
||||
const base = config.baseUrl.replace(/\/+$/, "");
|
||||
const response = await fetch(base + "/chat/completions", {
|
||||
signal: AbortSignal.timeout(170000),
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json", Authorization: "Bearer " + config.apiKey },
|
||||
body: JSON.stringify({ model: config.model, messages, temperature: options.temperature ?? 0.3 })
|
||||
|
||||
Loading…
Reference in New Issue
Block a user