fix: unify timeout to config value (5min default) for all evaluate APIs, add Korean timeout error guidance
This commit is contained in:
+8
-4
@@ -203,7 +203,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
stream: false
|
stream: false
|
||||||
};
|
};
|
||||||
|
|
||||||
const ollamaRes = await axios.post(targetUrl, payload, { timeout: 120000 });
|
const ollamaRes = await axios.post(targetUrl, payload, { timeout: getConfig().timeout });
|
||||||
const responseText = isLMStudio
|
const responseText = isLMStudio
|
||||||
? ollamaRes.data.choices?.[0]?.message?.content || ''
|
? ollamaRes.data.choices?.[0]?.message?.content || ''
|
||||||
: ollamaRes.data.message?.content || '';
|
: ollamaRes.data.message?.content || '';
|
||||||
@@ -248,7 +248,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
|
|
||||||
let responseText = "";
|
let responseText = "";
|
||||||
try {
|
try {
|
||||||
const ollamaRes = await axios.post(targetUrl, payload, { timeout: 120000 });
|
const ollamaRes = await axios.post(targetUrl, payload, { timeout: getConfig().timeout });
|
||||||
|
|
||||||
if (ollamaRes.data.error) {
|
if (ollamaRes.data.error) {
|
||||||
throw new Error(typeof ollamaRes.data.error === 'string' ? ollamaRes.data.error : JSON.stringify(ollamaRes.data.error));
|
throw new Error(typeof ollamaRes.data.error === 'string' ? ollamaRes.data.error : JSON.stringify(ollamaRes.data.error));
|
||||||
@@ -258,8 +258,12 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
? ollamaRes.data.choices?.[0]?.message?.content || ""
|
? ollamaRes.data.choices?.[0]?.message?.content || ""
|
||||||
: ollamaRes.data.message?.content || "";
|
: ollamaRes.data.message?.content || "";
|
||||||
} catch (apiErr: any) {
|
} catch (apiErr: any) {
|
||||||
|
const isTimeout = apiErr.code === 'ETIMEDOUT' || apiErr.code === 'ECONNABORTED' || apiErr.message?.includes('timeout');
|
||||||
|
const errDetail = isTimeout
|
||||||
|
? `AI 응답 시간 초과 — 모델이 문제를 풀기에 시간이 부족했습니다. 더 작은 모델(e2b)을 사용하거나 Settings에서 Request Timeout을 늘려주세요.`
|
||||||
|
: `오프라인: AI 엔진에 연결할 수 없습니다. (${apiErr.message})`;
|
||||||
res.writeHead(500, { 'Content-Type': 'application/json' });
|
res.writeHead(500, { 'Content-Type': 'application/json' });
|
||||||
res.end(JSON.stringify({ error: `오프라인: AI 엔진에 연결할 수 없습니다. (${apiErr.message})` }));
|
res.end(JSON.stringify({ error: errDetail }));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,7 +310,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
|
|
||||||
let responseText = "";
|
let responseText = "";
|
||||||
try {
|
try {
|
||||||
const ollamaRes = await axios.post(targetUrl, payload, { timeout: 120000 });
|
const ollamaRes = await axios.post(targetUrl, payload, { timeout: getConfig().timeout });
|
||||||
responseText = isLMStudio
|
responseText = isLMStudio
|
||||||
? ollamaRes.data.choices?.[0]?.message?.content || ""
|
? ollamaRes.data.choices?.[0]?.message?.content || ""
|
||||||
: ollamaRes.data.message?.content || "";
|
: ollamaRes.data.message?.content || "";
|
||||||
|
|||||||
Reference in New Issue
Block a user