Skip to content

Commit a93023b

Browse files
committed
fix: update GraphQL mutation input type and clean up comments and adding interactivity chat to do some tasks
1 parent acc75b6 commit a93023b

File tree

13 files changed

+646
-153
lines changed

13 files changed

+646
-153
lines changed

backend/src/chat/chat.resolver.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,38 @@ export class ChatResolver {
9898
}
9999
}
100100

101+
@Mutation(() => String)
102+
@JWTAuth()
103+
async triggerAgentChatStream(
104+
@Args('input') input: ChatInput,
105+
): Promise<string> {
106+
try {
107+
const iterator = this.chatProxyService.streamChat(input);
108+
let accumulatedContent = '';
109+
110+
for await (const chunk of iterator) {
111+
if (chunk) {
112+
// const enhancedChunk = {
113+
// ...chunk,
114+
// chatId: input.chatId,
115+
// };
116+
// await this.pubSub.publish(`chat_stream_${input.chatId}`, {
117+
// chatStream: enhancedChunk,
118+
// });
119+
120+
if (chunk.choices[0]?.delta?.content) {
121+
accumulatedContent += chunk.choices[0].delta.content;
122+
}
123+
}
124+
}
125+
126+
return accumulatedContent;
127+
} catch (error) {
128+
this.logger.error('Error in triggerChatStream:', error);
129+
throw error;
130+
}
131+
}
132+
101133
@Query(() => [String], { nullable: true })
102134
async getAvailableModelTags(): Promise<string[]> {
103135
try {

frontend/src/components/chat/chat-bottombar.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { motion, AnimatePresence } from 'framer-motion';
44
import TextareaAutosize from 'react-textarea-autosize';
55
import { PaperclipIcon, Send, X } from 'lucide-react';
66
import { cn } from '@/lib/utils';
7-
import { ChatProps } from './chat-panel';
7+
import { Message } from '../../const/MessageType';
88
import Image from 'next/image';
99
import {
1010
Tooltip,
@@ -13,14 +13,28 @@ import {
1313
TooltipTrigger,
1414
} from '@/components/ui/tooltip';
1515

16+
interface ChatBottombarProps {
17+
messages: Message[];
18+
input: string;
19+
handleInputChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
20+
handleSubmit: (e: React.FormEvent<HTMLFormElement>) => void;
21+
stop: () => void;
22+
formRef: React.RefObject<HTMLFormElement>;
23+
setInput?: React.Dispatch<React.SetStateAction<string>>;
24+
setMessages: (messages: Message[]) => void;
25+
setSelectedModel: React.Dispatch<React.SetStateAction<string>>;
26+
}
27+
1628
export default function ChatBottombar({
1729
messages,
1830
input,
1931
handleInputChange,
2032
handleSubmit,
2133
formRef,
2234
setInput,
23-
}: ChatProps) {
35+
setMessages,
36+
setSelectedModel,
37+
}: ChatBottombarProps) {
2438
const [isMobile, setIsMobile] = useState(false);
2539
const [isFocused, setIsFocused] = useState(false);
2640
const [attachments, setAttachments] = useState<File[]>([]);

0 commit comments

Comments
 (0)