mirror of
https://github.com/tcsenpai/agenticSeek.git
synced 2025-06-06 11:05:26 +00:00
refactor: self.role for router
This commit is contained in:
parent
06e6b2798b
commit
f4feb42dda
@ -2,4 +2,5 @@
|
|||||||
|
|
||||||
pip3 install --upgrade packaging
|
pip3 install --upgrade packaging
|
||||||
pip3 install --upgrade pip setuptools
|
pip3 install --upgrade pip setuptools
|
||||||
|
curl -fsSL https://ollama.com/install.sh | sh
|
||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt
|
@ -26,11 +26,7 @@ class BrowserAgent(Agent):
|
|||||||
self.tools = {
|
self.tools = {
|
||||||
"web_search": searxSearch(),
|
"web_search": searxSearch(),
|
||||||
}
|
}
|
||||||
self.role = {
|
self.role = "web"
|
||||||
"en": "web",
|
|
||||||
"fr": "web",
|
|
||||||
"zh": "网络",
|
|
||||||
}
|
|
||||||
self.type = "browser_agent"
|
self.type = "browser_agent"
|
||||||
self.browser = browser
|
self.browser = browser
|
||||||
self.current_page = ""
|
self.current_page = ""
|
||||||
|
@ -14,11 +14,7 @@ class CasualAgent(Agent):
|
|||||||
super().__init__(name, prompt_path, provider, verbose, None)
|
super().__init__(name, prompt_path, provider, verbose, None)
|
||||||
self.tools = {
|
self.tools = {
|
||||||
} # No tools for the casual agent
|
} # No tools for the casual agent
|
||||||
self.role = {
|
self.role = "talk"
|
||||||
"en": "talk",
|
|
||||||
"fr": "discuter",
|
|
||||||
"zh": "聊天",
|
|
||||||
}
|
|
||||||
self.type = "casual_agent"
|
self.type = "casual_agent"
|
||||||
|
|
||||||
def process(self, prompt, speech_module) -> str:
|
def process(self, prompt, speech_module) -> str:
|
||||||
|
@ -24,11 +24,7 @@ class CoderAgent(Agent):
|
|||||||
"file_finder": FileFinder()
|
"file_finder": FileFinder()
|
||||||
}
|
}
|
||||||
self.work_dir = self.tools["file_finder"].get_work_dir()
|
self.work_dir = self.tools["file_finder"].get_work_dir()
|
||||||
self.role = {
|
self.role = "code"
|
||||||
"en": "code",
|
|
||||||
"fr": "codage",
|
|
||||||
"zh": "编码",
|
|
||||||
}
|
|
||||||
self.type = "code_agent"
|
self.type = "code_agent"
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,11 +15,7 @@ class FileAgent(Agent):
|
|||||||
"bash": BashInterpreter()
|
"bash": BashInterpreter()
|
||||||
}
|
}
|
||||||
self.work_dir = self.tools["file_finder"].get_work_dir()
|
self.work_dir = self.tools["file_finder"].get_work_dir()
|
||||||
self.role = {
|
self.role = "files"
|
||||||
"en": "files",
|
|
||||||
"fr": "fichiers",
|
|
||||||
"zh": "文件",
|
|
||||||
}
|
|
||||||
self.type = "file_agent"
|
self.type = "file_agent"
|
||||||
|
|
||||||
def process(self, prompt, speech_module) -> str:
|
def process(self, prompt, speech_module) -> str:
|
||||||
|
@ -24,11 +24,7 @@ class PlannerAgent(Agent):
|
|||||||
"file": FileAgent(name, "prompts/base/file_agent.txt", provider, verbose=False),
|
"file": FileAgent(name, "prompts/base/file_agent.txt", provider, verbose=False),
|
||||||
"web": BrowserAgent(name, "prompts/base/browser_agent.txt", provider, verbose=False, browser=browser)
|
"web": BrowserAgent(name, "prompts/base/browser_agent.txt", provider, verbose=False, browser=browser)
|
||||||
}
|
}
|
||||||
self.role = {
|
self.role = "planification"
|
||||||
"en": "Complex Task",
|
|
||||||
"fr": "Tache complexe",
|
|
||||||
"zh": "复杂任务",
|
|
||||||
}
|
|
||||||
self.type = "planner_agent"
|
self.type = "planner_agent"
|
||||||
|
|
||||||
def parse_agent_tasks(self, text):
|
def parse_agent_tasks(self, text):
|
||||||
|
@ -129,13 +129,24 @@ class Provider:
|
|||||||
requests.post(route_gen, json={"messages": history})
|
requests.post(route_gen, json={"messages": history})
|
||||||
is_complete = False
|
is_complete = False
|
||||||
while not is_complete:
|
while not is_complete:
|
||||||
response = requests.get(f"http://{self.server_ip}/get_updated_sentence")
|
try:
|
||||||
if "error" in response.json():
|
response = requests.get(f"http://{self.server_ip}/get_updated_sentence")
|
||||||
pretty_print(response.json()["error"], color="failure")
|
print(response)
|
||||||
|
if "error" in response.json():
|
||||||
|
pretty_print(response.json()["error"], color="failure")
|
||||||
|
break
|
||||||
|
thought = response.json()["sentence"]
|
||||||
|
is_complete = bool(response.json()["is_complete"])
|
||||||
|
time.sleep(2)
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
pretty_print(f"HTTP request failed: {str(e)}", color="failure")
|
||||||
|
break
|
||||||
|
except ValueError as e:
|
||||||
|
pretty_print(f"Failed to parse JSON response: {str(e)}", color="failure")
|
||||||
|
break
|
||||||
|
except Exception as e:
|
||||||
|
pretty_print(f"An error occurred: {str(e)}", color="failure")
|
||||||
break
|
break
|
||||||
thought = response.json()["sentence"]
|
|
||||||
is_complete = bool(response.json()["is_complete"])
|
|
||||||
time.sleep(2)
|
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
raise Exception(f"{str(e)}\nError occured with server route. Are you using the correct address for the config.ini provider?") from e
|
raise Exception(f"{str(e)}\nError occured with server route. Are you using the correct address for the config.ini provider?") from e
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -300,6 +311,6 @@ class Provider:
|
|||||||
return thought
|
return thought
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
provider = Provider("server", "deepseek-r1:14b", "192.168.1.20:3333")
|
provider = Provider("server", "deepseek-r1:32b", " 172.81.127.6:8080")
|
||||||
res = provider.respond(["user", "Hello, how are you?"])
|
res = provider.respond(["user", "Hello, how are you?"])
|
||||||
print("Response:", res)
|
print("Response:", res)
|
||||||
|
@ -436,7 +436,7 @@ class AgentRouter:
|
|||||||
lang = self.lang_analysis.detect_language(text)
|
lang = self.lang_analysis.detect_language(text)
|
||||||
text = self.find_first_sentence(text)
|
text = self.find_first_sentence(text)
|
||||||
text = self.lang_analysis.translate(text, lang)
|
text = self.lang_analysis.translate(text, lang)
|
||||||
labels = [agent.role["en"] for agent in self.agents]
|
labels = [agent.role for agent in self.agents]
|
||||||
complexity = self.estimate_complexity(text)
|
complexity = self.estimate_complexity(text)
|
||||||
if complexity == None:
|
if complexity == None:
|
||||||
pretty_print(f"Humm, the task seem complex but you gave very little information. can you clarify?", color="info")
|
pretty_print(f"Humm, the task seem complex but you gave very little information. can you clarify?", color="info")
|
||||||
@ -449,8 +449,8 @@ class AgentRouter:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise e
|
raise e
|
||||||
for agent in self.agents:
|
for agent in self.agents:
|
||||||
if best_agent == agent.role["en"]:
|
if best_agent == agent.role:
|
||||||
role_name = agent.role[lang] if lang in agent.role else agent.role["en"]
|
role_name = agent.role
|
||||||
pretty_print(f"Selected agent: {agent.agent_name} (roles: {role_name})", color="warning")
|
pretty_print(f"Selected agent: {agent.agent_name} (roles: {role_name})", color="warning")
|
||||||
return agent
|
return agent
|
||||||
pretty_print(f"Error choosing agent.", color="failure")
|
pretty_print(f"Error choosing agent.", color="failure")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user