rasa-pro 3.14.0.dev2__py3-none-any.whl → 3.14.0.dev4__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/agents/agent_manager.py +2 -2
- rasa/agents/constants.py +9 -0
- rasa/agents/core/agent_protocol.py +1 -2
- rasa/agents/protocol/a2a/a2a_agent.py +628 -17
- rasa/agents/protocol/mcp/mcp_base_agent.py +35 -56
- rasa/agents/protocol/mcp/mcp_open_agent.py +3 -2
- rasa/agents/protocol/mcp/mcp_task_agent.py +38 -16
- rasa/agents/schemas/__init__.py +8 -2
- rasa/agents/schemas/agent_input.py +15 -1
- rasa/agents/schemas/agent_tool_schema.py +23 -1
- rasa/agents/templates/mcp_task_agent_prompt_template.jinja2 +6 -2
- rasa/core/actions/action.py +13 -8
- rasa/core/available_agents.py +3 -0
- rasa/core/channels/development_inspector.py +3 -3
- rasa/core/channels/hangouts.py +2 -2
- rasa/core/channels/inspector/dist/assets/{arc-2e78c586.js → arc-63212852.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-806b712e.js → blockDiagram-38ab4fdb-eecf6b13.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-0745efa9.js → c4Diagram-3d4e48cf-8f798a9a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-0cd70adf.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-7bd1082b.js → classDiagram-70f12bd4-df71a04c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-d937ba49.js → classDiagram-v2-f2320105-9b275968.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-a0f9c4ed.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-a2a564ca.js → createText-2e5e7dd3-1c669cad.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-b5256940.js → edges-e0da2a9e-b1553799.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-e6883ad2.js → erDiagram-9861fffd-112388d6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-e576fc02.js → flowDb-956e92f1-fdebec47.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-2e298d01.js → flowDiagram-66a62f08-6280ede1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-de9cc4aa.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-dd7b150a.js → flowchart-elk-definition-4a651766-e1dc03e5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-5b79575c.js → ganttDiagram-c361ad54-83f68c51.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-3016f40a.js → gitGraphDiagram-72cf32ee-22f8666f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-3e19170f.js → graph-ca9e6217.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-eb9c86de.js → index-3862675e-c5ceb692.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-1bd9135e.js → index-3e293924.js} +3 -3
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-b4280e4d.js → infoDiagram-f8f76790-faa9999b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-556091f8.js → journeyDiagram-49397b02-c4dda8d9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-08436411.js → layout-d4307784.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-683c4f3b.js → line-0567aaa7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-cee6d791.js → linear-c11b95cf.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-a0bf0b1a.js → mindmap-definition-fc14e90a-0c7d3ca9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-3730d5c4.js → pieDiagram-8a3498a8-34b433fa.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-12a20fed.js → quadrantDiagram-120e2f19-4cab816e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-b9732102.js → requirementDiagram-deff3bca-8c22fa9e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-a2e72776.js → sankeyDiagram-04a897e0-70ce9e8e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-8b7a76bb.js → sequenceDiagram-704730f1-fbcd7fc9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-e65853ac.js → stateDiagram-587899a1-45f05ea6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-6f58a44b.js → stateDiagram-v2-d93cdb3a-beab1ea6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-df25b934.js → styles-6aaf32cf-2f29dbd5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-88357141.js → styles-9a916d00-951eac83.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-d600174d.js → styles-c10674c1-897fbfdd.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-4adc3e0b.js → svgDrawCommon-08f97a94-d667fac1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-42816fa1.js → timeline-definition-85554ec2-e3205144.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-621eb66a.js → xychartDiagram-e933f94c-4abeb0e2.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/src/components/DialogueStack.tsx +1 -1
- rasa/core/channels/studio_chat.py +6 -6
- rasa/core/channels/voice_stream/genesys.py +1 -1
- rasa/core/policies/flow_policy.py +2 -2
- rasa/core/policies/flows/flow_executor.py +96 -17
- rasa/core/policies/flows/mcp_tool_executor.py +48 -11
- rasa/core/policies/intentless_policy.py +1 -1
- rasa/core/policies/unexpected_intent_policy.py +1 -0
- rasa/core/processor.py +12 -14
- rasa/core/tracker_stores/tracker_store.py +3 -7
- rasa/core/train.py +1 -1
- rasa/core/training/interactive.py +16 -16
- rasa/core/training/story_conflict.py +5 -5
- rasa/dialogue_understanding/commands/start_flow_command.py +36 -1
- rasa/dialogue_understanding/generator/llm_command_generator.py +1 -1
- rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +1 -1
- rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +5 -5
- rasa/dialogue_understanding/processor/command_processor.py +31 -15
- rasa/dialogue_understanding/stack/utils.py +14 -0
- rasa/e2e_test/e2e_test_runner.py +7 -2
- rasa/engine/caching.py +2 -2
- rasa/engine/recipes/default_components.py +10 -18
- rasa/graph_components/validators/default_recipe_validator.py +134 -134
- rasa/hooks.py +5 -5
- rasa/llm_fine_tuning/utils.py +2 -2
- rasa/model_manager/warm_rasa_process.py +1 -1
- rasa/nlu/extractors/extractor.py +2 -1
- rasa/plugin.py +8 -8
- rasa/privacy/privacy_manager.py +11 -2
- rasa/server.py +4 -2
- rasa/shared/core/events.py +9 -1
- rasa/shared/core/flows/flows_yaml_schema.json +12 -1
- rasa/shared/core/flows/steps/call.py +2 -0
- rasa/shared/core/flows/validation.py +3 -2
- rasa/shared/core/flows/yaml_flows_io.py +1 -1
- rasa/shared/core/slots.py +2 -2
- rasa/shared/core/trackers.py +5 -2
- rasa/shared/exceptions.py +4 -0
- rasa/shared/utils/yaml.py +3 -1
- rasa/tracing/instrumentation/instrumentation.py +8 -8
- rasa/tracing/instrumentation/intentless_policy_instrumentation.py +4 -4
- rasa/utils/common.py +26 -0
- rasa/utils/log_utils.py +1 -1
- rasa/utils/ml_utils.py +1 -1
- rasa/utils/tensorflow/rasa_layers.py +1 -1
- rasa/utils/train_utils.py +15 -15
- rasa/validator.py +16 -14
- rasa/version.py +1 -1
- {rasa_pro-3.14.0.dev2.dist-info → rasa_pro-3.14.0.dev4.dist-info}/METADATA +12 -15
- {rasa_pro-3.14.0.dev2.dist-info → rasa_pro-3.14.0.dev4.dist-info}/RECORD +107 -107
- 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_pro-3.14.0.dev2.dist-info → rasa_pro-3.14.0.dev4.dist-info}/NOTICE +0 -0
- {rasa_pro-3.14.0.dev2.dist-info → rasa_pro-3.14.0.dev4.dist-info}/WHEEL +0 -0
- {rasa_pro-3.14.0.dev2.dist-info → rasa_pro-3.14.0.dev4.dist-info}/entry_points.txt +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import json
|
|
2
2
|
from abc import abstractmethod
|
|
3
|
+
from inspect import isawaitable
|
|
3
4
|
from typing import Any, Dict, List, Optional, Tuple
|
|
4
5
|
|
|
5
6
|
import structlog
|
|
@@ -7,6 +8,8 @@ from jinja2 import Template
|
|
|
7
8
|
from mcp import ListToolsResult
|
|
8
9
|
|
|
9
10
|
from rasa.agents.constants import (
|
|
11
|
+
AGENT_DEFAULT_MAX_RETRIES,
|
|
12
|
+
AGENT_DEFAULT_TIMEOUT_SECONDS,
|
|
10
13
|
AGENT_METADATA_TOOL_RESULTS_KEY,
|
|
11
14
|
KEY_ARGUMENTS,
|
|
12
15
|
KEY_CONTENT,
|
|
@@ -25,6 +28,7 @@ from rasa.agents.schemas import (
|
|
|
25
28
|
AgentOutput,
|
|
26
29
|
AgentToolResult,
|
|
27
30
|
AgentToolSchema,
|
|
31
|
+
CustomToolSchema,
|
|
28
32
|
)
|
|
29
33
|
from rasa.core.available_agents import AgentConfig, AgentMCPServerConfig, ProtocolConfig
|
|
30
34
|
from rasa.shared.agents.utils import make_agent_identifier
|
|
@@ -103,15 +107,21 @@ class MCPBaseAgent(AgentProtocol):
|
|
|
103
107
|
log_source_method=LOG_COMPONENT_SOURCE_METHOD_INIT,
|
|
104
108
|
)
|
|
105
109
|
|
|
106
|
-
self._timeout = timeout or
|
|
110
|
+
self._timeout = timeout or AGENT_DEFAULT_TIMEOUT_SECONDS
|
|
107
111
|
|
|
108
|
-
self._max_retries = max_retries or
|
|
112
|
+
self._max_retries = max_retries or AGENT_DEFAULT_MAX_RETRIES
|
|
109
113
|
|
|
110
114
|
self._server_configs = server_configs or []
|
|
111
115
|
|
|
112
116
|
# Stores the MCP tools for the agent.
|
|
113
117
|
self._mcp_tools: List[AgentToolSchema] = []
|
|
114
118
|
|
|
119
|
+
# Stores the custom tools for the agent.
|
|
120
|
+
self._custom_tools: List[CustomToolSchema] = [
|
|
121
|
+
CustomToolSchema.from_dict(tool)
|
|
122
|
+
for tool in self.get_custom_tool_definitions()
|
|
123
|
+
]
|
|
124
|
+
|
|
115
125
|
# Maps the tool names to the MCP servers that provide them.
|
|
116
126
|
# key: tool name, value: server name.
|
|
117
127
|
self._tool_to_server_mapper: Dict[str, str] = {}
|
|
@@ -164,28 +174,29 @@ class MCPBaseAgent(AgentProtocol):
|
|
|
164
174
|
@classmethod
|
|
165
175
|
def get_agent_specific_built_in_tools(
|
|
166
176
|
cls, agent_input: AgentInput
|
|
167
|
-
) -> List[
|
|
177
|
+
) -> List[AgentToolSchema]:
|
|
168
178
|
"""Get agentic specific built-in tools."""
|
|
169
179
|
return []
|
|
170
180
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
This method can be overridden to provide
|
|
181
|
+
def get_custom_tool_definitions(self) -> List[Dict[str, Any]]:
|
|
182
|
+
"""Add custom tool definitions and their executors for MCP agents.
|
|
183
|
+
|
|
184
|
+
This method can be overridden to provide custom tools that the agent
|
|
175
185
|
can use during its operation. The tools should be defined in the OpenAI
|
|
176
186
|
JSON format, which includes the tool name, description, and parameters.
|
|
177
187
|
|
|
178
188
|
Refer: https://platform.openai.com/docs/guides/function-calling?api-mode=responses
|
|
179
189
|
|
|
180
|
-
|
|
181
|
-
|
|
190
|
+
Note:
|
|
191
|
+
The tool executor method should be a coroutine function that returns an
|
|
192
|
+
AgentToolResult object.
|
|
182
193
|
|
|
183
194
|
Returns:
|
|
184
|
-
A list of
|
|
195
|
+
A list of custom tool definitions along with their tool executor method.
|
|
185
196
|
|
|
186
197
|
Example:
|
|
187
198
|
```python
|
|
188
|
-
def
|
|
199
|
+
def get_custom_tool_definitions(self) -> List[Dict[str, Any]]:
|
|
189
200
|
return [
|
|
190
201
|
{
|
|
191
202
|
"type": "function",
|
|
@@ -207,6 +218,7 @@ class MCPBaseAgent(AgentProtocol):
|
|
|
207
218
|
"required": ["location"],
|
|
208
219
|
},
|
|
209
220
|
},
|
|
221
|
+
"tool_executor": self.get_current_weather,
|
|
210
222
|
}
|
|
211
223
|
]
|
|
212
224
|
```
|
|
@@ -334,23 +346,17 @@ class MCPBaseAgent(AgentProtocol):
|
|
|
334
346
|
session = await connection.ensure_active_session()
|
|
335
347
|
return await session.list_tools()
|
|
336
348
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
built_in_tools = []
|
|
341
|
-
if agent_specific_built_in_tools := cls.get_agent_specific_built_in_tools(
|
|
342
|
-
agent_input
|
|
343
|
-
):
|
|
344
|
-
built_in_tools.extend(agent_specific_built_in_tools)
|
|
345
|
-
if additional_tools := cls.get_additional_tools(agent_input):
|
|
346
|
-
built_in_tools.extend(additional_tools)
|
|
347
|
-
return [
|
|
348
|
-
AgentToolSchema.from_openai_json_format(tool) for tool in built_in_tools
|
|
349
|
-
]
|
|
349
|
+
def get_custom_tools(self) -> List[AgentToolSchema]:
|
|
350
|
+
"""Get the custom tools for the agent."""
|
|
351
|
+
return [tool.tool_definition for tool in self._custom_tools]
|
|
350
352
|
|
|
351
353
|
def get_available_tools(self, agent_input: AgentInput) -> List[AgentToolSchema]:
|
|
352
354
|
"""Get the available tools for the agent."""
|
|
353
|
-
return
|
|
355
|
+
return (
|
|
356
|
+
self._mcp_tools
|
|
357
|
+
+ self.get_agent_specific_built_in_tools(agent_input)
|
|
358
|
+
+ self.get_custom_tools()
|
|
359
|
+
)
|
|
354
360
|
|
|
355
361
|
async def _get_filtered_tools_from_server(
|
|
356
362
|
self,
|
|
@@ -567,33 +573,6 @@ class MCPBaseAgent(AgentProtocol):
|
|
|
567
573
|
),
|
|
568
574
|
)
|
|
569
575
|
|
|
570
|
-
async def execute_additional_tool(
|
|
571
|
-
self, tool_name: str, arguments: Dict[str, Any]
|
|
572
|
-
) -> Optional[AgentToolResult]:
|
|
573
|
-
"""Execute additional tool. Override to add logic for specific tool.
|
|
574
|
-
|
|
575
|
-
Args:
|
|
576
|
-
tool_name: The name of the tool to execute.
|
|
577
|
-
arguments: The arguments to pass to the tool.
|
|
578
|
-
|
|
579
|
-
Returns:
|
|
580
|
-
The result of the tool execution as an AgentOutput object.
|
|
581
|
-
|
|
582
|
-
Example:
|
|
583
|
-
```python
|
|
584
|
-
async def execute_additional_tool(
|
|
585
|
-
self, tool_name: str, arguments: Dict[str, Any]
|
|
586
|
-
) -> Optional[AgentToolResult]:
|
|
587
|
-
if tool_name == "get_location":
|
|
588
|
-
return get_location_tool(arguments)
|
|
589
|
-
elif tool_name == "get_current_weather":
|
|
590
|
-
return get_current_weather_tool(arguments)
|
|
591
|
-
return None
|
|
592
|
-
|
|
593
|
-
```
|
|
594
|
-
"""
|
|
595
|
-
return None
|
|
596
|
-
|
|
597
576
|
async def _execute_tool_call(
|
|
598
577
|
self, tool_name: str, arguments: Dict[str, Any]
|
|
599
578
|
) -> AgentToolResult:
|
|
@@ -610,10 +589,10 @@ class MCPBaseAgent(AgentProtocol):
|
|
|
610
589
|
The result of the tool execution as an AgentToolResult object.
|
|
611
590
|
"""
|
|
612
591
|
try:
|
|
613
|
-
|
|
614
|
-
tool_name
|
|
615
|
-
|
|
616
|
-
|
|
592
|
+
for custom_tool in self._custom_tools:
|
|
593
|
+
if custom_tool.tool_name == tool_name:
|
|
594
|
+
result = custom_tool.tool_executor(arguments)
|
|
595
|
+
return await result if isawaitable(result) else result
|
|
617
596
|
except Exception as e:
|
|
618
597
|
return AgentToolResult(
|
|
619
598
|
tool_name=tool_name,
|
|
@@ -24,6 +24,7 @@ from rasa.agents.schemas import (
|
|
|
24
24
|
AgentInput,
|
|
25
25
|
AgentOutput,
|
|
26
26
|
AgentToolResult,
|
|
27
|
+
AgentToolSchema,
|
|
27
28
|
)
|
|
28
29
|
from rasa.core.available_agents import AgentMCPServerConfig, ProtocolConfig
|
|
29
30
|
from rasa.shared.agents.utils import make_agent_identifier
|
|
@@ -105,9 +106,9 @@ class MCPOpenAgent(MCPBaseAgent):
|
|
|
105
106
|
@classmethod
|
|
106
107
|
def get_agent_specific_built_in_tools(
|
|
107
108
|
cls, agent_input: AgentInput
|
|
108
|
-
) -> List[
|
|
109
|
+
) -> List[AgentToolSchema]:
|
|
109
110
|
"""Get agentic specific built-in tools."""
|
|
110
|
-
return [cls.get_task_completed_tool()]
|
|
111
|
+
return [AgentToolSchema.from_openai_json_format(cls.get_task_completed_tool())]
|
|
111
112
|
|
|
112
113
|
def _run_task_completed_tool(
|
|
113
114
|
self,
|
|
@@ -18,7 +18,9 @@ from rasa.agents.schemas import (
|
|
|
18
18
|
AgentInput,
|
|
19
19
|
AgentOutput,
|
|
20
20
|
AgentToolResult,
|
|
21
|
+
AgentToolSchema,
|
|
21
22
|
)
|
|
23
|
+
from rasa.agents.schemas.agent_input import AgentInputSlot
|
|
22
24
|
from rasa.core.available_agents import AgentMCPServerConfig, ProtocolConfig
|
|
23
25
|
from rasa.shared.agents.utils import make_agent_identifier
|
|
24
26
|
from rasa.shared.constants import (
|
|
@@ -70,11 +72,18 @@ class MCPTaskAgent(MCPBaseAgent):
|
|
|
70
72
|
@classmethod
|
|
71
73
|
def get_agent_specific_built_in_tools(
|
|
72
74
|
cls, agent_input: AgentInput
|
|
73
|
-
) -> List[
|
|
75
|
+
) -> List[AgentToolSchema]:
|
|
74
76
|
"""Get agentic specific built-in tools."""
|
|
77
|
+
slot_names = cls._get_slot_names_from_exit_conditions(agent_input)
|
|
78
|
+
slot_definitions = [
|
|
79
|
+
slot for slot in agent_input.slots if slot.name in slot_names
|
|
80
|
+
]
|
|
81
|
+
|
|
75
82
|
return [
|
|
76
|
-
|
|
77
|
-
|
|
83
|
+
AgentToolSchema.from_openai_json_format(
|
|
84
|
+
cls.get_slot_specific_set_slot_tool(slot)
|
|
85
|
+
)
|
|
86
|
+
for slot in slot_definitions
|
|
78
87
|
]
|
|
79
88
|
|
|
80
89
|
@classmethod
|
|
@@ -89,11 +98,11 @@ class MCPTaskAgent(MCPBaseAgent):
|
|
|
89
98
|
for name in re.findall(r"\bslots\.(\w+)", condition)
|
|
90
99
|
}
|
|
91
100
|
|
|
101
|
+
slot_names = agent_input.slot_names
|
|
102
|
+
|
|
92
103
|
# Keep only slots that actually exist in agent_input.slots
|
|
93
104
|
valid_slot_names = [
|
|
94
|
-
slot_name
|
|
95
|
-
for slot_name in extracted_slot_names
|
|
96
|
-
if slot_name in agent_input.slots
|
|
105
|
+
slot_name for slot_name in extracted_slot_names if slot_name in slot_names
|
|
97
106
|
]
|
|
98
107
|
|
|
99
108
|
structlogger.debug(
|
|
@@ -105,15 +114,18 @@ class MCPTaskAgent(MCPBaseAgent):
|
|
|
105
114
|
return valid_slot_names
|
|
106
115
|
|
|
107
116
|
@classmethod
|
|
108
|
-
def get_slot_specific_set_slot_tool(cls,
|
|
117
|
+
def get_slot_specific_set_slot_tool(cls, slot: AgentInputSlot) -> Dict[str, Any]:
|
|
109
118
|
"""Get the set slot tool."""
|
|
119
|
+
tool_description = f"Set the slot '{slot.name}' to a specific value. "
|
|
120
|
+
tool_description += f"The slot type is {slot.type}."
|
|
121
|
+
if slot.type == "categorical":
|
|
122
|
+
tool_description += f" The allowed values are: {slot.allowed_values}."
|
|
123
|
+
|
|
110
124
|
return {
|
|
111
125
|
"type": "function",
|
|
112
126
|
"function": {
|
|
113
|
-
"name": f"set_slot_{
|
|
114
|
-
|
|
115
|
-
# (if present) to the description as well.
|
|
116
|
-
"description": f"Set the slot {slot_name} to a specific value.",
|
|
127
|
+
"name": f"set_slot_{slot.name}",
|
|
128
|
+
"description": tool_description,
|
|
117
129
|
"parameters": {
|
|
118
130
|
"type": "object",
|
|
119
131
|
"properties": {
|
|
@@ -234,12 +246,22 @@ class MCPTaskAgent(MCPBaseAgent):
|
|
|
234
246
|
),
|
|
235
247
|
)
|
|
236
248
|
|
|
249
|
+
def render_prompt_template(self, context: AgentInput) -> str:
|
|
250
|
+
"""Render the prompt template with the provided inputs."""
|
|
251
|
+
slot_names = self._get_slot_names_from_exit_conditions(context)
|
|
252
|
+
|
|
253
|
+
return Template(self.prompt_template).render(
|
|
254
|
+
**context.model_dump(exclude={"id", "timestamp", "events"}),
|
|
255
|
+
description=self._description,
|
|
256
|
+
slot_names=slot_names,
|
|
257
|
+
)
|
|
258
|
+
|
|
237
259
|
async def send_message(self, agent_input: AgentInput) -> AgentOutput:
|
|
238
260
|
"""Send a message to the LLM and return the response."""
|
|
239
261
|
messages = self.build_messages_for_llm_request(agent_input)
|
|
240
262
|
tool_results: Dict[str, AgentToolResult] = {}
|
|
241
263
|
|
|
242
|
-
|
|
264
|
+
_slot_values = {slot.name: slot.value for slot in agent_input.slots}
|
|
243
265
|
_available_tools = self.get_available_tools(agent_input)
|
|
244
266
|
_available_tools_names = [tool.name for tool in _available_tools]
|
|
245
267
|
|
|
@@ -337,10 +359,10 @@ class MCPTaskAgent(MCPBaseAgent):
|
|
|
337
359
|
tool_call.tool_name
|
|
338
360
|
):
|
|
339
361
|
if (
|
|
340
|
-
slot_name in
|
|
362
|
+
slot_name in _slot_values
|
|
341
363
|
and "slot_value" in tool_call.tool_args
|
|
342
364
|
):
|
|
343
|
-
|
|
365
|
+
_slot_values.update(
|
|
344
366
|
self._run_set_slot_tool(
|
|
345
367
|
slot_name, tool_call.tool_args
|
|
346
368
|
)
|
|
@@ -392,13 +414,13 @@ class MCPTaskAgent(MCPBaseAgent):
|
|
|
392
414
|
)
|
|
393
415
|
|
|
394
416
|
exit_met, internal_error = self._is_exit_conditions_met(
|
|
395
|
-
agent_input,
|
|
417
|
+
agent_input, _slot_values
|
|
396
418
|
)
|
|
397
419
|
|
|
398
420
|
# Agent signals task completion if exit conditions are met.
|
|
399
421
|
if exit_met:
|
|
400
422
|
return self._generate_agent_task_completed_output(
|
|
401
|
-
agent_input,
|
|
423
|
+
agent_input, _slot_values, tool_results
|
|
402
424
|
)
|
|
403
425
|
|
|
404
426
|
# If an internal error occurred while checking the exit
|
rasa/agents/schemas/__init__.py
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
from rasa.agents.schemas.agent_input import AgentInput
|
|
2
2
|
from rasa.agents.schemas.agent_output import AgentOutput
|
|
3
3
|
from rasa.agents.schemas.agent_tool_result import AgentToolResult
|
|
4
|
-
from rasa.agents.schemas.agent_tool_schema import AgentToolSchema
|
|
4
|
+
from rasa.agents.schemas.agent_tool_schema import AgentToolSchema, CustomToolSchema
|
|
5
5
|
|
|
6
|
-
__all__ = [
|
|
6
|
+
__all__ = [
|
|
7
|
+
"AgentInput",
|
|
8
|
+
"AgentOutput",
|
|
9
|
+
"AgentToolSchema",
|
|
10
|
+
"AgentToolResult",
|
|
11
|
+
"CustomToolSchema",
|
|
12
|
+
]
|
|
@@ -5,12 +5,21 @@ from pydantic import BaseModel
|
|
|
5
5
|
from rasa.shared.core.events import Event
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
class AgentInputSlot(BaseModel):
|
|
9
|
+
"""A class that represents the schema of the input slot to the agent."""
|
|
10
|
+
|
|
11
|
+
name: str
|
|
12
|
+
value: Any
|
|
13
|
+
type: str
|
|
14
|
+
allowed_values: Optional[List[Any]] = None
|
|
15
|
+
|
|
16
|
+
|
|
8
17
|
class AgentInput(BaseModel):
|
|
9
18
|
"""A class that represents the schema of the input to the agent."""
|
|
10
19
|
|
|
11
20
|
id: str
|
|
12
21
|
user_message: str
|
|
13
|
-
slots:
|
|
22
|
+
slots: List[AgentInputSlot]
|
|
14
23
|
conversation_history: str
|
|
15
24
|
events: List[Event]
|
|
16
25
|
metadata: Dict[str, Any]
|
|
@@ -22,3 +31,8 @@ class AgentInput(BaseModel):
|
|
|
22
31
|
"""
|
|
23
32
|
|
|
24
33
|
arbitrary_types_allowed = True
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def slot_names(self) -> List[str]:
|
|
37
|
+
"""Get the names of the slots in the input."""
|
|
38
|
+
return [slot.name for slot in self.slots]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any, Dict, Optional
|
|
1
|
+
from typing import Any, Callable, Dict, Optional
|
|
2
2
|
|
|
3
3
|
from mcp import Tool
|
|
4
4
|
from pydantic import BaseModel
|
|
@@ -6,6 +6,7 @@ from pydantic import BaseModel
|
|
|
6
6
|
from rasa.agents.constants import (
|
|
7
7
|
TOOL_ADDITIONAL_PROPERTIES_KEY,
|
|
8
8
|
TOOL_DESCRIPTION_KEY,
|
|
9
|
+
TOOL_EXECUTOR_KEY,
|
|
9
10
|
TOOL_NAME_KEY,
|
|
10
11
|
TOOL_PARAMETERS_KEY,
|
|
11
12
|
TOOL_PROPERTIES_KEY,
|
|
@@ -110,3 +111,24 @@ class AgentToolSchema(BaseModel):
|
|
|
110
111
|
TOOL_TYPE_KEY: TOOL_TYPE_FUNCTION_KEY,
|
|
111
112
|
TOOL_TYPE_FUNCTION_KEY: self.model_dump(exclude={TOOL_TYPE_KEY}),
|
|
112
113
|
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class CustomToolSchema(BaseModel):
|
|
117
|
+
"""A class that represents the schema of a custom agent tool."""
|
|
118
|
+
|
|
119
|
+
tool_name: str
|
|
120
|
+
tool_definition: AgentToolSchema
|
|
121
|
+
tool_executor: Callable
|
|
122
|
+
|
|
123
|
+
@classmethod
|
|
124
|
+
def from_dict(cls, config: Dict[str, Any]) -> "CustomToolSchema":
|
|
125
|
+
"""Convert a custom tool config to CustomToolSchema."""
|
|
126
|
+
agent_tool_schema = AgentToolSchema.from_openai_json_format(config)
|
|
127
|
+
if TOOL_EXECUTOR_KEY not in config:
|
|
128
|
+
raise ValueError("Custom tool executor is required.")
|
|
129
|
+
|
|
130
|
+
return cls(
|
|
131
|
+
tool_name=agent_tool_schema.name,
|
|
132
|
+
tool_definition=agent_tool_schema,
|
|
133
|
+
tool_executor=config[TOOL_EXECUTOR_KEY],
|
|
134
|
+
)
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
You are a helpful assistant that should assist the user in the best possible way.
|
|
2
2
|
|
|
3
|
-
###
|
|
3
|
+
### Description of your capabilities
|
|
4
4
|
{{ description }}
|
|
5
5
|
|
|
6
|
+
### Task
|
|
7
|
+
* Use the tools available to gather the required information to set the following slots: {{ slot_names }}.
|
|
8
|
+
* In order to set the slot values, use the `set_slot_<slot_name>` tool.
|
|
9
|
+
|
|
6
10
|
### Instructions
|
|
7
11
|
* Always make sure to output responses to the user in a clear, helpful format.
|
|
8
12
|
* Always avoid asking multiple questions at once. Ask questions sequentially one at a time and wait for the user's response before proceeding to next question.
|
|
@@ -10,4 +14,4 @@ You are a helpful assistant that should assist the user in the best possible way
|
|
|
10
14
|
* Strictly avoid making up information or ability to take some action which is not available in `tool` provided.
|
|
11
15
|
|
|
12
16
|
### Conversation history
|
|
13
|
-
{{ conversation_history }}
|
|
17
|
+
{{ conversation_history }}
|
rasa/core/actions/action.py
CHANGED
|
@@ -91,7 +91,12 @@ from rasa.shared.core.slot_mappings import (
|
|
|
91
91
|
)
|
|
92
92
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
93
93
|
from rasa.shared.exceptions import RasaException
|
|
94
|
-
from rasa.shared.nlu.constants import
|
|
94
|
+
from rasa.shared.nlu.constants import (
|
|
95
|
+
INTENT,
|
|
96
|
+
INTENT_NAME_KEY,
|
|
97
|
+
INTENT_RANKING_KEY,
|
|
98
|
+
PREDICTED_CONFIDENCE_KEY,
|
|
99
|
+
)
|
|
95
100
|
from rasa.shared.utils.io import raise_warning
|
|
96
101
|
from rasa.shared.utils.schemas.events import EVENTS_SCHEMA
|
|
97
102
|
from rasa.utils.endpoints import EndpointConfig
|
|
@@ -887,8 +892,8 @@ class RemoteAction(Action):
|
|
|
887
892
|
) -> List[BotUttered]:
|
|
888
893
|
"""Use the responses generated by the action endpoint and utter them."""
|
|
889
894
|
bot_messages = []
|
|
890
|
-
domain: Domain = kwargs.get("domain", None)
|
|
891
|
-
action_name: str = kwargs.get("action_name", None)
|
|
895
|
+
domain: Optional[Domain] = kwargs.get("domain", None)
|
|
896
|
+
action_name: Optional[str] = kwargs.get("action_name", None)
|
|
892
897
|
for response in responses:
|
|
893
898
|
generated_response = response.pop("response", None)
|
|
894
899
|
if generated_response is not None:
|
|
@@ -1029,13 +1034,13 @@ def _revert_affirmation_events(tracker: "DialogueStateTracker") -> List[Event]:
|
|
|
1029
1034
|
revert_events += _revert_rephrasing_events()
|
|
1030
1035
|
|
|
1031
1036
|
last_user_event = tracker.get_last_event_for(UserUttered)
|
|
1032
|
-
if not last_user_event:
|
|
1033
|
-
raise TypeError("Cannot find last event to revert to.")
|
|
1037
|
+
if not last_user_event or not isinstance(last_user_event, UserUttered):
|
|
1038
|
+
raise TypeError("Cannot find last user uttered event to revert to.")
|
|
1034
1039
|
|
|
1035
1040
|
last_user_event = copy.deepcopy(last_user_event)
|
|
1036
1041
|
# FIXME: better type annotation for `parse_data` would require
|
|
1037
1042
|
# a larger refactoring (e.g. switch to dataclass)
|
|
1038
|
-
last_user_event.parse_data[
|
|
1043
|
+
last_user_event.parse_data[INTENT][PREDICTED_CONFIDENCE_KEY] = 1.0 # type: ignore[literal-required]
|
|
1039
1044
|
|
|
1040
1045
|
return revert_events + [last_user_event]
|
|
1041
1046
|
|
|
@@ -1052,8 +1057,8 @@ def _revert_single_affirmation_events() -> List[Event]:
|
|
|
1052
1057
|
|
|
1053
1058
|
def _revert_successful_rephrasing(tracker: "DialogueStateTracker") -> List[Event]:
|
|
1054
1059
|
last_user_event = tracker.get_last_event_for(UserUttered)
|
|
1055
|
-
if not last_user_event:
|
|
1056
|
-
raise TypeError("Cannot find last event to revert to.")
|
|
1060
|
+
if not last_user_event or not isinstance(last_user_event, UserUttered):
|
|
1061
|
+
raise TypeError("Cannot find last user uttered event to revert to.")
|
|
1057
1062
|
|
|
1058
1063
|
last_user_event = copy.deepcopy(last_user_event)
|
|
1059
1064
|
return _revert_rephrasing_events() + [last_user_event]
|
rasa/core/available_agents.py
CHANGED
|
@@ -173,6 +173,9 @@ class AvailableAgents(metaclass=Singleton):
|
|
|
173
173
|
@classmethod
|
|
174
174
|
def reset_instance(cls) -> None:
|
|
175
175
|
cls._instance = None
|
|
176
|
+
# Also clear the metaclass singleton instances
|
|
177
|
+
if hasattr(type(cls), "_instances"):
|
|
178
|
+
type(cls)._instances.clear()
|
|
176
179
|
|
|
177
180
|
def as_json_list(self) -> List[Dict[str, Any]]:
|
|
178
181
|
"""Convert the available agents to a JSON-serializable list."""
|
|
@@ -70,17 +70,17 @@ class DevelopmentInspectorPlugin:
|
|
|
70
70
|
self.tasks.append(task)
|
|
71
71
|
self._cleanup_completed_tasks()
|
|
72
72
|
|
|
73
|
-
@hookimpl
|
|
73
|
+
@hookimpl
|
|
74
74
|
def after_new_user_message(self, tracker: DialogueStateTracker) -> None:
|
|
75
75
|
"""Broadcasts tracker updates after a new user message."""
|
|
76
76
|
self._create_broadcast_task(tracker)
|
|
77
77
|
|
|
78
|
-
@hookimpl
|
|
78
|
+
@hookimpl
|
|
79
79
|
def after_action_executed(self, tracker: DialogueStateTracker) -> None:
|
|
80
80
|
"""Broadcasts tracker updates after an action is executed."""
|
|
81
81
|
self._create_broadcast_task(tracker)
|
|
82
82
|
|
|
83
|
-
@hookimpl
|
|
83
|
+
@hookimpl
|
|
84
84
|
def after_server_stop(self) -> None:
|
|
85
85
|
"""Cancels all remaining tasks when the server stops."""
|
|
86
86
|
self._cancel_tasks()
|
rasa/core/channels/hangouts.py
CHANGED
|
@@ -213,7 +213,7 @@ class HangoutsInput(InputChannel):
|
|
|
213
213
|
# every message. Actual caching depends on response headers.
|
|
214
214
|
# see: https://github.com/googleapis/google-auth-library-python/blob/main/google/oauth2/id_token.py#L15 # noqa: E501
|
|
215
215
|
cached_session = cachecontrol.CacheControl(requests.session())
|
|
216
|
-
self.google_request = google.auth.transport.requests.Request(
|
|
216
|
+
self.google_request = google.auth.transport.requests.Request( # type: ignore[no-untyped-call]
|
|
217
217
|
session=cached_session
|
|
218
218
|
)
|
|
219
219
|
|
|
@@ -267,7 +267,7 @@ class HangoutsInput(InputChannel):
|
|
|
267
267
|
# see https://developers.google.com/chat/how-tos/bots-develop#verifying_bot_authenticity # noqa: E501
|
|
268
268
|
# and https://google-auth.readthedocs.io/en/latest/user-guide.html#identity-tokens # noqa: E501
|
|
269
269
|
try:
|
|
270
|
-
decoded_token = id_token.verify_token(
|
|
270
|
+
decoded_token = id_token.verify_token( # type: ignore[no-untyped-call]
|
|
271
271
|
bot_token,
|
|
272
272
|
self.google_request,
|
|
273
273
|
audience=self.project_id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{w as ln,c as H}from"./path-53f90ab3.js";import{aw as an,ax as V,ay as D,az as rn,aA as y,V as on,aB as K,aC as _,aD as un,aE as t,aF as sn,aG as tn,aH as fn}from"./index-
|
|
1
|
+
import{w as ln,c as H}from"./path-53f90ab3.js";import{aw as an,ax as V,ay as D,az as rn,aA as y,V as on,aB as K,aC as _,aD as un,aE as t,aF as sn,aG as tn,aH as fn}from"./index-3e293924.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function mn(l){return l.endAngle}function pn(l){return l&&l.padAngle}function xn(l,h,z,E,v,A,I,a){var B=z-l,i=E-h,n=I-v,m=a-A,r=m*B-n*i;if(!(r*r<y))return r=(n*(h-A)-m*(l-v))/r,[l+r*B,h+r*i]}function W(l,h,z,E,v,A,I){var a=l-z,B=h-E,i=(I?A:-A)/K(a*a+B*B),n=i*B,m=-i*a,r=l+n,s=h+m,f=z+n,c=E+m,O=(r+f)/2,o=(s+c)/2,p=f-r,g=c-s,R=p*p+g*g,T=v-A,w=r*c-f*s,C=(g<0?-1:1)*K(fn(0,T*T*R-w*w)),F=(w*g-p*C)/R,G=(-w*p-g*C)/R,P=(w*g+p*C)/R,x=(-w*p+g*C)/R,d=F-O,e=G-o,u=P-O,S=x-o;return d*d+e*e>u*u+S*S&&(F=P,G=x),{cx:F,cy:G,x01:-n,y01:-m,x11:F*(v/T-1),y11:G*(v/T-1)}}function vn(){var l=cn,h=yn,z=H(0),E=null,v=gn,A=mn,I=pn,a=null,B=ln(i);function i(){var n,m,r=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-rn,c=A.apply(this,arguments)-rn,O=un(c-f),o=c>f;if(a||(a=n=B()),s<r&&(m=s,s=r,r=m),!(s>y))a.moveTo(0,0);else if(O>on-y)a.moveTo(s*V(f),s*D(f)),a.arc(0,0,s,f,c,!o),r>y&&(a.moveTo(r*V(c),r*D(c)),a.arc(0,0,r,c,f,o));else{var p=f,g=c,R=f,T=c,w=O,C=O,F=I.apply(this,arguments)/2,G=F>y&&(E?+E.apply(this,arguments):K(r*r+s*s)),P=_(un(s-r)/2,+z.apply(this,arguments)),x=P,d=P,e,u;if(G>y){var S=sn(G/r*D(F)),L=sn(G/s*D(F));(w-=S*2)>y?(S*=o?1:-1,R+=S,T-=S):(w=0,R=T=(f+c)/2),(C-=L*2)>y?(L*=o?1:-1,p+=L,g-=L):(C=0,p=g=(f+c)/2)}var j=s*V(p),J=s*D(p),M=r*V(T),N=r*D(T);if(P>y){var Q=s*V(g),U=s*D(g),X=r*V(R),Y=r*D(R),q;if(O<an)if(q=xn(j,J,X,Y,Q,U,M,N)){var Z=j-q[0],$=J-q[1],k=Q-q[0],b=U-q[1],nn=1/D(tn((Z*k+$*b)/(K(Z*Z+$*$)*K(k*k+b*b)))/2),en=K(q[0]*q[0]+q[1]*q[1]);x=_(P,(r-en)/(nn-1)),d=_(P,(s-en)/(nn+1))}else x=d=0}C>y?d>y?(e=W(X,Y,j,J,s,d,o),u=W(Q,U,M,N,s,d,o),a.moveTo(e.cx+e.x01,e.cy+e.y01),d<P?a.arc(e.cx,e.cy,d,t(e.y01,e.x01),t(u.y01,u.x01),!o):(a.arc(e.cx,e.cy,d,t(e.y01,e.x01),t(e.y11,e.x11),!o),a.arc(0,0,s,t(e.cy+e.y11,e.cx+e.x11),t(u.cy+u.y11,u.cx+u.x11),!o),a.arc(u.cx,u.cy,d,t(u.y11,u.x11),t(u.y01,u.x01),!o))):(a.moveTo(j,J),a.arc(0,0,s,p,g,!o)):a.moveTo(j,J),!(r>y)||!(w>y)?a.lineTo(M,N):x>y?(e=W(M,N,Q,U,r,-x,o),u=W(j,J,X,Y,r,-x,o),a.lineTo(e.cx+e.x01,e.cy+e.y01),x<P?a.arc(e.cx,e.cy,x,t(e.y01,e.x01),t(u.y01,u.x01),!o):(a.arc(e.cx,e.cy,x,t(e.y01,e.x01),t(e.y11,e.x11),!o),a.arc(0,0,r,t(e.cy+e.y11,e.cx+e.x11),t(u.cy+u.y11,u.cx+u.x11),o),a.arc(u.cx,u.cy,x,t(u.y11,u.x11),t(u.y01,u.x01),!o))):a.arc(0,0,r,T,R,o)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,m=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[V(m)*n,D(m)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:H(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:H(+n),i):h},i.cornerRadius=function(n){return arguments.length?(z=typeof n=="function"?n:H(+n),i):z},i.padRadius=function(n){return arguments.length?(E=n==null?null:typeof n=="function"?n:H(+n),i):E},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:H(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:H(+n),i):A},i.padAngle=function(n){return arguments.length?(I=typeof n=="function"?n:H(+n),i):I},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{vn as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as he,_ as se,h as H,i as Ee,l as S,E as ye,B as we,j as De,o as ve}from"./index-
|
|
1
|
+
import{c as he,_ as se,h as H,i as Ee,l as S,E as ye,B as we,j as De,o as ve}from"./index-3e293924.js";import{c as Ne}from"./clone-a0f9c4ed.js";import{i as ke,c as Ie,b as Oe,d as Te,a as ge,p as ze}from"./edges-e0da2a9e-b1553799.js";import{G as Ce}from"./graph-ca9e6217.js";import{o as Ae}from"./ordinal-ba9b4969.js";import{s as Re}from"./Tableau10-1b767f5e.js";import{c as Be}from"./channel-0cd70adf.js";import"./createText-2e5e7dd3-1c669cad.js";import"./line-0567aaa7.js";import"./array-9f3ba611.js";import"./path-53f90ab3.js";import"./init-77b53fdd.js";var le,oe,ee=function(){var e=function(D,o,s,i){for(s=s||{},i=D.length;i--;s[D[i]]=o);return s},a=[1,7],d=[1,13],c=[1,14],n=[1,15],g=[1,19],l=[1,16],f=[1,17],b=[1,18],p=[8,30],x=[8,21,28,29,30,31,32,40,44,47],E=[1,23],T=[1,24],v=[8,15,16,21,28,29,30,31,32,40,44,47],N=[8,15,16,21,27,28,29,30,31,32,40,44,47],y=[1,49],L={trace:function(){},yy:{},symbols_:{error:2,spaceLines:3,SPACELINE:4,NL:5,separator:6,SPACE:7,EOF:8,start:9,BLOCK_DIAGRAM_KEY:10,document:11,stop:12,statement:13,link:14,LINK:15,START_LINK:16,LINK_LABEL:17,STR:18,nodeStatement:19,columnsStatement:20,SPACE_BLOCK:21,blockStatement:22,classDefStatement:23,cssClassStatement:24,styleStatement:25,node:26,SIZE:27,COLUMNS:28,"id-block":29,end:30,block:31,NODE_ID:32,nodeShapeNLabel:33,dirList:34,DIR:35,NODE_DSTART:36,NODE_DEND:37,BLOCK_ARROW_START:38,BLOCK_ARROW_END:39,classDef:40,CLASSDEF_ID:41,CLASSDEF_STYLEOPTS:42,DEFAULT:43,class:44,CLASSENTITY_IDS:45,STYLECLASS:46,style:47,STYLE_ENTITY_IDS:48,STYLE_DEFINITION_DATA:49,$accept:0,$end:1},terminals_:{2:"error",4:"SPACELINE",5:"NL",7:"SPACE",8:"EOF",10:"BLOCK_DIAGRAM_KEY",15:"LINK",16:"START_LINK",17:"LINK_LABEL",18:"STR",21:"SPACE_BLOCK",27:"SIZE",28:"COLUMNS",29:"id-block",30:"end",31:"block",32:"NODE_ID",35:"DIR",36:"NODE_DSTART",37:"NODE_DEND",38:"BLOCK_ARROW_START",39:"BLOCK_ARROW_END",40:"classDef",41:"CLASSDEF_ID",42:"CLASSDEF_STYLEOPTS",43:"DEFAULT",44:"class",45:"CLASSENTITY_IDS",46:"STYLECLASS",47:"style",48:"STYLE_ENTITY_IDS",49:"STYLE_DEFINITION_DATA"},productions_:[0,[3,1],[3,2],[3,2],[6,1],[6,1],[6,1],[9,3],[12,1],[12,1],[12,2],[12,2],[11,1],[11,2],[14,1],[14,4],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[19,3],[19,2],[19,1],[20,1],[22,4],[22,3],[26,1],[26,2],[34,1],[34,2],[33,3],[33,4],[23,3],[23,3],[24,3],[25,3]],performAction:function(o,s,i,u,h,t,m){var r=t.length-1;switch(h){case 4:u.getLogger().debug("Rule: separator (NL) ");break;case 5:u.getLogger().debug("Rule: separator (Space) ");break;case 6:u.getLogger().debug("Rule: separator (EOF) ");break;case 7:u.getLogger().debug("Rule: hierarchy: ",t[r-1]),u.setHierarchy(t[r-1]);break;case 8:u.getLogger().debug("Stop NL ");break;case 9:u.getLogger().debug("Stop EOF ");break;case 10:u.getLogger().debug("Stop NL2 ");break;case 11:u.getLogger().debug("Stop EOF2 ");break;case 12:u.getLogger().debug("Rule: statement: ",t[r]),typeof t[r].length=="number"?this.$=t[r]:this.$=[t[r]];break;case 13:u.getLogger().debug("Rule: statement #2: ",t[r-1]),this.$=[t[r-1]].concat(t[r]);break;case 14:u.getLogger().debug("Rule: link: ",t[r],o),this.$={edgeTypeStr:t[r],label:""};break;case 15:u.getLogger().debug("Rule: LABEL link: ",t[r-3],t[r-1],t[r]),this.$={edgeTypeStr:t[r],label:t[r-1]};break;case 18:const R=parseInt(t[r]),Y=u.generateId();this.$={id:Y,type:"space",label:"",width:R,children:[]};break;case 23:u.getLogger().debug("Rule: (nodeStatement link node) ",t[r-2],t[r-1],t[r]," typestr: ",t[r-1].edgeTypeStr);const F=u.edgeStrToEdgeData(t[r-1].edgeTypeStr);this.$=[{id:t[r-2].id,label:t[r-2].label,type:t[r-2].type,directions:t[r-2].directions},{id:t[r-2].id+"-"+t[r].id,start:t[r-2].id,end:t[r].id,label:t[r-1].label,type:"edge",directions:t[r].directions,arrowTypeEnd:F,arrowTypeStart:"arrow_open"},{id:t[r].id,label:t[r].label,type:u.typeStr2Type(t[r].typeStr),directions:t[r].directions}];break;case 24:u.getLogger().debug("Rule: nodeStatement (abc88 node size) ",t[r-1],t[r]),this.$={id:t[r-1].id,label:t[r-1].label,type:u.typeStr2Type(t[r-1].typeStr),directions:t[r-1].directions,widthInColumns:parseInt(t[r],10)};break;case 25:u.getLogger().debug("Rule: nodeStatement (node) ",t[r]),this.$={id:t[r].id,label:t[r].label,type:u.typeStr2Type(t[r].typeStr),directions:t[r].directions,widthInColumns:1};break;case 26:u.getLogger().debug("APA123",this?this:"na"),u.getLogger().debug("COLUMNS: ",t[r]),this.$={type:"column-setting",columns:t[r]==="auto"?-1:parseInt(t[r])};break;case 27:u.getLogger().debug("Rule: id-block statement : ",t[r-2],t[r-1]),u.generateId(),this.$={...t[r-2],type:"composite",children:t[r-1]};break;case 28:u.getLogger().debug("Rule: blockStatement : ",t[r-2],t[r-1],t[r]);const C=u.generateId();this.$={id:C,type:"composite",label:"",children:t[r-1]};break;case 29:u.getLogger().debug("Rule: node (NODE_ID separator): ",t[r]),this.$={id:t[r]};break;case 30:u.getLogger().debug("Rule: node (NODE_ID nodeShapeNLabel separator): ",t[r-1],t[r]),this.$={id:t[r-1],label:t[r].label,typeStr:t[r].typeStr,directions:t[r].directions};break;case 31:u.getLogger().debug("Rule: dirList: ",t[r]),this.$=[t[r]];break;case 32:u.getLogger().debug("Rule: dirList: ",t[r-1],t[r]),this.$=[t[r-1]].concat(t[r]);break;case 33:u.getLogger().debug("Rule: nodeShapeNLabel: ",t[r-2],t[r-1],t[r]),this.$={typeStr:t[r-2]+t[r],label:t[r-1]};break;case 34:u.getLogger().debug("Rule: BLOCK_ARROW nodeShapeNLabel: ",t[r-3],t[r-2]," #3:",t[r-1],t[r]),this.$={typeStr:t[r-3]+t[r],label:t[r-2],directions:t[r-1]};break;case 35:case 36:this.$={type:"classDef",id:t[r-1].trim(),css:t[r].trim()};break;case 37:this.$={type:"applyClass",id:t[r-1].trim(),styleClass:t[r].trim()};break;case 38:this.$={type:"applyStyles",id:t[r-1].trim(),stylesStr:t[r].trim()};break}},table:[{9:1,10:[1,2]},{1:[3]},{11:3,13:4,19:5,20:6,21:a,22:8,23:9,24:10,25:11,26:12,28:d,29:c,31:n,32:g,40:l,44:f,47:b},{8:[1,20]},e(p,[2,12],{13:4,19:5,20:6,22:8,23:9,24:10,25:11,26:12,11:21,21:a,28:d,29:c,31:n,32:g,40:l,44:f,47:b}),e(x,[2,16],{14:22,15:E,16:T}),e(x,[2,17]),e(x,[2,18]),e(x,[2,19]),e(x,[2,20]),e(x,[2,21]),e(x,[2,22]),e(v,[2,25],{27:[1,25]}),e(x,[2,26]),{19:26,26:12,32:g},{11:27,13:4,19:5,20:6,21:a,22:8,23:9,24:10,25:11,26:12,28:d,29:c,31:n,32:g,40:l,44:f,47:b},{41:[1,28],43:[1,29]},{45:[1,30]},{48:[1,31]},e(N,[2,29],{33:32,36:[1,33],38:[1,34]}),{1:[2,7]},e(p,[2,13]),{26:35,32:g},{32:[2,14]},{17:[1,36]},e(v,[2,24]),{11:37,13:4,14:22,15:E,16:T,19:5,20:6,21:a,22:8,23:9,24:10,25:11,26:12,28:d,29:c,31:n,32:g,40:l,44:f,47:b},{30:[1,38]},{42:[1,39]},{42:[1,40]},{46:[1,41]},{49:[1,42]},e(N,[2,30]),{18:[1,43]},{18:[1,44]},e(v,[2,23]),{18:[1,45]},{30:[1,46]},e(x,[2,28]),e(x,[2,35]),e(x,[2,36]),e(x,[2,37]),e(x,[2,38]),{37:[1,47]},{34:48,35:y},{15:[1,50]},e(x,[2,27]),e(N,[2,33]),{39:[1,51]},{34:52,35:y,39:[2,31]},{32:[2,15]},e(N,[2,34]),{39:[2,32]}],defaultActions:{20:[2,7],23:[2,14],50:[2,15],52:[2,32]},parseError:function(o,s){if(s.recoverable)this.trace(o);else{var i=new Error(o);throw i.hash=s,i}},parse:function(o){var s=this,i=[0],u=[],h=[null],t=[],m=this.table,r="",R=0,Y=0,F=2,C=1,Le=t.slice.call(arguments,1),w=Object.create(this.lexer),K={yy:{}};for(var Z in this.yy)Object.prototype.hasOwnProperty.call(this.yy,Z)&&(K.yy[Z]=this.yy[Z]);w.setInput(o,K.yy),K.yy.lexer=w,K.yy.parser=this,typeof w.yylloc>"u"&&(w.yylloc={});var J=w.yylloc;t.push(J);var me=w.options&&w.options.ranges;typeof K.yy.parseError=="function"?this.parseError=K.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function _e(){var P;return P=u.pop()||w.lex()||C,typeof P!="number"&&(P instanceof Array&&(u=P,P=u.pop()),P=s.symbols_[P]||P),P}for(var I,M,z,Q,W={},X,B,ae,G;;){if(M=i[i.length-1],this.defaultActions[M]?z=this.defaultActions[M]:((I===null||typeof I>"u")&&(I=_e()),z=m[M]&&m[M][I]),typeof z>"u"||!z.length||!z[0]){var $="";G=[];for(X in m[M])this.terminals_[X]&&X>F&&G.push("'"+this.terminals_[X]+"'");w.showPosition?$="Parse error on line "+(R+1)+`:
|
|
2
2
|
`+w.showPosition()+`
|
|
3
3
|
Expecting `+G.join(", ")+", got '"+(this.terminals_[I]||I)+"'":$="Parse error on line "+(R+1)+": Unexpected "+(I==C?"end of input":"'"+(this.terminals_[I]||I)+"'"),this.parseError($,{text:w.match,token:this.terminals_[I]||I,line:w.yylineno,loc:J,expected:G})}if(z[0]instanceof Array&&z.length>1)throw new Error("Parse Error: multiple actions possible at state: "+M+", token: "+I);switch(z[0]){case 1:i.push(I),h.push(w.yytext),t.push(w.yylloc),i.push(z[1]),I=null,Y=w.yyleng,r=w.yytext,R=w.yylineno,J=w.yylloc;break;case 2:if(B=this.productions_[z[1]][1],W.$=h[h.length-B],W._$={first_line:t[t.length-(B||1)].first_line,last_line:t[t.length-1].last_line,first_column:t[t.length-(B||1)].first_column,last_column:t[t.length-1].last_column},me&&(W._$.range=[t[t.length-(B||1)].range[0],t[t.length-1].range[1]]),Q=this.performAction.apply(W,[r,Y,R,K.yy,z[1],h,t].concat(Le)),typeof Q<"u")return Q;B&&(i=i.slice(0,-1*B*2),h=h.slice(0,-1*B),t=t.slice(0,-1*B)),i.push(this.productions_[z[1]][0]),h.push(W.$),t.push(W._$),ae=m[i[i.length-2]][i[i.length-1]],i.push(ae);break;case 3:return!0}}return!0}},A=function(){var D={EOF:1,parseError:function(s,i){if(this.yy.parser)this.yy.parser.parseError(s,i);else throw new Error(s)},setInput:function(o,s){return this.yy=s||this.yy||{},this._input=o,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var o=this._input[0];this.yytext+=o,this.yyleng++,this.offset++,this.match+=o,this.matched+=o;var s=o.match(/(?:\r\n?|\n).*/g);return s?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),o},unput:function(o){var s=o.length,i=o.split(/(?:\r\n?|\n)/g);this._input=o+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-s),this.offset-=s;var u=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var h=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===u.length?this.yylloc.first_column:0)+u[u.length-i.length].length-i[0].length:this.yylloc.first_column-s},this.options.ranges&&(this.yylloc.range=[h[0],h[0]+this.yyleng-s]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
4
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},less:function(o){this.unput(this.match.slice(o))},pastInput:function(){var o=this.matched.substr(0,this.matched.length-this.match.length);return(o.length>20?"...":"")+o.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var o=this.match;return o.length<20&&(o+=this._input.substr(0,20-o.length)),(o.substr(0,20)+(o.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var o=this.pastInput(),s=new Array(o.length+1).join("-");return o+this.upcomingInput()+`
|