feat: implement error handling for empty upstream responses in chat streams and update UI to display stream-level errors

This commit is contained in:
CJACK
2026-04-13 03:22:38 +08:00
parent acb110865f
commit d78789a66e
4 changed files with 124 additions and 1 deletions

View File

@@ -133,7 +133,9 @@ export default function ChatPanel({
)}
<div className="text-sm leading-7 text-foreground whitespace-pre-wrap">
{streamingContent || response?.choices?.[0]?.message?.content || (response?.error && <span className="text-destructive font-medium">{response.error}</span>) || (loading && <span className="text-muted-foreground italic">{t('apiTester.generating')}</span>)}
{response?.success === false
? <span className="text-destructive font-medium">{response.error || t('apiTester.requestFailed')}</span>
: (streamingContent || response?.choices?.[0]?.message?.content || (loading && <span className="text-muted-foreground italic">{t('apiTester.generating')}</span>))}
{isStreaming && <span className="inline-block w-1.5 h-4 bg-primary ml-1 align-middle animate-pulse" />}
</div>
</div>