Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Jan 29, 2025
1 parent a60a82e commit 8bc295b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 51 deletions.
5 changes: 1 addition & 4 deletions docs/agents/create_agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ The recommended way to create agents is through `AgentPool`:

```python
async with AgentPool("agents.yml") as pool:
# Get basic agent
# Get agent
agent = pool.get_agent("analyzer")

# Get agent with model override
agent = pool.get_agent("analyzer", model_override="gpt-4")

# Get agent with dependencies
agent = pool.get_agent("reviewer", deps=pr_context)

Expand Down
2 changes: 0 additions & 2 deletions docs/agents/team.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ team = Team(
# Create from agent names
team = pool.create_team(
agents=["analyzer", "planner", "executor"],
model_override="gpt-4", # Override model for all agents
environment_override="env.yml", # Override environment
shared_prompt="Team objective", # Common prompt
)
```
Expand Down
11 changes: 1 addition & 10 deletions docs/concepts/pool.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,7 @@ clone = await pool.clone_agent(
)

# Clone with model override
gpt3_clone = await pool.clone_agent(
"analyzer",
model_override="openai:gpt-3.5-turbo"
)
gpt3_clone = await pool.clone_agent("analyzer")

```

Expand All @@ -204,12 +201,6 @@ The pool can also create teams from its registered agents:
# Create team from agent names
team = pool.create_team(["analyzer", "planner", "executor"])

# With model override for all agents
team = pool.create_team(
["analyzer", "planner"],
model_override="openai:gpt-4-turbo"
)

# With shared prompt
team = pool.create_team(
["researcher", "writer"],
Expand Down
27 changes: 2 additions & 25 deletions src/llmling_agent/delegation/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ def create_team_run(
agents: Sequence[str],
validator: MessageNode[Any, TResult] | None = None,
*,
model_override: str | None = None,
shared_prompt: str | None = None,
picker: AnyAgent[Any, Any] | None = None,
num_picks: int | None = None,
Expand All @@ -204,7 +203,6 @@ def create_team_run[TDeps, TResult](
agents: Sequence[MessageNode[TDeps, Any]],
validator: MessageNode[Any, TResult] | None = None,
*,
model_override: str | None = None,
shared_prompt: str | None = None,
picker: AnyAgent[Any, Any] | None = None,
num_picks: int | None = None,
Expand All @@ -217,7 +215,6 @@ def create_team_run(
agents: Sequence[AgentName | MessageNode[Any, Any]],
validator: MessageNode[Any, TResult] | None = None,
*,
model_override: str | None = None,
shared_prompt: str | None = None,
picker: AnyAgent[Any, Any] | None = None,
num_picks: int | None = None,
Expand All @@ -229,7 +226,6 @@ def create_team_run(
agents: Sequence[AgentName | MessageNode[Any, Any]] | None = None,
validator: MessageNode[Any, TResult] | None = None,
*,
model_override: str | None = None,
shared_prompt: str | None = None,
picker: AnyAgent[Any, Any] | None = None,
num_picks: int | None = None,
Expand All @@ -240,7 +236,6 @@ def create_team_run(
Args:
agents: List of agent names or team/agent instances (all if None)
validator: Node to validate the results of the TeamRun
model_override: Optional model to use for all agents
shared_prompt: Optional prompt for all agents
picker: Agent to use for picking agents
num_picks: Number of agents to pick
Expand All @@ -255,7 +250,7 @@ def create_team_run(
resolved_agents: list[MessageNode[Any, Any]] = []
for agent in agents:
if isinstance(agent, str):
agent = self.get_agent(agent, model_override=model_override)
agent = self.get_agent(agent)
resolved_agents.append(agent)
return TeamRun(
resolved_agents,
Expand All @@ -274,7 +269,6 @@ def create_team[TDeps](
self,
agents: Sequence[MessageNode[TDeps, Any]],
*,
model_override: str | None = None,
shared_prompt: str | None = None,
picker: AnyAgent[Any, Any] | None = None,
num_picks: int | None = None,
Expand All @@ -286,7 +280,6 @@ def create_team(
self,
agents: Sequence[AgentName | MessageNode[Any, Any]],
*,
model_override: str | None = None,
shared_prompt: str | None = None,
picker: AnyAgent[Any, Any] | None = None,
num_picks: int | None = None,
Expand All @@ -297,7 +290,6 @@ def create_team(
self,
agents: Sequence[AgentName | MessageNode[Any, Any]] | None = None,
*,
model_override: str | None = None,
shared_prompt: str | None = None,
picker: AnyAgent[Any, Any] | None = None,
num_picks: int | None = None,
Expand All @@ -307,7 +299,6 @@ def create_team(
Args:
agents: List of agent names or instances (all if None)
model_override: Optional model to use for all agents
shared_prompt: Optional prompt for all agents
picker: Agent to use for picking agents
num_picks: Number of agents to pick
Expand All @@ -322,7 +313,7 @@ def create_team(
resolved_agents: list[MessageNode[Any, Any]] = []
for agent in agents:
if isinstance(agent, str):
agent = self.get_agent(agent, model_override=model_override)
agent = self.get_agent(agent)
resolved_agents.append(agent)

return Team(
Expand Down Expand Up @@ -476,7 +467,6 @@ async def clone_agent[TDeps](
agent: AgentName | Agent[TDeps],
new_name: AgentName | None = None,
*,
model_override: str | None = None,
system_prompts: list[str] | None = None,
template_context: dict[str, Any] | None = None,
) -> Agent[TDeps]: ...
Expand All @@ -487,7 +477,6 @@ async def clone_agent[TDeps, TResult](
agent: StructuredAgent[TDeps, TResult],
new_name: AgentName | None = None,
*,
model_override: str | None = None,
system_prompts: list[str] | None = None,
template_context: dict[str, Any] | None = None,
) -> StructuredAgent[TDeps, TResult]: ...
Expand All @@ -497,7 +486,6 @@ async def clone_agent[TDeps, TAgentResult](
agent: AgentName | AnyAgent[TDeps, TAgentResult],
new_name: AgentName | None = None,
*,
model_override: str | None = None,
system_prompts: list[str] | None = None,
template_context: dict[str, Any] | None = None,
) -> AnyAgent[TDeps, TAgentResult]:
Expand All @@ -506,7 +494,6 @@ async def clone_agent[TDeps, TAgentResult](
Args:
agent: Agent instance or name to clone
new_name: Optional name for the clone
model_override: Optional different model
system_prompts: Optional different prompts
template_context: Variables for template rendering
Expand All @@ -530,8 +517,6 @@ async def clone_agent[TDeps, TAgentResult](
new_config = config.model_copy(deep=True)

# Apply overrides
if model_override:
new_config.model = model_override
if system_prompts:
new_config.system_prompts = system_prompts

Expand Down Expand Up @@ -564,7 +549,6 @@ async def create_agent(
*,
session: SessionIdType | SessionQuery = None,
name_override: str | None = None,
model_override: str | None = None,
) -> Agent[TPoolDeps]: ...

@overload
Expand All @@ -575,7 +559,6 @@ async def create_agent[TCustomDeps](
deps: TCustomDeps,
session: SessionIdType | SessionQuery = None,
name_override: str | None = None,
model_override: str | None = None,
) -> Agent[TCustomDeps]: ...

@overload
Expand All @@ -586,7 +569,6 @@ async def create_agent[TResult](
return_type: type[TResult],
session: SessionIdType | SessionQuery = None,
name_override: str | None = None,
model_override: str | None = None,
) -> StructuredAgent[TPoolDeps, TResult]: ...

@overload
Expand All @@ -598,7 +580,6 @@ async def create_agent[TCustomDeps, TResult](
return_type: type[TResult],
session: SessionIdType | SessionQuery = None,
name_override: str | None = None,
model_override: str | None = None,
) -> StructuredAgent[TCustomDeps, TResult]: ...

async def create_agent(
Expand All @@ -609,7 +590,6 @@ async def create_agent(
return_type: Any | None = None,
session: SessionIdType | SessionQuery = None,
name_override: str | None = None,
model_override: str | None = None,
) -> AnyAgent[Any, Any]:
"""Create a new agent instance from configuration.
Expand All @@ -619,7 +599,6 @@ async def create_agent(
return_type: Optional type for structured responses
session: Optional session ID or query to recover conversation
name_override: Optional different name for this instance
model_override: Optional model override
Returns:
New agent instance with the specified configuration
Expand All @@ -635,8 +614,6 @@ async def create_agent(
# Use Manifest.get_agent for proper initialization
final_deps = deps if deps is not None else self.shared_deps
agent = self.manifest.get_agent(name, deps=final_deps)
if model_override:
agent.set_model(model_override)
# Override name if requested
if name_override:
agent.name = name_override
Expand Down
8 changes: 3 additions & 5 deletions src/llmling_agent_cli/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,9 @@ async def run_chat():
connect_nodes=False, # We'll handle connections manually
) as pool:
# Get main agent
agent: Agent[Any] = pool.get_agent(
agent_name,
model_override=model,
session=session_id,
)
agent: Agent[Any] = pool.get_agent(agent_name, session=session_id)
if model:
agent.set_model(model)

# Set up forwarding if requested
if connections:
Expand Down
7 changes: 2 additions & 5 deletions src/llmling_agent_cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def run_command(
),
show_metadata: bool = t.Option(False, "--metadata", help="Show message metadata"),
show_costs: bool = t.Option(False, "--costs", help="Show token usage and costs"),
model: str = t.Option(None, "--model", "-m", help="Override model"),
verbose: bool = verbose_opt,
):
"""Run agent(s) with prompts.
Expand Down Expand Up @@ -82,12 +81,10 @@ def on_message(chat_message: ChatMessage[Any]):
for prompt in prompts:
match execution_mode:
case "parallel":
team = pool.create_team(agent_names, model_override=model)
team = pool.create_team(agent_names)
responses = await team.execute(prompt)
case "sequential":
team_run = pool.create_team_run(
agent_names, model_override=model
)
team_run = pool.create_team_run(agent_names)
responses = await team_run.execute(prompt)
# case "controlled":
# responses = await group.run_controlled(prompt)
Expand Down

0 comments on commit 8bc295b

Please sign in to comment.