feat: add thinking content to chat response

This commit is contained in:
shokollm
2026-04-10 09:16:08 +00:00
parent db4fb83243
commit 57fa200ba9
5 changed files with 26 additions and 5 deletions

View File

@@ -123,6 +123,7 @@ export interface BotChatRequest {
export interface BotChatResponse {
response: string;
thinking: string | null;
strategy_config: StrategyConfig | null;
success: boolean;
}

View File

@@ -9,6 +9,7 @@
let botId = $derived($page.params.id);
let isSending = $state(false);
let showStrategy = $state(false);
let thinkingContent = $state('');
onMount(async () => {
if (!$isAuthenticated && !$isLoading) {
@@ -43,6 +44,7 @@
if (isSending) return;
isSending = true;
thinkingContent = '';
// Add user's message immediately so it shows even before API response
addMessage({ role: 'user', content: message });
@@ -55,6 +57,8 @@
const response = await api.bots.chat(botId, message, controller.signal);
clearTimeout(timeoutId);
// Set thinking content for display
thinkingContent = response.thinking || '';
addMessage({ role: 'assistant', content: response.response });
if (response.strategy_config) {
@@ -109,7 +113,8 @@
bot={$currentBotStore}
messages={$chatStore}
isThinking={isSending}
onSendMessage={handleSendMessage}
{thinkingContent}
onSendMessage={handleSendMessage}
/>
</div>