mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: [BREAKING] Renamed AgentProtocol to SupportsAgentRun (#3717)
* Renamed AgentProtocol to AgentLike * Resolved comments * Renamed AgentLike to SupportsAgentRun * Resolved comments
This commit is contained in:
committed by
GitHub
Unverified
parent
ac17adb595
commit
15256bb616
@@ -17,8 +17,8 @@ from typing import Any, cast
|
||||
import yaml
|
||||
from agent_framework import (
|
||||
AgentExecutor,
|
||||
AgentProtocol,
|
||||
CheckpointStorage,
|
||||
SupportsAgentRun,
|
||||
Workflow,
|
||||
get_logger,
|
||||
)
|
||||
@@ -78,13 +78,13 @@ class WorkflowFactory:
|
||||
workflow = factory.create_workflow_from_yaml_path("workflow.yaml")
|
||||
"""
|
||||
|
||||
_agents: dict[str, AgentProtocol | AgentExecutor]
|
||||
_agents: dict[str, SupportsAgentRun | AgentExecutor]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
agent_factory: AgentFactory | None = None,
|
||||
agents: Mapping[str, AgentProtocol | AgentExecutor] | None = None,
|
||||
agents: Mapping[str, SupportsAgentRun | AgentExecutor] | None = None,
|
||||
bindings: Mapping[str, Any] | None = None,
|
||||
env_file: str | None = None,
|
||||
checkpoint_storage: CheckpointStorage | None = None,
|
||||
@@ -132,7 +132,7 @@ class WorkflowFactory:
|
||||
)
|
||||
"""
|
||||
self._agent_factory = agent_factory or AgentFactory(env_file_path=env_file)
|
||||
self._agents: dict[str, AgentProtocol | AgentExecutor] = dict(agents) if agents else {}
|
||||
self._agents: dict[str, SupportsAgentRun | AgentExecutor] = dict(agents) if agents else {}
|
||||
self._bindings: dict[str, Any] = dict(bindings) if bindings else {}
|
||||
self._checkpoint_storage = checkpoint_storage
|
||||
|
||||
@@ -323,7 +323,7 @@ class WorkflowFactory:
|
||||
description = workflow_def.get("description")
|
||||
|
||||
# Create agents from definitions
|
||||
agents: dict[str, AgentProtocol | AgentExecutor] = dict(self._agents)
|
||||
agents: dict[str, SupportsAgentRun | AgentExecutor] = dict(self._agents)
|
||||
agent_defs = workflow_def.get("agents", {})
|
||||
|
||||
for agent_name, agent_def in agent_defs.items():
|
||||
@@ -347,7 +347,7 @@ class WorkflowFactory:
|
||||
workflow_def: dict[str, Any],
|
||||
name: str,
|
||||
description: str | None,
|
||||
agents: dict[str, AgentProtocol | AgentExecutor],
|
||||
agents: dict[str, SupportsAgentRun | AgentExecutor],
|
||||
) -> Workflow:
|
||||
"""Create workflow from definition.
|
||||
|
||||
@@ -506,7 +506,7 @@ class WorkflowFactory:
|
||||
f"Invalid agent definition. Expected 'file', 'kind', or 'connection': {agent_def}"
|
||||
)
|
||||
|
||||
def register_agent(self, name: str, agent: AgentProtocol | AgentExecutor) -> "WorkflowFactory":
|
||||
def register_agent(self, name: str, agent: SupportsAgentRun | AgentExecutor) -> "WorkflowFactory":
|
||||
"""Register an agent instance with the factory for use in workflows.
|
||||
|
||||
Registered agents are available to InvokeAzureAgent actions by name.
|
||||
|
||||
Reference in New Issue
Block a user