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",
|
agent_name="Unknown",
|
||||||
success="false",
|
success="false",
|
||||||
blocks={},
|
blocks={},
|
||||||
status="No agent working.",
|
status="Agent working...",
|
||||||
timestamp=str(time.time())
|
timestamp=str(time.time())
|
||||||
)
|
)
|
||||||
if is_generating:
|
if is_generating:
|
||||||
|
@ -14,13 +14,15 @@ function App() {
|
|||||||
const messagesEndRef = useRef(null);
|
const messagesEndRef = useRef(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const intervalId = setInterval(() => {
|
if (!isLoading) {
|
||||||
checkHealth();
|
const intervalId = setInterval(() => {
|
||||||
fetchLatestAnswer();
|
checkHealth();
|
||||||
fetchScreenshot();
|
fetchLatestAnswer();
|
||||||
}, 1500);
|
fetchScreenshot();
|
||||||
return () => clearInterval(intervalId);
|
}, 1500);
|
||||||
}, [messages]);
|
return () => clearInterval(intervalId);
|
||||||
|
}
|
||||||
|
}, [isLoading, messages]);
|
||||||
|
|
||||||
const checkHealth = async () => {
|
const checkHealth = async () => {
|
||||||
try {
|
try {
|
||||||
@ -71,21 +73,35 @@ function App() {
|
|||||||
try {
|
try {
|
||||||
const res = await axios.get('http://0.0.0.0:8000/latest_answer');
|
const res = await axios.get('http://0.0.0.0:8000/latest_answer');
|
||||||
const data = res.data;
|
const data = res.data;
|
||||||
|
|
||||||
|
if (!data.answer || data.answer.trim() === '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const answerExists = messages.some(
|
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) {
|
if (!answerExists) {
|
||||||
setMessages((prev) => [
|
setMessages((prev) => [
|
||||||
...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);
|
setStatus(data.status);
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching latest answer:", error);
|
console.error('Error fetching latest answer:', error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -100,10 +116,12 @@ function App() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
console.log('Sending query:', query);
|
console.log('Sending query:', query);
|
||||||
|
setQuery('waiting for response...');
|
||||||
const res = await axios.post('http://0.0.0.0:8000/query', {
|
const res = await axios.post('http://0.0.0.0:8000/query', {
|
||||||
query,
|
query,
|
||||||
tts_enabled: false
|
tts_enabled: false
|
||||||
});
|
});
|
||||||
|
setQuery('Enter your query...');
|
||||||
console.log('Response:', res.data);
|
console.log('Response:', res.data);
|
||||||
const data = res.data;
|
const data = res.data;
|
||||||
setResponseData(data);
|
setResponseData(data);
|
||||||
|
@ -372,7 +372,7 @@ class BrowserAgent(Agent):
|
|||||||
self.status_message = "Summarizing findings..."
|
self.status_message = "Summarizing findings..."
|
||||||
answer, reasoning = await self.llm_request()
|
answer, reasoning = await self.llm_request()
|
||||||
pretty_print(answer, color="output")
|
pretty_print(answer, color="output")
|
||||||
self.status_message = "Done"
|
self.status_message = "Ready"
|
||||||
return answer, reasoning
|
return answer, reasoning
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -23,7 +23,7 @@ class CasualAgent(Agent):
|
|||||||
animate_thinking("Thinking...", color="status")
|
animate_thinking("Thinking...", color="status")
|
||||||
answer, reasoning = await self.llm_request()
|
answer, reasoning = await self.llm_request()
|
||||||
self.last_answer = answer
|
self.last_answer = answer
|
||||||
self.status_message = "Done"
|
self.status_message = "Ready"
|
||||||
return answer, reasoning
|
return answer, reasoning
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -69,7 +69,7 @@ class CoderAgent(Agent):
|
|||||||
self.status_message = "Correcting code..."
|
self.status_message = "Correcting code..."
|
||||||
self.show_answer()
|
self.show_answer()
|
||||||
attempt += 1
|
attempt += 1
|
||||||
self.status_message = "Done"
|
self.status_message = "Ready"
|
||||||
if attempt == max_attempts:
|
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 "I'm sorry, I couldn't find a solution to your problem. How would you like me to proceed ?", reasoning
|
||||||
return answer, reasoning
|
return answer, reasoning
|
||||||
|
@ -30,7 +30,7 @@ class FileAgent(Agent):
|
|||||||
exec_success, _ = self.execute_modules(answer)
|
exec_success, _ = self.execute_modules(answer)
|
||||||
answer = self.remove_blocks(answer)
|
answer = self.remove_blocks(answer)
|
||||||
self.last_answer = answer
|
self.last_answer = answer
|
||||||
self.status_message = "Done"
|
self.status_message = "Ready"
|
||||||
return answer, reasoning
|
return answer, reasoning
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user