import React, { useState } from 'react'; import { Send } from 'lucide-react'; const TalkToAgent = () => { const [messages, setMessages] = useState([ { role: 'bot', content: "I'm CAWNCADE's internal agent. I have access to Serper and Tavily. How can I help you research today?" } ]); const [input, setInput] = useState(""); const [isTyping, setIsTyping] = useState(false); const handleSend = async () => { if (!input.trim()) return; const newMsg = { role: 'user', content: input }; setMessages([...messages, newMsg]); setInput(""); setIsTyping(true); try { // Call your new /api/v1/chat endpoint const response = await fetch('/api/v1/chat', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: input, session_id: 'default' }) }); const data = await response.json(); setMessages(prev => [...prev, { role: 'bot', content: data.output }]); } catch (e) { setMessages(prev => [...prev, { role: 'bot', content: "Chat service unavailable." }]); } finally { setIsTyping(false); } }; return (

Agent Console

Follow-up research and conversational investigation.

{messages.map((m, i) => (

{m.content}

))} {isTyping &&
Agent is thinking and researching...
}
setInput(e.target.value)} onKeyDown={(e) => e.key === 'Enter' && handleSend()} className="min-h-[44px] flex-1 rounded-xl border border-sky-500/30 bg-slate-900/70 p-3 text-white outline-none transition-colors focus:border-emerald-500/50" placeholder="Ask a follow-up question..." />
); }; export default TalkToAgent;