rasa-pro 3.14.0rc2__py3-none-any.whl → 3.14.0rc4__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/protocol/a2a/a2a_agent.py +50 -42
- rasa/agents/protocol/mcp/mcp_base_agent.py +15 -1
- rasa/agents/utils.py +27 -5
- rasa/agents/validation.py +64 -13
- rasa/api.py +1 -2
- rasa/builder/copilot/constants.py +4 -0
- rasa/builder/copilot/copilot.py +37 -1
- rasa/builder/copilot/copilot_templated_message_provider.py +23 -0
- rasa/builder/copilot/models.py +43 -49
- rasa/builder/copilot/prompts/copilot_system_prompt.jinja2 +33 -12
- rasa/builder/copilot/prompts/latest_user_message_context_prompt.jinja2 +59 -29
- rasa/builder/copilot/telemetry.py +8 -0
- rasa/builder/copilot/templated_messages/copilot_templated_responses.yml +3 -0
- rasa/builder/copilot/templated_messages/copilot_welcome_messages.yml +56 -0
- rasa/builder/jobs.py +162 -5
- rasa/builder/models.py +3 -0
- rasa/builder/service.py +1 -0
- rasa/cli/dialogue_understanding_test.py +1 -0
- rasa/cli/e2e_test.py +1 -0
- rasa/cli/inspect.py +1 -0
- rasa/cli/project_templates/basic/tests/e2e_test_cases/without_stub/general/feedback.yml +46 -0
- rasa/cli/project_templates/basic/tests/e2e_test_cases/without_stub/general/goodbye.yml +9 -0
- rasa/cli/project_templates/basic/tests/e2e_test_cases/without_stub/general/help.yml +8 -0
- rasa/cli/project_templates/basic/tests/e2e_test_cases/without_stub/general/human_handoff.yml +41 -0
- rasa/cli/project_templates/basic/tests/e2e_test_cases/without_stub/general/patterns.yml +32 -0
- rasa/cli/project_templates/basic/tests/e2e_test_cases/without_stub/general/show_faqs.yml +8 -0
- rasa/cli/project_templates/telco/data/network/flow_solve_internet_issue.yml +2 -2
- rasa/cli/project_templates/telco/domain/network/solve_internet_issue.yml +1 -2
- rasa/cli/project_templates/telco/tests/e2e_test_cases/with_stub/network/solve_internet_not_slow.yml +33 -0
- rasa/cli/project_templates/telco/tests/e2e_test_cases/with_stub/network/solve_internet_slow.yml +47 -0
- rasa/cli/project_templates/telco/tests/e2e_test_cases/without_stub/general/hello.yml +8 -0
- rasa/cli/run.py +1 -5
- rasa/cli/shell.py +1 -0
- rasa/cli/train.py +1 -0
- rasa/cli/validation/bot_config.py +9 -2
- rasa/core/available_agents.py +65 -55
- rasa/core/config/available_endpoints.py +6 -3
- rasa/core/config/configuration.py +36 -1
- rasa/core/policies/flows/agent_executor.py +16 -8
- rasa/dialogue_understanding/commands/start_flow_command.py +10 -3
- rasa/dialogue_understanding/commands/utils.py +15 -4
- rasa/dialogue_understanding/generator/llm_based_command_generator.py +4 -2
- rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +4 -4
- rasa/dialogue_understanding/generator/single_step/search_ready_llm_command_generator.py +4 -4
- rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +2 -2
- rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +22 -20
- rasa/dialogue_understanding_test/du_test_runner.py +2 -2
- rasa/e2e_test/e2e_test_runner.py +2 -2
- rasa/engine/validation.py +6 -2
- rasa/shared/agents/auth/auth_strategy/oauth2_auth_strategy.py +10 -4
- rasa/shared/agents/auth/constants.py +1 -0
- rasa/shared/agents/auth/utils.py +85 -0
- rasa/shared/constants.py +3 -0
- rasa/shared/core/flows/steps/call.py +2 -2
- rasa/shared/utils/llm.py +33 -0
- rasa/telemetry.py +3 -3
- rasa/utils/pypred.py +7 -0
- rasa/validator.py +127 -2
- rasa/version.py +1 -1
- {rasa_pro-3.14.0rc2.dist-info → rasa_pro-3.14.0rc4.dist-info}/METADATA +19 -7
- {rasa_pro-3.14.0rc2.dist-info → rasa_pro-3.14.0rc4.dist-info}/RECORD +81 -71
- rasa/cli/project_templates/telco/tests/e2e_test_cases/network/solve_internet_issue.yml +0 -57
- /rasa/cli/project_templates/{finance/tests/e2e_test_cases → basic/tests/e2e_test_cases/without_stub}/general/hello.yml +0 -0
- /rasa/cli/project_templates/finance/tests/e2e_test_cases/{accounts → without_stub/accounts}/check_balance.yml +0 -0
- /rasa/cli/project_templates/finance/tests/e2e_test_cases/{accounts → without_stub/accounts}/download_statements.yml +0 -0
- /rasa/cli/project_templates/finance/tests/e2e_test_cases/{cards → without_stub/cards}/block_card.yml +0 -0
- /rasa/cli/project_templates/finance/tests/e2e_test_cases/{general → without_stub/general}/bot_challenge.yml +0 -0
- /rasa/cli/project_templates/finance/tests/e2e_test_cases/{general → without_stub/general}/feedback.yml +0 -0
- /rasa/cli/project_templates/finance/tests/e2e_test_cases/{general → without_stub/general}/goodbye.yml +0 -0
- /rasa/cli/project_templates/{telco/tests/e2e_test_cases → finance/tests/e2e_test_cases/without_stub}/general/hello.yml +0 -0
- /rasa/cli/project_templates/finance/tests/e2e_test_cases/{general → without_stub/general}/human_handoff.yml +0 -0
- /rasa/cli/project_templates/finance/tests/e2e_test_cases/{general → without_stub/general}/patterns.yml +0 -0
- /rasa/cli/project_templates/finance/tests/e2e_test_cases/{transfers → without_stub/transfers}/transfer_money.yml +0 -0
- /rasa/cli/project_templates/telco/tests/e2e_test_cases/{billing → without_stub/billing}/understand_bill.yml +0 -0
- /rasa/cli/project_templates/telco/tests/e2e_test_cases/{general → without_stub/general}/bot_challenge.yml +0 -0
- /rasa/cli/project_templates/telco/tests/e2e_test_cases/{general → without_stub/general}/feedback.yml +0 -0
- /rasa/cli/project_templates/telco/tests/e2e_test_cases/{general → without_stub/general}/goodbye.yml +0 -0
- /rasa/cli/project_templates/telco/tests/e2e_test_cases/{general → without_stub/general}/human_handoff.yml +0 -0
- /rasa/cli/project_templates/telco/tests/e2e_test_cases/{general → without_stub/general}/patterns.yml +0 -0
- {rasa_pro-3.14.0rc2.dist-info → rasa_pro-3.14.0rc4.dist-info}/NOTICE +0 -0
- {rasa_pro-3.14.0rc2.dist-info → rasa_pro-3.14.0rc4.dist-info}/WHEEL +0 -0
- {rasa_pro-3.14.0rc2.dist-info → rasa_pro-3.14.0rc4.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
test_cases:
|
|
2
|
+
- test_case: test pattern session start
|
|
3
|
+
steps:
|
|
4
|
+
- user: "/session_start"
|
|
5
|
+
assertions:
|
|
6
|
+
- flow_started: "pattern_session_start"
|
|
7
|
+
- bot_uttered:
|
|
8
|
+
utter_name: "utter_welcome"
|
|
9
|
+
#
|
|
10
|
+
- test_case: test basic conversation flow
|
|
11
|
+
steps:
|
|
12
|
+
- user: "hello"
|
|
13
|
+
assertions:
|
|
14
|
+
- flow_started: "hello"
|
|
15
|
+
- bot_uttered:
|
|
16
|
+
utter_name: "utter_hello"
|
|
17
|
+
- user: "what can you help me with?"
|
|
18
|
+
assertions:
|
|
19
|
+
- flow_started: "help"
|
|
20
|
+
- bot_uttered:
|
|
21
|
+
utter_name: "utter_what_can_you_do"
|
|
22
|
+
- user: "show me faqs"
|
|
23
|
+
assertions:
|
|
24
|
+
- flow_started: "show_faqs"
|
|
25
|
+
- bot_uttered:
|
|
26
|
+
utter_name: "utter_top_faqs"
|
|
27
|
+
- user: "goodbye"
|
|
28
|
+
assertions:
|
|
29
|
+
- flow_started: "goodbye_flow"
|
|
30
|
+
- bot_uttered:
|
|
31
|
+
utter_name: "utter_goodbye"
|
|
32
|
+
- flow_started: "leave_feedback"
|
|
@@ -69,5 +69,5 @@ flows:
|
|
|
69
69
|
#when it is False this means this flow will only be run if it is called by another flow, not the user.
|
|
70
70
|
description: run diagnostics to check the internet speed for the user
|
|
71
71
|
steps:
|
|
72
|
-
- action:
|
|
73
|
-
- action: actions_run_speed_test
|
|
72
|
+
- action: utter_communicate_run_diagnostics
|
|
73
|
+
- action: actions_run_speed_test
|
|
@@ -14,7 +14,7 @@ responses:
|
|
|
14
14
|
- text: |
|
|
15
15
|
I see.
|
|
16
16
|
Let me try to identify the root cause of the issue you are facing.
|
|
17
|
-
|
|
17
|
+
utter_communicate_run_diagnostics:
|
|
18
18
|
- text: |
|
|
19
19
|
I will run a network diagnostics for you 🛜
|
|
20
20
|
Wait a moment please...
|
|
@@ -72,4 +72,3 @@ responses:
|
|
|
72
72
|
actions:
|
|
73
73
|
- actions_run_speed_test
|
|
74
74
|
- action_sleep_few_sec
|
|
75
|
-
|
rasa/cli/project_templates/telco/tests/e2e_test_cases/with_stub/network/solve_internet_not_slow.yml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
stub_custom_actions:
|
|
2
|
+
actions_run_speed_test:
|
|
3
|
+
events:
|
|
4
|
+
- event: slot
|
|
5
|
+
name: network_speed
|
|
6
|
+
value: 150.0
|
|
7
|
+
responses:
|
|
8
|
+
- text: "Thank you for waiting... ✅ "
|
|
9
|
+
action_sleep_few_sec:
|
|
10
|
+
events: []
|
|
11
|
+
responses: []
|
|
12
|
+
|
|
13
|
+
test_cases:
|
|
14
|
+
- test_case: Solving Internet issue not slow
|
|
15
|
+
steps:
|
|
16
|
+
- user: "Hey, my internet is very slow. What's going on?"
|
|
17
|
+
assertions:
|
|
18
|
+
- flow_started: "fix_internet_slow"
|
|
19
|
+
- bot_uttered:
|
|
20
|
+
utter_name: "utter_acknowledge_issue"
|
|
21
|
+
- action_executed: action_sleep_few_sec
|
|
22
|
+
- flow_started: "run_diagnostics"
|
|
23
|
+
- bot_uttered:
|
|
24
|
+
utter_name: "utter_speed_network_not_issue"
|
|
25
|
+
- action_executed: "actions_run_speed_test"
|
|
26
|
+
- bot_uttered:
|
|
27
|
+
utter_name: "utter_propose_other_solutions"
|
|
28
|
+
- action_executed: "action_sleep_few_sec"
|
|
29
|
+
- bot_uttered:
|
|
30
|
+
utter_name: "utter_ask_more_help_needed"
|
|
31
|
+
- user: "/SetSlots(more_help_needed=True)"
|
|
32
|
+
assertions:
|
|
33
|
+
- flow_started: "human_handoff"
|
rasa/cli/project_templates/telco/tests/e2e_test_cases/with_stub/network/solve_internet_slow.yml
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
stub_custom_actions:
|
|
2
|
+
actions_run_speed_test:
|
|
3
|
+
events:
|
|
4
|
+
- event: slot
|
|
5
|
+
name: network_speed
|
|
6
|
+
value: 50.0
|
|
7
|
+
responses:
|
|
8
|
+
- text: "Thank you for waiting... ✅ "
|
|
9
|
+
action_sleep_few_sec:
|
|
10
|
+
events: []
|
|
11
|
+
responses: []
|
|
12
|
+
|
|
13
|
+
test_cases:
|
|
14
|
+
- test_case: Solving Internet slow issue
|
|
15
|
+
steps:
|
|
16
|
+
- user: "Hey, my internet is very slow. What's going on?"
|
|
17
|
+
assertions:
|
|
18
|
+
- flow_started: "fix_internet_slow"
|
|
19
|
+
- bot_uttered:
|
|
20
|
+
utter_name: "utter_acknowledge_issue"
|
|
21
|
+
- action_executed: action_sleep_few_sec
|
|
22
|
+
- flow_started: "run_diagnostics"
|
|
23
|
+
- bot_uttered:
|
|
24
|
+
utter_name: "utter_communicate_run_diagnostics"
|
|
25
|
+
- action_executed: "actions_run_speed_test"
|
|
26
|
+
- bot_uttered:
|
|
27
|
+
utter_name: "utter_acknowledge_speed_test_not_good"
|
|
28
|
+
- action_executed: "action_sleep_few_sec"
|
|
29
|
+
- bot_uttered:
|
|
30
|
+
utter_name: "utter_propose_reboot_router_solution"
|
|
31
|
+
- action_executed: "action_sleep_few_sec"
|
|
32
|
+
- flow_started: "reboot_router"
|
|
33
|
+
- bot_uttered:
|
|
34
|
+
utter_name: "utter_explain_reboot_router"
|
|
35
|
+
- bot_uttered:
|
|
36
|
+
utter_name: "utter_ask_reboot_router"
|
|
37
|
+
buttons:
|
|
38
|
+
- title: "Done"
|
|
39
|
+
payload: "/SetSlots(reboot_router=True)"
|
|
40
|
+
- title: "Facing a problem"
|
|
41
|
+
payload: "/SetSlots(reboot_router=False)"
|
|
42
|
+
- user: "/SetSlots(reboot_router=False)"
|
|
43
|
+
assertions:
|
|
44
|
+
- slot_was_set:
|
|
45
|
+
- name: "reboot_router"
|
|
46
|
+
value: False
|
|
47
|
+
- flow_started: "human_handoff"
|
rasa/cli/run.py
CHANGED
|
@@ -88,7 +88,7 @@ def run(args: argparse.Namespace) -> None:
|
|
|
88
88
|
"""
|
|
89
89
|
Configuration.initialise_endpoints(
|
|
90
90
|
args.endpoints,
|
|
91
|
-
).initialise_credentials(
|
|
91
|
+
).initialise_sub_agents(args.sub_agents).initialise_credentials(
|
|
92
92
|
args.credentials,
|
|
93
93
|
)
|
|
94
94
|
|
|
@@ -108,7 +108,6 @@ def run(args: argparse.Namespace) -> None:
|
|
|
108
108
|
# configured
|
|
109
109
|
|
|
110
110
|
import rasa.model
|
|
111
|
-
from rasa.core.available_agents import AvailableAgents
|
|
112
111
|
|
|
113
112
|
# start server if remote storage is configured
|
|
114
113
|
if args.remote_storage is not None:
|
|
@@ -122,9 +121,6 @@ def run(args: argparse.Namespace) -> None:
|
|
|
122
121
|
rasa_run(**vars(args))
|
|
123
122
|
return
|
|
124
123
|
|
|
125
|
-
# load sub-agents
|
|
126
|
-
AvailableAgents.get_instance(args.sub_agents)
|
|
127
|
-
|
|
128
124
|
# start server if local model found
|
|
129
125
|
args.model = _validate_model_path(args.model, "model", DEFAULT_MODELS_PATH)
|
|
130
126
|
local_model_set = True
|
rasa/cli/shell.py
CHANGED
|
@@ -115,6 +115,7 @@ def shell(args: argparse.Namespace) -> None:
|
|
|
115
115
|
# it can be used safely throughout the codebase with
|
|
116
116
|
# `Configuration.get_instance().endpoints`
|
|
117
117
|
Configuration.initialise_endpoints(endpoints_path=Path(args.endpoints))
|
|
118
|
+
Configuration.initialise_sub_agents(args.sub_agents)
|
|
118
119
|
model = get_validated_path(args.model, "model", DEFAULT_MODELS_PATH)
|
|
119
120
|
|
|
120
121
|
try:
|
rasa/cli/train.py
CHANGED
|
@@ -128,6 +128,7 @@ def run_training(args: argparse.Namespace, can_exit: bool = False) -> Optional[T
|
|
|
128
128
|
# Validates and loads endpoints with proper endpoint file location
|
|
129
129
|
# TODO(Radovan): this should be probably be done in Configuration
|
|
130
130
|
_check_nlg_endpoint_validity(args.endpoints)
|
|
131
|
+
Configuration.initialise_sub_agents(args.sub_agents)
|
|
131
132
|
|
|
132
133
|
training_files = [
|
|
133
134
|
get_validated_path(f, "data", DEFAULT_DATA_PATH, none_is_valid=True)
|
|
@@ -5,6 +5,7 @@ from typing import TYPE_CHECKING, Optional
|
|
|
5
5
|
import structlog
|
|
6
6
|
|
|
7
7
|
from rasa import telemetry
|
|
8
|
+
from rasa.core.constants import DEFAULT_SUB_AGENTS
|
|
8
9
|
from rasa.exceptions import ValidationError
|
|
9
10
|
from rasa.shared.importers.importer import TrainingDataImporter
|
|
10
11
|
from rasa.shared.utils.common import display_research_study_prompt
|
|
@@ -188,20 +189,26 @@ def validate_files(
|
|
|
188
189
|
validator, max_history, fail_on_warnings
|
|
189
190
|
)
|
|
190
191
|
valid_flows = validator.verify_flows()
|
|
192
|
+
valid_prompt_templates = validator.verify_prompt_templates()
|
|
191
193
|
if validator.config:
|
|
192
194
|
valid_translations = validator.verify_translations(summary_mode=True)
|
|
193
195
|
else:
|
|
194
196
|
valid_translations = True
|
|
195
197
|
valid_CALM_slot_mappings = validator.validate_CALM_slot_mappings()
|
|
196
198
|
|
|
197
|
-
# Validate sub-agents
|
|
198
|
-
|
|
199
|
+
# Validate sub-agents
|
|
200
|
+
sub_agents_path = sub_agents or DEFAULT_SUB_AGENTS
|
|
201
|
+
valid_sub_agents = _validate_sub_agents(sub_agents_path)
|
|
202
|
+
|
|
203
|
+
if valid_sub_agents:
|
|
204
|
+
valid_sub_agents = validator.validate_agent_flow_conflicts(sub_agents_path)
|
|
199
205
|
|
|
200
206
|
all_good = (
|
|
201
207
|
valid_domain
|
|
202
208
|
and valid_nlu
|
|
203
209
|
and valid_stories
|
|
204
210
|
and valid_flows
|
|
211
|
+
and valid_prompt_templates
|
|
205
212
|
and valid_translations
|
|
206
213
|
and valid_CALM_slot_mappings
|
|
207
214
|
and valid_sub_agents
|
rasa/core/available_agents.py
CHANGED
|
@@ -9,7 +9,7 @@ from pydantic import BaseModel, Field, model_validator
|
|
|
9
9
|
from ruamel import yaml as yaml
|
|
10
10
|
|
|
11
11
|
from rasa.exceptions import ValidationError
|
|
12
|
-
from rasa.utils.
|
|
12
|
+
from rasa.shared.utils.yaml import read_config_file
|
|
13
13
|
|
|
14
14
|
DEFAULT_AGENTS_CONFIG_FOLDER = "sub_agents"
|
|
15
15
|
|
|
@@ -89,48 +89,68 @@ class AgentConfig(BaseModel):
|
|
|
89
89
|
connections: Optional[AgentConnections] = None
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
class AvailableAgents
|
|
92
|
+
class AvailableAgents:
|
|
93
93
|
"""Collection of configured agents."""
|
|
94
94
|
|
|
95
|
-
_instance = None
|
|
96
|
-
|
|
97
95
|
def __init__(self, agents: Optional[Dict[str, AgentConfig]] = None) -> None:
|
|
98
96
|
"""Create an `AvailableAgents` object."""
|
|
99
|
-
self.agents = agents or {}
|
|
97
|
+
self.agents: Dict[str, AgentConfig] = agents or {}
|
|
100
98
|
|
|
101
99
|
@classmethod
|
|
102
|
-
def
|
|
100
|
+
def read_from_folder(cls, sub_agents_folder: str) -> AvailableAgents:
|
|
103
101
|
"""Read the different agents from the given folder."""
|
|
104
102
|
agents: Dict[str, AgentConfig] = {}
|
|
105
103
|
|
|
106
|
-
if not os.path.isdir(
|
|
107
|
-
if
|
|
104
|
+
if not os.path.isdir(sub_agents_folder):
|
|
105
|
+
if sub_agents_folder != DEFAULT_AGENTS_CONFIG_FOLDER:
|
|
108
106
|
# User explicitly specified a folder, it should exist
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
f"
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
f"exist or is not a directory."
|
|
107
|
+
raise ValidationError(
|
|
108
|
+
code="agent.sub_agents_folder_not_found",
|
|
109
|
+
event_info=f"The specified agents config folder "
|
|
110
|
+
f"'{sub_agents_folder}' does not exist or is not a "
|
|
111
|
+
f"directory.",
|
|
112
|
+
details={"folder": sub_agents_folder},
|
|
116
113
|
)
|
|
117
114
|
else:
|
|
118
115
|
# We are using the default folder, it may not be created yet
|
|
119
116
|
# Init with an empty agents in this case
|
|
120
117
|
structlogger.info(
|
|
121
|
-
f"Default agents config folder '{
|
|
122
|
-
f"Agent configurations won't be loaded."
|
|
118
|
+
f"Default agents config folder '{sub_agents_folder}' does not "
|
|
119
|
+
f"exist. Agent configurations won't be loaded."
|
|
123
120
|
)
|
|
124
121
|
return cls(agents)
|
|
125
122
|
|
|
126
123
|
# First, load all agent configs into a temporary list for validation
|
|
127
124
|
agent_configs: List[AgentConfig] = []
|
|
128
|
-
for agent_name in os.listdir(
|
|
129
|
-
|
|
125
|
+
for agent_name in os.listdir(sub_agents_folder):
|
|
126
|
+
agent_folder = os.path.join(sub_agents_folder, agent_name)
|
|
127
|
+
if not os.path.isdir(agent_folder):
|
|
128
|
+
raise ValidationError(
|
|
129
|
+
code="agent.invalid_directory_structure",
|
|
130
|
+
event_info=f"Invalid structure: '{agent_folder}' is not a folder. "
|
|
131
|
+
f"Each agent must be stored in its own folder inside "
|
|
132
|
+
f"'{sub_agents_folder}'. Expected structure: "
|
|
133
|
+
f"{sub_agents_folder}/<agent_name>/config.yml",
|
|
134
|
+
details={
|
|
135
|
+
"agent_name": agent_name,
|
|
136
|
+
"sub_agents_folder": sub_agents_folder,
|
|
137
|
+
},
|
|
138
|
+
)
|
|
139
|
+
config_path = os.path.join(agent_folder, "config.yml")
|
|
130
140
|
if not os.path.isfile(config_path):
|
|
131
|
-
|
|
141
|
+
raise ValidationError(
|
|
142
|
+
code="agent.missing_config_file",
|
|
143
|
+
event_info=f"Missing config file for agent '{agent_name}'. "
|
|
144
|
+
f"Expected file: '{config_path}'. "
|
|
145
|
+
f"Each agent folder must contain a 'config.yml' file.",
|
|
146
|
+
details={
|
|
147
|
+
"agent_name": agent_name,
|
|
148
|
+
"expected_config_file": config_path,
|
|
149
|
+
"sub_agents_folder": sub_agents_folder,
|
|
150
|
+
},
|
|
151
|
+
)
|
|
132
152
|
try:
|
|
133
|
-
agent_config = cls.
|
|
153
|
+
agent_config = cls._read_agent_config_file(config_path)
|
|
134
154
|
if not isinstance(agent_config, AgentConfig):
|
|
135
155
|
raise ValueError(f"Invalid agent config type for {agent_name}")
|
|
136
156
|
agent_configs.append(agent_config)
|
|
@@ -140,7 +160,7 @@ class AvailableAgents(metaclass=Singleton):
|
|
|
140
160
|
event_info=f"Failed to load agent '{agent_name}': {e}",
|
|
141
161
|
details={
|
|
142
162
|
"agent_name": agent_name,
|
|
143
|
-
"
|
|
163
|
+
"sub_agents_folder": sub_agents_folder,
|
|
144
164
|
"error": str(e),
|
|
145
165
|
},
|
|
146
166
|
)
|
|
@@ -153,27 +173,23 @@ class AvailableAgents(metaclass=Singleton):
|
|
|
153
173
|
for agent_config in agent_configs:
|
|
154
174
|
agents[agent_config.agent.name] = agent_config
|
|
155
175
|
|
|
176
|
+
structlogger.info(f"Loaded agent configs: {[k for k in agents.keys()]}")
|
|
156
177
|
return cls(agents)
|
|
157
178
|
|
|
158
179
|
@staticmethod
|
|
159
|
-
def
|
|
160
|
-
"""
|
|
180
|
+
def from_dict(data: Dict[str, Any]) -> AgentConfig:
|
|
181
|
+
"""Parse the agent config from raw data into Pydantic models.
|
|
161
182
|
|
|
162
183
|
Args:
|
|
163
|
-
|
|
184
|
+
data: Raw data from the config file as a dictionary.
|
|
164
185
|
|
|
165
186
|
Returns:
|
|
166
|
-
The parsed AgentConfig.
|
|
187
|
+
The parsed AgentConfig as a Pydantic model.
|
|
167
188
|
|
|
168
189
|
Raises:
|
|
169
|
-
yaml.YAMLError: If the YAML file is invalid.
|
|
170
190
|
ValueError: If the data structure is invalid for Pydantic models.
|
|
171
191
|
"""
|
|
172
|
-
|
|
173
|
-
data = yaml.safe_load(f)
|
|
174
|
-
|
|
175
|
-
# Create the agent config (this will trigger Pydantic validation)
|
|
176
|
-
agent_config = AgentConfig(
|
|
192
|
+
return AgentConfig(
|
|
177
193
|
agent=AgentInfo(**data.get("agent", {})),
|
|
178
194
|
configuration=AgentConfiguration(**data.get("configuration", {}))
|
|
179
195
|
if data.get("configuration")
|
|
@@ -183,24 +199,22 @@ class AvailableAgents(metaclass=Singleton):
|
|
|
183
199
|
else None,
|
|
184
200
|
)
|
|
185
201
|
|
|
186
|
-
return agent_config
|
|
187
|
-
|
|
188
202
|
@classmethod
|
|
189
|
-
def
|
|
190
|
-
|
|
191
|
-
) -> AvailableAgents:
|
|
192
|
-
"""Get the singleton instance of `AvailableAgents`."""
|
|
193
|
-
if cls._instance is None:
|
|
194
|
-
cls._instance = cls._read_agent_folder(agent_folder)
|
|
203
|
+
def _read_agent_config_file(cls, config_path: str) -> AgentConfig:
|
|
204
|
+
"""Read the agent config from a yaml file into Pydantic models.
|
|
195
205
|
|
|
196
|
-
|
|
206
|
+
Args:
|
|
207
|
+
config_path: Path to the config file.
|
|
197
208
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
209
|
+
Returns:
|
|
210
|
+
The parsed AgentConfig.
|
|
211
|
+
|
|
212
|
+
Raises:
|
|
213
|
+
yaml.YAMLError: If the YAML file is invalid.
|
|
214
|
+
ValidationError: If the data structure is invalid for Pydantic models.
|
|
215
|
+
"""
|
|
216
|
+
data = read_config_file(config_path)
|
|
217
|
+
return cls.from_dict(data)
|
|
204
218
|
|
|
205
219
|
def as_json_list(self) -> List[Dict[str, Any]]:
|
|
206
220
|
"""Convert the available agents to a JSON-serializable list."""
|
|
@@ -218,12 +232,8 @@ class AvailableAgents(metaclass=Singleton):
|
|
|
218
232
|
for agent_name, agent_config in self.agents.items()
|
|
219
233
|
]
|
|
220
234
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
instance = cls.get_instance()
|
|
224
|
-
return instance.agents.get(agent_id)
|
|
235
|
+
def get_agent_config(self, agent_id: str) -> Optional[AgentConfig]:
|
|
236
|
+
return self.agents.get(agent_id)
|
|
225
237
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
instance = cls.get_instance()
|
|
229
|
-
return len(instance.agents) > 0
|
|
238
|
+
def has_agents(self) -> bool:
|
|
239
|
+
return len(self.agents) > 0
|
|
@@ -7,6 +7,7 @@ from typing import Any, Dict, List, Optional, Union
|
|
|
7
7
|
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
|
8
8
|
|
|
9
9
|
from rasa.core.constants import MCP_SERVERS_KEY
|
|
10
|
+
from rasa.shared.agents.auth.utils import validate_secrets_in_params
|
|
10
11
|
from rasa.shared.core.constants import (
|
|
11
12
|
GLOBAL_SILENCE_TIMEOUT_DEFAULT_VALUE,
|
|
12
13
|
GLOBAL_SILENCE_TIMEOUT_KEY,
|
|
@@ -77,6 +78,11 @@ class MCPServerConfig(BaseModel):
|
|
|
77
78
|
# validate that name and url are not empty
|
|
78
79
|
if not self.name or not self.url:
|
|
79
80
|
raise ValueError("Name and URL cannot be empty")
|
|
81
|
+
# validate secrets in additional_params
|
|
82
|
+
if self.additional_params:
|
|
83
|
+
validate_secrets_in_params(
|
|
84
|
+
self.additional_params, f"MCP server - '{self.name}'"
|
|
85
|
+
)
|
|
80
86
|
return self
|
|
81
87
|
|
|
82
88
|
@model_validator(mode="before")
|
|
@@ -94,12 +100,9 @@ class MCPServerConfig(BaseModel):
|
|
|
94
100
|
class AvailableEndpoints:
|
|
95
101
|
"""Collection of configured endpoints."""
|
|
96
102
|
|
|
97
|
-
_instance = None
|
|
98
|
-
|
|
99
103
|
@classmethod
|
|
100
104
|
def read_endpoints(cls, endpoint_file: Path) -> AvailableEndpoints:
|
|
101
105
|
"""Read the different endpoints from a yaml file."""
|
|
102
|
-
|
|
103
106
|
nlg = read_endpoint_config(endpoint_file, endpoint_type="nlg")
|
|
104
107
|
nlu = read_endpoint_config(endpoint_file, endpoint_type="nlu")
|
|
105
108
|
action = read_endpoint_config(endpoint_file, endpoint_type="action_endpoint")
|
|
@@ -7,6 +7,7 @@ from typing import Literal, Optional
|
|
|
7
7
|
import structlog
|
|
8
8
|
|
|
9
9
|
from rasa.cli.validation.config_path_validation import get_validated_path
|
|
10
|
+
from rasa.core.available_agents import DEFAULT_AGENTS_CONFIG_FOLDER, AvailableAgents
|
|
10
11
|
from rasa.core.config.available_endpoints import AvailableEndpoints
|
|
11
12
|
from rasa.core.config.credentials import CredentialsConfig
|
|
12
13
|
from rasa.core.config.message_procesing_config import MessageProcessingConfig
|
|
@@ -146,10 +147,12 @@ class Configuration:
|
|
|
146
147
|
def __init__(
|
|
147
148
|
self,
|
|
148
149
|
endpoints: AvailableEndpoints,
|
|
150
|
+
available_agents: AvailableAgents,
|
|
149
151
|
credentials: Optional[CredentialsConfig] = None,
|
|
150
152
|
message_processing_config: Optional[MessageProcessingConfig] = None,
|
|
151
153
|
):
|
|
152
154
|
self.credentials = credentials
|
|
155
|
+
self.available_agents = available_agents
|
|
153
156
|
self.endpoints = endpoints
|
|
154
157
|
self.message_processing_config = message_processing_config
|
|
155
158
|
|
|
@@ -159,6 +162,7 @@ class Configuration:
|
|
|
159
162
|
cls._instance = Configuration(
|
|
160
163
|
credentials=None,
|
|
161
164
|
endpoints=AvailableEndpoints(),
|
|
165
|
+
available_agents=AvailableAgents(),
|
|
162
166
|
message_processing_config=None,
|
|
163
167
|
)
|
|
164
168
|
return cls._instance
|
|
@@ -177,7 +181,10 @@ class Configuration:
|
|
|
177
181
|
)
|
|
178
182
|
if cls._instance is None:
|
|
179
183
|
cls._instance = Configuration(
|
|
180
|
-
endpoints=endpoints,
|
|
184
|
+
endpoints=endpoints,
|
|
185
|
+
available_agents=AvailableAgents(),
|
|
186
|
+
credentials=None,
|
|
187
|
+
message_processing_config=None,
|
|
181
188
|
)
|
|
182
189
|
else:
|
|
183
190
|
cls._instance.endpoints = endpoints
|
|
@@ -189,6 +196,7 @@ class Configuration:
|
|
|
189
196
|
if cls._instance is None:
|
|
190
197
|
cls._instance = Configuration(
|
|
191
198
|
endpoints=AvailableEndpoints(),
|
|
199
|
+
available_agents=AvailableAgents(),
|
|
192
200
|
credentials=None,
|
|
193
201
|
message_processing_config=None,
|
|
194
202
|
)
|
|
@@ -217,6 +225,7 @@ class Configuration:
|
|
|
217
225
|
message_processing_config=message_processing_config,
|
|
218
226
|
credentials=None,
|
|
219
227
|
endpoints=AvailableEndpoints(),
|
|
228
|
+
available_agents=AvailableAgents(),
|
|
220
229
|
)
|
|
221
230
|
else:
|
|
222
231
|
cls._instance.message_processing_config = message_processing_config
|
|
@@ -240,12 +249,37 @@ class Configuration:
|
|
|
240
249
|
cls._instance = Configuration(
|
|
241
250
|
credentials=credentials,
|
|
242
251
|
endpoints=AvailableEndpoints(),
|
|
252
|
+
available_agents=AvailableAgents(),
|
|
243
253
|
message_processing_config=None,
|
|
244
254
|
)
|
|
245
255
|
else:
|
|
246
256
|
cls._instance.credentials = credentials
|
|
247
257
|
return cls._instance
|
|
248
258
|
|
|
259
|
+
@classmethod
|
|
260
|
+
def initialise_sub_agents(cls, sub_agents_path: Optional[Path]) -> Configuration:
|
|
261
|
+
sub_agents_folder = (
|
|
262
|
+
str(sub_agents_path)
|
|
263
|
+
if sub_agents_path is not None
|
|
264
|
+
else DEFAULT_AGENTS_CONFIG_FOLDER
|
|
265
|
+
)
|
|
266
|
+
logger.debug(
|
|
267
|
+
"configuration.initialise_sub_agents.start",
|
|
268
|
+
sub_agents_folder=sub_agents_folder,
|
|
269
|
+
)
|
|
270
|
+
available_agents = AvailableAgents.read_from_folder(sub_agents_folder)
|
|
271
|
+
|
|
272
|
+
if cls._instance is None:
|
|
273
|
+
cls._instance = Configuration(
|
|
274
|
+
endpoints=AvailableEndpoints(),
|
|
275
|
+
available_agents=available_agents,
|
|
276
|
+
credentials=None,
|
|
277
|
+
message_processing_config=None,
|
|
278
|
+
)
|
|
279
|
+
else:
|
|
280
|
+
cls._instance.available_agents = available_agents
|
|
281
|
+
return cls._instance
|
|
282
|
+
|
|
249
283
|
@classmethod
|
|
250
284
|
def get_instance(cls) -> Configuration:
|
|
251
285
|
if cls._instance is None:
|
|
@@ -254,6 +288,7 @@ class Configuration:
|
|
|
254
288
|
"Call appropriate 'initialise' methods to "
|
|
255
289
|
"load the config when Rasa Pro starts: "
|
|
256
290
|
"initialise_endpoints(), "
|
|
291
|
+
"initialise_sub_agents(), "
|
|
257
292
|
"initialise_credentials(), "
|
|
258
293
|
"initialise_message_processing()"
|
|
259
294
|
)
|
|
@@ -16,7 +16,7 @@ from rasa.agents.constants import (
|
|
|
16
16
|
from rasa.agents.core.types import AgentStatus, ProtocolType
|
|
17
17
|
from rasa.agents.schemas import AgentInput, AgentOutput
|
|
18
18
|
from rasa.agents.schemas.agent_input import AgentInputSlot
|
|
19
|
-
from rasa.core.
|
|
19
|
+
from rasa.core.config.configuration import Configuration
|
|
20
20
|
from rasa.core.policies.flows.flow_step_result import (
|
|
21
21
|
ContinueFlowWithNextStep,
|
|
22
22
|
FlowActionPrediction,
|
|
@@ -47,12 +47,13 @@ from rasa.shared.core.events import (
|
|
|
47
47
|
AgentStarted,
|
|
48
48
|
Event,
|
|
49
49
|
SlotSet,
|
|
50
|
+
deserialise_events,
|
|
50
51
|
)
|
|
51
52
|
from rasa.shared.core.flows.steps import (
|
|
52
53
|
CallFlowStep,
|
|
53
54
|
)
|
|
54
55
|
from rasa.shared.core.slots import CategoricalSlot, Slot
|
|
55
|
-
from rasa.shared.core.trackers import DialogueStateTracker
|
|
56
|
+
from rasa.shared.core.trackers import DialogueStateTracker, EventVerbosity
|
|
56
57
|
from rasa.shared.utils.llm import tracker_as_readable_transcript
|
|
57
58
|
|
|
58
59
|
structlogger = structlog.get_logger()
|
|
@@ -61,8 +62,9 @@ MAX_AGENT_RETRIES = 3
|
|
|
61
62
|
|
|
62
63
|
|
|
63
64
|
def remove_agent_stack_frame(stack: DialogueStack, agent_id: str) -> None:
|
|
64
|
-
"""Finishes the agentic loop by popping the agent stack frame from
|
|
65
|
-
|
|
65
|
+
"""Finishes the agentic loop by popping the agent stack frame from provided `stack`.
|
|
66
|
+
|
|
67
|
+
The `tracker.stack` is NOT modified.
|
|
66
68
|
"""
|
|
67
69
|
agent_stack_frame = stack.find_agent_stack_frame_by_agent(agent_id)
|
|
68
70
|
if not agent_stack_frame:
|
|
@@ -136,7 +138,9 @@ async def run_agent(
|
|
|
136
138
|
final_events.append(AgentStarted(step.call, step.flow_id))
|
|
137
139
|
|
|
138
140
|
# send the input to the agent and wait for a response
|
|
139
|
-
protocol_type = get_protocol_type(
|
|
141
|
+
protocol_type = get_protocol_type(
|
|
142
|
+
step, Configuration.get_instance().available_agents.get_agent_config(step.call)
|
|
143
|
+
)
|
|
140
144
|
output: AgentOutput = await _call_agent_with_retry(
|
|
141
145
|
agent_name=step.call,
|
|
142
146
|
protocol_type=protocol_type,
|
|
@@ -471,8 +475,9 @@ def _create_action_prediction(
|
|
|
471
475
|
def _create_agent_request_user_input_prediction(
|
|
472
476
|
message: Optional[str], events: Optional[List[Event]]
|
|
473
477
|
) -> FlowActionPrediction:
|
|
474
|
-
"""Create a prediction for requesting user input from the agent
|
|
475
|
-
|
|
478
|
+
"""Create a prediction for requesting user input from the agent and waiting for it.
|
|
479
|
+
|
|
480
|
+
This function creates a prediction that will pause the flow and wait for user input.
|
|
476
481
|
"""
|
|
477
482
|
return _create_action_prediction(
|
|
478
483
|
ACTION_AGENT_REQUEST_USER_INPUT_NAME, message, events
|
|
@@ -529,7 +534,9 @@ def _prepare_agent_input(
|
|
|
529
534
|
tracker.current_slot_values(), slots, step.exit_if
|
|
530
535
|
),
|
|
531
536
|
conversation_history=tracker_as_readable_transcript(tracker),
|
|
532
|
-
events=
|
|
537
|
+
events=deserialise_events(
|
|
538
|
+
tracker.current_state(EventVerbosity.ALL).get("events") or []
|
|
539
|
+
),
|
|
533
540
|
metadata=agent_input_metadata,
|
|
534
541
|
)
|
|
535
542
|
|
|
@@ -550,6 +557,7 @@ def _prepare_slots_for_agent(
|
|
|
550
557
|
Args:
|
|
551
558
|
slot_values: The full slot dictionary from the tracker.
|
|
552
559
|
slot_definitions: The slot definitions from the domain.
|
|
560
|
+
exit_if: Optional list of exit conditions that determine which slots to keep.
|
|
553
561
|
|
|
554
562
|
Returns:
|
|
555
563
|
A list of slots containing the name, current value, type, and allowed values.
|