feat : file agent improved
This commit is contained in:
@@ -176,7 +176,6 @@ class Agent():
|
||||
blocks, save_path = tool.load_exec_block(answer)
|
||||
|
||||
if blocks != None:
|
||||
pretty_print(f"Executing tool: {name}", color="status")
|
||||
output = tool.execute(blocks)
|
||||
feedback = tool.interpreter_feedback(output) # tool interpreter feedback
|
||||
success = not tool.execution_failure_check(output)
|
||||
|
||||
@@ -13,11 +13,7 @@ class CasualAgent(Agent):
|
||||
"""
|
||||
super().__init__(name, prompt_path, provider, verbose)
|
||||
self.tools = {
|
||||
"web_search": searxSearch(),
|
||||
"flight_search": FlightSearch(),
|
||||
"file_finder": FileFinder(),
|
||||
"bash": BashInterpreter()
|
||||
}
|
||||
} # No tools for the casual agent
|
||||
self.role = {
|
||||
"en": "talk",
|
||||
"fr": "discuter",
|
||||
@@ -27,19 +23,10 @@ class CasualAgent(Agent):
|
||||
self.type = "casual_agent"
|
||||
|
||||
def process(self, prompt, speech_module) -> str:
|
||||
complete = False
|
||||
self.memory.push('user', prompt)
|
||||
|
||||
while not complete:
|
||||
animate_thinking("Thinking...", color="status")
|
||||
answer, reasoning = self.llm_request()
|
||||
exec_success, _ = self.execute_modules(answer)
|
||||
answer = self.remove_blocks(answer)
|
||||
self.last_answer = answer
|
||||
complete = True
|
||||
for tool in self.tools.values():
|
||||
if tool.found_executable_blocks():
|
||||
complete = False # AI read results and continue the conversation
|
||||
animate_thinking("Thinking...", color="status")
|
||||
answer, reasoning = self.llm_request()
|
||||
self.last_answer = answer
|
||||
return answer, reasoning
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -33,11 +33,17 @@ class CoderAgent(Agent):
|
||||
attempt = 0
|
||||
max_attempts = 3
|
||||
self.memory.push('user', prompt)
|
||||
clarify_trigger = "REQUEST_CLARIFICATION"
|
||||
|
||||
while attempt < max_attempts:
|
||||
animate_thinking("Thinking...", color="status")
|
||||
self.wait_message(speech_module)
|
||||
answer, reasoning = self.llm_request()
|
||||
if clarify_trigger in answer:
|
||||
return answer.replace(clarify_trigger, ""), reasoning
|
||||
if not "```" in answer:
|
||||
self.last_answer = answer
|
||||
break
|
||||
animate_thinking("Executing code...", color="status")
|
||||
exec_success, _ = self.execute_modules(answer)
|
||||
answer = self.remove_blocks(answer)
|
||||
|
||||
@@ -14,6 +14,7 @@ class FileAgent(Agent):
|
||||
"file_finder": FileFinder(),
|
||||
"bash": BashInterpreter()
|
||||
}
|
||||
self.work_dir = self.tools["file_finder"].get_work_dir()
|
||||
self.role = {
|
||||
"en": "files",
|
||||
"fr": "fichiers",
|
||||
@@ -24,6 +25,7 @@ class FileAgent(Agent):
|
||||
|
||||
def process(self, prompt, speech_module) -> str:
|
||||
exec_success = False
|
||||
prompt += f"\nWork directory: {self.work_dir}"
|
||||
self.memory.push('user', prompt)
|
||||
|
||||
self.wait_message(speech_module)
|
||||
|
||||
Reference in New Issue
Block a user