mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-25 17:54:34 +08:00
fix(ai): handle model output truncation
This commit is contained in:
1 parent
02b75f8532
commit
1388aaccf7
13 files changed
+229
-11
No files matched your search
@@ -253,6 +253,8 @@ export async function runServerAgent(options: RunAgentOptions): Promise<void> {
|
||||
maxToolRounds: DEFAULT_MAX_TOOL_ROUNDS,
|
||||
abortSignal,
|
||||
providerSessionId: aiChatId,
|
||||
locale,
|
||||
logger: aiLogger ?? undefined,
|
||||
steerMessage,
|
||||
thinkingLevel: thinkingLevel as import('@openchatlab/core').ThinkingLevel | undefined,
|
||||
onConvertToLlm: (filteredMessages) => {
|
||||
@@ -268,12 +270,14 @@ export async function runServerAgent(options: RunAgentOptions): Promise<void> {
|
||||
},
|
||||
})
|
||||
|
||||
if (result.error) {
|
||||
if (result.error && !abortSignal?.aborted) {
|
||||
const friendlyMessage = formatAIError(result.error)
|
||||
onEvent({ type: 'error', error: { name: 'AgentError', message: friendlyMessage } })
|
||||
}
|
||||
|
||||
handler.emitStatus('completed', cachedMessages, { force: true })
|
||||
handler.emitStatus(abortSignal?.aborted ? 'aborted' : result.error ? 'error' : 'completed', cachedMessages, {
|
||||
force: true,
|
||||
})
|
||||
onEvent({ type: 'done', isFinished: true, usage: result.usage })
|
||||
} catch (error) {
|
||||
const friendlyMessage = formatAIError(error)
|
||||
|
||||
Reference in new issue
Block a user