rasa-pro 3.14.0.dev1__py3-none-any.whl → 3.14.0.dev20250818__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rasa-pro might be problematic. Click here for more details.
- rasa/api.py +0 -5
- rasa/cli/arguments/default_arguments.py +0 -12
- rasa/cli/arguments/run.py +0 -2
- rasa/cli/dialogue_understanding_test.py +0 -4
- rasa/cli/e2e_test.py +0 -4
- rasa/cli/inspect.py +0 -3
- rasa/cli/llm_fine_tuning.py +0 -5
- rasa/cli/run.py +0 -4
- rasa/cli/shell.py +0 -3
- rasa/constants.py +0 -6
- rasa/core/actions/action.py +2 -42
- rasa/core/agent.py +0 -16
- rasa/core/available_endpoints.py +0 -30
- rasa/core/channels/inspector/dist/assets/{arc-2e78c586.js → arc-1ddec37b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-806b712e.js → blockDiagram-38ab4fdb-18af387c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-0745efa9.js → c4Diagram-3d4e48cf-250127a3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-59f6d54b.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-7bd1082b.js → classDiagram-70f12bd4-c3388b34.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-d937ba49.js → classDiagram-v2-f2320105-9c893a82.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-26177ddb.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-a2a564ca.js → createText-2e5e7dd3-c111213b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-b5256940.js → edges-e0da2a9e-812a729d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-e6883ad2.js → erDiagram-9861fffd-fd5051bc.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-e576fc02.js → flowDb-956e92f1-3287ac02.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-2e298d01.js → flowDiagram-66a62f08-692fb0b2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-29c03f5a.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-dd7b150a.js → flowchart-elk-definition-4a651766-008376f1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-5b79575c.js → ganttDiagram-c361ad54-df330a69.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-3016f40a.js → gitGraphDiagram-72cf32ee-e03676fb.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-3e19170f.js → graph-46fad2ba.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-eb9c86de.js → index-3862675e-a484ac55.js} +1 -1
- rasa/core/channels/inspector/dist/assets/index-a003633f.js +1335 -0
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-b4280e4d.js → infoDiagram-f8f76790-3f9e6ec2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-556091f8.js → journeyDiagram-49397b02-79f72383.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-08436411.js → layout-aad098e5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-683c4f3b.js → line-219ab7ae.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-cee6d791.js → linear-2cddbe62.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-a0bf0b1a.js → mindmap-definition-fc14e90a-1d41ed99.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-3730d5c4.js → pieDiagram-8a3498a8-cc496ee8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-12a20fed.js → quadrantDiagram-120e2f19-84d32884.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-b9732102.js → requirementDiagram-deff3bca-c0deb984.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-a2e72776.js → sankeyDiagram-04a897e0-b9d7fd62.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-8b7a76bb.js → sequenceDiagram-704730f1-7d517565.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-e65853ac.js → stateDiagram-587899a1-98ef9b27.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-6f58a44b.js → stateDiagram-v2-d93cdb3a-cee70748.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-df25b934.js → styles-6aaf32cf-3f9d1c96.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-88357141.js → styles-9a916d00-67471923.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-d600174d.js → styles-c10674c1-bd093fb7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-4adc3e0b.js → svgDrawCommon-08f97a94-675794e8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-42816fa1.js → timeline-definition-85554ec2-0ac67617.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-621eb66a.js → xychartDiagram-e933f94c-c018dc37.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/src/components/DialogueStack.tsx +5 -7
- rasa/core/channels/inspector/src/helpers/formatters.ts +3 -24
- rasa/core/channels/inspector/src/theme/base/styles.ts +1 -19
- rasa/core/channels/inspector/src/types.ts +0 -4
- rasa/core/constants.py +0 -4
- rasa/core/policies/enterprise_search_policy.py +2 -4
- rasa/core/policies/flow_policy.py +2 -2
- rasa/core/policies/flows/flow_executor.py +35 -374
- rasa/core/processor.py +1 -6
- rasa/core/run.py +1 -8
- rasa/core/utils.py +1 -21
- rasa/dialogue_understanding/commands/__init__.py +0 -8
- rasa/dialogue_understanding/commands/cancel_flow_command.py +4 -97
- rasa/dialogue_understanding/commands/chit_chat_answer_command.py +0 -11
- rasa/dialogue_understanding/commands/knowledge_answer_command.py +0 -11
- rasa/dialogue_understanding/commands/start_flow_command.py +8 -129
- rasa/dialogue_understanding/commands/utils.py +2 -6
- rasa/dialogue_understanding/generator/command_parser.py +0 -4
- rasa/dialogue_understanding/generator/llm_based_command_generator.py +12 -50
- rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +6 -7
- rasa/dialogue_understanding/generator/single_step/search_ready_llm_command_generator.py +6 -7
- rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +2 -41
- rasa/dialogue_understanding/patterns/continue_interrupted.py +1 -163
- rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +7 -51
- rasa/dialogue_understanding/stack/dialogue_stack.py +2 -123
- rasa/dialogue_understanding/stack/frames/flow_stack_frame.py +0 -57
- rasa/dialogue_understanding/stack/utils.py +2 -3
- rasa/dialogue_understanding_test/du_test_runner.py +2 -7
- rasa/e2e_test/e2e_test_runner.py +0 -5
- rasa/server.py +0 -10
- rasa/shared/constants.py +0 -5
- rasa/shared/core/constants.py +1 -12
- rasa/shared/core/domain.py +5 -5
- rasa/shared/core/events.py +0 -319
- rasa/shared/core/flows/flows_list.py +2 -2
- rasa/shared/core/flows/flows_yaml_schema.json +186 -101
- rasa/shared/core/flows/steps/call.py +5 -51
- rasa/shared/core/flows/validation.py +7 -45
- rasa/shared/core/flows/yaml_flows_io.py +3 -3
- rasa/shared/providers/llm/_base_litellm_client.py +7 -39
- rasa/shared/providers/llm/litellm_router_llm_client.py +4 -8
- rasa/shared/providers/llm/llm_client.py +3 -7
- rasa/shared/providers/llm/llm_response.py +0 -49
- rasa/shared/providers/llm/self_hosted_llm_client.py +4 -8
- rasa/shared/utils/llm.py +5 -28
- rasa/shared/utils/schemas/events.py +0 -42
- rasa/studio/upload.py +7 -4
- rasa/tracing/instrumentation/instrumentation.py +2 -4
- rasa/utils/common.py +0 -53
- rasa/version.py +1 -1
- {rasa_pro-3.14.0.dev1.dist-info → rasa_pro-3.14.0.dev20250818.dist-info}/METADATA +2 -3
- {rasa_pro-3.14.0.dev1.dist-info → rasa_pro-3.14.0.dev20250818.dist-info}/RECORD +107 -143
- rasa/agents/__init__.py +0 -0
- rasa/agents/agent_factory.py +0 -122
- rasa/agents/agent_manager.py +0 -162
- rasa/agents/constants.py +0 -31
- rasa/agents/core/__init__.py +0 -0
- rasa/agents/core/agent_protocol.py +0 -108
- rasa/agents/core/types.py +0 -70
- rasa/agents/exceptions.py +0 -8
- rasa/agents/protocol/__init__.py +0 -5
- rasa/agents/protocol/a2a/__init__.py +0 -0
- rasa/agents/protocol/a2a/a2a_agent.py +0 -51
- rasa/agents/protocol/mcp/__init__.py +0 -0
- rasa/agents/protocol/mcp/mcp_base_agent.py +0 -697
- rasa/agents/protocol/mcp/mcp_open_agent.py +0 -275
- rasa/agents/protocol/mcp/mcp_task_agent.py +0 -447
- rasa/agents/schemas/__init__.py +0 -6
- rasa/agents/schemas/agent_input.py +0 -24
- rasa/agents/schemas/agent_output.py +0 -26
- rasa/agents/schemas/agent_tool_result.py +0 -51
- rasa/agents/schemas/agent_tool_schema.py +0 -112
- rasa/agents/templates/__init__.py +0 -0
- rasa/agents/templates/mcp_open_agent_prompt_template.jinja2 +0 -15
- rasa/agents/templates/mcp_task_agent_prompt_template.jinja2 +0 -13
- rasa/agents/utils.py +0 -72
- rasa/core/available_agents.py +0 -196
- rasa/core/channels/inspector/dist/assets/channel-c436ca7c.js +0 -1
- rasa/core/channels/inspector/dist/assets/clone-50dd656b.js +0 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-2b2aeaf8.js +0 -1
- rasa/core/channels/inspector/dist/assets/index-1bd9135e.js +0 -1353
- rasa/core/policies/flows/mcp_tool_executor.py +0 -240
- rasa/dialogue_understanding/commands/continue_agent_command.py +0 -91
- rasa/dialogue_understanding/commands/restart_agent_command.py +0 -146
- rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v2_claude_3_5_sonnet_20240620_template.jinja2 +0 -61
- rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +0 -61
- rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v3_claude_3_5_sonnet_20240620_template.jinja2 +0 -81
- rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +0 -81
- rasa/shared/agents/__init__.py +0 -0
- rasa/shared/agents/utils.py +0 -35
- rasa/shared/utils/mcp/__init__.py +0 -0
- rasa/shared/utils/mcp/server_connection.py +0 -157
- {rasa_pro-3.14.0.dev1.dist-info → rasa_pro-3.14.0.dev20250818.dist-info}/NOTICE +0 -0
- {rasa_pro-3.14.0.dev1.dist-info → rasa_pro-3.14.0.dev20250818.dist-info}/WHEEL +0 -0
- {rasa_pro-3.14.0.dev1.dist-info → rasa_pro-3.14.0.dev20250818.dist-info}/entry_points.txt +0 -0
rasa/agents/agent_factory.py
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
from typing import Any, ClassVar, Dict, List, Type
|
|
2
|
-
|
|
3
|
-
import structlog
|
|
4
|
-
|
|
5
|
-
from rasa.agents.core.agent_protocol import AgentProtocol
|
|
6
|
-
from rasa.agents.core.types import ProtocolType
|
|
7
|
-
from rasa.agents.protocol import A2AAgent, MCPOpenAgent, MCPTaskAgent
|
|
8
|
-
from rasa.core.available_agents import AgentConfig
|
|
9
|
-
from rasa.shared.utils.common import class_from_module_path
|
|
10
|
-
|
|
11
|
-
structlogger = structlog.get_logger()
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class AgentFactory:
|
|
15
|
-
"""Factory for creating agent instances based on the protocol type."""
|
|
16
|
-
|
|
17
|
-
_protocols: ClassVar[Dict[ProtocolType, Type[AgentProtocol]]] = {
|
|
18
|
-
ProtocolType.A2A: A2AAgent,
|
|
19
|
-
ProtocolType.MCP_OPEN: MCPOpenAgent,
|
|
20
|
-
ProtocolType.MCP_TASK: MCPTaskAgent,
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@classmethod
|
|
24
|
-
def create_client(
|
|
25
|
-
cls, protocol_type: ProtocolType, config: AgentConfig
|
|
26
|
-
) -> AgentProtocol:
|
|
27
|
-
"""Create an agent instance based on the protocol type.
|
|
28
|
-
|
|
29
|
-
Args:
|
|
30
|
-
protocol_type: The protocol type of the agent.
|
|
31
|
-
config: The configuration for the agent as an AgentConfig object.
|
|
32
|
-
|
|
33
|
-
Returns:
|
|
34
|
-
An instance of the agent.
|
|
35
|
-
"""
|
|
36
|
-
# If the agent is a custom agent, we need to create it from the module
|
|
37
|
-
if config.configuration and config.configuration.module:
|
|
38
|
-
agent_class: Type[AgentProtocol] = class_from_module_path(
|
|
39
|
-
config.configuration.module
|
|
40
|
-
)
|
|
41
|
-
if not cls._is_valid_custom_agent(agent_class, protocol_type):
|
|
42
|
-
raise ValueError(
|
|
43
|
-
f"Agent class {agent_class} does not subclass the "
|
|
44
|
-
f"{cls._get_agent_class_from_protocol(protocol_type).__name__} "
|
|
45
|
-
f"agent class."
|
|
46
|
-
)
|
|
47
|
-
structlogger.debug(
|
|
48
|
-
"agent_factory.create_client.custom_agent",
|
|
49
|
-
event_info=(
|
|
50
|
-
f"Initializing `{agent_class.__name__}` for agent "
|
|
51
|
-
f"`{config.agent.name}` with protocol `{protocol_type.value}`"
|
|
52
|
-
),
|
|
53
|
-
agent_name=config.agent.name,
|
|
54
|
-
protocol_type=protocol_type.value,
|
|
55
|
-
agent_class=agent_class.__name__,
|
|
56
|
-
)
|
|
57
|
-
return agent_class.from_config(config)
|
|
58
|
-
|
|
59
|
-
# If the agent is a built-in agent, we need to create it from the protocol class
|
|
60
|
-
protocol_class = cls._get_agent_class_from_protocol(protocol_type)
|
|
61
|
-
if protocol_class is None:
|
|
62
|
-
raise ValueError(
|
|
63
|
-
f"Unsupported protocol: {protocol_type}. "
|
|
64
|
-
f"Supported protocols: {cls.get_supported_protocols()}"
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
structlogger.debug(
|
|
68
|
-
"agent_factory.create_client",
|
|
69
|
-
event_info=(
|
|
70
|
-
f"Initializing `{protocol_class.__name__}` for agent "
|
|
71
|
-
f"`{config.agent.name}` with protocol `{protocol_type.value}`"
|
|
72
|
-
),
|
|
73
|
-
agent_name=config.agent.name,
|
|
74
|
-
protocol_type=protocol_type.value,
|
|
75
|
-
agent_class=protocol_class.__name__,
|
|
76
|
-
)
|
|
77
|
-
return protocol_class.from_config(config)
|
|
78
|
-
|
|
79
|
-
@classmethod
|
|
80
|
-
def register_protocol(
|
|
81
|
-
cls, protocol_type: ProtocolType, protocol_class: Type[AgentProtocol]
|
|
82
|
-
) -> None:
|
|
83
|
-
"""Register new protocol implementation.
|
|
84
|
-
|
|
85
|
-
Args:
|
|
86
|
-
protocol_type: The protocol type of the agent.
|
|
87
|
-
protocol_class: The class that implements the protocol.
|
|
88
|
-
"""
|
|
89
|
-
if cls.is_protocol_supported(protocol_type):
|
|
90
|
-
raise ValueError(f"Protocol {protocol_type} already registered.")
|
|
91
|
-
cls._protocols[protocol_type] = protocol_class
|
|
92
|
-
|
|
93
|
-
@classmethod
|
|
94
|
-
def get_supported_protocols(cls) -> List[ProtocolType]:
|
|
95
|
-
"""Get all supported protocol types."""
|
|
96
|
-
return list(cls._protocols.keys())
|
|
97
|
-
|
|
98
|
-
@classmethod
|
|
99
|
-
def _get_agent_class_from_protocol(
|
|
100
|
-
cls, protocol_type: ProtocolType
|
|
101
|
-
) -> Type[AgentProtocol]:
|
|
102
|
-
"""Get the class that implements the protocol."""
|
|
103
|
-
if not cls.is_protocol_supported(protocol_type):
|
|
104
|
-
raise ValueError(
|
|
105
|
-
f"Unsupported protocol: {protocol_type}. "
|
|
106
|
-
f"Supported protocols: {cls.get_supported_protocols()}"
|
|
107
|
-
)
|
|
108
|
-
return cls._protocols[protocol_type]
|
|
109
|
-
|
|
110
|
-
@classmethod
|
|
111
|
-
def is_protocol_supported(cls, protocol_type: ProtocolType) -> bool:
|
|
112
|
-
"""Check if the protocol is supported."""
|
|
113
|
-
return protocol_type in cls._protocols
|
|
114
|
-
|
|
115
|
-
@classmethod
|
|
116
|
-
def _is_valid_custom_agent(
|
|
117
|
-
cls, agent_class: Any, protocol_type: ProtocolType
|
|
118
|
-
) -> bool:
|
|
119
|
-
"""Check if the agent class is valid."""
|
|
120
|
-
return issubclass(
|
|
121
|
-
agent_class, cls._get_agent_class_from_protocol(protocol_type)
|
|
122
|
-
)
|
rasa/agents/agent_manager.py
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
from typing import ClassVar, Dict
|
|
2
|
-
|
|
3
|
-
import structlog
|
|
4
|
-
|
|
5
|
-
from rasa.agents.agent_factory import AgentFactory
|
|
6
|
-
from rasa.agents.core.agent_protocol import AgentProtocol
|
|
7
|
-
from rasa.agents.core.types import AgentIdentifier, ProtocolType
|
|
8
|
-
from rasa.agents.schemas import AgentInput, AgentOutput
|
|
9
|
-
from rasa.core.available_agents import AgentConfig
|
|
10
|
-
from rasa.shared.agents.utils import make_agent_identifier
|
|
11
|
-
from rasa.utils.singleton import Singleton
|
|
12
|
-
|
|
13
|
-
structlogger = structlog.get_logger()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class AgentManager(metaclass=Singleton):
|
|
17
|
-
"""High-level agent management with protocol abstraction"""
|
|
18
|
-
|
|
19
|
-
agents: ClassVar[Dict[AgentIdentifier, AgentProtocol]] = {}
|
|
20
|
-
|
|
21
|
-
def _add_agent(
|
|
22
|
-
self, agent_identifier: AgentIdentifier, agent: AgentProtocol
|
|
23
|
-
) -> None:
|
|
24
|
-
"""Add an agent to the manager.
|
|
25
|
-
|
|
26
|
-
Args:
|
|
27
|
-
agent_identifier: The identifier of the agent.
|
|
28
|
-
agent: The agent to add.
|
|
29
|
-
"""
|
|
30
|
-
if agent_identifier in self.agents:
|
|
31
|
-
raise ValueError(f"Agent {agent_identifier} already exists")
|
|
32
|
-
self.agents[agent_identifier] = agent
|
|
33
|
-
|
|
34
|
-
def _remove_agent(self, agent_identifier: AgentIdentifier) -> None:
|
|
35
|
-
"""Remove an agent from the manager.
|
|
36
|
-
|
|
37
|
-
Args:
|
|
38
|
-
agent_identifier: The identifier of the agent.
|
|
39
|
-
|
|
40
|
-
Raises:
|
|
41
|
-
ValueError: If the agent is not connected.
|
|
42
|
-
"""
|
|
43
|
-
if agent_identifier not in self.agents:
|
|
44
|
-
raise ValueError(f"Agent {agent_identifier} not connected")
|
|
45
|
-
del self.agents[agent_identifier]
|
|
46
|
-
|
|
47
|
-
def get_agent(self, agent_name: str, protocol_type: ProtocolType) -> AgentProtocol:
|
|
48
|
-
"""Retrieve connected agent instance.
|
|
49
|
-
|
|
50
|
-
Args:
|
|
51
|
-
agent_name: The name of the agent.
|
|
52
|
-
protocol_type: The protocol type of the agent.
|
|
53
|
-
|
|
54
|
-
Returns:
|
|
55
|
-
The agent.
|
|
56
|
-
|
|
57
|
-
Raises:
|
|
58
|
-
ValueError: If the agent is not connected.
|
|
59
|
-
"""
|
|
60
|
-
agent_identifier = make_agent_identifier(agent_name, protocol_type)
|
|
61
|
-
if agent_identifier not in self.agents:
|
|
62
|
-
raise ValueError(f"Agent {agent_identifier} not connected")
|
|
63
|
-
return self.agents[agent_identifier]
|
|
64
|
-
|
|
65
|
-
async def connect_agent(
|
|
66
|
-
self, agent_name: str, protocol_type: ProtocolType, config: AgentConfig
|
|
67
|
-
) -> None:
|
|
68
|
-
"""Connect to agent using specified protocol, load the default resources
|
|
69
|
-
and persist the agent to the manager in a ready-to-use state so that
|
|
70
|
-
it can be used immediately to send messages to the agent.
|
|
71
|
-
|
|
72
|
-
Args:
|
|
73
|
-
agent_name: The name of the agent.
|
|
74
|
-
protocol_type: The protocol type of the agent.
|
|
75
|
-
config: The configuration for the agent as an AgentConfig object.
|
|
76
|
-
|
|
77
|
-
Raises:
|
|
78
|
-
ConnectionError: If the agent connection fails.
|
|
79
|
-
"""
|
|
80
|
-
try:
|
|
81
|
-
# Create the agent client
|
|
82
|
-
client = AgentFactory.create_client(protocol_type, config)
|
|
83
|
-
|
|
84
|
-
# Connect the agent client
|
|
85
|
-
await client.connect()
|
|
86
|
-
|
|
87
|
-
# Add the agent to the manager
|
|
88
|
-
agent_identifier = make_agent_identifier(agent_name, protocol_type)
|
|
89
|
-
self._add_agent(agent_identifier, client)
|
|
90
|
-
structlogger.info(
|
|
91
|
-
"agent_manager.connect_agent.success",
|
|
92
|
-
agent_id=str(agent_identifier),
|
|
93
|
-
agent_name=agent_name,
|
|
94
|
-
event_info=f"Connected to agent - `{agent_identifier}` successfully",
|
|
95
|
-
)
|
|
96
|
-
except Exception as e:
|
|
97
|
-
event_info = f"Failed to connect agent {agent_identifier}"
|
|
98
|
-
structlogger.error(
|
|
99
|
-
"agent_manager.connect_agent.failed_to_connect",
|
|
100
|
-
agent_id=str(agent_identifier),
|
|
101
|
-
event_info=event_info,
|
|
102
|
-
)
|
|
103
|
-
raise ConnectionError(e)
|
|
104
|
-
|
|
105
|
-
async def run_agent(
|
|
106
|
-
self, agent_name: str, protocol_type: ProtocolType, context: AgentInput
|
|
107
|
-
) -> AgentOutput:
|
|
108
|
-
"""Run an agent, send the input to the agent and return the agent response.
|
|
109
|
-
|
|
110
|
-
Args:
|
|
111
|
-
agent_name: The name of the agent.
|
|
112
|
-
protocol_type: The protocol type of the agent.
|
|
113
|
-
context: The input to the agent as an AgentInput object.
|
|
114
|
-
|
|
115
|
-
Returns:
|
|
116
|
-
The response from the agent.
|
|
117
|
-
"""
|
|
118
|
-
agent = self.get_agent(agent_name, protocol_type)
|
|
119
|
-
|
|
120
|
-
# Process input before sending
|
|
121
|
-
processed_input = await agent.process_input(context)
|
|
122
|
-
|
|
123
|
-
# Send message to agent
|
|
124
|
-
output = await agent.run(processed_input)
|
|
125
|
-
|
|
126
|
-
# Process output before returning
|
|
127
|
-
processed_output = await agent.process_output(output)
|
|
128
|
-
|
|
129
|
-
return processed_output
|
|
130
|
-
|
|
131
|
-
async def disconnect_agent(
|
|
132
|
-
self, agent_name: str, protocol_type: ProtocolType
|
|
133
|
-
) -> None:
|
|
134
|
-
"""Disconnect agent and remove from agent manager.
|
|
135
|
-
|
|
136
|
-
Args:
|
|
137
|
-
agent_name: The name of the agent.
|
|
138
|
-
protocol_type: The protocol type of the agent.
|
|
139
|
-
|
|
140
|
-
Raises:
|
|
141
|
-
ValueError: If the agent is not connected.
|
|
142
|
-
ConnectionError: If the agent disconnection fails.
|
|
143
|
-
"""
|
|
144
|
-
agent_identifier = make_agent_identifier(agent_name, protocol_type)
|
|
145
|
-
if agent_identifier not in self.agents:
|
|
146
|
-
raise ValueError(f"Agent {agent_identifier} not connected")
|
|
147
|
-
try:
|
|
148
|
-
await self.get_agent(agent_name, protocol_type).disconnect()
|
|
149
|
-
self._remove_agent(agent_identifier)
|
|
150
|
-
structlogger.info(
|
|
151
|
-
"agent_manager.disconnect_agent.success",
|
|
152
|
-
agent_id=str(agent_identifier),
|
|
153
|
-
event_info=f"Disconnected from agent - {agent_identifier} successfully",
|
|
154
|
-
)
|
|
155
|
-
except Exception as e:
|
|
156
|
-
event_info = f"Failed to disconnect agent {agent_identifier}"
|
|
157
|
-
structlogger.error(
|
|
158
|
-
"agent_manager.disconnect_agent.failed_to_disconnect",
|
|
159
|
-
agent_id=str(agent_identifier),
|
|
160
|
-
event_info=event_info,
|
|
161
|
-
)
|
|
162
|
-
raise ConnectionError(e)
|
rasa/agents/constants.py
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# MCP Tool related constants (primary)
|
|
2
|
-
TOOL_TYPE_KEY = "type"
|
|
3
|
-
TOOL_NAME_KEY = "name"
|
|
4
|
-
TOOL_DESCRIPTION_KEY = "description"
|
|
5
|
-
TOOL_PARAMETERS_KEY = "parameters"
|
|
6
|
-
TOOL_STRICT_KEY = "strict"
|
|
7
|
-
TOOL_TYPE_FUNCTION_KEY = "function"
|
|
8
|
-
|
|
9
|
-
# MCP Tool related constants (secondary)
|
|
10
|
-
TOOL_ADDITIONAL_PROPERTIES_KEY = "additionalProperties"
|
|
11
|
-
TOOL_PROPERTIES_KEY = "properties"
|
|
12
|
-
TOOL_REQUIRED_KEY = "required"
|
|
13
|
-
TOOL_PROPERTY_TYPE_KEY = "type"
|
|
14
|
-
|
|
15
|
-
# MCP Message related constants
|
|
16
|
-
KEY_ROLE = "role"
|
|
17
|
-
KEY_CONTENT = "content"
|
|
18
|
-
|
|
19
|
-
# MCP Tool call related constants
|
|
20
|
-
KEY_TOOL_CALL_ID = "tool_call_id"
|
|
21
|
-
KEY_FUNCTION = "function"
|
|
22
|
-
KEY_NAME = "name"
|
|
23
|
-
KEY_ARGUMENTS = "arguments"
|
|
24
|
-
KEY_ID = "id"
|
|
25
|
-
KEY_TYPE = "type"
|
|
26
|
-
KEY_TOOL_CALLS = "tool_calls"
|
|
27
|
-
|
|
28
|
-
# Agent output metadata related constants
|
|
29
|
-
AGENT_METADATA_AGENT_RESPONSE_KEY = "agent_response"
|
|
30
|
-
AGENT_METADATA_TOOL_RESULTS_KEY = "tool_results"
|
|
31
|
-
AGENT_METADATA_EXIT_IF_KEY = "exit_if"
|
rasa/agents/core/__init__.py
DELETED
|
File without changes
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import TYPE_CHECKING, Protocol, runtime_checkable
|
|
4
|
-
|
|
5
|
-
if TYPE_CHECKING:
|
|
6
|
-
from rasa.agents.core.types import ProtocolType
|
|
7
|
-
from rasa.agents.schemas.agent_input import AgentInput
|
|
8
|
-
from rasa.agents.schemas.agent_output import AgentOutput
|
|
9
|
-
from rasa.core.available_agents import AgentConfig
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@runtime_checkable
|
|
13
|
-
class AgentProtocol(Protocol):
|
|
14
|
-
"""
|
|
15
|
-
Python protocol for interfacing with agent clients that implement the
|
|
16
|
-
agent communication protocols like MCP, A2A, ACP, etc.
|
|
17
|
-
"""
|
|
18
|
-
|
|
19
|
-
@classmethod
|
|
20
|
-
def from_config(cls, config: AgentConfig) -> AgentProtocol:
|
|
21
|
-
"""
|
|
22
|
-
Initialize the Agent with the given configuration.
|
|
23
|
-
|
|
24
|
-
This class method should be implemented to parse the given
|
|
25
|
-
configuration and create an instance of an agent.
|
|
26
|
-
|
|
27
|
-
Args:
|
|
28
|
-
config: The configuration for the agent as an AgentConfig object.
|
|
29
|
-
|
|
30
|
-
Returns:
|
|
31
|
-
An instance of the agent.
|
|
32
|
-
"""
|
|
33
|
-
...
|
|
34
|
-
|
|
35
|
-
@property
|
|
36
|
-
def protocol_type(self) -> "ProtocolType":
|
|
37
|
-
"""
|
|
38
|
-
Returns the protocol type of the agent.
|
|
39
|
-
|
|
40
|
-
This property should be implemented to return the protocol type of the agent.
|
|
41
|
-
This is used to determine the type of agent to create in the AgentFactory.
|
|
42
|
-
"""
|
|
43
|
-
...
|
|
44
|
-
|
|
45
|
-
async def connect(self) -> None:
|
|
46
|
-
"""
|
|
47
|
-
Establish connection to agent/server.
|
|
48
|
-
|
|
49
|
-
This method should be implemented to establish a connection to the agent/server
|
|
50
|
-
and load any necessary resources.
|
|
51
|
-
"""
|
|
52
|
-
...
|
|
53
|
-
|
|
54
|
-
async def disconnect(self) -> None:
|
|
55
|
-
"""
|
|
56
|
-
Close connection to agent/server.
|
|
57
|
-
|
|
58
|
-
This method should be implemented to close the connection to the agent/server
|
|
59
|
-
and release any necessary resources.
|
|
60
|
-
"""
|
|
61
|
-
...
|
|
62
|
-
|
|
63
|
-
async def process_input(self, input: "AgentInput") -> "AgentInput":
|
|
64
|
-
"""
|
|
65
|
-
Pre-process the input before sending it to the agent.
|
|
66
|
-
|
|
67
|
-
This method should be implemented to pre-process the input before sending it
|
|
68
|
-
to the agent. This can be used to add any necessary metadata or context to the
|
|
69
|
-
input, or to filter the input.
|
|
70
|
-
|
|
71
|
-
Args:
|
|
72
|
-
input: The input to the agent as an AgentInput object.
|
|
73
|
-
|
|
74
|
-
Returns:
|
|
75
|
-
The processed input to the agent as an AgentInput object.
|
|
76
|
-
"""
|
|
77
|
-
...
|
|
78
|
-
|
|
79
|
-
async def run(self, input: "AgentInput") -> "AgentOutput":
|
|
80
|
-
"""
|
|
81
|
-
Send a message to Agent/server and return response.
|
|
82
|
-
|
|
83
|
-
This method should be implemented to send a message to the agent/server and
|
|
84
|
-
return the response in an AgentOutput object.
|
|
85
|
-
|
|
86
|
-
Args:
|
|
87
|
-
input: The input to the agent as an AgentInput object.
|
|
88
|
-
|
|
89
|
-
Returns:
|
|
90
|
-
The output from the agent as an AgentOutput object.
|
|
91
|
-
"""
|
|
92
|
-
...
|
|
93
|
-
|
|
94
|
-
async def process_output(self, output: "AgentOutput") -> "AgentOutput":
|
|
95
|
-
"""
|
|
96
|
-
Post-process the output before returning it to Rasa.
|
|
97
|
-
|
|
98
|
-
This method should be implemented to post-process the output before returning
|
|
99
|
-
it to Rasa. This can be used to add any necessary metadata or context to the
|
|
100
|
-
output, or to filter the output.
|
|
101
|
-
|
|
102
|
-
Args:
|
|
103
|
-
output: The output from the agent as an AgentOutput object.
|
|
104
|
-
|
|
105
|
-
Returns:
|
|
106
|
-
The processed output from the agent as an AgentOutput object.
|
|
107
|
-
"""
|
|
108
|
-
...
|
rasa/agents/core/types.py
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"""Fundamental types for the agent protocol."""
|
|
2
|
-
|
|
3
|
-
from enum import Enum
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class ProtocolType(Enum):
|
|
7
|
-
"""An Enum class that represents the supported protocol types."""
|
|
8
|
-
|
|
9
|
-
MCP_OPEN = "mcp_open"
|
|
10
|
-
MCP_TASK = "mcp_task"
|
|
11
|
-
A2A = "a2a"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class AgentIdentifier:
|
|
15
|
-
"""Represents a unique agent identifier combining agent_id and protocol_type."""
|
|
16
|
-
|
|
17
|
-
SEPARATOR = "::"
|
|
18
|
-
|
|
19
|
-
def __init__(self, agent_name: str, protocol_type: ProtocolType):
|
|
20
|
-
self.agent_name = agent_name
|
|
21
|
-
self.protocol_type = protocol_type
|
|
22
|
-
|
|
23
|
-
def __str__(self) -> str:
|
|
24
|
-
return f"{self.agent_name}{self.SEPARATOR}{self.protocol_type.value}"
|
|
25
|
-
|
|
26
|
-
def __repr__(self) -> str:
|
|
27
|
-
return (
|
|
28
|
-
f"AgentIdentifier(agent_name='{self.agent_name}', "
|
|
29
|
-
f"protocol_type='{self.protocol_type.value}')"
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
def __eq__(self, other: object) -> bool:
|
|
33
|
-
if isinstance(other, AgentIdentifier):
|
|
34
|
-
return (
|
|
35
|
-
self.agent_name == other.agent_name
|
|
36
|
-
and self.protocol_type == other.protocol_type
|
|
37
|
-
)
|
|
38
|
-
elif isinstance(other, str):
|
|
39
|
-
return str(self) == other
|
|
40
|
-
return False
|
|
41
|
-
|
|
42
|
-
def __hash__(self) -> int:
|
|
43
|
-
return hash((self.agent_name, self.protocol_type))
|
|
44
|
-
|
|
45
|
-
@classmethod
|
|
46
|
-
def from_string(cls, identifier: str) -> "AgentIdentifier":
|
|
47
|
-
"""Create an AgentIdentifier from a string representation."""
|
|
48
|
-
if cls.SEPARATOR not in identifier:
|
|
49
|
-
raise ValueError(f"Invalid agent identifier format: {identifier}")
|
|
50
|
-
|
|
51
|
-
parts = identifier.split(cls.SEPARATOR, 1)
|
|
52
|
-
if len(parts) != 2:
|
|
53
|
-
raise ValueError(f"Invalid agent identifier format: {identifier}")
|
|
54
|
-
|
|
55
|
-
agent_name, protocol_str = parts
|
|
56
|
-
try:
|
|
57
|
-
protocol_type = ProtocolType(protocol_str)
|
|
58
|
-
except ValueError:
|
|
59
|
-
raise ValueError(f"Invalid protocol type: {protocol_str}")
|
|
60
|
-
|
|
61
|
-
return cls(agent_name, protocol_type)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
class AgentStatus(Enum):
|
|
65
|
-
"""A Enum class that represents the status of the agent."""
|
|
66
|
-
|
|
67
|
-
COMPLETED = "completed"
|
|
68
|
-
INPUT_REQUIRED = "input_required"
|
|
69
|
-
FATAL_ERROR = "fatal_error"
|
|
70
|
-
RECOVERABLE_ERROR = "recoverable_error"
|
rasa/agents/exceptions.py
DELETED
rasa/agents/protocol/__init__.py
DELETED
|
File without changes
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
from typing import Any, Dict, Optional
|
|
2
|
-
|
|
3
|
-
import httpx
|
|
4
|
-
|
|
5
|
-
from rasa.agents.core.agent_protocol import AgentProtocol
|
|
6
|
-
from rasa.agents.core.types import ProtocolType
|
|
7
|
-
from rasa.agents.schemas import AgentInput, AgentOutput
|
|
8
|
-
from rasa.core.available_agents import AgentConfig
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class A2AAgent(AgentProtocol):
|
|
12
|
-
"""A2A client implementation"""
|
|
13
|
-
|
|
14
|
-
def __init__(self, config: Dict[str, Any]) -> None:
|
|
15
|
-
self.client: Optional[httpx.AsyncClient] = None
|
|
16
|
-
self.agent_card = None
|
|
17
|
-
self.url = None
|
|
18
|
-
self.config = config
|
|
19
|
-
|
|
20
|
-
@classmethod
|
|
21
|
-
def from_config(cls, config: AgentConfig) -> AgentProtocol:
|
|
22
|
-
"""Initialize the A2A Agent with the given configuration."""
|
|
23
|
-
return cls(config)
|
|
24
|
-
|
|
25
|
-
@property
|
|
26
|
-
def protocol_type(self) -> ProtocolType:
|
|
27
|
-
return ProtocolType.A2A
|
|
28
|
-
|
|
29
|
-
async def connect(self) -> None:
|
|
30
|
-
# A2A-specific connection logic
|
|
31
|
-
# Fetch agent card, establish HTTP connection
|
|
32
|
-
return
|
|
33
|
-
|
|
34
|
-
async def disconnect(self) -> None:
|
|
35
|
-
# A2A-specific disconnection logic
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
async def process_input(self, input: AgentInput) -> AgentInput:
|
|
39
|
-
"""Pre-process the input before sending it to the agent."""
|
|
40
|
-
# A2A-specific input processing logic
|
|
41
|
-
return input
|
|
42
|
-
|
|
43
|
-
async def run(self, input: AgentInput) -> AgentOutput:
|
|
44
|
-
"""Send a message to Agent/server and return response."""
|
|
45
|
-
# A2A-specific message sending logic
|
|
46
|
-
return AgentOutput()
|
|
47
|
-
|
|
48
|
-
async def process_output(self, output: AgentOutput) -> AgentOutput:
|
|
49
|
-
"""Post-process the output before returning it to Rasa."""
|
|
50
|
-
# A2A-specific output processing logic
|
|
51
|
-
return output
|
|
File without changes
|