diff --git a/app/components/Stream.tsx b/app/components/Stream.tsx index 271506d..e056fd5 100644 --- a/app/components/Stream.tsx +++ b/app/components/Stream.tsx @@ -16,9 +16,6 @@ export default function Stream({ className }: StreamProps) { const [isThinking, setIsThinking] = useState(true); const [loadingDots, setLoadingDots] = useState(''); const bottomRef = useRef(null); - const conversationId = useMemo(() => { - return generateUUID(); - }, []); const handleSuccess = useCallback((messages: AgentMessage[]) => { let message = messages.find((res) => res.event === 'agent'); @@ -42,7 +39,6 @@ export default function Stream({ className }: StreamProps) { const { postChat, isLoading } = useChat({ onSuccess: handleSuccess, - conversationId, }); // enables live stream of agent thoughts diff --git a/app/hooks/useChat.ts b/app/hooks/useChat.ts index 652e3d9..3a3caaa 100644 --- a/app/hooks/useChat.ts +++ b/app/hooks/useChat.ts @@ -1,6 +1,7 @@ import { useCallback, useState } from 'react'; import { API_URL } from '../config'; import type { AgentMessage } from '../types'; +import { generateUUID } from '../utils'; type UseChatResponse = { messages?: AgentMessage[]; @@ -30,7 +31,10 @@ export default function useChat({ headers: { 'Content-Type': 'application/json', }, - body: JSON.stringify({ input, conversation_id: conversationId }), + body: JSON.stringify({ + input, + conversation_id: conversationId || generateUUID(), + }), }); if (!response.ok) {