Skip to content

Commit

Permalink
Add Agent Type Attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
dewmal committed Aug 15, 2024
1 parent b0fb5cc commit eae91c3
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions bindings/ceylon/ceylon/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


class Agent(Worker, AgentCommon):
agent_type = "AGENT"
history_responses = []

def __init__(self, name="admin",
Expand Down
1 change: 1 addition & 0 deletions bindings/ceylon/ceylon/core/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


class Worker(WorkerAgent, Processor, MessageHandler, EventHandler):
agent_type = "WORKER"

def __init__(self, name="admin", workspace_id=DEFAULT_WORKSPACE_ID, admin_peer="", admin_port=DEFAULT_ADMIN_PORT,
role="worker",
Expand Down
5 changes: 4 additions & 1 deletion bindings/ceylon/ceylon/llm/llm_task_coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pydantic.v1
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate, PromptTemplate
from loguru import logger

from ceylon.llm.llm_task_operator import LLMTaskOperator
from ceylon.static_val import DEFAULT_WORKSPACE_ID, DEFAULT_ADMIN_PORT
Expand Down Expand Up @@ -43,6 +44,7 @@ def __init__(self, tasks: List[Task], agents: List[LLMTaskOperator], llm=None, t
self.tool_llm = tool_llm
self.tasks = tasks
self.agents = agents
logger.info(f"LLM Task Coordinator initialized with {len(tasks)} tasks and {len(self.get_llm_operators)} agents {[agent for agent in self.get_llm_operators]}")
super().__init__(name=name, port=port, tasks=tasks, agents=agents)

async def get_task_executor(self, task: SubTask) -> str:
Expand All @@ -68,7 +70,8 @@ async def update_task(self, idx: int, task: Task):
def get_llm_operators(self) -> List[LLMTaskOperator]:
operators = []
for agent in self.agents:
if isinstance(agent, LLMTaskOperator):
if isinstance(agent, LLMTaskOperator) and hasattr(agent,
"agent_type") and agent.agent_type == LLMTaskOperator.agent_type:
operators.append(agent)

return operators
Expand Down
3 changes: 3 additions & 0 deletions bindings/ceylon/ceylon/llm/llm_task_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@


class LLMTaskOperator(TaskOperator):
"""LLM-based task operator."""
agent_type = "LLM_TASK_OPERATOR"

def __init__(self, name: str, role: str, context: str, skills: List[str],
tools: List[Any] = None, llm=None, tool_llm=None, verbose=False,
workspace_id="ceylon_agent_stack",
Expand Down
3 changes: 0 additions & 3 deletions bindings/ceylon/ceylon/task/task_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ class Task(BaseModel):

def add_subtask(self, subtask: SubTask):
subtask.parent_task_id = self.id
if subtask.name in self.subtasks:
raise ValueError(f"Subtask with id {subtask.name} already exists")

self.subtasks[subtask.name] = subtask
self._validate_dependencies()
self.execution_order = self.get_execution_order()
Expand Down
2 changes: 2 additions & 0 deletions bindings/ceylon/ceylon/task/task_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@


class TaskOperator(Agent, abc.ABC):
agent_type = "TASK_OPERATOR"

def __init__(self, name: str, role: str, workspace_id: str = DEFAULT_WORKSPACE_ID,
admin_port: int = DEFAULT_ADMIN_PORT, *args,
**kwargs):
Expand Down
2 changes: 1 addition & 1 deletion bindings/ceylon/tests/tasks/llm_software_agency.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
),
AgentMonitor()
]
# enable_log("DEBUG")
# enable_log("INFO")
# Initialize TaskManager
task_manager = LLMTaskCoordinator(tasks, agents, tool_llm=tool_llm, llm=llm)

Expand Down

0 comments on commit eae91c3

Please sign in to comment.