rasa-pro 3.13.0.dev3__py3-none-any.whl → 3.13.0.dev7__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/__main__.py +3 -1
- rasa/api.py +4 -0
- rasa/cli/arguments/default_arguments.py +13 -1
- rasa/cli/arguments/train.py +2 -0
- rasa/cli/evaluate.py +1 -1
- rasa/cli/export.py +2 -2
- rasa/cli/inspect.py +8 -4
- rasa/cli/project_templates/default/config.yml +5 -32
- rasa/cli/project_templates/{calm → default}/e2e_tests/cancelations/user_cancels_during_a_correction.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/cancelations/user_changes_mind_on_a_whim.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/corrections/user_corrects_contact_handle.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/corrections/user_corrects_contact_name.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_adds_contact_to_their_list.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_lists_contacts.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_removes_contact.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_removes_contact_from_list.yml +1 -1
- rasa/cli/project_templates/default/endpoints.yml +18 -2
- rasa/cli/scaffold.py +3 -4
- rasa/cli/studio/download.py +1 -1
- rasa/cli/studio/upload.py +0 -6
- rasa/cli/train.py +1 -0
- rasa/constants.py +2 -0
- rasa/core/agent.py +2 -2
- rasa/core/brokers/kafka.py +4 -0
- rasa/core/brokers/pika.py +4 -0
- rasa/core/brokers/sql.py +1 -1
- rasa/core/channels/channel.py +68 -5
- rasa/core/channels/inspector/.eslintrc.cjs +12 -6
- rasa/core/channels/inspector/.prettierrc +5 -0
- rasa/core/channels/inspector/README.md +10 -4
- rasa/core/channels/inspector/dist/assets/{arc-c7691751.js → arc-c4b064fc.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-ab99dff7.js → blockDiagram-38ab4fdb-215b5026.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-08c35a6b.js → c4Diagram-3d4e48cf-2b54a0a3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-3730f5fd.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-9e9c71c9.js → classDiagram-70f12bd4-daacea5f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-15e7e2bf.js → classDiagram-v2-f2320105-930d4dc2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-e847561e.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-9c105cb1.js → createText-2e5e7dd3-83c206ba.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-77e89e48.js → edges-e0da2a9e-b0eb01d0.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-7a011646.js → erDiagram-9861fffd-17586500.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-b6f105ac.js → flowDb-956e92f1-be2a1776.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-ce4f18c2.js → flowDiagram-66a62f08-c2120ebd.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-efbbfe00.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-cb5f6da4.js → flowchart-elk-definition-4a651766-a6ab5c48.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-e4d19e28.js → ganttDiagram-c361ad54-ef613457.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-727b1c33.js → gitGraphDiagram-72cf32ee-d59185b3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-6e2ab9a7.js → graph-0f155405.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-84ec700f.js → index-3862675e-d5f1d1b7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-098a1a24.js → index-47737d3a.js} +162 -149
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-78dda442.js → infoDiagram-f8f76790-b07d141f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-f1cc6dd1.js → journeyDiagram-49397b02-1936d429.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-d98dcd0c.js → layout-dde8d0f3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-838e3d82.js → line-0c2c7ee0.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-eae72406.js → linear-35dd89a4.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-c96fd84b.js → mindmap-definition-fc14e90a-56192851.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-c936d4e2.js → pieDiagram-8a3498a8-fc21ed78.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-b338eb8f.js → quadrantDiagram-120e2f19-25e98518.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-c6b6c0d5.js → requirementDiagram-deff3bca-546ff1f5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-b9372e19.js → sankeyDiagram-04a897e0-02d8b82d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-479e0a3f.js → sequenceDiagram-704730f1-3ca5a92e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-fd26eebc.js → stateDiagram-587899a1-128ea07c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-3233e0ae.js → stateDiagram-v2-d93cdb3a-95f290af.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-1fdd392b.js → styles-6aaf32cf-4984898a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-6d7bfa1b.js → styles-9a916d00-1bf266ba.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-f86aab11.js → styles-c10674c1-60521c63.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-e3e49d7a.js → svgDrawCommon-08f97a94-a25b6e12.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-6fe08b4d.js → timeline-definition-85554ec2-0fc086bf.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-c2e06fd6.js → xychartDiagram-e933f94c-44ee592e.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/package.json +3 -1
- rasa/core/channels/inspector/src/App.tsx +92 -90
- rasa/core/channels/inspector/src/components/Chat.tsx +61 -36
- rasa/core/channels/inspector/src/components/DiagramFlow.tsx +40 -43
- rasa/core/channels/inspector/src/components/DialogueInformation.tsx +57 -57
- rasa/core/channels/inspector/src/components/DialogueStack.tsx +36 -27
- rasa/core/channels/inspector/src/components/ExpandIcon.tsx +4 -4
- rasa/core/channels/inspector/src/components/FullscreenButton.tsx +7 -7
- rasa/core/channels/inspector/src/components/LoadingSpinner.tsx +28 -12
- rasa/core/channels/inspector/src/components/NoActiveFlow.tsx +9 -9
- rasa/core/channels/inspector/src/components/RasaLogo.tsx +5 -5
- rasa/core/channels/inspector/src/components/RecruitmentPanel.tsx +55 -60
- rasa/core/channels/inspector/src/components/SaraDiagrams.tsx +5 -5
- rasa/core/channels/inspector/src/components/Slots.tsx +22 -22
- rasa/core/channels/inspector/src/components/Welcome.tsx +28 -31
- rasa/core/channels/inspector/src/helpers/audio/audiostream.ts +245 -0
- rasa/core/channels/inspector/src/helpers/audio/microphone-processor.js +12 -0
- rasa/core/channels/inspector/src/helpers/audio/playback-processor.js +36 -0
- rasa/core/channels/inspector/src/helpers/conversation.ts +16 -0
- rasa/core/channels/inspector/src/helpers/formatters.test.ts +181 -181
- rasa/core/channels/inspector/src/helpers/formatters.ts +111 -111
- rasa/core/channels/inspector/src/helpers/utils.ts +78 -61
- rasa/core/channels/inspector/src/main.tsx +8 -8
- rasa/core/channels/inspector/src/theme/Button/Button.ts +8 -8
- rasa/core/channels/inspector/src/theme/Heading/Heading.ts +7 -7
- rasa/core/channels/inspector/src/theme/Input/Input.ts +9 -9
- rasa/core/channels/inspector/src/theme/Link/Link.ts +6 -6
- rasa/core/channels/inspector/src/theme/Modal/Modal.ts +13 -13
- rasa/core/channels/inspector/src/theme/Table/Table.tsx +10 -10
- rasa/core/channels/inspector/src/theme/Tooltip/Tooltip.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/breakpoints.ts +7 -7
- rasa/core/channels/inspector/src/theme/base/colors.ts +64 -64
- rasa/core/channels/inspector/src/theme/base/fonts/fontFaces.css +21 -18
- rasa/core/channels/inspector/src/theme/base/radii.ts +8 -8
- rasa/core/channels/inspector/src/theme/base/shadows.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/sizes.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/space.ts +12 -12
- rasa/core/channels/inspector/src/theme/base/styles.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/typography.ts +12 -12
- rasa/core/channels/inspector/src/theme/base/zIndices.ts +3 -3
- rasa/core/channels/inspector/src/theme/index.ts +38 -38
- rasa/core/channels/inspector/src/types.ts +56 -50
- rasa/core/channels/inspector/yarn.lock +5 -0
- rasa/core/channels/voice_ready/audiocodes.py +75 -32
- rasa/core/channels/voice_ready/twilio_voice.py +48 -1
- rasa/core/channels/voice_stream/tts/azure.py +11 -2
- rasa/core/channels/voice_stream/twilio_media_streams.py +101 -26
- rasa/core/channels/voice_stream/voice_channel.py +28 -2
- rasa/core/concurrent_lock_store.py +24 -10
- rasa/core/evaluation/marker_tracker_loader.py +1 -1
- rasa/core/exporter.py +1 -1
- rasa/core/lock_store.py +151 -60
- rasa/core/nlg/contextual_response_rephraser.py +4 -2
- rasa/core/nlg/summarize.py +1 -1
- rasa/core/persistor.py +55 -20
- rasa/core/policies/enterprise_search_policy.py +7 -4
- rasa/core/policies/intentless_policy.py +15 -9
- rasa/core/processor.py +2 -2
- rasa/core/run.py +7 -2
- rasa/core/{auth_retry_tracker_store.py → tracker_stores/auth_retry_tracker_store.py} +5 -1
- rasa/core/tracker_stores/dynamo_tracker_store.py +218 -0
- rasa/core/tracker_stores/mongo_tracker_store.py +206 -0
- rasa/core/tracker_stores/redis_tracker_store.py +219 -0
- rasa/core/tracker_stores/sql_tracker_store.py +555 -0
- rasa/core/tracker_stores/tracker_store.py +805 -0
- rasa/core/utils.py +6 -0
- rasa/dialogue_understanding/coexistence/llm_based_router.py +8 -3
- rasa/dialogue_understanding/commands/clarify_command.py +2 -2
- rasa/dialogue_understanding/commands/knowledge_answer_command.py +2 -2
- rasa/dialogue_understanding/generator/constants.py +2 -2
- rasa/dialogue_understanding/generator/llm_based_command_generator.py +1 -1
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +33 -12
- rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +2 -2
- rasa/dialogue_understanding_test/du_test_case.py +16 -8
- rasa/hooks.py +2 -2
- rasa/keys +1 -0
- rasa/llm_fine_tuning/paraphrasing/conversation_rephraser.py +4 -2
- rasa/model_manager/config.py +3 -1
- rasa/model_manager/model_api.py +1 -2
- rasa/model_manager/runner_service.py +8 -4
- rasa/model_manager/trainer_service.py +1 -0
- rasa/model_training.py +12 -3
- rasa/nlu/extractors/crf_entity_extractor.py +66 -16
- rasa/plugin.py +1 -4
- rasa/server.py +6 -2
- rasa/shared/constants.py +4 -0
- rasa/shared/core/domain.py +165 -11
- rasa/shared/core/events.py +68 -2
- rasa/shared/core/flows/flow.py +155 -131
- rasa/shared/core/flows/flow_step.py +19 -3
- rasa/shared/core/flows/flow_step_links.py +15 -0
- rasa/shared/core/flows/flow_step_sequence.py +6 -0
- rasa/shared/core/flows/nlu_trigger.py +13 -0
- rasa/shared/core/flows/steps/action.py +7 -4
- rasa/shared/core/flows/steps/call.py +11 -4
- rasa/shared/core/flows/steps/collect.py +27 -6
- rasa/shared/core/flows/steps/internal.py +6 -1
- rasa/shared/core/flows/steps/link.py +7 -4
- rasa/shared/core/flows/steps/no_operation.py +7 -4
- rasa/shared/core/flows/steps/set_slots.py +8 -4
- rasa/shared/core/flows/yaml_flows_io.py +106 -5
- rasa/shared/importers/importer.py +8 -0
- rasa/shared/providers/_configs/azure_openai_client_config.py +4 -0
- rasa/shared/providers/_configs/openai_client_config.py +4 -0
- rasa/shared/providers/_utils.py +83 -0
- rasa/shared/providers/embedding/_base_litellm_embedding_client.py +3 -0
- rasa/shared/providers/llm/_base_litellm_client.py +11 -5
- rasa/shared/providers/llm/azure_openai_llm_client.py +6 -68
- rasa/shared/providers/router/_base_litellm_router_client.py +53 -1
- rasa/shared/utils/common.py +42 -0
- rasa/studio/download/__init__.py +0 -0
- rasa/studio/download/domains.py +49 -0
- rasa/studio/download/download.py +439 -0
- rasa/studio/download/flows.py +359 -0
- rasa/studio/results_logger.py +6 -1
- rasa/studio/upload.py +69 -5
- rasa/telemetry.py +2 -2
- rasa/tracing/config.py +1 -1
- rasa/tracing/instrumentation/attribute_extractors.py +1 -1
- rasa/tracing/instrumentation/instrumentation.py +1 -1
- rasa/utils/common.py +36 -0
- rasa/utils/endpoints.py +22 -1
- rasa/utils/licensing.py +2 -3
- rasa/validator.py +1 -2
- rasa/version.py +1 -1
- {rasa_pro-3.13.0.dev3.dist-info → rasa_pro-3.13.0.dev7.dist-info}/METADATA +10 -10
- {rasa_pro-3.13.0.dev3.dist-info → rasa_pro-3.13.0.dev7.dist-info}/RECORD +213 -210
- rasa/cli/project_templates/calm/config.yml +0 -10
- rasa/cli/project_templates/calm/credentials.yml +0 -33
- rasa/cli/project_templates/calm/endpoints.yml +0 -58
- rasa/cli/project_templates/default/actions/actions.py +0 -27
- rasa/cli/project_templates/default/data/nlu.yml +0 -91
- rasa/cli/project_templates/default/data/rules.yml +0 -13
- rasa/cli/project_templates/default/data/stories.yml +0 -30
- rasa/cli/project_templates/default/domain.yml +0 -34
- rasa/cli/project_templates/default/tests/test_stories.yml +0 -91
- rasa/core/channels/inspector/dist/assets/channel-11268142.js +0 -1
- rasa/core/channels/inspector/dist/assets/clone-ff7f2ce7.js +0 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-cba7ae20.js +0 -1
- rasa/core/channels/inspector/src/helpers/audiostream.ts +0 -191
- rasa/core/tracker_store.py +0 -1792
- rasa/studio/download.py +0 -489
- /rasa/cli/project_templates/{calm → default}/actions/action_template.py +0 -0
- /rasa/cli/project_templates/{calm → default}/actions/add_contact.py +0 -0
- /rasa/cli/project_templates/{calm → default}/actions/db.py +0 -0
- /rasa/cli/project_templates/{calm → default}/actions/list_contacts.py +0 -0
- /rasa/cli/project_templates/{calm → default}/actions/remove_contact.py +0 -0
- /rasa/cli/project_templates/{calm → default}/data/flows/add_contact.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/data/flows/list_contacts.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/data/flows/remove_contact.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/db/contacts.json +0 -0
- /rasa/cli/project_templates/{calm → default}/domain/add_contact.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/domain/list_contacts.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/domain/remove_contact.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/domain/shared.yml +0 -0
- /rasa/{cli/project_templates/calm/actions → core/tracker_stores}/__init__.py +0 -0
- {rasa_pro-3.13.0.dev3.dist-info → rasa_pro-3.13.0.dev7.dist-info}/NOTICE +0 -0
- {rasa_pro-3.13.0.dev3.dist-info → rasa_pro-3.13.0.dev7.dist-info}/WHEEL +0 -0
- {rasa_pro-3.13.0.dev3.dist-info → rasa_pro-3.13.0.dev7.dist-info}/entry_points.txt +0 -0
rasa/core/utils.py
CHANGED
|
@@ -198,6 +198,9 @@ class AvailableEndpoints:
|
|
|
198
198
|
model_groups = read_property_config_from_endpoints_file(
|
|
199
199
|
endpoint_file, property_name="model_groups"
|
|
200
200
|
)
|
|
201
|
+
privacy = read_property_config_from_endpoints_file(
|
|
202
|
+
endpoint_file, property_name="privacy"
|
|
203
|
+
)
|
|
201
204
|
|
|
202
205
|
return cls(
|
|
203
206
|
nlg,
|
|
@@ -209,6 +212,7 @@ class AvailableEndpoints:
|
|
|
209
212
|
event_broker,
|
|
210
213
|
vector_store,
|
|
211
214
|
model_groups,
|
|
215
|
+
privacy,
|
|
212
216
|
)
|
|
213
217
|
|
|
214
218
|
def __init__(
|
|
@@ -222,6 +226,7 @@ class AvailableEndpoints:
|
|
|
222
226
|
event_broker: Optional[EndpointConfig] = None,
|
|
223
227
|
vector_store: Optional[EndpointConfig] = None,
|
|
224
228
|
model_groups: Optional[List[Dict[str, Any]]] = None,
|
|
229
|
+
privacy: Optional[Dict[Text, Any]] = None,
|
|
225
230
|
) -> None:
|
|
226
231
|
"""Create an `AvailableEndpoints` object."""
|
|
227
232
|
self.model = model
|
|
@@ -233,6 +238,7 @@ class AvailableEndpoints:
|
|
|
233
238
|
self.event_broker = event_broker
|
|
234
239
|
self.vector_store = vector_store
|
|
235
240
|
self.model_groups = model_groups
|
|
241
|
+
self.privacy = privacy
|
|
236
242
|
|
|
237
243
|
@classmethod
|
|
238
244
|
def get_instance(
|
|
@@ -23,11 +23,14 @@ from rasa.engine.recipes.default_recipe import DefaultV1Recipe
|
|
|
23
23
|
from rasa.engine.storage.resource import Resource
|
|
24
24
|
from rasa.engine.storage.storage import ModelStorage
|
|
25
25
|
from rasa.shared.constants import (
|
|
26
|
+
LOGIT_BIAS_CONFIG_KEY,
|
|
27
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY,
|
|
26
28
|
MODEL_CONFIG_KEY,
|
|
27
29
|
OPENAI_PROVIDER,
|
|
28
30
|
PROMPT_CONFIG_KEY,
|
|
29
31
|
PROVIDER_CONFIG_KEY,
|
|
30
32
|
ROUTE_TO_CALM_SLOT,
|
|
33
|
+
TEMPERATURE_CONFIG_KEY,
|
|
31
34
|
TIMEOUT_CONFIG_KEY,
|
|
32
35
|
)
|
|
33
36
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
@@ -66,9 +69,11 @@ DEFAULT_LLM_CONFIG = {
|
|
|
66
69
|
PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
|
|
67
70
|
MODEL_CONFIG_KEY: DEFAULT_OPENAI_CHAT_MODEL_NAME,
|
|
68
71
|
TIMEOUT_CONFIG_KEY: 7,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
TEMPERATURE_CONFIG_KEY: 0.0,
|
|
73
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY: 1,
|
|
74
|
+
LOGIT_BIAS_CONFIG_KEY: {
|
|
75
|
+
str(token_id): 100 for token_id in A_TO_C_TOKEN_IDS_CHATGPT
|
|
76
|
+
},
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
structlogger = structlog.get_logger()
|
|
@@ -117,9 +117,9 @@ class ClarifyCommand(Command):
|
|
|
117
117
|
@staticmethod
|
|
118
118
|
def regex_pattern() -> str:
|
|
119
119
|
mapper = {
|
|
120
|
-
CommandSyntaxVersion.v1: r"Clarify\(([\"\'a-zA-Z0-9_, ]*)\)",
|
|
120
|
+
CommandSyntaxVersion.v1: r"Clarify\(([\"\'a-zA-Z0-9_, -]*)\)",
|
|
121
121
|
CommandSyntaxVersion.v2: (
|
|
122
|
-
r"""^[\s\W\d]*disambiguate flows (["'a-zA-Z0-9_, ]*)['"`]*$"""
|
|
122
|
+
r"""^[\s\W\d]*disambiguate flows (["'a-zA-Z0-9_, -]*)['"`]*$"""
|
|
123
123
|
),
|
|
124
124
|
}
|
|
125
125
|
return mapper.get(
|
|
@@ -65,7 +65,7 @@ class KnowledgeAnswerCommand(FreeFormAnswerCommand):
|
|
|
65
65
|
"""Converts the command to a DSL string."""
|
|
66
66
|
mapper = {
|
|
67
67
|
CommandSyntaxVersion.v1: "SearchAndReply()",
|
|
68
|
-
CommandSyntaxVersion.v2: "
|
|
68
|
+
CommandSyntaxVersion.v2: "search and reply",
|
|
69
69
|
}
|
|
70
70
|
return mapper.get(
|
|
71
71
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -81,7 +81,7 @@ class KnowledgeAnswerCommand(FreeFormAnswerCommand):
|
|
|
81
81
|
def regex_pattern() -> str:
|
|
82
82
|
mapper = {
|
|
83
83
|
CommandSyntaxVersion.v1: r"SearchAndReply\(\)",
|
|
84
|
-
CommandSyntaxVersion.v2: r"""^[\s\W\d]*
|
|
84
|
+
CommandSyntaxVersion.v2: r"""^[\s\W\d]*search and reply['"`]*$""",
|
|
85
85
|
}
|
|
86
86
|
return mapper.get(
|
|
87
87
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from rasa.shared.constants import (
|
|
2
|
-
|
|
2
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY,
|
|
3
3
|
MODEL_CONFIG_KEY,
|
|
4
4
|
OPENAI_PROVIDER,
|
|
5
5
|
PROVIDER_CONFIG_KEY,
|
|
@@ -15,7 +15,7 @@ DEFAULT_LLM_CONFIG = {
|
|
|
15
15
|
PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
|
|
16
16
|
MODEL_CONFIG_KEY: DEFAULT_OPENAI_CHAT_MODEL_NAME_ADVANCED,
|
|
17
17
|
TEMPERATURE_CONFIG_KEY: 0.0,
|
|
18
|
-
|
|
18
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY: DEFAULT_OPENAI_MAX_GENERATED_TOKENS,
|
|
19
19
|
TIMEOUT_CONFIG_KEY: 7,
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -527,7 +527,7 @@ class LLMBasedCommandGenerator(
|
|
|
527
527
|
either contain a StartFlowCommand or a SetSlot command
|
|
528
528
|
for the current collect step.
|
|
529
529
|
"""
|
|
530
|
-
return self.config.get(KEY_MINIMIZE_NUM_CALLS,
|
|
530
|
+
return self.config.get(KEY_MINIMIZE_NUM_CALLS, True) and (
|
|
531
531
|
self._prior_commands_contain_start_flow(prior_commands)
|
|
532
532
|
or self._prior_commands_contain_set_slot_for_active_collect_step(
|
|
533
533
|
prior_commands, flows, tracker
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
## Task Description
|
|
2
|
-
Your task is to analyze the current conversation context and generate a list of actions to start new business processes that we call flows, to extract slots, or respond to
|
|
2
|
+
Your task is to analyze the current conversation context and generate a list of actions to start new business processes that we call flows, to extract slots, or respond to off-topic and knowledge requests.
|
|
3
3
|
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -12,31 +12,52 @@ Use the following structured data:
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
14
|
## Available Actions:
|
|
15
|
-
* `start flow flow_name`:
|
|
16
|
-
* `set slot slot_name slot_value`:
|
|
17
|
-
* `
|
|
18
|
-
* `
|
|
19
|
-
* `
|
|
20
|
-
* `offtopic reply`: Responding to casual or social user messages that are unrelated to any flows, engaging in friendly conversation and addressing off-topic remarks.
|
|
21
|
-
* `hand over`: Handing over to a human, in case the user seems frustrated or explicitly asks to speak to one.
|
|
15
|
+
* `start flow flow_name`: Start a flow. For example, `start flow transfer_money` or `start flow list_contacts`.
|
|
16
|
+
* `set slot slot_name slot_value`: Set a slot for the active flow. For example, `set slot transfer_money_recipient Freddy`. Can be used to correct and change previously set values.
|
|
17
|
+
* `disambiguate flows flow_name1 flow_name2 ... flow_name_n`: When a message could refer to multiple flows, list the possible flows as options to clarify. Example: `disambiguate flows list_contacts add_contact remove_contact`.
|
|
18
|
+
* `search and reply`: Provide a response from the knowledge base to address the user’s inquiry when no flows fit, including domain knowledge, FAQs, and all off-topic or social messages.
|
|
19
|
+
* `cancel flow`: Cancel the current flow if the user requests it.
|
|
22
20
|
|
|
23
21
|
---
|
|
24
22
|
|
|
25
|
-
## General
|
|
23
|
+
## General Instructions
|
|
24
|
+
### Start Flow
|
|
25
|
+
* Only start a flow if the user's message is clear and fully addressed by that flow's description and purpose.
|
|
26
|
+
* Pay close attention to exact wording and scope in the flow description — do not assume or “stretch” the intended use of a flow.
|
|
27
|
+
### Set Slot
|
|
26
28
|
* Do not fill slots with abstract values or placeholders.
|
|
27
29
|
* For categorical slots try to match the user message with allowed slot values. Use "other" if you cannot match it.
|
|
28
30
|
* Set the boolean slots based on the user response. Map positive responses to `True`, and negative to `False`.
|
|
29
31
|
* Extract text slot values exactly as provided by the user. Avoid assumptions, format changes, or partial extractions.
|
|
32
|
+
### Disambiguate Flows
|
|
33
|
+
* Use `disambiguate flows` when the user's message matches multiple flows and you cannot decide which flow is most appropriate.
|
|
34
|
+
* If the user message is short and not precise enough to start a flow or `search and reply`, disambiguate.
|
|
35
|
+
* If a single flow is a strong/plausible fit, prefer starting that flow directly.
|
|
36
|
+
* If a user's message unambiguously and distinctly matches multiple flows, start all relevant flows at once (rather than disambiguating).
|
|
37
|
+
### Search and Reply
|
|
38
|
+
* Only start `search and reply` if the user intent is clear.
|
|
39
|
+
* Flow Priority: If you are unsure between starting a flow or `search and reply`, always prioritize starting a flow.
|
|
40
|
+
### Cancel Flow
|
|
41
|
+
* Do not cancel any flow unless the user explicitly requests it.
|
|
42
|
+
* Multiple flows can be started without cancelling the previous, if the user wants to pursue multiple processes.
|
|
43
|
+
### General Tips
|
|
30
44
|
* Only use information provided by the user.
|
|
31
|
-
* Use clarification in ambiguous cases.
|
|
32
|
-
* Multiple flows can be started. If a user wants to digress into a second flow, you do not need to cancel the current flow.
|
|
33
|
-
* Do not cancel the flow unless the user explicitly requests it.
|
|
34
45
|
* Strictly adhere to the provided action format.
|
|
35
46
|
* Focus on the last message and take it one step at a time.
|
|
36
47
|
* Use the previous conversation steps only to aid understanding.
|
|
37
48
|
|
|
38
49
|
---
|
|
39
50
|
|
|
51
|
+
## Decision Rule Table
|
|
52
|
+
| Condition | Action |
|
|
53
|
+
|-------------------------------------------------------|--------------------|
|
|
54
|
+
| Flow perfectly matches user's message | start flow |
|
|
55
|
+
| Multiple flows are equally strong, relevant matches | disambiguate flows |
|
|
56
|
+
| User's message is unclear or imprecise | disambiguate flows |
|
|
57
|
+
| No flow fits at all, but knowledge base may help | search and reply |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
40
61
|
## Current State
|
|
41
62
|
{% if current_flow != None %}Use the following structured data:
|
|
42
63
|
```json
|
|
@@ -47,7 +47,7 @@ from rasa.shared.constants import (
|
|
|
47
47
|
AWS_BEDROCK_PROVIDER,
|
|
48
48
|
AZURE_OPENAI_PROVIDER,
|
|
49
49
|
EMBEDDINGS_CONFIG_KEY,
|
|
50
|
-
|
|
50
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY,
|
|
51
51
|
PROMPT_TEMPLATE_CONFIG_KEY,
|
|
52
52
|
ROUTE_TO_CALM_SLOT,
|
|
53
53
|
TEMPERATURE_CONFIG_KEY,
|
|
@@ -81,7 +81,7 @@ DEFAULT_LLM_CONFIG = {
|
|
|
81
81
|
PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
|
|
82
82
|
MODEL_CONFIG_KEY: MODEL_NAME_GPT_4O_2024_11_20,
|
|
83
83
|
TEMPERATURE_CONFIG_KEY: 0.0,
|
|
84
|
-
|
|
84
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY: DEFAULT_OPENAI_MAX_GENERATED_TOKENS,
|
|
85
85
|
TIMEOUT_CONFIG_KEY: 7,
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -261,19 +261,27 @@ class DialogueUnderstandingTestStep(BaseModel):
|
|
|
261
261
|
# Safely extract commands from the step.
|
|
262
262
|
commands = []
|
|
263
263
|
for command in step.get(KEY_COMMANDS, []):
|
|
264
|
+
parsed_commands = None
|
|
264
265
|
try:
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
default_commands_to_remove=remove_default_commands,
|
|
272
|
-
)
|
|
266
|
+
parsed_commands = parse_commands(
|
|
267
|
+
command,
|
|
268
|
+
flows,
|
|
269
|
+
clarify_options_optional=True,
|
|
270
|
+
additional_commands=custom_command_classes,
|
|
271
|
+
default_commands_to_remove=remove_default_commands,
|
|
273
272
|
)
|
|
274
273
|
except (IndexError, ValueError) as e:
|
|
275
274
|
raise ValueError(f"Failed to parse command '{command}': {e}") from e
|
|
276
275
|
|
|
276
|
+
if not parsed_commands:
|
|
277
|
+
raise ValueError(
|
|
278
|
+
f"Failed to parse command '{command}': command parser returned "
|
|
279
|
+
f"None. Please make sure that you are using the correct command "
|
|
280
|
+
f"syntax and the command arguments are valid."
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
commands.extend(parsed_commands)
|
|
284
|
+
|
|
277
285
|
# Construct the DialogueUnderstandingTestStep
|
|
278
286
|
return DialogueUnderstandingTestStep(
|
|
279
287
|
actor=ACTOR_USER if ACTOR_USER in step else ACTOR_BOT,
|
rasa/hooks.py
CHANGED
|
@@ -12,7 +12,7 @@ if TYPE_CHECKING:
|
|
|
12
12
|
from rasa.anonymization.anonymization_pipeline import AnonymizationPipeline
|
|
13
13
|
from rasa.cli import SubParsersAction
|
|
14
14
|
from rasa.core.brokers.broker import EventBroker
|
|
15
|
-
from rasa.core.tracker_store import TrackerStore
|
|
15
|
+
from rasa.core.tracker_stores.tracker_store import TrackerStore
|
|
16
16
|
from rasa.shared.core.domain import Domain
|
|
17
17
|
from rasa.utils.endpoints import EndpointConfig
|
|
18
18
|
|
|
@@ -80,7 +80,7 @@ def create_tracker_store(
|
|
|
80
80
|
domain: "Domain",
|
|
81
81
|
event_broker: Optional["EventBroker"],
|
|
82
82
|
) -> "TrackerStore":
|
|
83
|
-
from rasa.core.auth_retry_tracker_store import AuthRetryTrackerStore
|
|
83
|
+
from rasa.core.tracker_stores.auth_retry_tracker_store import AuthRetryTrackerStore
|
|
84
84
|
from rasa.utils.endpoints import EndpointConfig
|
|
85
85
|
|
|
86
86
|
if isinstance(endpoint_config, EndpointConfig):
|
rasa/keys
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"segment": "CcvVD1I68Nkkxrv93cIqv1twIwrwG8nz", "sentry": "a283f1fde04347b099c8d729109dd450@o251570"}
|
|
@@ -11,10 +11,12 @@ from rasa.llm_fine_tuning.paraphrasing.rephrased_user_message import (
|
|
|
11
11
|
)
|
|
12
12
|
from rasa.shared.constants import (
|
|
13
13
|
LLM_CONFIG_KEY,
|
|
14
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY,
|
|
14
15
|
MODEL_CONFIG_KEY,
|
|
15
16
|
MODEL_NAME_CONFIG_KEY,
|
|
16
17
|
PROMPT_TEMPLATE_CONFIG_KEY,
|
|
17
18
|
PROVIDER_CONFIG_KEY,
|
|
19
|
+
TEMPERATURE_CONFIG_KEY,
|
|
18
20
|
TIMEOUT_CONFIG_KEY,
|
|
19
21
|
)
|
|
20
22
|
from rasa.shared.exceptions import ProviderClientAPIException
|
|
@@ -39,8 +41,8 @@ DEFAULT_LLM_CONFIG = {
|
|
|
39
41
|
PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
|
|
40
42
|
MODEL_CONFIG_KEY: "gpt-4o-mini",
|
|
41
43
|
TIMEOUT_CONFIG_KEY: 7,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
TEMPERATURE_CONFIG_KEY: 0.0,
|
|
45
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY: 4096,
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
structlogger = structlog.get_logger()
|
rasa/model_manager/config.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import sys
|
|
3
3
|
|
|
4
|
+
from rasa.constants import RASA_REMOTE_STORAGE_ENV_VAR_NAME
|
|
5
|
+
|
|
4
6
|
DEFAULT_SERVER_BASE_WORKING_DIRECTORY = "working-data"
|
|
5
7
|
|
|
6
8
|
SERVER_BASE_WORKING_DIRECTORY = os.environ.get(
|
|
@@ -12,7 +14,7 @@ SERVER_PORT = os.environ.get("RASA_MODEL_SERVER_PORT", 8000)
|
|
|
12
14
|
SERVER_BASE_URL = os.environ.get("RASA_MODEL_SERVER_BASE_URL", None)
|
|
13
15
|
|
|
14
16
|
# defaults to storing on the local hard drive
|
|
15
|
-
SERVER_MODEL_REMOTE_STORAGE = os.environ.get(
|
|
17
|
+
SERVER_MODEL_REMOTE_STORAGE = os.environ.get(RASA_REMOTE_STORAGE_ENV_VAR_NAME, None)
|
|
16
18
|
|
|
17
19
|
# The path to the python executable that is running this script
|
|
18
20
|
# we will use the same python to run training / bots
|
rasa/model_manager/model_api.py
CHANGED
|
@@ -532,8 +532,7 @@ def size_of_model(model_name: str) -> Optional[int]:
|
|
|
532
532
|
model_name=model_file_name,
|
|
533
533
|
)
|
|
534
534
|
return fetch_size_of_remote_model(
|
|
535
|
-
model_file_name,
|
|
536
|
-
config.SERVER_MODEL_REMOTE_STORAGE,
|
|
535
|
+
model_file_name, config.SERVER_MODEL_REMOTE_STORAGE, model_path
|
|
537
536
|
)
|
|
538
537
|
raise ModelNotFound("Model not found.")
|
|
539
538
|
|
|
@@ -166,13 +166,13 @@ def fetch_remote_model_to_dir(
|
|
|
166
166
|
) -> str:
|
|
167
167
|
"""Fetch the model from remote storage.
|
|
168
168
|
|
|
169
|
-
Returns the path to the model
|
|
169
|
+
Returns the path to the model directory.
|
|
170
170
|
"""
|
|
171
171
|
from rasa.core.persistor import get_persistor
|
|
172
172
|
|
|
173
173
|
persistor = get_persistor(storage_type)
|
|
174
174
|
|
|
175
|
-
# we
|
|
175
|
+
# we know there must be a persistor, because the config is set
|
|
176
176
|
# this is here to please the type checker for the call below
|
|
177
177
|
assert persistor is not None
|
|
178
178
|
|
|
@@ -182,7 +182,9 @@ def fetch_remote_model_to_dir(
|
|
|
182
182
|
raise ModelNotFound() from e
|
|
183
183
|
|
|
184
184
|
|
|
185
|
-
def fetch_size_of_remote_model(
|
|
185
|
+
def fetch_size_of_remote_model(
|
|
186
|
+
model_name: str, storage_type: str, model_path: str
|
|
187
|
+
) -> int:
|
|
186
188
|
"""Fetch the size of the model from remote storage."""
|
|
187
189
|
from rasa.core.persistor import get_persistor
|
|
188
190
|
|
|
@@ -192,7 +194,9 @@ def fetch_size_of_remote_model(model_name: str, storage_type: str) -> int:
|
|
|
192
194
|
# this is here to please the type checker for the call below
|
|
193
195
|
assert persistor is not None
|
|
194
196
|
|
|
195
|
-
return persistor.size_of_persisted_model(
|
|
197
|
+
return persistor.size_of_persisted_model(
|
|
198
|
+
model_name=model_name, target_path=model_path
|
|
199
|
+
)
|
|
196
200
|
|
|
197
201
|
|
|
198
202
|
def start_bot_process(
|
rasa/model_training.py
CHANGED
|
@@ -160,6 +160,7 @@ async def train(
|
|
|
160
160
|
remote_storage: Optional[StorageType] = None,
|
|
161
161
|
file_importer: Optional[TrainingDataImporter] = None,
|
|
162
162
|
keep_local_model_copy: bool = False,
|
|
163
|
+
remote_root_only: bool = False,
|
|
163
164
|
) -> TrainingResult:
|
|
164
165
|
"""Trains a Rasa model (Core and NLU).
|
|
165
166
|
|
|
@@ -187,6 +188,8 @@ async def train(
|
|
|
187
188
|
If it is not provided, a new instance will be created.
|
|
188
189
|
keep_local_model_copy: If `True` the model will be stored locally even if
|
|
189
190
|
remote storage is configured.
|
|
191
|
+
remote_root_only: If `True`, the model will be stored in the root of the
|
|
192
|
+
remote model storage.
|
|
190
193
|
|
|
191
194
|
Returns:
|
|
192
195
|
An instance of `TrainingResult`.
|
|
@@ -269,6 +272,7 @@ async def train(
|
|
|
269
272
|
dry_run=dry_run,
|
|
270
273
|
remote_storage=remote_storage,
|
|
271
274
|
keep_local_model_copy=keep_local_model_copy,
|
|
275
|
+
remote_root_only=remote_root_only,
|
|
272
276
|
**(core_additional_arguments or {}),
|
|
273
277
|
**(nlu_additional_arguments or {}),
|
|
274
278
|
)
|
|
@@ -284,6 +288,7 @@ async def _train_graph(
|
|
|
284
288
|
dry_run: bool = False,
|
|
285
289
|
remote_storage: Optional[StorageType] = None,
|
|
286
290
|
keep_local_model_copy: bool = False,
|
|
291
|
+
remote_root_only: bool = False,
|
|
287
292
|
**kwargs: Any,
|
|
288
293
|
) -> TrainingResult:
|
|
289
294
|
if model_to_finetune:
|
|
@@ -363,7 +368,9 @@ async def _train_graph(
|
|
|
363
368
|
is_finetuning=is_finetuning,
|
|
364
369
|
)
|
|
365
370
|
if remote_storage:
|
|
366
|
-
push_model_to_remote_storage(
|
|
371
|
+
push_model_to_remote_storage(
|
|
372
|
+
full_model_path, remote_storage, remote_root_only
|
|
373
|
+
)
|
|
367
374
|
if not keep_local_model_copy:
|
|
368
375
|
full_model_path.unlink()
|
|
369
376
|
structlogger.info(
|
|
@@ -581,14 +588,16 @@ async def train_nlu(
|
|
|
581
588
|
).model
|
|
582
589
|
|
|
583
590
|
|
|
584
|
-
def push_model_to_remote_storage(
|
|
591
|
+
def push_model_to_remote_storage(
|
|
592
|
+
model_path: Path, remote_storage: StorageType, remote_root_only: bool = False
|
|
593
|
+
) -> None:
|
|
585
594
|
"""Push model to remote storage."""
|
|
586
595
|
from rasa.core.persistor import get_persistor
|
|
587
596
|
|
|
588
597
|
persistor = get_persistor(remote_storage)
|
|
589
598
|
|
|
590
599
|
if persistor is not None:
|
|
591
|
-
persistor.persist(str(model_path))
|
|
600
|
+
persistor.persist(str(model_path), remote_root_only)
|
|
592
601
|
|
|
593
602
|
else:
|
|
594
603
|
raise RasaException(
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
|
+
import shutil
|
|
4
5
|
import typing
|
|
5
6
|
from collections import OrderedDict
|
|
6
7
|
from enum import Enum
|
|
8
|
+
from pathlib import Path
|
|
7
9
|
from typing import Any, Callable, Dict, List, Optional, Text, Tuple, Type
|
|
8
10
|
|
|
9
11
|
import numpy as np
|
|
@@ -43,6 +45,10 @@ if typing.TYPE_CHECKING:
|
|
|
43
45
|
|
|
44
46
|
CONFIG_FEATURES = "features"
|
|
45
47
|
|
|
48
|
+
TAGGERS_DIR = "taggers"
|
|
49
|
+
CRFSUITE_MODEL_FILE_NAME = "model.crfsuite"
|
|
50
|
+
PLAIN_CRF_MODEL_FILE_NAME = "model.txt"
|
|
51
|
+
|
|
46
52
|
|
|
47
53
|
class CRFToken:
|
|
48
54
|
def __init__(
|
|
@@ -419,19 +425,11 @@ class CRFEntityExtractor(GraphComponent, EntityExtractorMixin):
|
|
|
419
425
|
"""Loads trained component (see parent class for full docstring)."""
|
|
420
426
|
try:
|
|
421
427
|
with model_storage.read_from(resource) as model_dir:
|
|
422
|
-
dataset = rasa.shared.utils.io.read_json_file(
|
|
423
|
-
model_dir / "crf_dataset.json"
|
|
424
|
-
)
|
|
425
428
|
crf_order = rasa.shared.utils.io.read_json_file(
|
|
426
429
|
model_dir / "crf_order.json"
|
|
427
430
|
)
|
|
428
431
|
|
|
429
|
-
|
|
430
|
-
[CRFToken.create_from_dict(token_data) for token_data in sub_list]
|
|
431
|
-
for sub_list in dataset
|
|
432
|
-
]
|
|
433
|
-
|
|
434
|
-
entity_taggers = cls.train_model(dataset, config, crf_order)
|
|
432
|
+
entity_taggers = cls._load_taggers(model_dir, config)
|
|
435
433
|
|
|
436
434
|
entity_extractor = cls(config, model_storage, resource, entity_taggers)
|
|
437
435
|
entity_extractor.crf_order = crf_order
|
|
@@ -443,19 +441,71 @@ class CRFEntityExtractor(GraphComponent, EntityExtractorMixin):
|
|
|
443
441
|
)
|
|
444
442
|
return cls(config, model_storage, resource)
|
|
445
443
|
|
|
444
|
+
@classmethod
|
|
445
|
+
def _load_taggers(
|
|
446
|
+
cls, model_dir: Path, config: Dict[Text, Any]
|
|
447
|
+
) -> Dict[str, "CRF"]:
|
|
448
|
+
"""
|
|
449
|
+
Load taggers from model directory that persists trained binary
|
|
450
|
+
`model.crfsuite` files.
|
|
451
|
+
"""
|
|
452
|
+
|
|
453
|
+
import pycrfsuite
|
|
454
|
+
import sklearn_crfsuite
|
|
455
|
+
|
|
456
|
+
# Get tagger directories
|
|
457
|
+
taggers_base = model_dir / TAGGERS_DIR
|
|
458
|
+
if not taggers_base.exists():
|
|
459
|
+
return {}
|
|
460
|
+
|
|
461
|
+
taggers_dirs = [
|
|
462
|
+
directory for directory in taggers_base.iterdir() if directory.is_dir()
|
|
463
|
+
]
|
|
464
|
+
|
|
465
|
+
entity_taggers: Dict[str, "CRF"] = {}
|
|
466
|
+
|
|
467
|
+
for tagger_dir in taggers_dirs:
|
|
468
|
+
# Instantiate sklearns CRF wrapper for the pycrfsuite's Tagger
|
|
469
|
+
entity_tagger = sklearn_crfsuite.CRF(
|
|
470
|
+
algorithm="lbfgs",
|
|
471
|
+
# coefficient for L1 penalty
|
|
472
|
+
c1=config["L1_c"],
|
|
473
|
+
# coefficient for L2 penalty
|
|
474
|
+
c2=config["L2_c"],
|
|
475
|
+
# stop earlier
|
|
476
|
+
max_iterations=config["max_iterations"],
|
|
477
|
+
# include transitions that are possible, but not observed
|
|
478
|
+
all_possible_transitions=True,
|
|
479
|
+
)
|
|
480
|
+
|
|
481
|
+
# Load pycrfsuite tagger from the persisted binary model.crfsuite file
|
|
482
|
+
entity_tagger._tagger = pycrfsuite.Tagger()
|
|
483
|
+
entity_tagger._tagger.open(str(tagger_dir / CRFSUITE_MODEL_FILE_NAME))
|
|
484
|
+
|
|
485
|
+
entity_taggers[tagger_dir.name] = entity_tagger
|
|
486
|
+
|
|
487
|
+
return entity_taggers
|
|
488
|
+
|
|
446
489
|
def persist(self, dataset: List[List[CRFToken]]) -> None:
|
|
447
490
|
"""Persist this model into the passed directory."""
|
|
448
491
|
with self._model_storage.write_to(self._resource) as model_dir:
|
|
449
|
-
data_to_store = [
|
|
450
|
-
[token.to_dict() for token in sub_list] for sub_list in dataset
|
|
451
|
-
]
|
|
452
|
-
|
|
453
|
-
rasa.shared.utils.io.dump_obj_as_json_to_file(
|
|
454
|
-
model_dir / "crf_dataset.json", data_to_store
|
|
455
|
-
)
|
|
456
492
|
rasa.shared.utils.io.dump_obj_as_json_to_file(
|
|
457
493
|
model_dir / "crf_order.json", self.crf_order
|
|
458
494
|
)
|
|
495
|
+
if self.entity_taggers is not None:
|
|
496
|
+
for tag_name, entity_tagger in self.entity_taggers.items():
|
|
497
|
+
# Create the directories for storing the CRF model
|
|
498
|
+
tagger_dir = model_dir / TAGGERS_DIR / tag_name
|
|
499
|
+
tagger_dir.mkdir(parents=True, exist_ok=True)
|
|
500
|
+
# Create a plain text version of the CRF model
|
|
501
|
+
entity_tagger.tagger_.dump(
|
|
502
|
+
str(tagger_dir / PLAIN_CRF_MODEL_FILE_NAME)
|
|
503
|
+
)
|
|
504
|
+
# Persist binary version of the model.crfsuite
|
|
505
|
+
shutil.copy2(
|
|
506
|
+
src=entity_tagger.modelfile.name,
|
|
507
|
+
dst=tagger_dir / CRFSUITE_MODEL_FILE_NAME,
|
|
508
|
+
)
|
|
459
509
|
|
|
460
510
|
@classmethod
|
|
461
511
|
def _crf_tokens_to_features(
|
rasa/plugin.py
CHANGED
|
@@ -11,7 +11,7 @@ from rasa.cli import SubParsersAction
|
|
|
11
11
|
|
|
12
12
|
if TYPE_CHECKING:
|
|
13
13
|
from rasa.core.brokers.broker import EventBroker
|
|
14
|
-
from rasa.core.tracker_store import TrackerStore
|
|
14
|
+
from rasa.core.tracker_stores.tracker_store import TrackerStore
|
|
15
15
|
from rasa.shared.core.domain import Domain
|
|
16
16
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
17
17
|
from rasa.utils.endpoints import EndpointConfig
|
|
@@ -32,11 +32,8 @@ def plugin_manager() -> pluggy.PluginManager:
|
|
|
32
32
|
|
|
33
33
|
def init_hooks(manager: pluggy.PluginManager) -> None:
|
|
34
34
|
"""Initialise hooks into rasa."""
|
|
35
|
-
import rasa.utils.licensing
|
|
36
35
|
from rasa import hooks
|
|
37
36
|
|
|
38
|
-
rasa.utils.licensing.validate_license_from_env()
|
|
39
|
-
|
|
40
37
|
manager.register(hooks)
|
|
41
38
|
|
|
42
39
|
|
rasa/server.py
CHANGED
|
@@ -522,12 +522,15 @@ def configure_cors(
|
|
|
522
522
|
)
|
|
523
523
|
|
|
524
524
|
|
|
525
|
-
def add_root_route(app: Sanic) -> None:
|
|
525
|
+
def add_root_route(app: Sanic, is_inspector_enabled: bool = False) -> None:
|
|
526
526
|
"""Add '/' route to return hello."""
|
|
527
527
|
|
|
528
528
|
@app.get("/")
|
|
529
529
|
async def hello(request: Request) -> HTTPResponse:
|
|
530
530
|
"""Check if the server is running and responds with the version."""
|
|
531
|
+
if not is_inspector_enabled:
|
|
532
|
+
return response.text("Hello from Rasa: " + rasa.__version__)
|
|
533
|
+
|
|
531
534
|
html_content = f"""
|
|
532
535
|
<html>
|
|
533
536
|
<body>
|
|
@@ -688,6 +691,7 @@ def create_app(
|
|
|
688
691
|
jwt_private_key: Optional[Text] = None,
|
|
689
692
|
jwt_method: Text = "HS256",
|
|
690
693
|
endpoints: Optional[AvailableEndpoints] = None,
|
|
694
|
+
is_inspector_enabled: bool = False,
|
|
691
695
|
) -> Sanic:
|
|
692
696
|
"""Class representing a Rasa HTTP server."""
|
|
693
697
|
app = Sanic("rasa_server")
|
|
@@ -733,7 +737,7 @@ def create_app(
|
|
|
733
737
|
) -> HTTPResponse:
|
|
734
738
|
return response.json(exception.error_info, status=exception.status)
|
|
735
739
|
|
|
736
|
-
add_root_route(app)
|
|
740
|
+
add_root_route(app, is_inspector_enabled)
|
|
737
741
|
|
|
738
742
|
@app.get("/version")
|
|
739
743
|
async def version(request: Request) -> HTTPResponse:
|
rasa/shared/constants.py
CHANGED
|
@@ -197,7 +197,10 @@ PROVIDER_CONFIG_KEY = "provider"
|
|
|
197
197
|
REQUEST_TIMEOUT_CONFIG_KEY = "request_timeout" # deprecated
|
|
198
198
|
TIMEOUT_CONFIG_KEY = "timeout"
|
|
199
199
|
|
|
200
|
+
LOGIT_BIAS_CONFIG_KEY = "logit_bias"
|
|
201
|
+
MAX_RETRIES_CONFIG_KEY = "max_retries"
|
|
200
202
|
TEMPERATURE_CONFIG_KEY = "temperature"
|
|
203
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY = "max_completion_tokens"
|
|
201
204
|
MAX_TOKENS_CONFIG_KEY = "max_tokens"
|
|
202
205
|
|
|
203
206
|
DEPLOYMENT_NAME_CONFIG_KEY = "deployment_name"
|
|
@@ -238,6 +241,7 @@ EXTRA_PARAMETERS_KEY = "extra_parameters"
|
|
|
238
241
|
MODEL_GROUP_ID_KEY = "model_group_id"
|
|
239
242
|
MODEL_LIST_KEY = "model_list"
|
|
240
243
|
LITELLM_PARAMS_KEY = "litellm_params"
|
|
244
|
+
_VALIDATE_ENVIRONMENT_MISSING_KEYS_KEY = "missing_keys"
|
|
241
245
|
|
|
242
246
|
LLM_API_HEALTH_CHECK_ENV_VAR = "LLM_API_HEALTH_CHECK"
|
|
243
247
|
LLM_API_HEALTH_CHECK_DEFAULT_VALUE = "false"
|