rasa-pro 3.11.7__py3-none-any.whl → 3.11.9__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/cli/inspect.py +8 -4
- rasa/cli/run.py +10 -6
- rasa/cli/utils.py +7 -0
- rasa/core/channels/channel.py +93 -0
- rasa/core/channels/inspector/dist/assets/{arc-f0f8bd46.js → arc-f09fea11.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-7162c77d.js → blockDiagram-38ab4fdb-95518007.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-b1d0d098.js → c4Diagram-3d4e48cf-c91a4a08.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-cc7720dc.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-807a1b27.js → classDiagram-70f12bd4-27f7869b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-5238dcdb.js → classDiagram-v2-f2320105-1ab94cdb.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-3688e1f7.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-75dfaa67.js → createText-2e5e7dd3-a7900089.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-df20501d.js → edges-e0da2a9e-3d5b2697.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-13cf4797.js → erDiagram-9861fffd-443cc11b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-a4991264.js → flowDb-956e92f1-8a6f8c52.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-ccecf773.js → flowDiagram-66a62f08-06a0b4f3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-5055ec2d.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-b5801783.js → flowchart-elk-definition-4a651766-7a01e0b5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-161e079a.js → ganttDiagram-c361ad54-5f1289f2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-f38e86a4.js → gitGraphDiagram-72cf32ee-44409666.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-be6ef5d8.js → graph-3c393c89.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-d9ce8994.js → index-3862675e-4d0c4142.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-7794b245.js → index-b208b2c3.js} +140 -127
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-5000a3dc.js → infoDiagram-f8f76790-ae0fa7ff.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-8ef0a17a.js → journeyDiagram-49397b02-5c3b08cc.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-d649bc98.js → layout-b24c95cb.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-95add810.js → line-999a77c5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-f6025094.js → linear-81a792fd.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-2e8531c4.js → mindmap-definition-fc14e90a-c574f712.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-918adfdb.js → pieDiagram-8a3498a8-1919891d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-cbd01797.js → quadrantDiagram-120e2f19-26e43d09.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-6a8b877b.js → requirementDiagram-deff3bca-f4b22985.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-c377c3fe.js → sankeyDiagram-04a897e0-b957b472.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-ab9e9b7f.js → sequenceDiagram-704730f1-1d8ca073.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-5e6ae67d.js → stateDiagram-587899a1-c67b1b71.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-40643476.js → stateDiagram-v2-d93cdb3a-ee820f55.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-afb8d108.js → styles-6aaf32cf-b162bdf3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-7edc9423.js → styles-9a916d00-67a7b254.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-c1d8f7e9.js → styles-c10674c1-81a8ac73.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-f494b2ef.js → svgDrawCommon-08f97a94-ede42905.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-11c7cdd0.js → timeline-definition-85554ec2-b0f41635.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-3f191ec1.js → xychartDiagram-e933f94c-d715dfb0.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/src/App.tsx +3 -2
- rasa/core/channels/inspector/src/components/Chat.tsx +23 -2
- rasa/core/channels/inspector/src/components/DiagramFlow.tsx +2 -5
- rasa/core/channels/inspector/src/helpers/conversation.ts +16 -0
- rasa/core/channels/inspector/src/types.ts +1 -1
- rasa/core/channels/voice_ready/audiocodes.py +7 -4
- rasa/core/channels/voice_ready/jambonz.py +29 -8
- rasa/core/channels/voice_ready/jambonz_protocol.py +4 -0
- rasa/core/channels/voice_ready/twilio_voice.py +56 -8
- rasa/core/channels/voice_stream/asr/asr_event.py +5 -0
- rasa/core/channels/voice_stream/tts/azure.py +13 -5
- rasa/core/channels/voice_stream/twilio_media_streams.py +110 -32
- rasa/core/channels/voice_stream/voice_channel.py +30 -30
- rasa/e2e_test/utils/validation.py +3 -3
- rasa/shared/constants.py +1 -0
- rasa/shared/providers/_utils.py +84 -0
- rasa/shared/providers/llm/_base_litellm_client.py +5 -3
- rasa/shared/providers/llm/azure_openai_llm_client.py +6 -65
- rasa/shared/providers/router/_base_litellm_router_client.py +55 -1
- rasa/validator.py +1 -2
- rasa/version.py +1 -1
- {rasa_pro-3.11.7.dist-info → rasa_pro-3.11.9.dist-info}/METADATA +5 -5
- {rasa_pro-3.11.7.dist-info → rasa_pro-3.11.9.dist-info}/RECORD +69 -68
- rasa/core/channels/inspector/dist/assets/channel-e265ea59.js +0 -1
- rasa/core/channels/inspector/dist/assets/clone-21f8a43d.js +0 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-5c8ce12d.js +0 -1
- {rasa_pro-3.11.7.dist-info → rasa_pro-3.11.9.dist-info}/NOTICE +0 -0
- {rasa_pro-3.11.7.dist-info → rasa_pro-3.11.9.dist-info}/WHEEL +0 -0
- {rasa_pro-3.11.7.dist-info → rasa_pro-3.11.9.dist-info}/entry_points.txt +0 -0
|
@@ -22,6 +22,7 @@ from rasa.core.channels.voice_stream.asr.asr_event import (
|
|
|
22
22
|
ASREvent,
|
|
23
23
|
NewTranscript,
|
|
24
24
|
UserIsSpeaking,
|
|
25
|
+
UserSilence,
|
|
25
26
|
)
|
|
26
27
|
from sanic import Websocket # type: ignore
|
|
27
28
|
|
|
@@ -244,13 +245,7 @@ class VoiceInputChannel(InputChannel):
|
|
|
244
245
|
self.monitor_silence = monitor_silence
|
|
245
246
|
self.tts_cache = TTSCache(tts_config.get("cache_size", 1000))
|
|
246
247
|
|
|
247
|
-
async def
|
|
248
|
-
self,
|
|
249
|
-
voice_websocket: Websocket,
|
|
250
|
-
on_new_message: Callable[[UserMessage], Awaitable[Any]],
|
|
251
|
-
tts_engine: TTSEngine,
|
|
252
|
-
call_parameters: CallParameters,
|
|
253
|
-
) -> None:
|
|
248
|
+
async def monitor_silence_timeout(self, asr_event_queue: asyncio.Queue) -> None:
|
|
254
249
|
timeout = call_state.silence_timeout
|
|
255
250
|
if not timeout:
|
|
256
251
|
return
|
|
@@ -258,16 +253,8 @@ class VoiceInputChannel(InputChannel):
|
|
|
258
253
|
return
|
|
259
254
|
logger.debug("voice_channel.silence_timeout_watch_started", timeout=timeout)
|
|
260
255
|
await asyncio.sleep(timeout)
|
|
256
|
+
await asr_event_queue.put(UserSilence())
|
|
261
257
|
logger.debug("voice_channel.silence_timeout_tripped")
|
|
262
|
-
output_channel = self.create_output_channel(voice_websocket, tts_engine)
|
|
263
|
-
message = UserMessage(
|
|
264
|
-
"/silence_timeout",
|
|
265
|
-
output_channel,
|
|
266
|
-
call_parameters.stream_id,
|
|
267
|
-
input_channel=self.name(),
|
|
268
|
-
metadata=asdict(call_parameters),
|
|
269
|
-
)
|
|
270
|
-
await on_new_message(message)
|
|
271
258
|
|
|
272
259
|
@staticmethod
|
|
273
260
|
def _cancel_silence_timeout_watcher() -> None:
|
|
@@ -328,6 +315,7 @@ class VoiceInputChannel(InputChannel):
|
|
|
328
315
|
_call_state.set(CallState())
|
|
329
316
|
asr_engine = asr_engine_from_config(self.asr_config)
|
|
330
317
|
tts_engine = tts_engine_from_config(self.tts_config)
|
|
318
|
+
asr_event_queue: asyncio.Queue = asyncio.Queue()
|
|
331
319
|
await asr_engine.connect()
|
|
332
320
|
|
|
333
321
|
call_parameters = await self.collect_call_parameters(channel_websocket)
|
|
@@ -354,12 +342,7 @@ class VoiceInputChannel(InputChannel):
|
|
|
354
342
|
self._cancel_silence_timeout_watcher()
|
|
355
343
|
call_state.silence_timeout_watcher = ( # type: ignore[attr-defined]
|
|
356
344
|
asyncio.create_task(
|
|
357
|
-
self.
|
|
358
|
-
channel_websocket,
|
|
359
|
-
on_new_message,
|
|
360
|
-
tts_engine,
|
|
361
|
-
call_parameters,
|
|
362
|
-
)
|
|
345
|
+
self.monitor_silence_timeout(asr_event_queue)
|
|
363
346
|
)
|
|
364
347
|
)
|
|
365
348
|
if isinstance(channel_action, NewAudioAction):
|
|
@@ -368,8 +351,13 @@ class VoiceInputChannel(InputChannel):
|
|
|
368
351
|
# end stream event came from the other side
|
|
369
352
|
break
|
|
370
353
|
|
|
371
|
-
async def
|
|
354
|
+
async def receive_asr_events() -> None:
|
|
372
355
|
async for event in asr_engine.stream_asr_events():
|
|
356
|
+
await asr_event_queue.put(event)
|
|
357
|
+
|
|
358
|
+
async def handle_asr_events() -> None:
|
|
359
|
+
while True:
|
|
360
|
+
event = await asr_event_queue.get()
|
|
373
361
|
await self.handle_asr_event(
|
|
374
362
|
event,
|
|
375
363
|
channel_websocket,
|
|
@@ -378,16 +366,18 @@ class VoiceInputChannel(InputChannel):
|
|
|
378
366
|
call_parameters,
|
|
379
367
|
)
|
|
380
368
|
|
|
381
|
-
|
|
382
|
-
|
|
369
|
+
tasks = [
|
|
370
|
+
asyncio.create_task(consume_audio_bytes()),
|
|
371
|
+
asyncio.create_task(receive_asr_events()),
|
|
372
|
+
asyncio.create_task(handle_asr_events()),
|
|
373
|
+
]
|
|
383
374
|
await asyncio.wait(
|
|
384
|
-
|
|
375
|
+
tasks,
|
|
385
376
|
return_when=asyncio.FIRST_COMPLETED,
|
|
386
377
|
)
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
asr_event_task.cancel()
|
|
378
|
+
for task in tasks:
|
|
379
|
+
if not task.done():
|
|
380
|
+
task.cancel()
|
|
391
381
|
await tts_engine.close_connection()
|
|
392
382
|
await asr_engine.close_connection()
|
|
393
383
|
await channel_websocket.close()
|
|
@@ -425,3 +415,13 @@ class VoiceInputChannel(InputChannel):
|
|
|
425
415
|
elif isinstance(e, UserIsSpeaking):
|
|
426
416
|
self._cancel_silence_timeout_watcher()
|
|
427
417
|
call_state.is_user_speaking = True # type: ignore[attr-defined]
|
|
418
|
+
elif isinstance(e, UserSilence):
|
|
419
|
+
output_channel = self.create_output_channel(voice_websocket, tts_engine)
|
|
420
|
+
message = UserMessage(
|
|
421
|
+
"/silence_timeout",
|
|
422
|
+
output_channel,
|
|
423
|
+
call_parameters.stream_id,
|
|
424
|
+
input_channel=self.name(),
|
|
425
|
+
metadata=asdict(call_parameters),
|
|
426
|
+
)
|
|
427
|
+
await on_new_message(message)
|
|
@@ -6,6 +6,7 @@ import structlog
|
|
|
6
6
|
|
|
7
7
|
import rasa.shared.utils.io
|
|
8
8
|
from rasa.e2e_test.constants import SCHEMA_FILE_PATH
|
|
9
|
+
from rasa.exceptions import ModelNotFound
|
|
9
10
|
from rasa.shared.utils.yaml import read_schema_file
|
|
10
11
|
|
|
11
12
|
if TYPE_CHECKING:
|
|
@@ -54,10 +55,9 @@ def validate_model_path(model_path: Optional[str], parameter: str, default: str)
|
|
|
54
55
|
return model_path
|
|
55
56
|
|
|
56
57
|
if model_path and not Path(model_path).exists():
|
|
57
|
-
|
|
58
|
+
raise ModelNotFound(
|
|
58
59
|
f"The provided model path '{model_path}' could not be found. "
|
|
59
|
-
|
|
60
|
-
UserWarning,
|
|
60
|
+
"Provide an existing model path."
|
|
61
61
|
)
|
|
62
62
|
|
|
63
63
|
elif model_path is None:
|
rasa/shared/constants.py
CHANGED
|
@@ -220,6 +220,7 @@ EXTRA_PARAMETERS_KEY = "extra_parameters"
|
|
|
220
220
|
MODEL_GROUP_ID_KEY = "model_group_id"
|
|
221
221
|
MODEL_LIST_KEY = "model_list"
|
|
222
222
|
LITELLM_PARAMS_KEY = "litellm_params"
|
|
223
|
+
_VALIDATE_ENVIRONMENT_MISSING_KEYS_KEY = "missing_keys"
|
|
223
224
|
|
|
224
225
|
LLM_API_HEALTH_CHECK_ENV_VAR = "LLM_API_HEALTH_CHECK"
|
|
225
226
|
LLM_API_HEALTH_CHECK_DEFAULT_VALUE = "false"
|
rasa/shared/providers/_utils.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from typing import Optional, Dict, Any
|
|
2
|
+
|
|
1
3
|
import structlog
|
|
2
4
|
|
|
3
5
|
from rasa.shared.constants import (
|
|
@@ -9,6 +11,11 @@ from rasa.shared.constants import (
|
|
|
9
11
|
AWS_REGION_NAME_CONFIG_KEY,
|
|
10
12
|
AWS_SESSION_TOKEN_CONFIG_KEY,
|
|
11
13
|
AWS_SESSION_TOKEN_ENV_VAR,
|
|
14
|
+
AZURE_API_BASE_ENV_VAR,
|
|
15
|
+
API_BASE_CONFIG_KEY,
|
|
16
|
+
AZURE_API_VERSION_ENV_VAR,
|
|
17
|
+
API_VERSION_CONFIG_KEY,
|
|
18
|
+
DEPLOYMENT_CONFIG_KEY,
|
|
12
19
|
)
|
|
13
20
|
from rasa.shared.exceptions import ProviderClientValidationError
|
|
14
21
|
from litellm import validate_environment
|
|
@@ -77,3 +84,80 @@ def validate_aws_setup_for_litellm_clients(
|
|
|
77
84
|
missing_environment_variables=missing_environment_variables,
|
|
78
85
|
)
|
|
79
86
|
raise ProviderClientValidationError(event_info)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def validate_azure_client_setup(
|
|
90
|
+
api_base: Optional[str],
|
|
91
|
+
api_version: Optional[str],
|
|
92
|
+
deployment: Optional[str],
|
|
93
|
+
) -> None:
|
|
94
|
+
"""Validates the Azure setup for LiteLLM Router clients to ensure
|
|
95
|
+
that all required configuration parameters are set.
|
|
96
|
+
|
|
97
|
+
Raises:
|
|
98
|
+
ProviderClientValidationError: If any required Azure configurations
|
|
99
|
+
is missing.
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
def generate_event_info_for_missing_setting(
|
|
103
|
+
setting: str,
|
|
104
|
+
setting_env_var: Optional[str] = None,
|
|
105
|
+
setting_config_key: Optional[str] = None,
|
|
106
|
+
) -> str:
|
|
107
|
+
"""Generate a part of the message with instructions on what to set
|
|
108
|
+
for the missing client setting.
|
|
109
|
+
"""
|
|
110
|
+
info = "Set {setting} with {options}. "
|
|
111
|
+
options = ""
|
|
112
|
+
if setting_env_var is not None:
|
|
113
|
+
options += f"environment variable '{setting_env_var}'"
|
|
114
|
+
if setting_config_key is not None and setting_env_var is not None:
|
|
115
|
+
options += " or "
|
|
116
|
+
if setting_config_key is not None:
|
|
117
|
+
options += f"config key '{setting_config_key}'"
|
|
118
|
+
|
|
119
|
+
return info.format(setting=setting, options=options)
|
|
120
|
+
|
|
121
|
+
# All required settings for Azure OpenAI client
|
|
122
|
+
settings: Dict[str, Dict[str, Any]] = {
|
|
123
|
+
"API Base": {
|
|
124
|
+
"current_value": api_base,
|
|
125
|
+
"env_var": AZURE_API_BASE_ENV_VAR,
|
|
126
|
+
"config_key": API_BASE_CONFIG_KEY,
|
|
127
|
+
},
|
|
128
|
+
"API Version": {
|
|
129
|
+
"current_value": api_version,
|
|
130
|
+
"env_var": AZURE_API_VERSION_ENV_VAR,
|
|
131
|
+
"config_key": API_VERSION_CONFIG_KEY,
|
|
132
|
+
},
|
|
133
|
+
"Deployment Name": {
|
|
134
|
+
"current_value": deployment,
|
|
135
|
+
"env_var": None,
|
|
136
|
+
"config_key": DEPLOYMENT_CONFIG_KEY,
|
|
137
|
+
},
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
missing_settings = [
|
|
141
|
+
setting_name
|
|
142
|
+
for setting_name, setting_info in settings.items()
|
|
143
|
+
if setting_info["current_value"] is None
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
if missing_settings:
|
|
147
|
+
event_info = f"Client settings not set: " f"{', '.join(missing_settings)}. "
|
|
148
|
+
|
|
149
|
+
for missing_setting in missing_settings:
|
|
150
|
+
if settings[missing_setting]["current_value"] is not None:
|
|
151
|
+
continue
|
|
152
|
+
event_info += generate_event_info_for_missing_setting(
|
|
153
|
+
missing_setting,
|
|
154
|
+
settings[missing_setting]["env_var"],
|
|
155
|
+
settings[missing_setting]["config_key"],
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
structlogger.error(
|
|
159
|
+
"azure_openai_llm_client.not_configured",
|
|
160
|
+
event_info=event_info,
|
|
161
|
+
missing_settings=missing_settings,
|
|
162
|
+
)
|
|
163
|
+
raise ProviderClientValidationError(event_info)
|
|
@@ -9,7 +9,11 @@ from litellm import (
|
|
|
9
9
|
validate_environment,
|
|
10
10
|
)
|
|
11
11
|
|
|
12
|
-
from rasa.shared.constants import
|
|
12
|
+
from rasa.shared.constants import (
|
|
13
|
+
API_BASE_CONFIG_KEY,
|
|
14
|
+
API_KEY,
|
|
15
|
+
_VALIDATE_ENVIRONMENT_MISSING_KEYS_KEY,
|
|
16
|
+
)
|
|
13
17
|
from rasa.shared.exceptions import (
|
|
14
18
|
ProviderClientAPIException,
|
|
15
19
|
ProviderClientValidationError,
|
|
@@ -23,8 +27,6 @@ from rasa.shared.utils.io import suppress_logs, resolve_environment_variables
|
|
|
23
27
|
|
|
24
28
|
structlogger = structlog.get_logger()
|
|
25
29
|
|
|
26
|
-
_VALIDATE_ENVIRONMENT_MISSING_KEYS_KEY = "missing_keys"
|
|
27
|
-
|
|
28
30
|
# Suppress LiteLLM info and debug logs - Global level.
|
|
29
31
|
logging.getLogger("LiteLLM").setLevel(logging.WARNING)
|
|
30
32
|
|
|
@@ -9,9 +9,6 @@ from rasa.shared.constants import (
|
|
|
9
9
|
OPENAI_API_VERSION_ENV_VAR,
|
|
10
10
|
AZURE_API_BASE_ENV_VAR,
|
|
11
11
|
AZURE_API_VERSION_ENV_VAR,
|
|
12
|
-
API_BASE_CONFIG_KEY,
|
|
13
|
-
API_VERSION_CONFIG_KEY,
|
|
14
|
-
DEPLOYMENT_CONFIG_KEY,
|
|
15
12
|
AZURE_API_KEY_ENV_VAR,
|
|
16
13
|
OPENAI_API_TYPE_ENV_VAR,
|
|
17
14
|
OPENAI_API_KEY_ENV_VAR,
|
|
@@ -23,6 +20,7 @@ from rasa.shared.exceptions import ProviderClientValidationError
|
|
|
23
20
|
from rasa.shared.providers._configs.azure_openai_client_config import (
|
|
24
21
|
AzureOpenAIClientConfig,
|
|
25
22
|
)
|
|
23
|
+
from rasa.shared.providers._utils import validate_azure_client_setup
|
|
26
24
|
from rasa.shared.providers.llm._base_litellm_client import _BaseLiteLLMClient
|
|
27
25
|
from rasa.shared.utils.io import raise_deprecation_warning
|
|
28
26
|
|
|
@@ -295,65 +293,8 @@ class AzureOpenAILLMClient(_BaseLiteLLMClient):
|
|
|
295
293
|
def validate_client_setup(self) -> None:
|
|
296
294
|
"""Validates that all required configuration parameters are set."""
|
|
297
295
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
)
|
|
303
|
-
"""Generate a part of the message with instructions on what to set
|
|
304
|
-
for the missing client setting.
|
|
305
|
-
"""
|
|
306
|
-
info = "Set {setting} with {options}. "
|
|
307
|
-
options = ""
|
|
308
|
-
if setting_env_var is not None:
|
|
309
|
-
options += f"environment variable '{setting_env_var}'"
|
|
310
|
-
if setting_config_key is not None and setting_env_var is not None:
|
|
311
|
-
options += " or "
|
|
312
|
-
if setting_config_key is not None:
|
|
313
|
-
options += f"config key '{setting_config_key}'"
|
|
314
|
-
|
|
315
|
-
return info.format(setting=setting, options=options)
|
|
316
|
-
|
|
317
|
-
# All required settings for Azure OpenAI client
|
|
318
|
-
settings: Dict[str, Dict[str, Any]] = {
|
|
319
|
-
"API Base": {
|
|
320
|
-
"current_value": self.api_base,
|
|
321
|
-
"env_var": AZURE_API_BASE_ENV_VAR,
|
|
322
|
-
"config_key": API_BASE_CONFIG_KEY,
|
|
323
|
-
},
|
|
324
|
-
"API Version": {
|
|
325
|
-
"current_value": self.api_version,
|
|
326
|
-
"env_var": AZURE_API_VERSION_ENV_VAR,
|
|
327
|
-
"config_key": API_VERSION_CONFIG_KEY,
|
|
328
|
-
},
|
|
329
|
-
"Deployment Name": {
|
|
330
|
-
"current_value": self.deployment,
|
|
331
|
-
"env_var": None,
|
|
332
|
-
"config_key": DEPLOYMENT_CONFIG_KEY,
|
|
333
|
-
},
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
missing_settings = [
|
|
337
|
-
setting_name
|
|
338
|
-
for setting_name, setting_info in settings.items()
|
|
339
|
-
if setting_info["current_value"] is None
|
|
340
|
-
]
|
|
341
|
-
|
|
342
|
-
if missing_settings:
|
|
343
|
-
event_info = f"Client settings not set: " f"{', '.join(missing_settings)}. "
|
|
344
|
-
|
|
345
|
-
for missing_setting in missing_settings:
|
|
346
|
-
if settings[missing_setting]["current_value"] is not None:
|
|
347
|
-
continue
|
|
348
|
-
event_info += generate_event_info_for_missing_setting(
|
|
349
|
-
missing_setting,
|
|
350
|
-
settings[missing_setting]["env_var"],
|
|
351
|
-
settings[missing_setting]["config_key"],
|
|
352
|
-
)
|
|
353
|
-
|
|
354
|
-
structlogger.error(
|
|
355
|
-
"azure_openai_llm_client.not_configured",
|
|
356
|
-
event_info=event_info,
|
|
357
|
-
missing_settings=missing_settings,
|
|
358
|
-
)
|
|
359
|
-
raise ProviderClientValidationError(event_info)
|
|
296
|
+
return validate_azure_client_setup(
|
|
297
|
+
api_base=self.api_base,
|
|
298
|
+
api_version=self.api_version,
|
|
299
|
+
deployment=self.deployment,
|
|
300
|
+
)
|
|
@@ -2,7 +2,7 @@ from typing import Any, Dict, List
|
|
|
2
2
|
import os
|
|
3
3
|
import structlog
|
|
4
4
|
|
|
5
|
-
from litellm import Router
|
|
5
|
+
from litellm import Router, validate_environment
|
|
6
6
|
|
|
7
7
|
from rasa.shared.constants import (
|
|
8
8
|
MODEL_LIST_KEY,
|
|
@@ -14,11 +14,18 @@ from rasa.shared.constants import (
|
|
|
14
14
|
API_KEY,
|
|
15
15
|
MODEL_CONFIG_KEY,
|
|
16
16
|
USE_CHAT_COMPLETIONS_ENDPOINT_CONFIG_KEY,
|
|
17
|
+
API_BASE_CONFIG_KEY,
|
|
18
|
+
_VALIDATE_ENVIRONMENT_MISSING_KEYS_KEY,
|
|
19
|
+
AZURE_OPENAI_PROVIDER,
|
|
20
|
+
API_VERSION_CONFIG_KEY,
|
|
21
|
+
AZURE_API_BASE_ENV_VAR,
|
|
22
|
+
AZURE_API_VERSION_ENV_VAR,
|
|
17
23
|
)
|
|
18
24
|
from rasa.shared.exceptions import ProviderClientValidationError
|
|
19
25
|
from rasa.shared.providers._configs.litellm_router_client_config import (
|
|
20
26
|
LiteLLMRouterClientConfig,
|
|
21
27
|
)
|
|
28
|
+
from rasa.shared.providers._utils import validate_azure_client_setup
|
|
22
29
|
from rasa.shared.utils.io import resolve_environment_variables
|
|
23
30
|
|
|
24
31
|
structlogger = structlog.get_logger()
|
|
@@ -62,6 +69,7 @@ class _BaseLiteLLMRouterClient:
|
|
|
62
69
|
resolved_model_configurations = (
|
|
63
70
|
self._resolve_env_vars_in_model_configurations()
|
|
64
71
|
)
|
|
72
|
+
self._validate_model_configurations(resolved_model_configurations)
|
|
65
73
|
self._router_client = Router(
|
|
66
74
|
model_list=resolved_model_configurations, **router_settings
|
|
67
75
|
)
|
|
@@ -181,3 +189,49 @@ class _BaseLiteLLMRouterClient:
|
|
|
181
189
|
)
|
|
182
190
|
model_configuration_with_resolved_keys.append(resolved_model_configuration)
|
|
183
191
|
return model_configuration_with_resolved_keys
|
|
192
|
+
|
|
193
|
+
def _validate_model_configurations(
|
|
194
|
+
self, resolved_model_configurations: List[Dict[str, Any]]
|
|
195
|
+
) -> None:
|
|
196
|
+
"""Validates the model configurations.
|
|
197
|
+
|
|
198
|
+
Args:
|
|
199
|
+
resolved_model_configurations: (List[Dict[str, Any]]) The list of model
|
|
200
|
+
configurations with resolved environment variables.
|
|
201
|
+
|
|
202
|
+
Raises:
|
|
203
|
+
ProviderClientValidationError: If the model configurations are invalid.
|
|
204
|
+
"""
|
|
205
|
+
for model_configuration in resolved_model_configurations:
|
|
206
|
+
litellm_params = model_configuration.get(LITELLM_PARAMS_KEY, {})
|
|
207
|
+
|
|
208
|
+
model = litellm_params.get(MODEL_CONFIG_KEY)
|
|
209
|
+
provider, deployment = model.split("/", 1)
|
|
210
|
+
api_base = litellm_params.get(API_BASE_CONFIG_KEY)
|
|
211
|
+
|
|
212
|
+
if provider.lower() == AZURE_OPENAI_PROVIDER:
|
|
213
|
+
validate_azure_client_setup(
|
|
214
|
+
api_base=api_base or os.getenv(AZURE_API_BASE_ENV_VAR),
|
|
215
|
+
api_version=litellm_params.get(API_VERSION_CONFIG_KEY)
|
|
216
|
+
or os.getenv(AZURE_API_VERSION_ENV_VAR),
|
|
217
|
+
deployment=deployment,
|
|
218
|
+
)
|
|
219
|
+
else:
|
|
220
|
+
validation_info = validate_environment(
|
|
221
|
+
model=model,
|
|
222
|
+
api_key=litellm_params.get(API_KEY),
|
|
223
|
+
api_base=api_base,
|
|
224
|
+
)
|
|
225
|
+
if missing_environment_variables := validation_info.get(
|
|
226
|
+
_VALIDATE_ENVIRONMENT_MISSING_KEYS_KEY
|
|
227
|
+
):
|
|
228
|
+
event_info = (
|
|
229
|
+
f"Environment variables: {missing_environment_variables} "
|
|
230
|
+
f"not set. Required for API calls."
|
|
231
|
+
)
|
|
232
|
+
structlogger.error(
|
|
233
|
+
"base_litellm_router_client.validate_environment_variables",
|
|
234
|
+
event_info=event_info,
|
|
235
|
+
missing_environment_variables=missing_environment_variables,
|
|
236
|
+
)
|
|
237
|
+
raise ProviderClientValidationError(event_info)
|
rasa/validator.py
CHANGED
|
@@ -518,7 +518,7 @@ class Validator:
|
|
|
518
518
|
condition_active_loop
|
|
519
519
|
and condition_active_loop not in self.domain.form_names
|
|
520
520
|
):
|
|
521
|
-
structlogger.
|
|
521
|
+
structlogger.error(
|
|
522
522
|
"validator.verify_slot_mappings.not_in_domain",
|
|
523
523
|
slot=slot.name,
|
|
524
524
|
form=condition_active_loop,
|
|
@@ -553,7 +553,6 @@ class Validator:
|
|
|
553
553
|
f"The slot needs to be added to this key."
|
|
554
554
|
),
|
|
555
555
|
)
|
|
556
|
-
everything_is_alright = False
|
|
557
556
|
|
|
558
557
|
return everything_is_alright
|
|
559
558
|
|
rasa/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: rasa-pro
|
|
3
|
-
Version: 3.11.
|
|
3
|
+
Version: 3.11.9
|
|
4
4
|
Summary: State-of-the-art open-core Conversational AI framework for Enterprises that natively leverages generative AI for effortless assistant development.
|
|
5
5
|
Keywords: nlp,machine-learning,machine-learning-library,bot,bots,botkit,rasa conversational-agents,conversational-ai,chatbot,chatbot-framework,bot-framework
|
|
6
6
|
Author: Rasa Technologies GmbH
|
|
@@ -62,13 +62,13 @@ Requires-Dist: jsonschema (>=4.22)
|
|
|
62
62
|
Requires-Dist: keras (==2.14.0)
|
|
63
63
|
Requires-Dist: langchain (>=0.2.17,<0.3.0)
|
|
64
64
|
Requires-Dist: langchain-community (>=0.2.19,<0.3.0)
|
|
65
|
-
Requires-Dist: litellm (>=1.
|
|
65
|
+
Requires-Dist: litellm (>=1.64.1,<1.65.0)
|
|
66
66
|
Requires-Dist: matplotlib (>=3.7,<3.8)
|
|
67
67
|
Requires-Dist: mattermostwrapper (>=2.2,<2.3)
|
|
68
68
|
Requires-Dist: mlflow (>=2.15.1,<3.0.0) ; extra == "mlflow"
|
|
69
69
|
Requires-Dist: networkx (>=3.1,<3.2)
|
|
70
70
|
Requires-Dist: numpy (>=1.26.4,<1.27.0)
|
|
71
|
-
Requires-Dist: openai (>=1.
|
|
71
|
+
Requires-Dist: openai (>=1.68.2,<1.69.0)
|
|
72
72
|
Requires-Dist: openpyxl (>=3.1.5,<4.0.0)
|
|
73
73
|
Requires-Dist: opentelemetry-api (>=1.16.0,<1.17.0)
|
|
74
74
|
Requires-Dist: opentelemetry-exporter-jaeger (>=1.16.0,<1.17.0)
|
|
@@ -116,7 +116,7 @@ Requires-Dist: scikit-learn (>=1.5.1,<1.6.0)
|
|
|
116
116
|
Requires-Dist: scipy (>=1.13.1,<1.14.0)
|
|
117
117
|
Requires-Dist: sentencepiece[sentencepiece] (>=0.1.99,<0.2.0) ; extra == "transformers" or extra == "full"
|
|
118
118
|
Requires-Dist: sentry-sdk (>=1.14.0,<1.15.0)
|
|
119
|
-
Requires-Dist: setuptools (>=
|
|
119
|
+
Requires-Dist: setuptools (>=78.1.0,<78.2.0)
|
|
120
120
|
Requires-Dist: sklearn-crfsuite (>=0.3.6,<0.4.0)
|
|
121
121
|
Requires-Dist: skops (>=0.10.0,<0.11.0)
|
|
122
122
|
Requires-Dist: slack-sdk (>=3.27.1,<3.28.0)
|
|
@@ -146,7 +146,7 @@ Requires-Dist: typing-utils (>=0.1.0,<0.2.0)
|
|
|
146
146
|
Requires-Dist: ujson (>=5.8,<6.0)
|
|
147
147
|
Requires-Dist: webexteamssdk (>=1.6.1,<1.7.0)
|
|
148
148
|
Requires-Dist: websockets (>=10.4,<11.0)
|
|
149
|
-
Requires-Dist: wheel (>=0.
|
|
149
|
+
Requires-Dist: wheel (>=0.45.1)
|
|
150
150
|
Project-URL: Documentation, https://rasa.com/docs
|
|
151
151
|
Project-URL: Homepage, https://rasa.com
|
|
152
152
|
Project-URL: Repository, https://github.com/rasahq/rasa
|