Remove CRM chat fallback responses
This commit is contained in:
@@ -441,17 +441,9 @@ export async function runLangGraphCrmAgentFor(input: {
|
||||
}
|
||||
|
||||
if (!llmApiKey) {
|
||||
return {
|
||||
text: "LLM API key не задан. Сейчас включен fallback-агент без LLM.",
|
||||
plan: [
|
||||
"Проверить .env",
|
||||
"Добавить OPENROUTER_API_KEY (или LLM_API_KEY / OPENAI_API_KEY / DASHSCOPE_API_KEY / QWEN_API_KEY / GIGACHAT_AUTH_KEY+GIGACHAT_SCOPE)",
|
||||
"Перезапустить dev-сервер",
|
||||
],
|
||||
tools: [],
|
||||
thinking: ["LLM недоступна, возвращен fallback-ответ."],
|
||||
toolRuns: [],
|
||||
};
|
||||
throw new Error(
|
||||
"LLM API key is not configured. Set OPENROUTER_API_KEY (or GIGACHAT_AUTH_KEY/GIGACHAT_SCOPE) and restart.",
|
||||
);
|
||||
}
|
||||
|
||||
// Keep the dataset fresh so the "CRM filesystem" stays in sync with DB.
|
||||
@@ -1002,7 +994,7 @@ export async function runLangGraphCrmAgentFor(input: {
|
||||
};
|
||||
|
||||
const extractResult = (res: any) => {
|
||||
const fallbackText = (() => {
|
||||
const extractedText = (() => {
|
||||
const messages = Array.isArray(res?.messages) ? res.messages : [];
|
||||
for (let i = messages.length - 1; i >= 0; i -= 1) {
|
||||
const msg = messages[i];
|
||||
@@ -1015,7 +1007,7 @@ export async function runLangGraphCrmAgentFor(input: {
|
||||
})();
|
||||
|
||||
return {
|
||||
text: fallbackText.trim(),
|
||||
text: extractedText.trim(),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1063,16 +1055,13 @@ export async function runLangGraphCrmAgentFor(input: {
|
||||
),
|
||||
]);
|
||||
} catch (e: any) {
|
||||
await emitTrace({ text: "Один из шагов завершился ошибкой, пробую безопасный обход." });
|
||||
await emitTrace({ text: "Один из шагов завершился ошибкой." });
|
||||
cycleSpan?.end({
|
||||
output: "error",
|
||||
level: "ERROR",
|
||||
statusMessage: String(e?.message ?? e ?? "unknown_error"),
|
||||
});
|
||||
if (!finalText) {
|
||||
finalText = "Не удалось завершить задачу за отведенное время. Уточни запрос или сократи объем.";
|
||||
}
|
||||
break;
|
||||
throw e;
|
||||
}
|
||||
|
||||
const parsed = extractResult(res);
|
||||
|
||||
Reference in New Issue
Block a user