mirror of
https://github.com/tcsenpai/agenticSeek.git
synced 2025-06-06 11:05:26 +00:00
refactor : message for status
This commit is contained in:
parent
5ac7df1854
commit
0f09ef92dd
2
api.py
2
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:
|
||||
|
@ -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,22 +73,36 @@ 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();
|
||||
checkHealth();
|
||||
@ -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);
|
||||
|
@ -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__":
|
||||
|
@ -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__":
|
||||
|
@ -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
|
||||
|
@ -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__":
|
||||
|
Loading…
x
Reference in New Issue
Block a user