diff --git a/api.py b/api.py index e0e877e..ae08ad3 100755 --- a/api.py +++ b/api.py @@ -175,7 +175,7 @@ async def process_query(request: QueryRequest): agent_name="Unknown", success="false", blocks={}, - status="No agent working.", + status="Agent working...", timestamp=str(time.time()) ) if is_generating: diff --git a/frontend/agentic-seek-front/src/App.js b/frontend/agentic-seek-front/src/App.js index d48f9f1..98bf46d 100644 --- a/frontend/agentic-seek-front/src/App.js +++ b/frontend/agentic-seek-front/src/App.js @@ -14,13 +14,15 @@ function App() { const messagesEndRef = useRef(null); useEffect(() => { - const intervalId = setInterval(() => { - checkHealth(); - fetchLatestAnswer(); - fetchScreenshot(); - }, 1500); - return () => clearInterval(intervalId); - }, [messages]); + if (!isLoading) { + const intervalId = setInterval(() => { + checkHealth(); + fetchLatestAnswer(); + fetchScreenshot(); + }, 1500); + return () => clearInterval(intervalId); + } + }, [isLoading, messages]); const checkHealth = async () => { try { @@ -71,21 +73,35 @@ function App() { try { const res = await axios.get('http://0.0.0.0:8000/latest_answer'); const data = res.data; + + if (!data.answer || data.answer.trim() === '') { + return; + } const answerExists = messages.some( - (msg) => msg.timestamp === data.timestamp || data.answer === undefined + (msg) => + msg.timestamp === data.timestamp && + normalizeAnswer(msg.content) === normalizeAnswer(data.answer) ); + console.log('Fetched latest answer:', data.answer); if (!answerExists) { setMessages((prev) => [ ...prev, - { type: 'agent', content: data.answer, agentName: data.agent_name, status: data.status, timestamp: data.timestamp }, + { + type: 'agent', + content: data.answer, + agentName: data.agent_name, + status: data.status, + timestamp: data.timestamp, + }, ]); setStatus(data.status); scrollToBottom(); } } catch (error) { - console.error("Error fetching latest answer:", error); + console.error('Error fetching latest answer:', error); } }; + const handleSubmit = async (e) => { e.preventDefault(); @@ -100,10 +116,12 @@ function App() { try { console.log('Sending query:', query); + setQuery('waiting for response...'); const res = await axios.post('http://0.0.0.0:8000/query', { query, tts_enabled: false }); + setQuery('Enter your query...'); console.log('Response:', res.data); const data = res.data; setResponseData(data); diff --git a/sources/agents/browser_agent.py b/sources/agents/browser_agent.py index f9eee07..204455b 100644 --- a/sources/agents/browser_agent.py +++ b/sources/agents/browser_agent.py @@ -372,7 +372,7 @@ class BrowserAgent(Agent): self.status_message = "Summarizing findings..." answer, reasoning = await self.llm_request() pretty_print(answer, color="output") - self.status_message = "Done" + self.status_message = "Ready" return answer, reasoning if __name__ == "__main__": diff --git a/sources/agents/casual_agent.py b/sources/agents/casual_agent.py index 0215575..f756f27 100644 --- a/sources/agents/casual_agent.py +++ b/sources/agents/casual_agent.py @@ -23,7 +23,7 @@ class CasualAgent(Agent): animate_thinking("Thinking...", color="status") answer, reasoning = await self.llm_request() self.last_answer = answer - self.status_message = "Done" + self.status_message = "Ready" return answer, reasoning if __name__ == "__main__": diff --git a/sources/agents/code_agent.py b/sources/agents/code_agent.py index 8c0e468..dd133ab 100644 --- a/sources/agents/code_agent.py +++ b/sources/agents/code_agent.py @@ -69,7 +69,7 @@ class CoderAgent(Agent): self.status_message = "Correcting code..." self.show_answer() attempt += 1 - self.status_message = "Done" + self.status_message = "Ready" if attempt == max_attempts: return "I'm sorry, I couldn't find a solution to your problem. How would you like me to proceed ?", reasoning return answer, reasoning diff --git a/sources/agents/file_agent.py b/sources/agents/file_agent.py index 348e12c..f3169b1 100644 --- a/sources/agents/file_agent.py +++ b/sources/agents/file_agent.py @@ -30,7 +30,7 @@ class FileAgent(Agent): exec_success, _ = self.execute_modules(answer) answer = self.remove_blocks(answer) self.last_answer = answer - self.status_message = "Done" + self.status_message = "Ready" return answer, reasoning if __name__ == "__main__":