mirror of
https://github.com/tcsenpai/agenticSeek.git
synced 2025-06-05 02:25:27 +00:00
Feat : planning agent tasks parsing
This commit is contained in:
parent
0dbcf29701
commit
e6e48f7f3f
6
main.py
6
main.py
@ -7,7 +7,7 @@ import configparser
|
||||
|
||||
from sources.llm_provider import Provider
|
||||
from sources.interaction import Interaction
|
||||
from sources.agents import Agent, CoderAgent, CasualAgent, FileAgent
|
||||
from sources.agents import Agent, CoderAgent, CasualAgent, FileAgent, PlannerAgent
|
||||
|
||||
parser = argparse.ArgumentParser(description='Deepseek AI assistant')
|
||||
parser.add_argument('--no-speak', action='store_true',
|
||||
@ -42,6 +42,10 @@ def main():
|
||||
FileAgent(model=config["MAIN"]["provider_model"],
|
||||
name="File Agent",
|
||||
prompt_path="prompts/file_agent.txt",
|
||||
provider=provider),
|
||||
PlannerAgent(model=config["MAIN"]["provider_model"],
|
||||
name="Planner",
|
||||
prompt_path="prompts/planner_agent.txt",
|
||||
provider=provider)
|
||||
]
|
||||
|
||||
|
@ -11,12 +11,17 @@ You will be given a task and you will need to divide it into smaller tasks and a
|
||||
Here is an example:
|
||||
|
||||
User: Make a cool game to illustrate the current relation between USA and europe
|
||||
You: Sure, here is the plan:
|
||||
## I will do a web research to find the current relation between USA and europe
|
||||
- Web(name="web1"): Search for the current relation between USA and europe
|
||||
## I will then make a game to illustrate the current relation between USA and europe
|
||||
- Coder(name="coder1", need="web1"): Make a game to illustrate the current relation between USA and europe
|
||||
|
||||
You:
|
||||
|
||||
Sure, here is the plan:
|
||||
```plan
|
||||
Web(name="web1"): Search for the current relation between USA and europe
|
||||
Coder(name="coder1", need="web1"): Make a game to illustrate the current relation between USA and europe
|
||||
```
|
||||
Another example:
|
||||
|
||||
User: make a mobile app to check the weather in a specific city
|
||||
You: Sure, here is the plan:
|
||||
## I will do a web research to find the current weather in a specific city
|
||||
- Web(name="web1"): Search how to use weather api
|
||||
## I will then make a mobile app to check the weather in a specific city
|
||||
- Coder(name="coder1", need="web1"): Make a mobile app to check the weather in a specific city
|
@ -18,7 +18,7 @@ class CasualAgent(Agent):
|
||||
"file_finder": FileFinder(),
|
||||
"bash": BashInterpreter()
|
||||
}
|
||||
self.role = "talking"
|
||||
self.role = "talking, advices and philosophical"
|
||||
|
||||
def process(self, prompt, speech_module) -> str:
|
||||
complete = False
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
from sources.utility import pretty_print
|
||||
from sources.agents.agent import Agent, executorResult
|
||||
|
||||
from sources.tools.C_Interpreter import CInterpreter
|
||||
from sources.tools.GoInterpreter import GoInterpreter
|
||||
from sources.tools.PyInterpreter import PyInterpreter
|
||||
@ -21,7 +20,7 @@ class CoderAgent(Agent):
|
||||
"go": GoInterpreter(),
|
||||
"file_finder": FileFinder()
|
||||
}
|
||||
self.role = "coding"
|
||||
self.role = "coding and programming"
|
||||
|
||||
def process(self, prompt, speech_module) -> str:
|
||||
answer = ""
|
||||
|
@ -1,6 +1,9 @@
|
||||
|
||||
from sources.utility import pretty_print
|
||||
from sources.agents.agent import Agent, CoderAgent, FileAgent
|
||||
from sources.agents.agent import Agent
|
||||
from sources.agents.code_agent import CoderAgent
|
||||
from sources.agents.file_agent import FileAgent
|
||||
from sources.agents.casual_agent import CasualAgent
|
||||
|
||||
class PlannerAgent(Agent):
|
||||
def __init__(self, model, name, prompt_path, provider):
|
||||
@ -12,24 +15,48 @@ class PlannerAgent(Agent):
|
||||
}
|
||||
self.agents = {
|
||||
"coder": CoderAgent(model, name, prompt_path, provider),
|
||||
"file": FileAgent(model, name, prompt_path, provider)
|
||||
"file": FileAgent(model, name, prompt_path, provider),
|
||||
"web": CasualAgent(model, name, prompt_path, provider)
|
||||
}
|
||||
self.role = "planning"
|
||||
self.role = "complex programming tasks and web research"
|
||||
|
||||
def parse_agent_tasks(self, text):
|
||||
agents_tasks = []
|
||||
|
||||
lines = text.strip().split('\n')
|
||||
for line in lines:
|
||||
if not '-' in line:
|
||||
continue
|
||||
if not line.strip() or ':' not in line:
|
||||
continue
|
||||
agent_part, task = line.split(':', 1)
|
||||
task = task.strip()
|
||||
agent_info = agent_part.strip().split('(')
|
||||
agent_type = agent_info[0].strip()
|
||||
params_part = agent_info[1].rstrip(')').split(',')
|
||||
params = {}
|
||||
for param in params_part:
|
||||
key, value = param.split('=')
|
||||
params[key.strip()] = value.strip().strip('"')
|
||||
agent = {
|
||||
'type': agent_type,
|
||||
'name': params['name'],
|
||||
'task': task
|
||||
}
|
||||
if 'need' in params:
|
||||
agent['need'] = params['need']
|
||||
agents_tasks.append(agent)
|
||||
return agents_tasks
|
||||
|
||||
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
|
||||
pretty_print("Thinking...", color="status")
|
||||
print(self.memory.get())
|
||||
answer, reasoning = self.llm_request()
|
||||
agents_tasks = self.parse_agent_tasks(answer)
|
||||
print(agents_tasks)
|
||||
self.last_answer = answer
|
||||
return answer, reasoning
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -94,7 +94,8 @@ class Interaction:
|
||||
"""Request AI agents to process the user input."""
|
||||
if self.last_query is None or len(self.last_query) == 0:
|
||||
return
|
||||
agent = self.router.select_agent(self.last_query)
|
||||
#agent = self.router.select_agent(self.last_query)
|
||||
agent = self.agents[3]
|
||||
if agent is None:
|
||||
return
|
||||
if self.current_agent != agent:
|
||||
|
@ -8,6 +8,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
from sources.agents.agent import Agent
|
||||
from sources.agents.code_agent import CoderAgent
|
||||
from sources.agents.casual_agent import CasualAgent
|
||||
from sources.agents.planner_agent import PlannerAgent
|
||||
from sources.utility import pretty_print
|
||||
|
||||
class AgentRouter:
|
||||
@ -67,7 +68,8 @@ class AgentRouter:
|
||||
if __name__ == "__main__":
|
||||
agents = [
|
||||
CoderAgent("deepseek-r1:14b", "agent1", "../prompts/coder_agent.txt", "server"),
|
||||
CasualAgent("deepseek-r1:14b", "agent2", "../prompts/casual_agent.txt", "server")
|
||||
CasualAgent("deepseek-r1:14b", "agent2", "../prompts/casual_agent.txt", "server"),
|
||||
PlannerAgent("deepseek-r1:14b", "agent3", "../prompts/planner_agent.txt", "server")
|
||||
]
|
||||
router = AgentRouter(agents)
|
||||
|
||||
@ -79,6 +81,9 @@ if __name__ == "__main__":
|
||||
""",
|
||||
"""
|
||||
hey can you give dating advice ?
|
||||
""",
|
||||
"""
|
||||
Make a cool game to illustrate the current relation between USA and europe
|
||||
"""
|
||||
]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user