Feat : better file system interaction

This commit is contained in:
martin legrand
2025-03-09 12:45:29 +01:00
parent 06d207da53
commit 7710fb3f9d
13 changed files with 204 additions and 50 deletions
+2 -1
View File
@@ -2,5 +2,6 @@
from .agent import Agent
from .code_agent import CoderAgent
from .casual_agent import CasualAgent
from .file_agent import FileAgent
__all__ = ["Agent", "CoderAgent", "CasualAgent"]
__all__ = ["Agent", "CoderAgent", "CasualAgent", "FileAgent"]
+3 -1
View File
@@ -4,6 +4,7 @@ from sources.agents.agent import Agent
from sources.tools.webSearch import webSearch
from sources.tools.flightSearch import FlightSearch
from sources.tools.fileFinder import FileFinder
from sources.tools.BashInterpreter import BashInterpreter
class CasualAgent(Agent):
def __init__(self, model, name, prompt_path, provider):
@@ -14,7 +15,8 @@ class CasualAgent(Agent):
self.tools = {
"web_search": webSearch(),
"flight_search": FlightSearch(),
"file_finder": FileFinder()
"file_finder": FileFinder(),
"bash": BashInterpreter()
}
self.role = "talking"
+2
View File
@@ -40,6 +40,8 @@ class CoderAgent(Agent):
break
self.show_answer()
attempt += 1
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
if __name__ == "__main__":
+42
View File
@@ -0,0 +1,42 @@
from sources.utility import pretty_print
from sources.agents.agent import Agent
from sources.tools.fileFinder import FileFinder
from sources.tools.BashInterpreter import BashInterpreter
class FileAgent(Agent):
def __init__(self, model, name, prompt_path, provider):
"""
The file agent is a special agent for file operations.
"""
super().__init__(model, name, prompt_path, provider)
self.tools = {
"file_finder": FileFinder(),
"bash": BashInterpreter()
}
self.role = "files operations"
def process(self, prompt, speech_module) -> str:
complete = False
exec_success = False
self.memory.push('user', prompt)
self.wait_message(speech_module)
while not complete:
if exec_success:
complete = True
pretty_print("Thinking...", color="status")
answer, reasoning = self.llm_request()
exec_success, _ = self.execute_modules(answer)
answer = self.remove_blocks(answer)
self.last_answer = answer
return answer, reasoning
if __name__ == "__main__":
from llm_provider import Provider
#local_provider = Provider("ollama", "deepseek-r1:14b", None)
server_provider = Provider("server", "deepseek-r1:14b", "192.168.1.100:5000")
agent = FileAgent("deepseek-r1:14b", "jarvis", "prompts/file_agent.txt", server_provider)
ans = agent.process("What is the content of the file toto.py ?")
print(ans)