rasa-pro 3.11.0rc3__py3-none-any.whl → 3.11.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rasa-pro might be problematic. Click here for more details.
- rasa/__main__.py +9 -3
- rasa/cli/llm_fine_tuning.py +19 -11
- rasa/cli/project_templates/tutorial/config.yml +1 -3
- rasa/cli/project_templates/tutorial/endpoints.yml +8 -3
- rasa/cli/studio/upload.py +0 -15
- rasa/cli/train.py +9 -0
- rasa/cli/utils.py +1 -1
- rasa/core/channels/development_inspector.py +4 -1
- rasa/core/channels/inspector/dist/assets/{arc-bc141fb2.js → arc-861ddd57.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-d0fbc5ce-be2db283.js → c4Diagram-d0fbc5ce-921f02db.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-936ed81e-55366915.js → classDiagram-936ed81e-b436c4f8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-c3cb15f1-bb529518.js → classDiagram-v2-c3cb15f1-511a23cb.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{createText-62fc7601-b0ec81d6.js → createText-62fc7601-ef476ecd.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-f2ad444c-6166330c.js → edges-f2ad444c-f1878e0a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9d236eb7-5ccc6a8e.js → erDiagram-9d236eb7-fac75185.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-1972c806-fca3bfe4.js → flowDb-1972c806-201c5bbc.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-7ea5b25a-4739080f.js → flowDiagram-7ea5b25a-f904ae41.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-b080d6f2.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-abe16c3d-7c1b0e0f.js → flowchart-elk-definition-abe16c3d-1813da66.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-9b5ea136-772fd050.js → ganttDiagram-9b5ea136-872af172.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-99d0ae7c-8eae1dc9.js → gitGraphDiagram-99d0ae7c-34a0af5a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-2c4b9a3b-f55afcdf.js → index-2c4b9a3b-42ba3e3d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-e7cef9de.js → index-37817b51.js} +68 -68
- rasa/core/channels/inspector/dist/assets/{infoDiagram-736b4530-124d4a14.js → infoDiagram-736b4530-6b731386.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-df861f2b-7c4fae44.js → journeyDiagram-df861f2b-e8579ac6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-b9885fb6.js → layout-89e6403a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-7c59abb6.js → line-dc73d3fc.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-4776f780.js → linear-f5b1d2bc.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-beec6740-2332c46c.js → mindmap-definition-beec6740-82cb74fa.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-dbbf0591-8fb39303.js → pieDiagram-dbbf0591-bdf5f29b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-4d7f4fd6-3c7180a2.js → quadrantDiagram-4d7f4fd6-c7a0cbe4.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-6fc4c22a-e910bcb8.js → requirementDiagram-6fc4c22a-7ec5410f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-8f13d901-ead16c89.js → sankeyDiagram-8f13d901-caee5554.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-b655622a-29a02a19.js → sequenceDiagram-b655622a-2935f8db.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-59f0c015-042b3137.js → stateDiagram-59f0c015-8f5d9693.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-2b26beab-2178c0f3.js → stateDiagram-v2-2b26beab-d565d1de.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-080da4f6-23ffa4fc.js → styles-080da4f6-75ad421d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-3dcbcfbf-94f59763.js → styles-3dcbcfbf-7e764226.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9c745c82-78a6bebc.js → styles-9c745c82-7a4e0e61.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-4835440b-eae2a6f6.js → svgDrawCommon-4835440b-4019d1bf.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-5b62e21b-5c968d92.js → timeline-definition-5b62e21b-01ea12df.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-2b33534f-fd3db0d5.js → xychartDiagram-2b33534f-89407137.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/src/components/LoadingSpinner.tsx +1 -1
- rasa/core/channels/inspector/src/helpers/audiostream.ts +28 -2
- rasa/core/channels/voice_stream/asr/asr_engine.py +19 -1
- rasa/core/channels/voice_stream/asr/azure.py +13 -3
- rasa/core/channels/voice_stream/asr/deepgram.py +4 -3
- rasa/core/channels/voice_stream/tts/azure.py +3 -1
- rasa/core/channels/voice_stream/tts/cartesia.py +3 -3
- rasa/core/channels/voice_stream/tts/tts_engine.py +10 -1
- rasa/core/information_retrieval/qdrant.py +1 -0
- rasa/core/persistor.py +93 -49
- rasa/core/policies/flows/flow_executor.py +18 -8
- rasa/core/processor.py +7 -5
- rasa/core/utils.py +3 -1
- rasa/e2e_test/aggregate_test_stats_calculator.py +11 -1
- rasa/e2e_test/assertions.py +183 -19
- rasa/e2e_test/assertions_schema.yml +23 -0
- rasa/e2e_test/e2e_test_runner.py +4 -3
- rasa/engine/graph.py +9 -3
- rasa/engine/loader.py +12 -0
- rasa/engine/validation.py +345 -85
- rasa/model_manager/config.py +8 -0
- rasa/model_manager/model_api.py +166 -61
- rasa/model_manager/runner_service.py +31 -26
- rasa/model_manager/trainer_service.py +14 -23
- rasa/model_manager/warm_rasa_process.py +187 -0
- rasa/model_service.py +3 -5
- rasa/model_training.py +3 -1
- rasa/shared/constants.py +27 -0
- rasa/shared/core/domain.py +8 -5
- rasa/shared/core/flows/yaml_flows_io.py +13 -4
- rasa/shared/importers/importer.py +19 -2
- rasa/shared/importers/rasa.py +5 -1
- rasa/shared/nlu/training_data/formats/rasa_yaml.py +18 -3
- rasa/shared/providers/_utils.py +79 -0
- rasa/shared/providers/embedding/default_litellm_embedding_client.py +24 -0
- rasa/shared/providers/llm/default_litellm_llm_client.py +24 -0
- rasa/shared/utils/common.py +29 -2
- rasa/shared/utils/health_check/health_check.py +26 -24
- rasa/shared/utils/yaml.py +116 -31
- rasa/studio/data_handler.py +3 -1
- rasa/studio/upload.py +119 -57
- rasa/validator.py +40 -4
- rasa/version.py +1 -1
- {rasa_pro-3.11.0rc3.dist-info → rasa_pro-3.11.2.dist-info}/METADATA +2 -2
- {rasa_pro-3.11.0rc3.dist-info → rasa_pro-3.11.2.dist-info}/RECORD +91 -89
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-736177bf.js +0 -1
- {rasa_pro-3.11.0rc3.dist-info → rasa_pro-3.11.2.dist-info}/NOTICE +0 -0
- {rasa_pro-3.11.0rc3.dist-info → rasa_pro-3.11.2.dist-info}/WHEEL +0 -0
- {rasa_pro-3.11.0rc3.dist-info → rasa_pro-3.11.2.dist-info}/entry_points.txt +0 -0
rasa/engine/validation.py
CHANGED
|
@@ -16,6 +16,7 @@ from typing import (
|
|
|
16
16
|
Union,
|
|
17
17
|
TypeVar,
|
|
18
18
|
List,
|
|
19
|
+
Literal,
|
|
19
20
|
)
|
|
20
21
|
|
|
21
22
|
import rasa.utils.common
|
|
@@ -52,7 +53,7 @@ from rasa.engine.graph import (
|
|
|
52
53
|
GraphModelConfiguration,
|
|
53
54
|
)
|
|
54
55
|
from rasa.engine.storage.resource import Resource
|
|
55
|
-
from rasa.engine.storage.storage import ModelStorage
|
|
56
|
+
from rasa.engine.storage.storage import ModelStorage, ModelMetadata
|
|
56
57
|
from rasa.engine.training.fingerprinting import Fingerprintable
|
|
57
58
|
from rasa.shared.constants import (
|
|
58
59
|
DOCS_URL_GRAPH_COMPONENTS,
|
|
@@ -72,7 +73,14 @@ from rasa.shared.constants import (
|
|
|
72
73
|
ROUTING_STRATEGIES_REQUIRING_REDIS_CACHE,
|
|
73
74
|
ROUTING_STRATEGIES_NOT_REQUIRING_CACHE,
|
|
74
75
|
REDIS_HOST_CONFIG_KEY,
|
|
76
|
+
AWS_ACCESS_KEY_ID_CONFIG_KEY,
|
|
77
|
+
AWS_SECRET_ACCESS_KEY_CONFIG_KEY,
|
|
78
|
+
AWS_SESSION_TOKEN_CONFIG_KEY,
|
|
79
|
+
SENSITIVE_DATA,
|
|
75
80
|
USE_CHAT_COMPLETIONS_ENDPOINT_CONFIG_KEY,
|
|
81
|
+
API_TYPE_CONFIG_KEY,
|
|
82
|
+
VALID_PROVIDERS_FOR_API_TYPE_CONFIG_KEY,
|
|
83
|
+
PROVIDER_CONFIG_KEY,
|
|
76
84
|
)
|
|
77
85
|
from rasa.shared.core.constants import ACTION_RESET_ROUTING, ACTION_TRIGGER_CHITCHAT
|
|
78
86
|
from rasa.shared.core.domain import Domain
|
|
@@ -80,7 +88,6 @@ from rasa.shared.core.flows import FlowsList, Flow
|
|
|
80
88
|
from rasa.shared.core.slots import Slot
|
|
81
89
|
from rasa.shared.exceptions import RasaException
|
|
82
90
|
from rasa.shared.nlu.training_data.message import Message
|
|
83
|
-
from rasa.shared.utils.cli import print_error_and_exit
|
|
84
91
|
|
|
85
92
|
TypeAnnotation = Union[TypeVar, Text, Type, Optional[AvailableEndpoints]]
|
|
86
93
|
|
|
@@ -896,26 +903,45 @@ def _validate_component_model_client_config(
|
|
|
896
903
|
model_group_ids.append(component_config[key][MODEL_GROUP_CONFIG_KEY])
|
|
897
904
|
|
|
898
905
|
if len(component_config[key]) > 1:
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
906
|
+
structlogger.error(
|
|
907
|
+
"validation.validate_model_client_configuration_setup"
|
|
908
|
+
".only_model_group_reference_key_is_allowed",
|
|
909
|
+
event_info=(
|
|
910
|
+
f"You specified a '{MODEL_GROUP_CONFIG_KEY}' for the '{key}' "
|
|
911
|
+
f"config key for the component "
|
|
912
|
+
f"'{component_name or component_config['name']}'. "
|
|
913
|
+
"No other parameters are allowed under the "
|
|
914
|
+
f"'{key}' key in that case. Please update your config."
|
|
915
|
+
),
|
|
916
|
+
component_name=component_name or component_config["name"],
|
|
917
|
+
component_client_config_key=key,
|
|
905
918
|
)
|
|
919
|
+
sys.exit(1)
|
|
906
920
|
else:
|
|
907
921
|
model_group_syntax_used.append(False)
|
|
908
922
|
|
|
909
|
-
# check that
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
923
|
+
# check that any of the sensitive data keys is not set in config
|
|
924
|
+
for secret_key in SENSITIVE_DATA:
|
|
925
|
+
if secret_key in component_config[key]:
|
|
926
|
+
structlogger.error(
|
|
927
|
+
"validation.validate_model_client_configuration_setup"
|
|
928
|
+
".secret_key_not_allowed_in_the_config",
|
|
929
|
+
event_info=(
|
|
930
|
+
f"You specified '{secret_key}' in the config for "
|
|
931
|
+
f"'{component_name or component_config['name']}', "
|
|
932
|
+
f"which is not allowed. "
|
|
933
|
+
"Set secret keys through environment variables."
|
|
934
|
+
),
|
|
935
|
+
component_name=component_name or component_config["name"],
|
|
936
|
+
component_client_config_key=key,
|
|
937
|
+
secret_key=secret_key,
|
|
938
|
+
)
|
|
939
|
+
sys.exit(1)
|
|
916
940
|
|
|
917
941
|
|
|
918
|
-
def
|
|
942
|
+
def validate_model_client_configuration_setup_during_training_time(
|
|
943
|
+
config: Dict[str, Any],
|
|
944
|
+
) -> None:
|
|
919
945
|
"""Validates the model client configuration setup.
|
|
920
946
|
|
|
921
947
|
Checks the model configuration of the components in the pipeline.
|
|
@@ -924,6 +950,8 @@ def validate_model_client_configuration_setup(config: Dict[str, Any]) -> None:
|
|
|
924
950
|
the same time (either at component level itself or across different components)
|
|
925
951
|
- the LLM/embeddings is/are defined using the new syntax, but no model
|
|
926
952
|
group is defined or the referenced model group does not exist
|
|
953
|
+
- the LLM/embeddings provider is defined using 'api_type' key for providers other
|
|
954
|
+
than 'openai' or 'azure'
|
|
927
955
|
|
|
928
956
|
Args:
|
|
929
957
|
config: The config dictionary
|
|
@@ -940,22 +968,28 @@ def validate_model_client_configuration_setup(config: Dict[str, Any]) -> None:
|
|
|
940
968
|
if outer_key not in config or config[outer_key] is None:
|
|
941
969
|
continue
|
|
942
970
|
|
|
943
|
-
for
|
|
971
|
+
for component_config in config[outer_key]:
|
|
944
972
|
for key in [LLM_CONFIG_KEY, EMBEDDINGS_CONFIG_KEY]:
|
|
945
973
|
_validate_component_model_client_config(
|
|
946
|
-
|
|
974
|
+
component_config, key, model_group_syntax_used, model_group_ids
|
|
947
975
|
)
|
|
976
|
+
validate_api_type_config_key_usage(component_config, key)
|
|
948
977
|
|
|
949
978
|
# as flow retrieval is not a component itself, we need to
|
|
950
979
|
# check it separately
|
|
951
|
-
if FLOW_RETRIEVAL_KEY in
|
|
952
|
-
if EMBEDDINGS_CONFIG_KEY in
|
|
980
|
+
if FLOW_RETRIEVAL_KEY in component_config:
|
|
981
|
+
if EMBEDDINGS_CONFIG_KEY in component_config[FLOW_RETRIEVAL_KEY]:
|
|
953
982
|
_validate_component_model_client_config(
|
|
954
|
-
|
|
983
|
+
component_config[FLOW_RETRIEVAL_KEY],
|
|
955
984
|
EMBEDDINGS_CONFIG_KEY,
|
|
956
985
|
model_group_syntax_used,
|
|
957
986
|
model_group_ids,
|
|
958
|
-
|
|
987
|
+
component_config["name"] + "." + FLOW_RETRIEVAL_KEY,
|
|
988
|
+
)
|
|
989
|
+
validate_api_type_config_key_usage(
|
|
990
|
+
component_config[FLOW_RETRIEVAL_KEY],
|
|
991
|
+
EMBEDDINGS_CONFIG_KEY,
|
|
992
|
+
component_config["name"] + "." + FLOW_RETRIEVAL_KEY,
|
|
959
993
|
)
|
|
960
994
|
|
|
961
995
|
# also include the ContextualResponseRephraser component
|
|
@@ -970,14 +1004,19 @@ def validate_model_client_configuration_setup(config: Dict[str, Any]) -> None:
|
|
|
970
1004
|
)
|
|
971
1005
|
|
|
972
1006
|
if not is_uniform_bool_list(model_group_syntax_used):
|
|
973
|
-
|
|
974
|
-
"
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
1007
|
+
structlogger.error(
|
|
1008
|
+
"validation.validate_model_client_configuration_setup"
|
|
1009
|
+
".inconsistent_use_of_model_group_syntax",
|
|
1010
|
+
event_info=(
|
|
1011
|
+
"Some of your components refer to an LLM using the "
|
|
1012
|
+
f"'{MODEL_GROUP_CONFIG_KEY}' parameter, other components directly"
|
|
1013
|
+
f" define the LLM under the '{LLM_CONFIG_KEY}' or the "
|
|
1014
|
+
f"'{EMBEDDINGS_CONFIG_KEY}' key. You cannot use"
|
|
1015
|
+
" both types of definitions. Please chose one syntax "
|
|
1016
|
+
"and update your config."
|
|
1017
|
+
),
|
|
980
1018
|
)
|
|
1019
|
+
sys.exit(1)
|
|
981
1020
|
|
|
982
1021
|
# Print a deprecation warning in case the old syntax is used.
|
|
983
1022
|
if len(model_group_syntax_used) > 0 and model_group_syntax_used[0] is False:
|
|
@@ -993,12 +1032,17 @@ def validate_model_client_configuration_setup(config: Dict[str, Any]) -> None:
|
|
|
993
1032
|
|
|
994
1033
|
endpoints = AvailableEndpoints.get_instance()
|
|
995
1034
|
if len(model_group_ids) > 0 and endpoints.model_groups is None:
|
|
996
|
-
|
|
997
|
-
"
|
|
998
|
-
"
|
|
999
|
-
|
|
1000
|
-
|
|
1035
|
+
structlogger.error(
|
|
1036
|
+
"validation.validate_model_client_configuration_setup"
|
|
1037
|
+
".referencing_model_group_but_none_are_defined",
|
|
1038
|
+
event_info=(
|
|
1039
|
+
"You are referring to (a) model group(s) in your "
|
|
1040
|
+
"config.yml file, but no model group was defined in "
|
|
1041
|
+
"the endpoints.yml file. Please define the model "
|
|
1042
|
+
"group(s)."
|
|
1043
|
+
),
|
|
1001
1044
|
)
|
|
1045
|
+
sys.exit(1)
|
|
1002
1046
|
|
|
1003
1047
|
if endpoints.model_groups is None:
|
|
1004
1048
|
return
|
|
@@ -1009,23 +1053,146 @@ def validate_model_client_configuration_setup(config: Dict[str, Any]) -> None:
|
|
|
1009
1053
|
|
|
1010
1054
|
for model_group_id in model_group_ids:
|
|
1011
1055
|
if model_group_id not in existing_model_group_ids:
|
|
1012
|
-
|
|
1013
|
-
"
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1056
|
+
structlogger.error(
|
|
1057
|
+
"validation.validate_model_client_configuration_setup"
|
|
1058
|
+
".referencing_undefined_model_group",
|
|
1059
|
+
event_info=(
|
|
1060
|
+
"One of your components is referring to the model group "
|
|
1061
|
+
f"'{model_group_id}', but this model group does not exist in the "
|
|
1062
|
+
f"endpoints.yml file. Please chose one of the existing "
|
|
1063
|
+
f"model groups ({existing_model_group_ids}) or define "
|
|
1064
|
+
f"the model group for '{model_group_id}'."
|
|
1065
|
+
),
|
|
1066
|
+
referencing_model_group_id=model_group_id,
|
|
1067
|
+
existing_model_group_ids=existing_model_group_ids,
|
|
1018
1068
|
)
|
|
1069
|
+
sys.exit(1)
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
def _validate_component_model_client_config_has_references_to_endpoints(
|
|
1073
|
+
component_config: Dict[Text, Any],
|
|
1074
|
+
key: str,
|
|
1075
|
+
component_name: Optional[Text] = None,
|
|
1076
|
+
) -> None:
|
|
1077
|
+
"""Validates that the specified client configuration references a valid model group
|
|
1078
|
+
defined in the `endpoints.yml` file.
|
|
1079
|
+
|
|
1080
|
+
This function ensures that when the client configuration for a component uses the
|
|
1081
|
+
`model_group` key, the referenced model group exists in the `endpoints.yml` file.
|
|
1082
|
+
If the referenced model group is missing or invalid, an error is raised.
|
|
1083
|
+
|
|
1084
|
+
Args:
|
|
1085
|
+
component_config: The configuration dictionary for the component being
|
|
1086
|
+
validated.
|
|
1087
|
+
key: 'llm' or 'embeddings'
|
|
1088
|
+
component_name: Optional; the name of the component being validated, used for
|
|
1089
|
+
error messages.
|
|
1090
|
+
|
|
1091
|
+
Raises:
|
|
1092
|
+
SystemExit: If the referenced model group is missing or invalid.
|
|
1093
|
+
"""
|
|
1094
|
+
if key not in component_config:
|
|
1095
|
+
# no llm/embeddings configuration present
|
|
1096
|
+
return
|
|
1097
|
+
|
|
1098
|
+
endpoints = AvailableEndpoints.get_instance()
|
|
1099
|
+
|
|
1100
|
+
if MODEL_GROUP_CONFIG_KEY in component_config[key]:
|
|
1101
|
+
referencing_model_group_id = component_config[key][MODEL_GROUP_CONFIG_KEY]
|
|
1102
|
+
|
|
1103
|
+
if endpoints.model_groups is None:
|
|
1104
|
+
structlogger.error(
|
|
1105
|
+
"validation.validate_model_client_config_correctly_references_endpoints"
|
|
1106
|
+
".no_model_groups_defined",
|
|
1107
|
+
event_info=(
|
|
1108
|
+
f"Your {component_name or component_config.get('name') or ''} "
|
|
1109
|
+
f"component's '{key}' configuration of the trained model "
|
|
1110
|
+
f"references the model group '{referencing_model_group_id}', "
|
|
1111
|
+
f"but NO MODEL GROUPS ARE DEFINED in the endpoints.yml file. "
|
|
1112
|
+
f"Please add a definition for the required model group in the "
|
|
1113
|
+
f"endpoints.yml file."
|
|
1114
|
+
),
|
|
1115
|
+
component_name=component_name or component_config.get("name"),
|
|
1116
|
+
model_group_id=referencing_model_group_id,
|
|
1117
|
+
component_client_config_key=key,
|
|
1118
|
+
)
|
|
1119
|
+
sys.exit(1)
|
|
1120
|
+
|
|
1121
|
+
existing_model_group_ids = [
|
|
1122
|
+
model_group[MODEL_GROUP_ID_CONFIG_KEY]
|
|
1123
|
+
for model_group in endpoints.model_groups
|
|
1124
|
+
]
|
|
1125
|
+
|
|
1126
|
+
if referencing_model_group_id not in existing_model_group_ids:
|
|
1127
|
+
structlogger.error(
|
|
1128
|
+
"validation.validate_model_client_config_correctly_references_endpoints"
|
|
1129
|
+
".referenced_model_group_does_not_exist",
|
|
1130
|
+
event_info=(
|
|
1131
|
+
f"Your {component_name or component_config.get('name') or ''} "
|
|
1132
|
+
f"component's '{key}' configuration of the trained model "
|
|
1133
|
+
f"references the model group '{referencing_model_group_id}', "
|
|
1134
|
+
f"but this model group DOES NOT EXIST in the endpoints.yml file. "
|
|
1135
|
+
f"The endpoints.yml defines the following model groups: "
|
|
1136
|
+
f"{existing_model_group_ids}. "
|
|
1137
|
+
f"Please add a definition for the required model group in the "
|
|
1138
|
+
f"endpoints.yml file."
|
|
1139
|
+
),
|
|
1140
|
+
model_group_id=referencing_model_group_id,
|
|
1141
|
+
existing_model_group_ids=existing_model_group_ids,
|
|
1142
|
+
component_client_config_key=key,
|
|
1143
|
+
)
|
|
1144
|
+
sys.exit(1)
|
|
1145
|
+
|
|
1146
|
+
|
|
1147
|
+
def validate_model_client_configuration_setup_during_inference_time(
|
|
1148
|
+
model_metadata: ModelMetadata,
|
|
1149
|
+
) -> None:
|
|
1150
|
+
for (
|
|
1151
|
+
component_node_name,
|
|
1152
|
+
component_node,
|
|
1153
|
+
) in model_metadata.predict_schema.nodes.items():
|
|
1154
|
+
for client_config_key in [EMBEDDINGS_CONFIG_KEY, LLM_CONFIG_KEY]:
|
|
1155
|
+
if client_config_key not in component_node.config:
|
|
1156
|
+
continue
|
|
1157
|
+
|
|
1158
|
+
_validate_component_model_client_config_has_references_to_endpoints(
|
|
1159
|
+
component_config=component_node.config,
|
|
1160
|
+
key=client_config_key,
|
|
1161
|
+
component_name=component_node_name,
|
|
1162
|
+
)
|
|
1163
|
+
|
|
1164
|
+
# as flow retrieval is not a component itself, we need to
|
|
1165
|
+
# check it separately
|
|
1166
|
+
if FLOW_RETRIEVAL_KEY in component_node.config:
|
|
1167
|
+
if EMBEDDINGS_CONFIG_KEY in component_node.config[FLOW_RETRIEVAL_KEY]:
|
|
1168
|
+
_validate_component_model_client_config_has_references_to_endpoints(
|
|
1169
|
+
component_config=component_node.config[FLOW_RETRIEVAL_KEY],
|
|
1170
|
+
key=EMBEDDINGS_CONFIG_KEY,
|
|
1171
|
+
component_name=component_node_name + "." + FLOW_RETRIEVAL_KEY,
|
|
1172
|
+
)
|
|
1173
|
+
|
|
1174
|
+
# also include the ContextualResponseRephraser component
|
|
1175
|
+
endpoints = AvailableEndpoints.get_instance()
|
|
1176
|
+
if endpoints.nlg is not None:
|
|
1177
|
+
_validate_component_model_client_config_has_references_to_endpoints(
|
|
1178
|
+
component_config=endpoints.nlg.kwargs,
|
|
1179
|
+
key=LLM_CONFIG_KEY,
|
|
1180
|
+
component_name=ContextualResponseRephraser.__name__,
|
|
1181
|
+
)
|
|
1019
1182
|
|
|
1020
1183
|
|
|
1021
1184
|
def _validate_unique_model_group_ids(model_groups: List[Dict[str, Any]]) -> None:
|
|
1022
1185
|
# Each model id must be unique within the model_groups
|
|
1023
1186
|
model_ids = [model_group[MODEL_GROUP_ID_CONFIG_KEY] for model_group in model_groups]
|
|
1024
1187
|
if len(model_ids) != len(set(model_ids)):
|
|
1025
|
-
|
|
1026
|
-
"
|
|
1027
|
-
|
|
1188
|
+
structlogger.error(
|
|
1189
|
+
"validate_model_group_configuration_setup.non_unique_model_group_ids",
|
|
1190
|
+
event_info=(
|
|
1191
|
+
"Each model group id must be unique. Please make sure that "
|
|
1192
|
+
"the model group ids are unique in your endpoints.yml file."
|
|
1193
|
+
),
|
|
1028
1194
|
)
|
|
1195
|
+
sys.exit(1)
|
|
1029
1196
|
|
|
1030
1197
|
|
|
1031
1198
|
def _validate_model_group_with_multiple_models(
|
|
@@ -1037,13 +1204,18 @@ def _validate_model_group_with_multiple_models(
|
|
|
1037
1204
|
len(model_group[MODELS_CONFIG_KEY]) > 1
|
|
1038
1205
|
and ROUTER_CONFIG_KEY not in model_group
|
|
1039
1206
|
):
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1207
|
+
structlogger.error(
|
|
1208
|
+
"validate_model_group_configuration_setup.router_not_present",
|
|
1209
|
+
event_info=(
|
|
1210
|
+
f"You defined multiple models for the model group "
|
|
1211
|
+
f"'{model_group[MODEL_GROUP_ID_CONFIG_KEY]}', but no router. "
|
|
1212
|
+
"If a model group contains multiple models, a router must be "
|
|
1213
|
+
"defined. Please define a router for the model group "
|
|
1214
|
+
f"'{model_group[MODEL_GROUP_ID_CONFIG_KEY]}'."
|
|
1215
|
+
),
|
|
1216
|
+
model_group_id=model_group[MODEL_GROUP_ID_CONFIG_KEY],
|
|
1046
1217
|
)
|
|
1218
|
+
sys.exit(1)
|
|
1047
1219
|
|
|
1048
1220
|
|
|
1049
1221
|
def _validate_model_group_router_setting(
|
|
@@ -1056,28 +1228,49 @@ def _validate_model_group_router_setting(
|
|
|
1056
1228
|
|
|
1057
1229
|
for model_config in model_group.get(MODELS_CONFIG_KEY, []):
|
|
1058
1230
|
if USE_CHAT_COMPLETIONS_ENDPOINT_CONFIG_KEY in model_config:
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
f"
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1231
|
+
structlogger.error(
|
|
1232
|
+
"validation.validate_model_group_configuration_setup"
|
|
1233
|
+
f".{USE_CHAT_COMPLETIONS_ENDPOINT_CONFIG_KEY}_set_incorrectly",
|
|
1234
|
+
event_info=(
|
|
1235
|
+
f"You defined the '{USE_CHAT_COMPLETIONS_ENDPOINT_CONFIG_KEY}' "
|
|
1236
|
+
f"in the model group "
|
|
1237
|
+
f"'{model_group[MODEL_GROUP_ID_CONFIG_KEY]}'. This key is not "
|
|
1238
|
+
f"allowed in the model configuration as the router is defined. "
|
|
1239
|
+
f"Please remove this key from your model configuration and "
|
|
1240
|
+
f"update it in the '{ROUTER_CONFIG_KEY} configuration, as it "
|
|
1241
|
+
f"is a router level setting."
|
|
1242
|
+
),
|
|
1243
|
+
model_group_id=model_group[MODEL_GROUP_ID_CONFIG_KEY],
|
|
1066
1244
|
)
|
|
1245
|
+
sys.exit(1)
|
|
1067
1246
|
|
|
1068
1247
|
router_config = model_group[ROUTER_CONFIG_KEY]
|
|
1069
1248
|
if ROUTING_STRATEGY_CONFIG_KEY in router_config:
|
|
1070
1249
|
routing_strategy = router_config.get(ROUTING_STRATEGY_CONFIG_KEY)
|
|
1071
1250
|
if routing_strategy and routing_strategy not in VALID_ROUTING_STRATEGIES:
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1251
|
+
structlogger.error(
|
|
1252
|
+
"validation.validate_model_group_configuration_setup"
|
|
1253
|
+
".invalid_routing_strategy",
|
|
1254
|
+
event_info=(
|
|
1255
|
+
f"The routing strategy '{routing_strategy}' you defined for "
|
|
1256
|
+
f"the model group '{model_group[MODEL_GROUP_ID_CONFIG_KEY]}' "
|
|
1257
|
+
f"is not valid. Valid routing strategies are categorized as "
|
|
1258
|
+
f"follows:\n"
|
|
1259
|
+
f"- Strategies requiring Redis caching: "
|
|
1260
|
+
f"{', '.join(ROUTING_STRATEGIES_REQUIRING_REDIS_CACHE)}\n"
|
|
1261
|
+
f"- Strategies not requiring caching: "
|
|
1262
|
+
f"{', '.join(ROUTING_STRATEGIES_NOT_REQUIRING_CACHE)}"
|
|
1263
|
+
),
|
|
1264
|
+
model_group_id=model_group[MODEL_GROUP_ID_CONFIG_KEY],
|
|
1265
|
+
invalid_routing_strategy=routing_strategy,
|
|
1266
|
+
supported_routing_strategies_requiring_redis_cache=(
|
|
1267
|
+
ROUTING_STRATEGIES_REQUIRING_REDIS_CACHE
|
|
1268
|
+
),
|
|
1269
|
+
supported_routing_strategies_not_requiring_redis_cache=(
|
|
1270
|
+
ROUTING_STRATEGIES_NOT_REQUIRING_CACHE
|
|
1271
|
+
),
|
|
1080
1272
|
)
|
|
1273
|
+
sys.exit(1)
|
|
1081
1274
|
if (
|
|
1082
1275
|
routing_strategy in ROUTING_STRATEGIES_REQUIRING_REDIS_CACHE
|
|
1083
1276
|
and REDIS_HOST_CONFIG_KEY not in router_config
|
|
@@ -1091,6 +1284,7 @@ def _validate_model_group_router_setting(
|
|
|
1091
1284
|
f"'{REDIS_HOST_CONFIG_KEY}' to the router configuration for "
|
|
1092
1285
|
f"the model group '{model_group[MODEL_GROUP_ID_CONFIG_KEY]}'."
|
|
1093
1286
|
),
|
|
1287
|
+
model_group_id=model_group[MODEL_GROUP_ID_CONFIG_KEY],
|
|
1094
1288
|
)
|
|
1095
1289
|
|
|
1096
1290
|
|
|
@@ -1098,13 +1292,18 @@ def _validate_usage_of_environment_variables_in_model_group_config(
|
|
|
1098
1292
|
model_groups: List[Dict[str, Any]],
|
|
1099
1293
|
) -> None:
|
|
1100
1294
|
# Limit the use of ${env_var} in the model_groups config to the following variables:
|
|
1101
|
-
# deployment,
|
|
1295
|
+
# - deployment,
|
|
1296
|
+
# - api_base, api_version and api_key,
|
|
1297
|
+
# - aws_region_name, aws_access_key_id, aws_secret_access_key, and aws_session_token
|
|
1102
1298
|
allowed_env_vars = {
|
|
1103
1299
|
DEPLOYMENT_CONFIG_KEY,
|
|
1104
1300
|
API_BASE_CONFIG_KEY,
|
|
1105
1301
|
API_KEY,
|
|
1106
1302
|
API_VERSION_CONFIG_KEY,
|
|
1107
1303
|
AWS_REGION_NAME_CONFIG_KEY,
|
|
1304
|
+
AWS_ACCESS_KEY_ID_CONFIG_KEY,
|
|
1305
|
+
AWS_SECRET_ACCESS_KEY_CONFIG_KEY,
|
|
1306
|
+
AWS_SESSION_TOKEN_CONFIG_KEY,
|
|
1108
1307
|
}
|
|
1109
1308
|
|
|
1110
1309
|
for model_group in model_groups:
|
|
@@ -1112,39 +1311,62 @@ def _validate_usage_of_environment_variables_in_model_group_config(
|
|
|
1112
1311
|
for key, value in model_config.items():
|
|
1113
1312
|
if isinstance(value, str):
|
|
1114
1313
|
if re.match(r"\${(\w+)}", value) and key not in allowed_env_vars:
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1314
|
+
structlogger.error(
|
|
1315
|
+
"validation.validate_model_group_configuration_setup"
|
|
1316
|
+
".invalid_use_of_environment_variables",
|
|
1317
|
+
event_info=(
|
|
1318
|
+
f"You defined '{key}' as environment variable in model "
|
|
1319
|
+
f"group '{model_group[MODEL_GROUP_ID_CONFIG_KEY]}', "
|
|
1320
|
+
f"which is not allowed. "
|
|
1321
|
+
f"You can only use environment variables for the "
|
|
1322
|
+
f"following keys: {', '.join(allowed_env_vars)}. "
|
|
1323
|
+
f"Please update your config."
|
|
1324
|
+
),
|
|
1325
|
+
model_group_id=model_group[MODEL_GROUP_ID_CONFIG_KEY],
|
|
1326
|
+
key=key,
|
|
1327
|
+
allowed_keys_for_env_vars=allowed_env_vars,
|
|
1122
1328
|
)
|
|
1329
|
+
sys.exit(1)
|
|
1123
1330
|
|
|
1124
1331
|
|
|
1125
|
-
def
|
|
1332
|
+
def _validate_sensitive_keys_are_an_environment_variables_for_model_groups(
|
|
1126
1333
|
model_groups: List[Dict[str, Any]],
|
|
1127
1334
|
) -> None:
|
|
1128
1335
|
# the api key can only be set as an environment variable
|
|
1129
1336
|
for model_group in model_groups:
|
|
1130
1337
|
for model_config in model_group[MODELS_CONFIG_KEY]:
|
|
1131
1338
|
for key, value in model_config.items():
|
|
1132
|
-
if key
|
|
1339
|
+
if key in SENSITIVE_DATA:
|
|
1133
1340
|
if isinstance(value, str):
|
|
1134
1341
|
if not re.match(r"\${(\w+)}", value):
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1342
|
+
structlogger.error(
|
|
1343
|
+
"validation.validate_model_group_configuration_setup"
|
|
1344
|
+
".sensitive_key_string_value_must_be_set_as_env_var",
|
|
1345
|
+
event_info=(
|
|
1346
|
+
f"You defined the '{key}' in model group "
|
|
1347
|
+
f"'{model_group[MODEL_GROUP_ID_CONFIG_KEY]}' as a "
|
|
1348
|
+
f"string. The '{key}' must be set as an "
|
|
1349
|
+
f"environment variable. Please update your config."
|
|
1350
|
+
),
|
|
1351
|
+
key=key,
|
|
1352
|
+
model_group_id=model_group[MODEL_GROUP_ID_CONFIG_KEY],
|
|
1140
1353
|
)
|
|
1354
|
+
sys.exit(1)
|
|
1141
1355
|
else:
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1356
|
+
structlogger.error(
|
|
1357
|
+
"validation.validate_model_group_configuration_setup"
|
|
1358
|
+
".sensitive_key_must_be_set_as_env_var",
|
|
1359
|
+
event_info=(
|
|
1360
|
+
f"You should define the '{key}' in model group "
|
|
1361
|
+
f"'{model_group[MODEL_GROUP_ID_CONFIG_KEY]}' using the "
|
|
1362
|
+
f"environment variable syntax - "
|
|
1363
|
+
f"${{ENV_VARIABLE_NAME}}. "
|
|
1364
|
+
f"Please update your config."
|
|
1365
|
+
),
|
|
1366
|
+
key=key,
|
|
1367
|
+
model_group_id=model_group[MODEL_GROUP_ID_CONFIG_KEY],
|
|
1147
1368
|
)
|
|
1369
|
+
sys.exit(1)
|
|
1148
1370
|
|
|
1149
1371
|
|
|
1150
1372
|
def validate_model_group_configuration_setup() -> None:
|
|
@@ -1159,7 +1381,9 @@ def validate_model_group_configuration_setup() -> None:
|
|
|
1159
1381
|
_validate_usage_of_environment_variables_in_model_group_config(
|
|
1160
1382
|
endpoints.model_groups
|
|
1161
1383
|
)
|
|
1162
|
-
|
|
1384
|
+
_validate_sensitive_keys_are_an_environment_variables_for_model_groups(
|
|
1385
|
+
endpoints.model_groups
|
|
1386
|
+
)
|
|
1163
1387
|
_validate_model_group_router_setting(endpoints.model_groups)
|
|
1164
1388
|
|
|
1165
1389
|
|
|
@@ -1189,3 +1413,39 @@ def validate_command_generator_setup(
|
|
|
1189
1413
|
) -> None:
|
|
1190
1414
|
schema = model_configuration.predict_schema
|
|
1191
1415
|
validate_command_generator_exclusivity(schema)
|
|
1416
|
+
|
|
1417
|
+
|
|
1418
|
+
def validate_api_type_config_key_usage(
|
|
1419
|
+
component_config: Dict[str, Any],
|
|
1420
|
+
key: Literal["llm", "embeddings"],
|
|
1421
|
+
component_name: Optional[str] = None,
|
|
1422
|
+
) -> None:
|
|
1423
|
+
"""Validate the LLM/embeddings configuration of a component.
|
|
1424
|
+
|
|
1425
|
+
Validation fails, if
|
|
1426
|
+
- the LLM/embeddings provider is defined using 'api_type' key for providers other
|
|
1427
|
+
than 'openai' or 'azure'
|
|
1428
|
+
|
|
1429
|
+
Args:
|
|
1430
|
+
component_config: The config of the component
|
|
1431
|
+
key: either 'llm' or 'embeddings'
|
|
1432
|
+
component_name: the name of the component
|
|
1433
|
+
"""
|
|
1434
|
+
if component_config is None or key not in component_config:
|
|
1435
|
+
return
|
|
1436
|
+
|
|
1437
|
+
if API_TYPE_CONFIG_KEY in component_config[key]:
|
|
1438
|
+
api_type = component_config[key][API_TYPE_CONFIG_KEY]
|
|
1439
|
+
if api_type not in VALID_PROVIDERS_FOR_API_TYPE_CONFIG_KEY:
|
|
1440
|
+
structlogger.error(
|
|
1441
|
+
"validation.component.api_type_config_key_invalid",
|
|
1442
|
+
event_info=(
|
|
1443
|
+
f"You specified '{API_TYPE_CONFIG_KEY}: {api_type}' for "
|
|
1444
|
+
f"'{component_name or component_config['name']}', which is not "
|
|
1445
|
+
f"allowed. "
|
|
1446
|
+
f"The '{API_TYPE_CONFIG_KEY}' key can only be used for the "
|
|
1447
|
+
f"following providers: {VALID_PROVIDERS_FOR_API_TYPE_CONFIG_KEY}. "
|
|
1448
|
+
f"For other providers, please use the '{PROVIDER_CONFIG_KEY}' key."
|
|
1449
|
+
),
|
|
1450
|
+
)
|
|
1451
|
+
sys.exit(1)
|
rasa/model_manager/config.py
CHANGED
|
@@ -7,6 +7,8 @@ SERVER_BASE_WORKING_DIRECTORY = os.environ.get(
|
|
|
7
7
|
"RASA_MODEL_SERVER_BASE_DIRECTORY", DEFAULT_SERVER_BASE_WORKING_DIRECTORY
|
|
8
8
|
)
|
|
9
9
|
|
|
10
|
+
SERVER_PORT = os.environ.get("RASA_MODEL_SERVER_PORT", 8000)
|
|
11
|
+
|
|
10
12
|
SERVER_BASE_URL = os.environ.get("RASA_MODEL_SERVER_BASE_URL", None)
|
|
11
13
|
|
|
12
14
|
# defaults to storing on the local hard drive
|
|
@@ -30,3 +32,9 @@ MAX_PARALLEL_BOT_RUNS = os.getenv(
|
|
|
30
32
|
)
|
|
31
33
|
|
|
32
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
|
+
)
|