rasa-pro 3.11.0__py3-none-any.whl → 3.11.0a2__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.
- README.md +396 -17
- rasa/__main__.py +15 -31
- rasa/api.py +1 -5
- rasa/cli/arguments/default_arguments.py +2 -1
- rasa/cli/arguments/shell.py +1 -5
- rasa/cli/arguments/train.py +0 -14
- rasa/cli/e2e_test.py +1 -1
- rasa/cli/evaluate.py +8 -8
- rasa/cli/inspect.py +5 -7
- rasa/cli/interactive.py +0 -1
- rasa/cli/llm_fine_tuning.py +1 -1
- rasa/cli/project_templates/calm/config.yml +7 -5
- rasa/cli/project_templates/calm/endpoints.yml +2 -15
- rasa/cli/project_templates/tutorial/config.yml +5 -8
- rasa/cli/project_templates/tutorial/data/flows.yml +1 -1
- rasa/cli/project_templates/tutorial/data/patterns.yml +0 -5
- rasa/cli/project_templates/tutorial/domain.yml +0 -14
- rasa/cli/project_templates/tutorial/endpoints.yml +0 -5
- rasa/cli/run.py +1 -1
- rasa/cli/scaffold.py +2 -4
- rasa/cli/studio/studio.py +8 -18
- rasa/cli/studio/upload.py +15 -0
- rasa/cli/train.py +0 -3
- rasa/cli/utils.py +1 -6
- rasa/cli/x.py +8 -8
- rasa/constants.py +1 -3
- rasa/core/actions/action.py +33 -75
- rasa/core/actions/e2e_stub_custom_action_executor.py +1 -5
- rasa/core/actions/http_custom_action_executor.py +0 -4
- rasa/core/channels/channel.py +0 -20
- rasa/core/channels/development_inspector.py +2 -8
- rasa/core/channels/inspector/dist/assets/{arc-bc141fb2.js → arc-6852c607.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-d0fbc5ce-be2db283.js → c4Diagram-d0fbc5ce-acc952b2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-936ed81e-55366915.js → classDiagram-936ed81e-848a7597.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-c3cb15f1-bb529518.js → classDiagram-v2-c3cb15f1-a73d3e68.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{createText-62fc7601-b0ec81d6.js → createText-62fc7601-e5ee049d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-f2ad444c-6166330c.js → edges-f2ad444c-771e517e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9d236eb7-5ccc6a8e.js → erDiagram-9d236eb7-aa347178.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-1972c806-fca3bfe4.js → flowDb-1972c806-651fc57d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-7ea5b25a-4739080f.js → flowDiagram-7ea5b25a-ca67804f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-587d82d8.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-abe16c3d-7c1b0e0f.js → flowchart-elk-definition-abe16c3d-2dbc568d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-9b5ea136-772fd050.js → ganttDiagram-9b5ea136-25a65bd8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-99d0ae7c-8eae1dc9.js → gitGraphDiagram-99d0ae7c-fdc7378d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-2c4b9a3b-f55afcdf.js → index-2c4b9a3b-6f1fd606.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-e7cef9de.js → index-efdd30c1.js} +68 -68
- rasa/core/channels/inspector/dist/assets/{infoDiagram-736b4530-124d4a14.js → infoDiagram-736b4530-cb1a041a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-df861f2b-7c4fae44.js → journeyDiagram-df861f2b-14609879.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-b9885fb6.js → layout-2490f52b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-7c59abb6.js → line-40186f1f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-4776f780.js → linear-08814e93.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-beec6740-2332c46c.js → mindmap-definition-beec6740-1a534584.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-dbbf0591-8fb39303.js → pieDiagram-dbbf0591-72397b61.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-4d7f4fd6-3c7180a2.js → quadrantDiagram-4d7f4fd6-3bb0b6a3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-6fc4c22a-e910bcb8.js → requirementDiagram-6fc4c22a-57334f61.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-8f13d901-ead16c89.js → sankeyDiagram-8f13d901-111e1297.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-b655622a-29a02a19.js → sequenceDiagram-b655622a-10bcfe62.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-59f0c015-042b3137.js → stateDiagram-59f0c015-acaf7513.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-2b26beab-2178c0f3.js → stateDiagram-v2-2b26beab-3ec2a235.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-080da4f6-23ffa4fc.js → styles-080da4f6-62730289.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-3dcbcfbf-94f59763.js → styles-3dcbcfbf-5284ee76.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9c745c82-78a6bebc.js → styles-9c745c82-642435e3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-4835440b-eae2a6f6.js → svgDrawCommon-4835440b-b250a350.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-5b62e21b-5c968d92.js → timeline-definition-5b62e21b-c2b147ed.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-2b33534f-fd3db0d5.js → xychartDiagram-2b33534f-f92cfea9.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/src/App.tsx +1 -1
- rasa/core/channels/inspector/src/helpers/audiostream.ts +16 -77
- rasa/core/channels/socketio.py +2 -7
- rasa/core/channels/telegram.py +1 -1
- rasa/core/channels/twilio.py +1 -1
- rasa/core/channels/voice_ready/audiocodes.py +4 -15
- rasa/core/channels/voice_ready/jambonz.py +4 -15
- rasa/core/channels/voice_ready/twilio_voice.py +21 -6
- rasa/core/channels/voice_ready/utils.py +5 -6
- rasa/core/channels/voice_stream/asr/asr_engine.py +1 -19
- rasa/core/channels/voice_stream/asr/asr_event.py +0 -5
- rasa/core/channels/voice_stream/asr/deepgram.py +15 -28
- rasa/core/channels/voice_stream/audio_bytes.py +0 -1
- rasa/core/channels/voice_stream/browser_audio.py +9 -32
- rasa/core/channels/voice_stream/tts/azure.py +3 -9
- rasa/core/channels/voice_stream/tts/cartesia.py +8 -12
- rasa/core/channels/voice_stream/tts/tts_engine.py +1 -11
- rasa/core/channels/voice_stream/twilio_media_streams.py +19 -28
- rasa/core/channels/voice_stream/util.py +4 -4
- rasa/core/channels/voice_stream/voice_channel.py +42 -222
- rasa/core/featurizers/single_state_featurizer.py +1 -22
- rasa/core/featurizers/tracker_featurizers.py +18 -115
- rasa/core/information_retrieval/qdrant.py +0 -1
- rasa/core/nlg/contextual_response_rephraser.py +25 -44
- rasa/core/persistor.py +34 -191
- rasa/core/policies/enterprise_search_policy.py +60 -119
- rasa/core/policies/flows/flow_executor.py +4 -7
- rasa/core/policies/intentless_policy.py +22 -82
- rasa/core/policies/ted_policy.py +33 -58
- rasa/core/policies/unexpected_intent_policy.py +7 -15
- rasa/core/processor.py +5 -32
- rasa/core/training/interactive.py +35 -34
- rasa/core/utils.py +22 -58
- rasa/dialogue_understanding/coexistence/llm_based_router.py +12 -39
- rasa/dialogue_understanding/commands/__init__.py +0 -4
- rasa/dialogue_understanding/commands/change_flow_command.py +0 -6
- rasa/dialogue_understanding/commands/utils.py +0 -5
- rasa/dialogue_understanding/generator/constants.py +0 -2
- rasa/dialogue_understanding/generator/flow_retrieval.py +4 -49
- rasa/dialogue_understanding/generator/llm_based_command_generator.py +23 -37
- rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +10 -57
- rasa/dialogue_understanding/generator/nlu_command_adapter.py +1 -19
- rasa/dialogue_understanding/generator/single_step/command_prompt_template.jinja2 +0 -3
- rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +10 -90
- rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +0 -53
- rasa/dialogue_understanding/processor/command_processor.py +1 -21
- rasa/e2e_test/assertions.py +16 -133
- rasa/e2e_test/assertions_schema.yml +0 -23
- rasa/e2e_test/e2e_test_case.py +6 -85
- rasa/e2e_test/e2e_test_runner.py +4 -6
- rasa/e2e_test/utils/io.py +1 -3
- rasa/engine/loader.py +0 -12
- rasa/engine/validation.py +11 -541
- rasa/keys +1 -0
- rasa/llm_fine_tuning/notebooks/unsloth_finetuning.ipynb +407 -0
- rasa/model_training.py +7 -29
- rasa/nlu/classifiers/diet_classifier.py +25 -38
- rasa/nlu/classifiers/logistic_regression_classifier.py +9 -22
- rasa/nlu/classifiers/sklearn_intent_classifier.py +16 -37
- rasa/nlu/extractors/crf_entity_extractor.py +50 -93
- rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py +16 -45
- rasa/nlu/featurizers/sparse_featurizer/lexical_syntactic_featurizer.py +17 -52
- rasa/nlu/featurizers/sparse_featurizer/regex_featurizer.py +3 -5
- rasa/nlu/tokenizers/whitespace_tokenizer.py +14 -3
- rasa/server.py +1 -3
- rasa/shared/constants.py +0 -61
- rasa/shared/core/constants.py +0 -9
- rasa/shared/core/domain.py +5 -8
- rasa/shared/core/flows/flow.py +0 -5
- rasa/shared/core/flows/flows_list.py +1 -5
- rasa/shared/core/flows/flows_yaml_schema.json +0 -10
- rasa/shared/core/flows/validation.py +0 -96
- rasa/shared/core/flows/yaml_flows_io.py +4 -13
- rasa/shared/core/slots.py +0 -5
- rasa/shared/importers/importer.py +2 -19
- rasa/shared/importers/rasa.py +1 -5
- rasa/shared/nlu/training_data/features.py +2 -120
- rasa/shared/nlu/training_data/formats/rasa_yaml.py +3 -18
- rasa/shared/providers/_configs/azure_openai_client_config.py +3 -5
- rasa/shared/providers/_configs/openai_client_config.py +1 -1
- rasa/shared/providers/_configs/self_hosted_llm_client_config.py +0 -1
- rasa/shared/providers/_configs/utils.py +0 -16
- rasa/shared/providers/embedding/_base_litellm_embedding_client.py +29 -18
- rasa/shared/providers/embedding/azure_openai_embedding_client.py +21 -54
- rasa/shared/providers/embedding/default_litellm_embedding_client.py +0 -24
- rasa/shared/providers/llm/_base_litellm_client.py +31 -63
- rasa/shared/providers/llm/azure_openai_llm_client.py +29 -50
- rasa/shared/providers/llm/default_litellm_llm_client.py +0 -24
- rasa/shared/providers/llm/self_hosted_llm_client.py +29 -17
- rasa/shared/providers/mappings.py +0 -19
- rasa/shared/utils/common.py +2 -37
- rasa/shared/utils/io.py +6 -28
- rasa/shared/utils/llm.py +46 -353
- rasa/shared/utils/yaml.py +82 -181
- rasa/studio/auth.py +5 -3
- rasa/studio/config.py +4 -13
- rasa/studio/constants.py +0 -1
- rasa/studio/data_handler.py +4 -13
- rasa/studio/upload.py +80 -175
- rasa/telemetry.py +17 -94
- rasa/tracing/config.py +1 -3
- rasa/tracing/instrumentation/attribute_extractors.py +17 -94
- rasa/tracing/instrumentation/instrumentation.py +0 -121
- rasa/utils/common.py +0 -5
- rasa/utils/endpoints.py +1 -27
- rasa/utils/io.py +81 -7
- rasa/utils/log_utils.py +2 -9
- rasa/utils/tensorflow/model_data.py +193 -2
- rasa/validator.py +4 -110
- rasa/version.py +1 -1
- rasa_pro-3.11.0a2.dist-info/METADATA +576 -0
- {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a2.dist-info}/RECORD +181 -213
- rasa/core/actions/action_repeat_bot_messages.py +0 -89
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-736177bf.js +0 -1
- rasa/core/channels/voice_stream/asr/azure.py +0 -129
- rasa/core/channels/voice_stream/call_state.py +0 -23
- rasa/dialogue_understanding/commands/repeat_bot_messages_command.py +0 -60
- rasa/dialogue_understanding/commands/user_silence_command.py +0 -59
- rasa/dialogue_understanding/patterns/repeat.py +0 -37
- rasa/dialogue_understanding/patterns/user_silence.py +0 -37
- rasa/model_manager/__init__.py +0 -0
- rasa/model_manager/config.py +0 -40
- rasa/model_manager/model_api.py +0 -559
- rasa/model_manager/runner_service.py +0 -286
- rasa/model_manager/socket_bridge.py +0 -146
- rasa/model_manager/studio_jwt_auth.py +0 -86
- rasa/model_manager/trainer_service.py +0 -325
- rasa/model_manager/utils.py +0 -87
- rasa/model_manager/warm_rasa_process.py +0 -187
- rasa/model_service.py +0 -112
- rasa/shared/core/flows/utils.py +0 -39
- rasa/shared/providers/_configs/litellm_router_client_config.py +0 -220
- rasa/shared/providers/_configs/model_group_config.py +0 -167
- rasa/shared/providers/_configs/rasa_llm_client_config.py +0 -73
- rasa/shared/providers/_utils.py +0 -79
- rasa/shared/providers/embedding/litellm_router_embedding_client.py +0 -135
- rasa/shared/providers/llm/litellm_router_llm_client.py +0 -182
- rasa/shared/providers/llm/rasa_llm_client.py +0 -112
- rasa/shared/providers/router/__init__.py +0 -0
- rasa/shared/providers/router/_base_litellm_router_client.py +0 -183
- rasa/shared/providers/router/router_client.py +0 -73
- rasa/shared/utils/health_check/__init__.py +0 -0
- rasa/shared/utils/health_check/embeddings_health_check_mixin.py +0 -31
- rasa/shared/utils/health_check/health_check.py +0 -258
- rasa/shared/utils/health_check/llm_health_check_mixin.py +0 -31
- rasa/utils/sanic_error_handler.py +0 -32
- rasa/utils/tensorflow/feature_array.py +0 -366
- rasa_pro-3.11.0.dist-info/METADATA +0 -198
- {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a2.dist-info}/NOTICE +0 -0
- {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a2.dist-info}/WHEEL +0 -0
- {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a2.dist-info}/entry_points.txt +0 -0
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
from typing import Optional, Dict, Any, List
|
|
2
|
-
|
|
3
|
-
from rasa.core.actions.action import Action
|
|
4
|
-
from rasa.core.channels import OutputChannel
|
|
5
|
-
from rasa.core.nlg import NaturalLanguageGenerator
|
|
6
|
-
from rasa.dialogue_understanding.patterns.collect_information import (
|
|
7
|
-
CollectInformationPatternFlowStackFrame,
|
|
8
|
-
)
|
|
9
|
-
from rasa.dialogue_understanding.patterns.repeat import (
|
|
10
|
-
RepeatBotMessagesPatternFlowStackFrame,
|
|
11
|
-
)
|
|
12
|
-
from rasa.dialogue_understanding.patterns.user_silence import (
|
|
13
|
-
UserSilencePatternFlowStackFrame,
|
|
14
|
-
)
|
|
15
|
-
from rasa.shared.core.constants import ACTION_REPEAT_BOT_MESSAGES
|
|
16
|
-
from rasa.shared.core.domain import Domain
|
|
17
|
-
from rasa.shared.core.events import Event, BotUttered, UserUttered
|
|
18
|
-
from rasa.shared.core.trackers import DialogueStateTracker
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class ActionRepeatBotMessages(Action):
|
|
22
|
-
"""Action to repeat bot messages"""
|
|
23
|
-
|
|
24
|
-
def name(self) -> str:
|
|
25
|
-
"""Return the name of the action."""
|
|
26
|
-
return ACTION_REPEAT_BOT_MESSAGES
|
|
27
|
-
|
|
28
|
-
def _get_last_bot_events(self, tracker: DialogueStateTracker) -> List[Event]:
|
|
29
|
-
"""Get the last consecutive bot events before the most recent user message.
|
|
30
|
-
|
|
31
|
-
This function scans the dialogue history in reverse to find the last sequence of
|
|
32
|
-
bot responses that occurred without any user interruption. It filters out all
|
|
33
|
-
non-utterance events and stops when it encounters a user message after finding
|
|
34
|
-
bot messages.
|
|
35
|
-
|
|
36
|
-
Args:
|
|
37
|
-
tracker: DialogueStateTracker containing the conversation events.
|
|
38
|
-
|
|
39
|
-
Returns:
|
|
40
|
-
List[Event]: A list of consecutive BotUttered events that occurred
|
|
41
|
-
most recently, in chronological order. Returns an empty list
|
|
42
|
-
if no bot messages are found or if the last message was from
|
|
43
|
-
the user.
|
|
44
|
-
|
|
45
|
-
Example:
|
|
46
|
-
For events: [User1, Bot1, Bot2, User2, Bot4, Bot5, User3]
|
|
47
|
-
Returns: [Bot4, Bot5] (the last two bot events)
|
|
48
|
-
The elif condition doesn't break when it sees User3 event.
|
|
49
|
-
But it does at User2 event.
|
|
50
|
-
"""
|
|
51
|
-
# Skip action if we are in a collect information step whose
|
|
52
|
-
# default behavior is to repeat anyways
|
|
53
|
-
top_frame = tracker.stack.top(
|
|
54
|
-
lambda frame: isinstance(frame, RepeatBotMessagesPatternFlowStackFrame)
|
|
55
|
-
or isinstance(frame, UserSilencePatternFlowStackFrame)
|
|
56
|
-
)
|
|
57
|
-
if isinstance(top_frame, CollectInformationPatternFlowStackFrame):
|
|
58
|
-
return []
|
|
59
|
-
# filter user and bot events
|
|
60
|
-
filtered = [
|
|
61
|
-
e for e in tracker.events if isinstance(e, (BotUttered, UserUttered))
|
|
62
|
-
]
|
|
63
|
-
bot_events: List[Event] = []
|
|
64
|
-
|
|
65
|
-
# find the last BotUttered events
|
|
66
|
-
for e in reversed(filtered):
|
|
67
|
-
if isinstance(e, BotUttered):
|
|
68
|
-
# insert instead of append because the list is reversed
|
|
69
|
-
bot_events.insert(0, e)
|
|
70
|
-
|
|
71
|
-
# stop if a UserUttered event is found
|
|
72
|
-
# only if we have collected some bot events already
|
|
73
|
-
# this condition skips the first N UserUttered events
|
|
74
|
-
elif bot_events:
|
|
75
|
-
break
|
|
76
|
-
|
|
77
|
-
return bot_events
|
|
78
|
-
|
|
79
|
-
async def run(
|
|
80
|
-
self,
|
|
81
|
-
output_channel: OutputChannel,
|
|
82
|
-
nlg: NaturalLanguageGenerator,
|
|
83
|
-
tracker: DialogueStateTracker,
|
|
84
|
-
domain: Domain,
|
|
85
|
-
metadata: Optional[Dict[str, Any]] = None,
|
|
86
|
-
) -> List[Event]:
|
|
87
|
-
"""Send the last bot messages to the channel again"""
|
|
88
|
-
bot_events = self._get_last_bot_events(tracker)
|
|
89
|
-
return bot_events
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{p as e,f as o}from"./flowDb-1972c806-fca3bfe4.js";import{f as t,g as a}from"./styles-080da4f6-23ffa4fc.js";import{t as s}from"./index-e7cef9de.js";import"./layout-b9885fb6.js";import"./index-2c4b9a3b-f55afcdf.js";import"./edges-f2ad444c-6166330c.js";import"./createText-62fc7601-b0ec81d6.js";import"./line-7c59abb6.js";import"./array-9f3ba611.js";import"./path-53f90ab3.js";const k={parser:e,db:o,renderer:t,styles:a,init:r=>{r.flowchart||(r.flowchart={}),r.flowchart.arrowMarkerAbsolute=r.arrowMarkerAbsolute,s({flowchart:{arrowMarkerAbsolute:r.arrowMarkerAbsolute}}),t.setConf(r.flowchart),o.clear(),o.setGen("gen-2")}};export{k as diagram};
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from dataclasses import dataclass
|
|
3
|
-
from typing import Any, Dict, Optional, AsyncIterator
|
|
4
|
-
import asyncio
|
|
5
|
-
|
|
6
|
-
from rasa.core.channels.voice_stream.asr.asr_engine import ASREngine, ASREngineConfig
|
|
7
|
-
from rasa.core.channels.voice_stream.asr.asr_event import (
|
|
8
|
-
ASREvent,
|
|
9
|
-
NewTranscript,
|
|
10
|
-
UserIsSpeaking,
|
|
11
|
-
)
|
|
12
|
-
from rasa.core.channels.voice_stream.audio_bytes import HERTZ, RasaAudioBytes
|
|
13
|
-
from rasa.shared.constants import AZURE_SPEECH_API_KEY_ENV_VAR
|
|
14
|
-
from rasa.shared.exceptions import ConnectionException
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@dataclass
|
|
18
|
-
class AzureASRConfig(ASREngineConfig):
|
|
19
|
-
language: Optional[str] = None
|
|
20
|
-
speech_region: Optional[str] = None
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class AzureASR(ASREngine[AzureASRConfig]):
|
|
24
|
-
required_env_vars = (AZURE_SPEECH_API_KEY_ENV_VAR,)
|
|
25
|
-
required_packages = ("azure.cognitiveservices.speech",)
|
|
26
|
-
|
|
27
|
-
def __init__(self, config: Optional[AzureASRConfig] = None):
|
|
28
|
-
super().__init__(config)
|
|
29
|
-
|
|
30
|
-
import azure.cognitiveservices.speech as speechsdk
|
|
31
|
-
|
|
32
|
-
self.speech_recognizer: Optional[speechsdk.SpeechRecognizer] = None
|
|
33
|
-
self.stream: Optional[speechsdk.audio.PushAudioInputStream] = None
|
|
34
|
-
self.is_recognizing = False
|
|
35
|
-
self.queue: asyncio.Queue[speechsdk.SpeechRecognitionEventArgs] = (
|
|
36
|
-
asyncio.Queue()
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
@staticmethod
|
|
40
|
-
def validate_environment() -> None:
|
|
41
|
-
"""Make sure all needed requirements for this component are met."""
|
|
42
|
-
|
|
43
|
-
def signal_user_is_speaking(self, event: Any) -> None:
|
|
44
|
-
"""Replace the azure event with a generic is speaking event."""
|
|
45
|
-
self.fill_queue(UserIsSpeaking())
|
|
46
|
-
|
|
47
|
-
def fill_queue(self, event: Any) -> None:
|
|
48
|
-
"""Either puts the event or a dedicated ASR Event into the queue."""
|
|
49
|
-
self.queue.put_nowait(event)
|
|
50
|
-
|
|
51
|
-
async def connect(self) -> None:
|
|
52
|
-
import azure.cognitiveservices.speech as speechsdk
|
|
53
|
-
|
|
54
|
-
speech_config = speechsdk.SpeechConfig(
|
|
55
|
-
subscription=os.environ[AZURE_SPEECH_API_KEY_ENV_VAR],
|
|
56
|
-
region=self.config.speech_region,
|
|
57
|
-
)
|
|
58
|
-
audio_format = speechsdk.audio.AudioStreamFormat(
|
|
59
|
-
samples_per_second=HERTZ,
|
|
60
|
-
bits_per_sample=8,
|
|
61
|
-
channels=1,
|
|
62
|
-
wave_stream_format=speechsdk.AudioStreamWaveFormat.MULAW,
|
|
63
|
-
)
|
|
64
|
-
self.stream = speechsdk.audio.PushAudioInputStream(stream_format=audio_format)
|
|
65
|
-
audio_config = speechsdk.audio.AudioConfig(stream=self.stream)
|
|
66
|
-
self.speech_recognizer = speechsdk.SpeechRecognizer(
|
|
67
|
-
speech_config=speech_config,
|
|
68
|
-
language=self.config.language,
|
|
69
|
-
audio_config=audio_config,
|
|
70
|
-
)
|
|
71
|
-
self.speech_recognizer.recognized.connect(self.fill_queue)
|
|
72
|
-
self.speech_recognizer.recognizing.connect(self.signal_user_is_speaking)
|
|
73
|
-
self.speech_recognizer.start_continuous_recognition_async()
|
|
74
|
-
self.is_recognizing = True
|
|
75
|
-
|
|
76
|
-
async def close_connection(self) -> None:
|
|
77
|
-
if self.speech_recognizer is None:
|
|
78
|
-
raise ConnectionException("Websocket not connected.")
|
|
79
|
-
self.speech_recognizer.stop_continuous_recognition_async()
|
|
80
|
-
|
|
81
|
-
async def signal_audio_done(self) -> None:
|
|
82
|
-
"""Signal to the ASR Api that you are done sending data."""
|
|
83
|
-
self.is_recognizing = False
|
|
84
|
-
|
|
85
|
-
def rasa_audio_bytes_to_engine_bytes(self, chunk: RasaAudioBytes) -> bytes:
|
|
86
|
-
"""Convert RasaAudioBytes to bytes usable by this engine."""
|
|
87
|
-
return chunk
|
|
88
|
-
|
|
89
|
-
async def send_audio_chunks(self, chunk: RasaAudioBytes) -> None:
|
|
90
|
-
"""Send audio chunks to the ASR system via the websocket."""
|
|
91
|
-
if self.speech_recognizer is None or self.stream is None:
|
|
92
|
-
raise ConnectionException("ASR not connected.")
|
|
93
|
-
engine_bytes = self.rasa_audio_bytes_to_engine_bytes(chunk)
|
|
94
|
-
self.stream.write(engine_bytes)
|
|
95
|
-
|
|
96
|
-
async def stream_asr_events(self) -> AsyncIterator[ASREvent]:
|
|
97
|
-
"""Stream the events returned by the ASR system as it is fed audio bytes."""
|
|
98
|
-
if self.speech_recognizer is None:
|
|
99
|
-
raise ConnectionException("Websocket not connected.")
|
|
100
|
-
while self.is_recognizing or not self.queue.empty():
|
|
101
|
-
try:
|
|
102
|
-
message = await asyncio.wait_for(self.queue.get(), timeout=2)
|
|
103
|
-
asr_event = self.engine_event_to_asr_event(message)
|
|
104
|
-
if asr_event:
|
|
105
|
-
yield asr_event
|
|
106
|
-
except asyncio.TimeoutError:
|
|
107
|
-
pass
|
|
108
|
-
|
|
109
|
-
def engine_event_to_asr_event(self, e: Any) -> Optional[ASREvent]:
|
|
110
|
-
"""Translate an engine event to a common ASREvent."""
|
|
111
|
-
import azure.cognitiveservices.speech as speechsdk
|
|
112
|
-
|
|
113
|
-
if isinstance(e, speechsdk.SpeechRecognitionEventArgs) and isinstance(
|
|
114
|
-
e.result, speechsdk.SpeechRecognitionResult
|
|
115
|
-
):
|
|
116
|
-
return NewTranscript(e.result.text)
|
|
117
|
-
if isinstance(e, ASREvent):
|
|
118
|
-
# transformation happened before
|
|
119
|
-
return e
|
|
120
|
-
|
|
121
|
-
return None
|
|
122
|
-
|
|
123
|
-
@staticmethod
|
|
124
|
-
def get_default_config() -> AzureASRConfig:
|
|
125
|
-
return AzureASRConfig("en-US", "germanywestcentral")
|
|
126
|
-
|
|
127
|
-
@classmethod
|
|
128
|
-
def from_config_dict(cls, config: Dict) -> "AzureASR":
|
|
129
|
-
return AzureASR(AzureASRConfig.from_dict(config))
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import asyncio
|
|
2
|
-
from contextvars import ContextVar
|
|
3
|
-
from werkzeug.local import LocalProxy
|
|
4
|
-
from dataclasses import dataclass
|
|
5
|
-
from typing import Optional
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
# Per voice session data
|
|
9
|
-
# This is similar to how flask makes the "request" object available as a global variable
|
|
10
|
-
# It's a "global" variable that is local to an async task (i.e. websocket session)
|
|
11
|
-
@dataclass
|
|
12
|
-
class CallState:
|
|
13
|
-
is_user_speaking: bool = False
|
|
14
|
-
is_bot_speaking: bool = False
|
|
15
|
-
silence_timeout_watcher: Optional[asyncio.Task] = None
|
|
16
|
-
silence_timeout: Optional[float] = None
|
|
17
|
-
latest_bot_audio_id: Optional[str] = None
|
|
18
|
-
should_hangup: bool = False
|
|
19
|
-
connection_failed: bool = False
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
_call_state: ContextVar[CallState] = ContextVar("call_state")
|
|
23
|
-
call_state = LocalProxy(_call_state)
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from dataclasses import dataclass
|
|
4
|
-
from typing import Any, Dict, List
|
|
5
|
-
from rasa.dialogue_understanding.commands import Command
|
|
6
|
-
from rasa.dialogue_understanding.patterns.repeat import (
|
|
7
|
-
RepeatBotMessagesPatternFlowStackFrame,
|
|
8
|
-
)
|
|
9
|
-
from rasa.shared.core.events import Event
|
|
10
|
-
from rasa.shared.core.flows import FlowsList
|
|
11
|
-
from rasa.shared.core.trackers import DialogueStateTracker
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@dataclass
|
|
15
|
-
class RepeatBotMessagesCommand(Command):
|
|
16
|
-
"""A command to indicate that the bot should repeat its last messages."""
|
|
17
|
-
|
|
18
|
-
@classmethod
|
|
19
|
-
def command(cls) -> str:
|
|
20
|
-
"""Returns the command type."""
|
|
21
|
-
return "repeat"
|
|
22
|
-
|
|
23
|
-
@classmethod
|
|
24
|
-
def from_dict(cls, data: Dict[str, Any]) -> RepeatBotMessagesCommand:
|
|
25
|
-
"""Converts the dictionary to a command.
|
|
26
|
-
|
|
27
|
-
Returns:
|
|
28
|
-
The converted dictionary.
|
|
29
|
-
"""
|
|
30
|
-
return RepeatBotMessagesCommand()
|
|
31
|
-
|
|
32
|
-
def run_command_on_tracker(
|
|
33
|
-
self,
|
|
34
|
-
tracker: DialogueStateTracker,
|
|
35
|
-
all_flows: FlowsList,
|
|
36
|
-
original_tracker: DialogueStateTracker,
|
|
37
|
-
) -> List[Event]:
|
|
38
|
-
"""Runs the command on the tracker.
|
|
39
|
-
Get all the bot utterances until last user utterance and repeat them.
|
|
40
|
-
|
|
41
|
-
Args:
|
|
42
|
-
tracker: The tracker to run the command on.
|
|
43
|
-
all_flows: All flows in the assistant.
|
|
44
|
-
original_tracker: The tracker before any command was executed.
|
|
45
|
-
|
|
46
|
-
Returns:
|
|
47
|
-
The events to apply to the tracker.
|
|
48
|
-
"""
|
|
49
|
-
stack = tracker.stack
|
|
50
|
-
stack.push(RepeatBotMessagesPatternFlowStackFrame())
|
|
51
|
-
return tracker.create_stack_updated_events(stack)
|
|
52
|
-
|
|
53
|
-
def __hash__(self) -> int:
|
|
54
|
-
return hash(self.command())
|
|
55
|
-
|
|
56
|
-
def __eq__(self, other: object) -> bool:
|
|
57
|
-
if not isinstance(other, RepeatBotMessagesCommand):
|
|
58
|
-
return False
|
|
59
|
-
|
|
60
|
-
return True
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from dataclasses import dataclass
|
|
4
|
-
from typing import Any, Dict, List
|
|
5
|
-
from rasa.dialogue_understanding.commands import Command
|
|
6
|
-
from rasa.dialogue_understanding.patterns.user_silence import (
|
|
7
|
-
UserSilencePatternFlowStackFrame,
|
|
8
|
-
)
|
|
9
|
-
from rasa.shared.core.events import Event
|
|
10
|
-
from rasa.shared.core.flows import FlowsList
|
|
11
|
-
from rasa.shared.core.trackers import DialogueStateTracker
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@dataclass
|
|
15
|
-
class UserSilenceCommand(Command):
|
|
16
|
-
"""A command to indicate user silence."""
|
|
17
|
-
|
|
18
|
-
@classmethod
|
|
19
|
-
def command(cls) -> str:
|
|
20
|
-
"""Returns the command type."""
|
|
21
|
-
return "user silence"
|
|
22
|
-
|
|
23
|
-
@classmethod
|
|
24
|
-
def from_dict(cls, data: Dict[str, Any]) -> UserSilenceCommand:
|
|
25
|
-
"""Converts the dictionary to a command.
|
|
26
|
-
|
|
27
|
-
Returns:
|
|
28
|
-
The converted dictionary.
|
|
29
|
-
"""
|
|
30
|
-
return UserSilenceCommand()
|
|
31
|
-
|
|
32
|
-
def run_command_on_tracker(
|
|
33
|
-
self,
|
|
34
|
-
tracker: DialogueStateTracker,
|
|
35
|
-
all_flows: FlowsList,
|
|
36
|
-
original_tracker: DialogueStateTracker,
|
|
37
|
-
) -> List[Event]:
|
|
38
|
-
"""Runs the command on the tracker.
|
|
39
|
-
|
|
40
|
-
Args:
|
|
41
|
-
tracker: The tracker to run the command on.
|
|
42
|
-
all_flows: All flows in the assistant.
|
|
43
|
-
original_tracker: The tracker before any command was executed.
|
|
44
|
-
|
|
45
|
-
Returns:
|
|
46
|
-
The events to apply to the tracker.
|
|
47
|
-
"""
|
|
48
|
-
stack = tracker.stack
|
|
49
|
-
stack.push(UserSilencePatternFlowStackFrame())
|
|
50
|
-
return tracker.create_stack_updated_events(stack)
|
|
51
|
-
|
|
52
|
-
def __hash__(self) -> int:
|
|
53
|
-
return hash(self.command())
|
|
54
|
-
|
|
55
|
-
def __eq__(self, other: object) -> bool:
|
|
56
|
-
if not isinstance(other, UserSilenceCommand):
|
|
57
|
-
return False
|
|
58
|
-
|
|
59
|
-
return True
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from dataclasses import dataclass
|
|
4
|
-
from typing import Any, Dict
|
|
5
|
-
|
|
6
|
-
from rasa.dialogue_understanding.stack.frames import PatternFlowStackFrame
|
|
7
|
-
from rasa.shared.constants import RASA_DEFAULT_FLOW_PATTERN_PREFIX
|
|
8
|
-
|
|
9
|
-
FLOW_PATTERN_REPEAT = RASA_DEFAULT_FLOW_PATTERN_PREFIX + "repeat_bot_messages"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@dataclass
|
|
13
|
-
class RepeatBotMessagesPatternFlowStackFrame(PatternFlowStackFrame):
|
|
14
|
-
"""A flow stack frame that can get added when bot messages should be repeated"""
|
|
15
|
-
|
|
16
|
-
flow_id: str = FLOW_PATTERN_REPEAT
|
|
17
|
-
"""The ID of the flow."""
|
|
18
|
-
|
|
19
|
-
@classmethod
|
|
20
|
-
def type(cls) -> str:
|
|
21
|
-
"""Returns the type of the frame."""
|
|
22
|
-
return FLOW_PATTERN_REPEAT
|
|
23
|
-
|
|
24
|
-
@staticmethod
|
|
25
|
-
def from_dict(data: Dict[str, Any]) -> RepeatBotMessagesPatternFlowStackFrame:
|
|
26
|
-
"""Creates a `DialogueStackFrame` from a dictionary.
|
|
27
|
-
|
|
28
|
-
Args:
|
|
29
|
-
data: The dictionary to create the `DialogueStackFrame` from.
|
|
30
|
-
|
|
31
|
-
Returns:
|
|
32
|
-
The created `DialogueStackFrame`.
|
|
33
|
-
"""
|
|
34
|
-
return RepeatBotMessagesPatternFlowStackFrame(
|
|
35
|
-
frame_id=data["frame_id"],
|
|
36
|
-
step_id=data["step_id"],
|
|
37
|
-
)
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
from dataclasses import dataclass
|
|
3
|
-
from typing import Any, Dict
|
|
4
|
-
|
|
5
|
-
from rasa.dialogue_understanding.stack.frames import PatternFlowStackFrame
|
|
6
|
-
from rasa.shared.constants import RASA_DEFAULT_FLOW_PATTERN_PREFIX
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
FLOW_PATTERN_USER_SILENCE = RASA_DEFAULT_FLOW_PATTERN_PREFIX + "user_silence"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@dataclass
|
|
13
|
-
class UserSilencePatternFlowStackFrame(PatternFlowStackFrame):
|
|
14
|
-
"""A flow stack frame that can get added when the silence timeout trips."""
|
|
15
|
-
|
|
16
|
-
flow_id: str = FLOW_PATTERN_USER_SILENCE
|
|
17
|
-
"""The ID of the flow."""
|
|
18
|
-
|
|
19
|
-
@classmethod
|
|
20
|
-
def type(cls) -> str:
|
|
21
|
-
"""Returns the type of the frame."""
|
|
22
|
-
return FLOW_PATTERN_USER_SILENCE
|
|
23
|
-
|
|
24
|
-
@staticmethod
|
|
25
|
-
def from_dict(data: Dict[str, Any]) -> UserSilencePatternFlowStackFrame:
|
|
26
|
-
"""Creates a `DialogueStackFrame` from a dictionary.
|
|
27
|
-
|
|
28
|
-
Args:
|
|
29
|
-
data: The dictionary to create the `DialogueStackFrame` from.
|
|
30
|
-
|
|
31
|
-
Returns:
|
|
32
|
-
The created `DialogueStackFrame`.
|
|
33
|
-
"""
|
|
34
|
-
return UserSilencePatternFlowStackFrame(
|
|
35
|
-
frame_id=data["frame_id"],
|
|
36
|
-
step_id=data["step_id"],
|
|
37
|
-
)
|
rasa/model_manager/__init__.py
DELETED
|
File without changes
|
rasa/model_manager/config.py
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
import os
|
|
3
|
-
|
|
4
|
-
DEFAULT_SERVER_BASE_WORKING_DIRECTORY = "working-data"
|
|
5
|
-
|
|
6
|
-
SERVER_BASE_WORKING_DIRECTORY = os.environ.get(
|
|
7
|
-
"RASA_MODEL_SERVER_BASE_DIRECTORY", DEFAULT_SERVER_BASE_WORKING_DIRECTORY
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
SERVER_PORT = os.environ.get("RASA_MODEL_SERVER_PORT", 8000)
|
|
11
|
-
|
|
12
|
-
SERVER_BASE_URL = os.environ.get("RASA_MODEL_SERVER_BASE_URL", None)
|
|
13
|
-
|
|
14
|
-
# defaults to storing on the local hard drive
|
|
15
|
-
SERVER_MODEL_REMOTE_STORAGE = os.environ.get("RASA_REMOTE_STORAGE", None)
|
|
16
|
-
|
|
17
|
-
# The path to the python executable that is running this script
|
|
18
|
-
# we will use the same python to run training / bots
|
|
19
|
-
RASA_PYTHON_PATH = sys.executable
|
|
20
|
-
|
|
21
|
-
# the max limit for parallel training requests
|
|
22
|
-
DEFAULT_MAX_PARALLEL_TRAININGS = 10
|
|
23
|
-
|
|
24
|
-
MAX_PARALLEL_TRAININGS = os.getenv(
|
|
25
|
-
"MAX_PARALLEL_TRAININGS", DEFAULT_MAX_PARALLEL_TRAININGS
|
|
26
|
-
)
|
|
27
|
-
# the max limit for parallel running bots
|
|
28
|
-
DEFAULT_MAX_PARALLEL_BOT_RUNS = 10
|
|
29
|
-
|
|
30
|
-
MAX_PARALLEL_BOT_RUNS = os.getenv(
|
|
31
|
-
"MAX_PARALLEL_BOT_RUNS", DEFAULT_MAX_PARALLEL_BOT_RUNS
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
DEFAULT_SERVER_PATH_PREFIX = "talk"
|
|
35
|
-
|
|
36
|
-
DEFAULT_MIN_REQUIRED_DISCSPACE_MB = 1
|
|
37
|
-
|
|
38
|
-
MIN_REQUIRED_DISCSPACE_MB = int(
|
|
39
|
-
os.getenv("MIN_REQUIRED_DISCSPACE_MB", DEFAULT_MIN_REQUIRED_DISCSPACE_MB)
|
|
40
|
-
)
|