diff --git a/prompts/planner_agent.txt b/prompts/planner_agent.txt new file mode 100644 index 0000000..05da72f --- /dev/null +++ b/prompts/planner_agent.txt @@ -0,0 +1,22 @@ +You are a planner agent. +Your goal is to divide and conquer the task using the following agents: +- Coder: An expert coder agent. +- File: An expert agent for finding files. +- Web: An expert agent for web search. + +Agents are other AI that obey your instructions. + +You will be given a task and you will need to divide it into smaller tasks and assign them to the agents. + +Here is an example: + +User: Make a cool 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 +``` + diff --git a/sources/agents/__init__.py b/sources/agents/__init__.py index b4fbefb..4949eb8 100644 --- a/sources/agents/__init__.py +++ b/sources/agents/__init__.py @@ -3,5 +3,6 @@ from .agent import Agent from .code_agent import CoderAgent from .casual_agent import CasualAgent from .file_agent import FileAgent +from .planner_agent import PlannerAgent -__all__ = ["Agent", "CoderAgent", "CasualAgent", "FileAgent"] +__all__ = ["Agent", "CoderAgent", "CasualAgent", "FileAgent", "PlannerAgent"] diff --git a/sources/agents/planner_agent.py b/sources/agents/planner_agent.py new file mode 100644 index 0000000..d7e0032 --- /dev/null +++ b/sources/agents/planner_agent.py @@ -0,0 +1,39 @@ + +from sources.utility import pretty_print +from sources.agents.agent import Agent, CoderAgent, FileAgent + +class PlannerAgent(Agent): + def __init__(self, model, name, prompt_path, provider): + """ + The planner agent is a special agent that divides and conquers the task. + """ + super().__init__(model, name, prompt_path, provider) + self.tools = { + } + self.agents = { + "coder": CoderAgent(model, name, prompt_path, provider), + "file": FileAgent(model, name, prompt_path, provider) + } + self.role = "planning" + + 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 + server_provider = Provider("server", "deepseek-r1:14b", "192.168.1.100:5000") + agent = PlannerAgent("deepseek-r1:14b", "jarvis", "prompts/planner_agent.txt", server_provider) + ans = agent.process("Make a cool game to illustrate the current relation between USA and europe") \ No newline at end of file