mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Improve empty assistant messages
This commit is contained in:
1 file changed
+42
-7
@@ -1,6 +1,7 @@
|
||||
import { useState, useRef, useEffect } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Send, Settings, Play, CloudUpload, Loader2, MessageSquarePlus } from 'lucide-react';
|
||||
import { useAISettings } from '@/hooks/useAISettings';
|
||||
import { useFS } from '@/hooks/useFS';
|
||||
@@ -354,6 +355,11 @@ BASE_DOMAIN=nostrdeploy.com`);
|
||||
<div className="flex-1 overflow-y-scroll overflow-x-hidden" ref={scrollAreaRef}>
|
||||
<div className="p-4 space-y-4">
|
||||
{messages.map((message, index) => {
|
||||
// Skip assistant messages with no content
|
||||
if (message.role === 'assistant' && !message.content) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Find the corresponding tool call for tool messages
|
||||
let toolCall: OpenAI.Chat.Completions.ChatCompletionMessageToolCall | undefined = undefined;
|
||||
if (message.role === 'tool' && 'tool_call_id' in message) {
|
||||
@@ -378,13 +384,42 @@ BASE_DOMAIN=nostrdeploy.com`);
|
||||
);
|
||||
})}
|
||||
{streamingMessage && (
|
||||
<AIMessageItem
|
||||
key="streaming-message"
|
||||
message={streamingMessage}
|
||||
userDisplayName="You"
|
||||
isCurrentlyLoading
|
||||
onStopGeneration={stopGeneration}
|
||||
/>
|
||||
streamingMessage.content ? (
|
||||
<AIMessageItem
|
||||
key="streaming-message"
|
||||
message={streamingMessage}
|
||||
userDisplayName="You"
|
||||
isCurrentlyLoading
|
||||
onStopGeneration={stopGeneration}
|
||||
/>
|
||||
) : (
|
||||
<div key="streaming-loading" className="flex gap-3">
|
||||
<div className="h-8 w-8 flex-shrink-0 flex items-center justify-center">
|
||||
<div className="h-8 w-8 rounded-full bg-muted flex items-center justify-center">
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
<span className="font-medium text-sm">Assistant</span>
|
||||
<span className="text-xs text-muted-foreground">AI</span>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={stopGeneration}
|
||||
className="ml-auto gap-1 h-6 px-2 text-xs"
|
||||
>
|
||||
<Loader2 className="h-3 w-3 animate-spin" />
|
||||
Stop
|
||||
</Button>
|
||||
</div>
|
||||
<div className="text-sm space-y-2">
|
||||
<Skeleton className="h-4 w-full" />
|
||||
<Skeleton className="h-4 w-3/4" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user