From 2e1ff7c5beb4ca9c97e02b48faf5b4cefb5f60cc Mon Sep 17 00:00:00 2001 From: Yx Jiang <2237303+yxjiang@users.noreply.github.com> Date: Mon, 18 Mar 2024 22:33:44 -0700 Subject: [PATCH 1/2] Update agent --- polymind/core/agent.py | 6 ++++-- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/polymind/core/agent.py b/polymind/core/agent.py index d25ab3e..6f90982 100644 --- a/polymind/core/agent.py +++ b/polymind/core/agent.py @@ -20,12 +20,13 @@ class ThoughtProcess(BaseModel, ABC): def __str__(self): return self.thought_process_name - async def __call__(self, input: Message, agent: "Agent") -> Message: + async def __call__(self, agent: "Agent", input: Message) -> Message: """Makes the instance callable, delegating to the execute method. This allows the instance to be used as a callable object, simplifying the syntax for executing the thought process. Args: + agent (Agent): The agent who is executing the thought process. input (Message): The input message to the thought process. Returns: @@ -34,11 +35,12 @@ async def __call__(self, input: Message, agent: "Agent") -> Message: return await self._execute(input) @abstractmethod - async def _execute(self, input: Message) -> Message: + async def _execute(self, agent: "Agent", input: Message) -> Message: """Execute the thought process and return the result. The derived class must implement this method to define the behavior of the thought process. Args: + agent (Agent): The agent who is executing the thought process. input (Message): The input to the thought process carried in a message. Returns: diff --git a/pyproject.toml b/pyproject.toml index 2ea858e..bbc6abf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "polymind" -version = "0.0.18" # Update this version before publishing to PyPI +version = "0.0.19" # Update this version before publishing to PyPI description = "PolyMind is a customizable collaborative multi-agent framework for collective intelligence and distributed problem solving." authors = ["TechTao"] license = "MIT License" From 0f4106ec86046b286a384386388a156406b1f55a Mon Sep 17 00:00:00 2001 From: Yx Jiang <2237303+yxjiang@users.noreply.github.com> Date: Mon, 18 Mar 2024 22:36:19 -0700 Subject: [PATCH 2/2] Update agent --- polymind/core/agent.py | 2 +- tests/polymind/core/test_agent.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/polymind/core/agent.py b/polymind/core/agent.py index 6f90982..a740a61 100644 --- a/polymind/core/agent.py +++ b/polymind/core/agent.py @@ -32,7 +32,7 @@ async def __call__(self, agent: "Agent", input: Message) -> Message: Returns: Message: The output message from the thought process. """ - return await self._execute(input) + return await self._execute(agent=agent, input=input) @abstractmethod async def _execute(self, agent: "Agent", input: Message) -> Message: diff --git a/tests/polymind/core/test_agent.py b/tests/polymind/core/test_agent.py index f95fe4f..d9ab2f8 100644 --- a/tests/polymind/core/test_agent.py +++ b/tests/polymind/core/test_agent.py @@ -10,7 +10,7 @@ class MockThoughtProcess(ThoughtProcess): - async def _execute(self, input: Message) -> Message: + async def _execute(self, agent: Agent, input: Message) -> Message: # Implement a simple test logic, for example, just echo back the input with some modification modified_content = {"processed": True, **input.content} return Message(content=modified_content) @@ -30,7 +30,7 @@ async def test_process_simple_message(self): input_message = Message(content={"hello": "world"}) # Now, pass both the input_message and agent to the thought_process call - output_message = await thought_process(input_message, agent) + output_message = await thought_process(agent=agent, input=input_message) # Assertions to verify the behavior assert output_message.content.get("processed") == True