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,135 +0,0 @@
|
|
|
1
|
-
from typing import Any, Dict, List
|
|
2
|
-
import logging
|
|
3
|
-
import structlog
|
|
4
|
-
|
|
5
|
-
from rasa.shared.exceptions import ProviderClientAPIException
|
|
6
|
-
from rasa.shared.providers._configs.litellm_router_client_config import (
|
|
7
|
-
LiteLLMRouterClientConfig,
|
|
8
|
-
)
|
|
9
|
-
from rasa.shared.providers.embedding._base_litellm_embedding_client import (
|
|
10
|
-
_BaseLiteLLMEmbeddingClient,
|
|
11
|
-
)
|
|
12
|
-
from rasa.shared.providers.embedding.embedding_response import EmbeddingResponse
|
|
13
|
-
from rasa.shared.providers.router._base_litellm_router_client import (
|
|
14
|
-
_BaseLiteLLMRouterClient,
|
|
15
|
-
)
|
|
16
|
-
from rasa.shared.utils.io import suppress_logs
|
|
17
|
-
|
|
18
|
-
structlogger = structlog.get_logger()
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class LiteLLMRouterEmbeddingClient(
|
|
22
|
-
_BaseLiteLLMRouterClient, _BaseLiteLLMEmbeddingClient
|
|
23
|
-
):
|
|
24
|
-
"""A client for interfacing with LiteLLM Router Embedding endpoints.
|
|
25
|
-
|
|
26
|
-
Parameters:
|
|
27
|
-
model_group_id (str): The model group ID.
|
|
28
|
-
model_configurations (List[Dict[str, Any]]): The list of model configurations.
|
|
29
|
-
router_settings (Dict[str, Any]): The router settings.
|
|
30
|
-
kwargs (Optional[Dict[str, Any]]): Additional configuration parameters.
|
|
31
|
-
|
|
32
|
-
Raises:
|
|
33
|
-
ProviderClientValidationError: If validation of the client setup fails.
|
|
34
|
-
"""
|
|
35
|
-
|
|
36
|
-
def __init__(
|
|
37
|
-
self,
|
|
38
|
-
model_group_id: str,
|
|
39
|
-
model_configurations: List[Dict[str, Any]],
|
|
40
|
-
router_settings: Dict[str, Any],
|
|
41
|
-
**kwargs: Any,
|
|
42
|
-
):
|
|
43
|
-
super().__init__(
|
|
44
|
-
model_group_id, model_configurations, router_settings, **kwargs
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
@classmethod
|
|
48
|
-
def from_config(cls, config: Dict[str, Any]) -> "LiteLLMRouterEmbeddingClient":
|
|
49
|
-
"""Instantiates a LiteLLM Router Embedding client from a configuration dict.
|
|
50
|
-
|
|
51
|
-
Args:
|
|
52
|
-
config: (Dict[str, Any]) The configuration dictionary.
|
|
53
|
-
|
|
54
|
-
Returns:
|
|
55
|
-
LiteLLMRouterLLMClient: The instantiated LiteLLM Router LLM client.
|
|
56
|
-
|
|
57
|
-
Raises:
|
|
58
|
-
ValueError: If the configuration is invalid.
|
|
59
|
-
"""
|
|
60
|
-
try:
|
|
61
|
-
client_config = LiteLLMRouterClientConfig.from_dict(config)
|
|
62
|
-
except (KeyError, ValueError) as e:
|
|
63
|
-
message = "Cannot instantiate a client from the passed configuration."
|
|
64
|
-
structlogger.error(
|
|
65
|
-
"litellm_router_llm_client.from_config.error",
|
|
66
|
-
message=message,
|
|
67
|
-
config=config,
|
|
68
|
-
original_error=e,
|
|
69
|
-
)
|
|
70
|
-
raise
|
|
71
|
-
|
|
72
|
-
return cls(
|
|
73
|
-
model_group_id=client_config.model_group_id,
|
|
74
|
-
model_configurations=client_config.litellm_model_list,
|
|
75
|
-
router_settings=client_config.litellm_router_settings,
|
|
76
|
-
**client_config.extra_parameters,
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
@suppress_logs(log_level=logging.WARNING)
|
|
80
|
-
def embed(self, documents: List[str]) -> EmbeddingResponse:
|
|
81
|
-
"""
|
|
82
|
-
Embeds a list of documents synchronously.
|
|
83
|
-
|
|
84
|
-
Args:
|
|
85
|
-
documents: List of documents to be embedded.
|
|
86
|
-
|
|
87
|
-
Returns:
|
|
88
|
-
List of embedding vectors.
|
|
89
|
-
|
|
90
|
-
Raises:
|
|
91
|
-
ProviderClientAPIException: If API calls raised an error.
|
|
92
|
-
"""
|
|
93
|
-
self.validate_documents(documents)
|
|
94
|
-
try:
|
|
95
|
-
response = self.router_client.embedding(
|
|
96
|
-
input=documents, **self._embedding_fn_args
|
|
97
|
-
)
|
|
98
|
-
return self._format_response(response)
|
|
99
|
-
except Exception as e:
|
|
100
|
-
raise ProviderClientAPIException(
|
|
101
|
-
message="Failed to embed documents", original_exception=e
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
@suppress_logs(log_level=logging.WARNING)
|
|
105
|
-
async def aembed(self, documents: List[str]) -> EmbeddingResponse:
|
|
106
|
-
"""
|
|
107
|
-
Embeds a list of documents asynchronously.
|
|
108
|
-
|
|
109
|
-
Args:
|
|
110
|
-
documents: List of documents to be embedded.
|
|
111
|
-
|
|
112
|
-
Returns:
|
|
113
|
-
List of embedding vectors.
|
|
114
|
-
|
|
115
|
-
Raises:
|
|
116
|
-
ProviderClientAPIException: If API calls raised an error.
|
|
117
|
-
"""
|
|
118
|
-
self.validate_documents(documents)
|
|
119
|
-
try:
|
|
120
|
-
response = await self.router_client.aembedding(
|
|
121
|
-
input=documents, **self._embedding_fn_args
|
|
122
|
-
)
|
|
123
|
-
return self._format_response(response)
|
|
124
|
-
except Exception as e:
|
|
125
|
-
raise ProviderClientAPIException(
|
|
126
|
-
message="Failed to embed documents", original_exception=e
|
|
127
|
-
)
|
|
128
|
-
|
|
129
|
-
@property
|
|
130
|
-
def _embedding_fn_args(self) -> Dict[str, Any]:
|
|
131
|
-
"""Returns the arguments to be passed to the embedding function."""
|
|
132
|
-
return {
|
|
133
|
-
**self._litellm_extra_parameters,
|
|
134
|
-
"model": self._model_group_id,
|
|
135
|
-
}
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
from typing import Any, Dict, List, Union
|
|
2
|
-
import logging
|
|
3
|
-
import structlog
|
|
4
|
-
|
|
5
|
-
from rasa.shared.exceptions import ProviderClientAPIException
|
|
6
|
-
from rasa.shared.providers._configs.litellm_router_client_config import (
|
|
7
|
-
LiteLLMRouterClientConfig,
|
|
8
|
-
)
|
|
9
|
-
from rasa.shared.providers.llm._base_litellm_client import _BaseLiteLLMClient
|
|
10
|
-
from rasa.shared.providers.llm.llm_response import LLMResponse
|
|
11
|
-
from rasa.shared.providers.router._base_litellm_router_client import (
|
|
12
|
-
_BaseLiteLLMRouterClient,
|
|
13
|
-
)
|
|
14
|
-
from rasa.shared.utils.io import suppress_logs
|
|
15
|
-
|
|
16
|
-
structlogger = structlog.get_logger()
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class LiteLLMRouterLLMClient(_BaseLiteLLMRouterClient, _BaseLiteLLMClient):
|
|
20
|
-
"""A client for interfacing with LiteLLM Router LLM endpoints.
|
|
21
|
-
|
|
22
|
-
Parameters:
|
|
23
|
-
model_group_id (str): The model group ID.
|
|
24
|
-
model_configurations (List[Dict[str, Any]]): The list of model configurations.
|
|
25
|
-
router_settings (Dict[str, Any]): The router settings.
|
|
26
|
-
kwargs (Optional[Dict[str, Any]]): Additional configuration parameters.
|
|
27
|
-
|
|
28
|
-
Raises:
|
|
29
|
-
ProviderClientValidationError: If validation of the client setup fails.
|
|
30
|
-
"""
|
|
31
|
-
|
|
32
|
-
def __init__(
|
|
33
|
-
self,
|
|
34
|
-
model_group_id: str,
|
|
35
|
-
model_configurations: List[Dict[str, Any]],
|
|
36
|
-
router_settings: Dict[str, Any],
|
|
37
|
-
**kwargs: Any,
|
|
38
|
-
):
|
|
39
|
-
super().__init__(
|
|
40
|
-
model_group_id, model_configurations, router_settings, **kwargs
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
@classmethod
|
|
44
|
-
def from_config(cls, config: Dict[str, Any]) -> "LiteLLMRouterLLMClient":
|
|
45
|
-
"""Instantiates a LiteLLM Router LLM client from a configuration dict.
|
|
46
|
-
|
|
47
|
-
Args:
|
|
48
|
-
config: (Dict[str, Any]) The configuration dictionary.
|
|
49
|
-
|
|
50
|
-
Returns:
|
|
51
|
-
LiteLLMRouterLLMClient: The instantiated LiteLLM Router LLM client.
|
|
52
|
-
|
|
53
|
-
Raises:
|
|
54
|
-
ValueError: If the configuration is invalid.
|
|
55
|
-
"""
|
|
56
|
-
try:
|
|
57
|
-
client_config = LiteLLMRouterClientConfig.from_dict(config)
|
|
58
|
-
except (KeyError, ValueError) as e:
|
|
59
|
-
message = "Cannot instantiate a client from the passed configuration."
|
|
60
|
-
structlogger.error(
|
|
61
|
-
"litellm_router_llm_client.from_config.error",
|
|
62
|
-
message=message,
|
|
63
|
-
config=config,
|
|
64
|
-
original_error=e,
|
|
65
|
-
)
|
|
66
|
-
raise
|
|
67
|
-
|
|
68
|
-
return cls(
|
|
69
|
-
model_group_id=client_config.model_group_id,
|
|
70
|
-
model_configurations=client_config.litellm_model_list,
|
|
71
|
-
router_settings=client_config.litellm_router_settings,
|
|
72
|
-
use_chat_completions_endpoint=client_config.use_chat_completions_endpoint,
|
|
73
|
-
**client_config.extra_parameters,
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
@suppress_logs(log_level=logging.WARNING)
|
|
77
|
-
def _text_completion(self, prompt: Union[List[str], str]) -> LLMResponse:
|
|
78
|
-
"""
|
|
79
|
-
Synchronously generate completions for given prompt.
|
|
80
|
-
|
|
81
|
-
Args:
|
|
82
|
-
prompt: Prompt to generate the completion for.
|
|
83
|
-
Returns:
|
|
84
|
-
List of message completions.
|
|
85
|
-
Raises:
|
|
86
|
-
ProviderClientAPIException: If the API request fails.
|
|
87
|
-
"""
|
|
88
|
-
try:
|
|
89
|
-
response = self.router_client.text_completion(
|
|
90
|
-
prompt=prompt, **self._completion_fn_args
|
|
91
|
-
)
|
|
92
|
-
return self._format_text_completion_response(response)
|
|
93
|
-
except Exception as e:
|
|
94
|
-
raise ProviderClientAPIException(e)
|
|
95
|
-
|
|
96
|
-
@suppress_logs(log_level=logging.WARNING)
|
|
97
|
-
async def _atext_completion(self, prompt: Union[List[str], str]) -> LLMResponse:
|
|
98
|
-
"""
|
|
99
|
-
Asynchronously generate completions for given prompt.
|
|
100
|
-
|
|
101
|
-
Args:
|
|
102
|
-
prompt: Prompt to generate the completion for.
|
|
103
|
-
Returns:
|
|
104
|
-
List of message completions.
|
|
105
|
-
Raises:
|
|
106
|
-
ProviderClientAPIException: If the API request fails.
|
|
107
|
-
"""
|
|
108
|
-
try:
|
|
109
|
-
response = await self.router_client.atext_completion(
|
|
110
|
-
prompt=prompt, **self._completion_fn_args
|
|
111
|
-
)
|
|
112
|
-
return self._format_text_completion_response(response)
|
|
113
|
-
except Exception as e:
|
|
114
|
-
raise ProviderClientAPIException(e)
|
|
115
|
-
|
|
116
|
-
@suppress_logs(log_level=logging.WARNING)
|
|
117
|
-
def completion(self, messages: Union[List[str], str]) -> LLMResponse:
|
|
118
|
-
"""
|
|
119
|
-
Synchronously generate completions for given list of messages.
|
|
120
|
-
|
|
121
|
-
Method overrides the base class method to call the appropriate
|
|
122
|
-
completion method based on the configuration. If the chat completions
|
|
123
|
-
endpoint is enabled, the completion method is called. Otherwise, the
|
|
124
|
-
text_completion method is called.
|
|
125
|
-
|
|
126
|
-
Args:
|
|
127
|
-
messages: List of messages or a single message to generate the
|
|
128
|
-
completion for.
|
|
129
|
-
Returns:
|
|
130
|
-
List of message completions.
|
|
131
|
-
Raises:
|
|
132
|
-
ProviderClientAPIException: If the API request fails.
|
|
133
|
-
"""
|
|
134
|
-
if not self._use_chat_completions_endpoint:
|
|
135
|
-
return self._text_completion(messages)
|
|
136
|
-
try:
|
|
137
|
-
formatted_messages = self._format_messages(messages)
|
|
138
|
-
response = self.router_client.completion(
|
|
139
|
-
messages=formatted_messages, **self._completion_fn_args
|
|
140
|
-
)
|
|
141
|
-
return self._format_response(response)
|
|
142
|
-
except Exception as e:
|
|
143
|
-
raise ProviderClientAPIException(e)
|
|
144
|
-
|
|
145
|
-
@suppress_logs(log_level=logging.WARNING)
|
|
146
|
-
async def acompletion(self, messages: Union[List[str], str]) -> LLMResponse:
|
|
147
|
-
"""
|
|
148
|
-
Asynchronously generate completions for given list of messages.
|
|
149
|
-
|
|
150
|
-
Method overrides the base class method to call the appropriate
|
|
151
|
-
completion method based on the configuration. If the chat completions
|
|
152
|
-
endpoint is enabled, the completion method is called. Otherwise, the
|
|
153
|
-
text_completion method is called.
|
|
154
|
-
|
|
155
|
-
Args:
|
|
156
|
-
messages: List of messages or a single message to generate the
|
|
157
|
-
completion for.
|
|
158
|
-
Returns:
|
|
159
|
-
List of message completions.
|
|
160
|
-
Raises:
|
|
161
|
-
ProviderClientAPIException: If the API request fails.
|
|
162
|
-
"""
|
|
163
|
-
if not self._use_chat_completions_endpoint:
|
|
164
|
-
return await self._atext_completion(messages)
|
|
165
|
-
try:
|
|
166
|
-
formatted_messages = self._format_messages(messages)
|
|
167
|
-
response = await self.router_client.acompletion(
|
|
168
|
-
messages=formatted_messages, **self._completion_fn_args
|
|
169
|
-
)
|
|
170
|
-
return self._format_response(response)
|
|
171
|
-
except Exception as e:
|
|
172
|
-
raise ProviderClientAPIException(e)
|
|
173
|
-
|
|
174
|
-
@property
|
|
175
|
-
def _completion_fn_args(self) -> Dict[str, Any]:
|
|
176
|
-
"""Returns the completion arguments for invoking a call through
|
|
177
|
-
LiteLLM's completion functions.
|
|
178
|
-
"""
|
|
179
|
-
return {
|
|
180
|
-
**self._litellm_extra_parameters,
|
|
181
|
-
"model": self.model_group_id,
|
|
182
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
from typing import Any, Dict, Optional
|
|
2
|
-
|
|
3
|
-
import structlog
|
|
4
|
-
|
|
5
|
-
from rasa.shared.constants import (
|
|
6
|
-
RASA_PROVIDER,
|
|
7
|
-
OPENAI_PROVIDER,
|
|
8
|
-
)
|
|
9
|
-
from rasa.shared.providers._configs.rasa_llm_client_config import (
|
|
10
|
-
RasaLLMClientConfig,
|
|
11
|
-
)
|
|
12
|
-
from rasa.utils.licensing import retrieve_license_from_env
|
|
13
|
-
from rasa.shared.providers.llm._base_litellm_client import _BaseLiteLLMClient
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
structlogger = structlog.get_logger()
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class RasaLLMClient(_BaseLiteLLMClient):
|
|
20
|
-
"""A client for interfacing with a Rasa-Hosted LLM endpoint that uses
|
|
21
|
-
|
|
22
|
-
Parameters:
|
|
23
|
-
model (str): The model or deployment name.
|
|
24
|
-
api_base (str): The base URL of the API endpoint.
|
|
25
|
-
kwargs: Any: Additional configuration parameters that can include, but
|
|
26
|
-
are not limited to model parameters and lite-llm specific
|
|
27
|
-
parameters. These parameters will be passed to the
|
|
28
|
-
completion/acompletion calls. To see what it can include, visit:
|
|
29
|
-
|
|
30
|
-
Raises:
|
|
31
|
-
ProviderClientValidationError: If validation of the client setup fails.
|
|
32
|
-
ProviderClientAPIException: If the API request fails.
|
|
33
|
-
"""
|
|
34
|
-
|
|
35
|
-
def __init__(
|
|
36
|
-
self,
|
|
37
|
-
model: str,
|
|
38
|
-
api_base: str,
|
|
39
|
-
**kwargs: Any,
|
|
40
|
-
):
|
|
41
|
-
super().__init__() # type: ignore
|
|
42
|
-
self._model = model
|
|
43
|
-
self._api_base = api_base
|
|
44
|
-
self._use_chat_completions_endpoint = True
|
|
45
|
-
self._extra_parameters = kwargs or {}
|
|
46
|
-
|
|
47
|
-
@property
|
|
48
|
-
def model(self) -> str:
|
|
49
|
-
return self._model
|
|
50
|
-
|
|
51
|
-
@property
|
|
52
|
-
def api_base(self) -> Optional[str]:
|
|
53
|
-
"""
|
|
54
|
-
Returns the base API URL for the openai llm client.
|
|
55
|
-
"""
|
|
56
|
-
return self._api_base
|
|
57
|
-
|
|
58
|
-
@property
|
|
59
|
-
def provider(self) -> str:
|
|
60
|
-
"""
|
|
61
|
-
Returns the provider name for the self hosted llm client.
|
|
62
|
-
|
|
63
|
-
Returns:
|
|
64
|
-
String representing the provider name.
|
|
65
|
-
"""
|
|
66
|
-
return RASA_PROVIDER
|
|
67
|
-
|
|
68
|
-
@property
|
|
69
|
-
def _litellm_model_name(self) -> str:
|
|
70
|
-
return f"{OPENAI_PROVIDER}/{self._model}"
|
|
71
|
-
|
|
72
|
-
@property
|
|
73
|
-
def _litellm_extra_parameters(self) -> Dict[str, Any]:
|
|
74
|
-
return self._extra_parameters
|
|
75
|
-
|
|
76
|
-
@property
|
|
77
|
-
def config(self) -> dict:
|
|
78
|
-
return RasaLLMClientConfig(
|
|
79
|
-
model=self._model,
|
|
80
|
-
api_base=self._api_base,
|
|
81
|
-
extra_parameters=self._extra_parameters,
|
|
82
|
-
).to_dict()
|
|
83
|
-
|
|
84
|
-
@property
|
|
85
|
-
def _completion_fn_args(self) -> Dict[str, Any]:
|
|
86
|
-
"""Returns the completion arguments for invoking a call through
|
|
87
|
-
LiteLLM's completion functions.
|
|
88
|
-
"""
|
|
89
|
-
fn_args = super()._completion_fn_args
|
|
90
|
-
fn_args.update(
|
|
91
|
-
{"api_base": self.api_base, "api_key": retrieve_license_from_env()}
|
|
92
|
-
)
|
|
93
|
-
return fn_args
|
|
94
|
-
|
|
95
|
-
@classmethod
|
|
96
|
-
def from_config(cls, config: Dict[str, Any]) -> "RasaLLMClient":
|
|
97
|
-
try:
|
|
98
|
-
client_config = RasaLLMClientConfig.from_dict(config)
|
|
99
|
-
except ValueError as e:
|
|
100
|
-
message = "Cannot instantiate a client from the passed configuration."
|
|
101
|
-
structlogger.error(
|
|
102
|
-
"rasa_llm_client.from_config.error",
|
|
103
|
-
message=message,
|
|
104
|
-
config=config,
|
|
105
|
-
original_error=e,
|
|
106
|
-
)
|
|
107
|
-
raise
|
|
108
|
-
return cls(
|
|
109
|
-
model=client_config.model,
|
|
110
|
-
api_base=client_config.api_base,
|
|
111
|
-
**client_config.extra_parameters,
|
|
112
|
-
)
|
|
File without changes
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
from typing import Any, Dict, List
|
|
2
|
-
import os
|
|
3
|
-
import structlog
|
|
4
|
-
|
|
5
|
-
from litellm import Router
|
|
6
|
-
|
|
7
|
-
from rasa.shared.constants import (
|
|
8
|
-
MODEL_LIST_KEY,
|
|
9
|
-
MODEL_GROUP_ID_CONFIG_KEY,
|
|
10
|
-
ROUTER_CONFIG_KEY,
|
|
11
|
-
SELF_HOSTED_VLLM_PREFIX,
|
|
12
|
-
SELF_HOSTED_VLLM_API_KEY_ENV_VAR,
|
|
13
|
-
LITELLM_PARAMS_KEY,
|
|
14
|
-
API_KEY,
|
|
15
|
-
MODEL_CONFIG_KEY,
|
|
16
|
-
USE_CHAT_COMPLETIONS_ENDPOINT_CONFIG_KEY,
|
|
17
|
-
)
|
|
18
|
-
from rasa.shared.exceptions import ProviderClientValidationError
|
|
19
|
-
from rasa.shared.providers._configs.litellm_router_client_config import (
|
|
20
|
-
LiteLLMRouterClientConfig,
|
|
21
|
-
)
|
|
22
|
-
from rasa.shared.utils.io import resolve_environment_variables
|
|
23
|
-
|
|
24
|
-
structlogger = structlog.get_logger()
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class _BaseLiteLLMRouterClient:
|
|
28
|
-
"""An abstract base class for LiteLLM Router clients.
|
|
29
|
-
|
|
30
|
-
This class defines the interface and common functionality for all the router clients
|
|
31
|
-
based on LiteLLM.
|
|
32
|
-
|
|
33
|
-
The class is made private to prevent it from being part of the public-facing
|
|
34
|
-
interface, as it serves as an internal base class for specific implementations of
|
|
35
|
-
router clients that are based on LiteLLM router implementation.
|
|
36
|
-
|
|
37
|
-
Parameters:
|
|
38
|
-
model_group_id (str): The model group ID.
|
|
39
|
-
model_configurations (List[Dict[str, Any]]): The list of model configurations.
|
|
40
|
-
router_settings (Dict[str, Any]): The router settings.
|
|
41
|
-
kwargs (Optional[Dict[str, Any]]): Additional configuration parameters.
|
|
42
|
-
|
|
43
|
-
Raises:
|
|
44
|
-
ProviderClientValidationError: If validation of the client setup fails.
|
|
45
|
-
"""
|
|
46
|
-
|
|
47
|
-
def __init__(
|
|
48
|
-
self,
|
|
49
|
-
model_group_id: str,
|
|
50
|
-
model_configurations: List[Dict[str, Any]],
|
|
51
|
-
router_settings: Dict[str, Any],
|
|
52
|
-
use_chat_completions_endpoint: bool = True,
|
|
53
|
-
**kwargs: Any,
|
|
54
|
-
):
|
|
55
|
-
self._model_group_id = model_group_id
|
|
56
|
-
self._model_configurations = model_configurations
|
|
57
|
-
self._router_settings = router_settings
|
|
58
|
-
self._use_chat_completions_endpoint = use_chat_completions_endpoint
|
|
59
|
-
self._extra_parameters = kwargs or {}
|
|
60
|
-
self.additional_client_setup()
|
|
61
|
-
try:
|
|
62
|
-
resolved_model_configurations = (
|
|
63
|
-
self._resolve_env_vars_in_model_configurations()
|
|
64
|
-
)
|
|
65
|
-
self._router_client = Router(
|
|
66
|
-
model_list=resolved_model_configurations, **router_settings
|
|
67
|
-
)
|
|
68
|
-
except Exception as e:
|
|
69
|
-
event_info = "Cannot instantiate a router client."
|
|
70
|
-
structlogger.error(
|
|
71
|
-
"_base_litellm_router_client.init.error",
|
|
72
|
-
event_info=event_info,
|
|
73
|
-
model_group_id=model_group_id,
|
|
74
|
-
models=model_configurations,
|
|
75
|
-
router=router_settings,
|
|
76
|
-
original_error=e,
|
|
77
|
-
)
|
|
78
|
-
raise ProviderClientValidationError(f"{event_info} Original error: {e}")
|
|
79
|
-
|
|
80
|
-
def additional_client_setup(self) -> None:
|
|
81
|
-
"""Additional setup for the LiteLLM Router client."""
|
|
82
|
-
# If the model configuration is self-hosted VLLM, set a dummy API key if not
|
|
83
|
-
# provided. A bug in the LiteLLM library requires an API key to be set even if
|
|
84
|
-
# it is not required.
|
|
85
|
-
for model_configuration in self.model_configurations:
|
|
86
|
-
if (
|
|
87
|
-
f"{SELF_HOSTED_VLLM_PREFIX}/"
|
|
88
|
-
in model_configuration[LITELLM_PARAMS_KEY][MODEL_CONFIG_KEY]
|
|
89
|
-
and API_KEY not in model_configuration[LITELLM_PARAMS_KEY]
|
|
90
|
-
and not os.getenv(SELF_HOSTED_VLLM_API_KEY_ENV_VAR)
|
|
91
|
-
):
|
|
92
|
-
os.environ[SELF_HOSTED_VLLM_API_KEY_ENV_VAR] = "dummy api key"
|
|
93
|
-
return
|
|
94
|
-
|
|
95
|
-
@classmethod
|
|
96
|
-
def from_config(cls, config: Dict[str, Any]) -> "_BaseLiteLLMRouterClient":
|
|
97
|
-
"""Instantiates a LiteLLM Router Embedding client from a configuration dict.
|
|
98
|
-
|
|
99
|
-
Args:
|
|
100
|
-
config: (Dict[str, Any]) The configuration dictionary.
|
|
101
|
-
|
|
102
|
-
Returns:
|
|
103
|
-
LiteLLMRouterLLMClient: The instantiated LiteLLM Router LLM client.
|
|
104
|
-
|
|
105
|
-
Raises:
|
|
106
|
-
ValueError: If the configuration is invalid.
|
|
107
|
-
"""
|
|
108
|
-
try:
|
|
109
|
-
client_config = LiteLLMRouterClientConfig.from_dict(config)
|
|
110
|
-
except (KeyError, ValueError) as e:
|
|
111
|
-
message = "Cannot instantiate a client from the passed configuration."
|
|
112
|
-
structlogger.error(
|
|
113
|
-
"litellm_router_llm_client.from_config.error",
|
|
114
|
-
message=message,
|
|
115
|
-
config=config,
|
|
116
|
-
original_error=e,
|
|
117
|
-
)
|
|
118
|
-
raise
|
|
119
|
-
|
|
120
|
-
return cls(
|
|
121
|
-
model_group_id=client_config.model_group_id,
|
|
122
|
-
model_configurations=client_config.litellm_model_list,
|
|
123
|
-
router_settings=client_config.litellm_router_settings,
|
|
124
|
-
use_chat_completions_endpoint=client_config.use_chat_completions_endpoint,
|
|
125
|
-
**client_config.extra_parameters,
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
@property
|
|
129
|
-
def model_group_id(self) -> str:
|
|
130
|
-
"""Returns the model group ID for the LiteLLM Router client."""
|
|
131
|
-
return self._model_group_id
|
|
132
|
-
|
|
133
|
-
@property
|
|
134
|
-
def model_configurations(self) -> List[Dict[str, Any]]:
|
|
135
|
-
"""Returns the model configurations for the LiteLLM Router client."""
|
|
136
|
-
return self._model_configurations
|
|
137
|
-
|
|
138
|
-
@property
|
|
139
|
-
def router_settings(self) -> Dict[str, Any]:
|
|
140
|
-
"""Returns the router settings for the LiteLLM Router client."""
|
|
141
|
-
return self._router_settings
|
|
142
|
-
|
|
143
|
-
@property
|
|
144
|
-
def router_client(self) -> Router:
|
|
145
|
-
"""Returns the instantiated LiteLLM Router client."""
|
|
146
|
-
return self._router_client
|
|
147
|
-
|
|
148
|
-
@property
|
|
149
|
-
def use_chat_completions_endpoint(self) -> bool:
|
|
150
|
-
"""Returns whether to use the chat completions endpoint."""
|
|
151
|
-
return self._use_chat_completions_endpoint
|
|
152
|
-
|
|
153
|
-
@property
|
|
154
|
-
def _litellm_extra_parameters(self) -> Dict[str, Any]:
|
|
155
|
-
"""
|
|
156
|
-
Returns the extra parameters for the LiteLLM Router client.
|
|
157
|
-
|
|
158
|
-
Returns:
|
|
159
|
-
Dictionary containing the model parameters.
|
|
160
|
-
"""
|
|
161
|
-
return self._extra_parameters
|
|
162
|
-
|
|
163
|
-
@property
|
|
164
|
-
def config(self) -> Dict:
|
|
165
|
-
"""Returns the configuration for the LiteLLM Router client in LiteLLM format."""
|
|
166
|
-
return {
|
|
167
|
-
MODEL_GROUP_ID_CONFIG_KEY: self.model_group_id,
|
|
168
|
-
MODEL_LIST_KEY: self.model_configurations,
|
|
169
|
-
ROUTER_CONFIG_KEY: self.router_settings,
|
|
170
|
-
USE_CHAT_COMPLETIONS_ENDPOINT_CONFIG_KEY: (
|
|
171
|
-
self.use_chat_completions_endpoint
|
|
172
|
-
),
|
|
173
|
-
**self._litellm_extra_parameters,
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
def _resolve_env_vars_in_model_configurations(self) -> List:
|
|
177
|
-
model_configuration_with_resolved_keys = []
|
|
178
|
-
for model_configuration in self.model_configurations:
|
|
179
|
-
resolved_model_configuration = resolve_environment_variables(
|
|
180
|
-
model_configuration
|
|
181
|
-
)
|
|
182
|
-
model_configuration_with_resolved_keys.append(resolved_model_configuration)
|
|
183
|
-
return model_configuration_with_resolved_keys
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
from typing import Any, Dict, List, Protocol, runtime_checkable
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
@runtime_checkable
|
|
5
|
-
class RouterClient(Protocol):
|
|
6
|
-
"""
|
|
7
|
-
Protocol for a Router client that specifies the interface for interacting
|
|
8
|
-
with the API.
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
@classmethod
|
|
12
|
-
def from_config(cls, config: dict) -> "RouterClient":
|
|
13
|
-
"""
|
|
14
|
-
Initializes the router client with the given configuration.
|
|
15
|
-
|
|
16
|
-
This class method should be implemented to parse the given
|
|
17
|
-
configuration and create an instance of an router client.
|
|
18
|
-
"""
|
|
19
|
-
...
|
|
20
|
-
|
|
21
|
-
@property
|
|
22
|
-
def config(self) -> Dict:
|
|
23
|
-
"""
|
|
24
|
-
Returns the configuration for that the router client is initialized with.
|
|
25
|
-
|
|
26
|
-
This property should be implemented to return a dictionary containing
|
|
27
|
-
the client configuration settings for the router client.
|
|
28
|
-
"""
|
|
29
|
-
...
|
|
30
|
-
|
|
31
|
-
@property
|
|
32
|
-
def router_settings(self) -> Dict[str, Any]:
|
|
33
|
-
"""
|
|
34
|
-
Returns the router settings for the Router client.
|
|
35
|
-
|
|
36
|
-
This property should be implemented to return a dictionary containing
|
|
37
|
-
the router settings for the router client.
|
|
38
|
-
"""
|
|
39
|
-
...
|
|
40
|
-
|
|
41
|
-
@property
|
|
42
|
-
def model_group_id(self) -> str:
|
|
43
|
-
"""
|
|
44
|
-
Returns the model group ID for the Router client.
|
|
45
|
-
|
|
46
|
-
This property should be implemented to return the model group ID
|
|
47
|
-
for the router client.
|
|
48
|
-
"""
|
|
49
|
-
...
|
|
50
|
-
|
|
51
|
-
@property
|
|
52
|
-
def model_configurations(self) -> List[Dict[str, Any]]:
|
|
53
|
-
"""
|
|
54
|
-
Returns the list of model configurations for the Router client.
|
|
55
|
-
|
|
56
|
-
This property should be implemented to return the list of model configurations
|
|
57
|
-
for the router client as a list of dictionaries.
|
|
58
|
-
|
|
59
|
-
Each dictionary should contain the model configuration.
|
|
60
|
-
Ideally, the `ModelGroupConfig` should parse the model configurations
|
|
61
|
-
and generate this list of dictionaries.
|
|
62
|
-
"""
|
|
63
|
-
...
|
|
64
|
-
|
|
65
|
-
@property
|
|
66
|
-
def router_client(self) -> object:
|
|
67
|
-
"""
|
|
68
|
-
Returns the instantiated Router client.
|
|
69
|
-
|
|
70
|
-
This property should be implemented to return the instantiated
|
|
71
|
-
Router client.
|
|
72
|
-
"""
|
|
73
|
-
...
|
|
File without changes
|