rasa-pro 3.8.17__py3-none-any.whl → 3.9.14__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 +5 -5
- rasa/__main__.py +14 -9
- rasa/anonymization/anonymization_pipeline.py +0 -1
- rasa/anonymization/anonymization_rule_executor.py +3 -3
- rasa/anonymization/utils.py +4 -3
- rasa/api.py +2 -2
- rasa/cli/arguments/default_arguments.py +1 -1
- rasa/cli/arguments/run.py +2 -2
- rasa/cli/arguments/test.py +1 -1
- rasa/cli/arguments/train.py +10 -10
- rasa/cli/e2e_test.py +27 -7
- rasa/cli/export.py +0 -1
- rasa/cli/license.py +3 -3
- rasa/cli/project_templates/calm/actions/action_template.py +1 -1
- rasa/cli/project_templates/calm/config.yml +1 -1
- rasa/cli/project_templates/calm/credentials.yml +1 -1
- rasa/cli/project_templates/calm/data/flows/add_contact.yml +1 -1
- rasa/cli/project_templates/calm/data/flows/remove_contact.yml +1 -1
- rasa/cli/project_templates/calm/domain/add_contact.yml +8 -2
- rasa/cli/project_templates/calm/domain/list_contacts.yml +3 -0
- rasa/cli/project_templates/calm/domain/remove_contact.yml +9 -2
- rasa/cli/project_templates/calm/domain/shared.yml +5 -0
- rasa/cli/project_templates/calm/endpoints.yml +4 -4
- rasa/cli/project_templates/default/actions/actions.py +1 -1
- rasa/cli/project_templates/default/config.yml +5 -5
- rasa/cli/project_templates/default/credentials.yml +1 -1
- rasa/cli/project_templates/default/endpoints.yml +4 -4
- rasa/cli/project_templates/default/tests/test_stories.yml +1 -1
- rasa/cli/project_templates/tutorial/config.yml +1 -1
- rasa/cli/project_templates/tutorial/credentials.yml +1 -1
- rasa/cli/project_templates/tutorial/data/patterns.yml +6 -0
- rasa/cli/project_templates/tutorial/domain.yml +4 -0
- rasa/cli/project_templates/tutorial/endpoints.yml +6 -6
- rasa/cli/run.py +0 -1
- rasa/cli/scaffold.py +3 -2
- rasa/cli/studio/download.py +11 -0
- rasa/cli/studio/studio.py +180 -24
- rasa/cli/studio/upload.py +0 -8
- rasa/cli/telemetry.py +18 -6
- rasa/cli/utils.py +21 -10
- rasa/cli/x.py +3 -2
- rasa/core/actions/action.py +90 -315
- rasa/core/actions/action_exceptions.py +24 -0
- rasa/core/actions/constants.py +3 -0
- rasa/core/actions/custom_action_executor.py +188 -0
- rasa/core/actions/forms.py +11 -7
- rasa/core/actions/grpc_custom_action_executor.py +251 -0
- rasa/core/actions/http_custom_action_executor.py +140 -0
- rasa/core/actions/loops.py +3 -0
- rasa/core/actions/two_stage_fallback.py +1 -1
- rasa/core/agent.py +2 -4
- rasa/core/brokers/pika.py +1 -2
- rasa/core/channels/audiocodes.py +1 -1
- rasa/core/channels/botframework.py +0 -1
- rasa/core/channels/callback.py +0 -1
- rasa/core/channels/console.py +6 -8
- rasa/core/channels/development_inspector.py +1 -1
- rasa/core/channels/facebook.py +0 -3
- rasa/core/channels/hangouts.py +0 -6
- rasa/core/channels/inspector/dist/assets/{arc-5623b6dc.js → arc-b6e548fe.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-d0fbc5ce-685c106a.js → c4Diagram-d0fbc5ce-fa03ac9e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-936ed81e-8cbed007.js → classDiagram-936ed81e-ee67392a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-c3cb15f1-5889cf12.js → classDiagram-v2-c3cb15f1-9b283fae.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{createText-62fc7601-24c249d7.js → createText-62fc7601-8b6fcc2a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-f2ad444c-7dd06a75.js → edges-f2ad444c-22e77f4f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9d236eb7-62c1e54c.js → erDiagram-9d236eb7-60ffc87f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-1972c806-ce49b86f.js → flowDb-1972c806-9dd802e4.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-7ea5b25a-4067e48f.js → flowDiagram-7ea5b25a-5fa1912f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-1844e5a5.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-abe16c3d-59fe4051.js → flowchart-elk-definition-abe16c3d-622a1fd2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-9b5ea136-47e3a43b.js → ganttDiagram-9b5ea136-e285a63a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-99d0ae7c-5a2ac0d9.js → gitGraphDiagram-99d0ae7c-f237bdca.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-2c4b9a3b-dfb8efc4.js → index-2c4b9a3b-4b03d70e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-268a75c0.js → index-a5d3e69d.js} +4 -4
- rasa/core/channels/inspector/dist/assets/{infoDiagram-736b4530-b0c470f2.js → infoDiagram-736b4530-72a0fa5f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-df861f2b-2edb829a.js → journeyDiagram-df861f2b-82218c41.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-b6873d69.js → layout-78cff630.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-1efc5781.js → line-5038b469.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-661e9b94.js → linear-c4fc4098.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-beec6740-2d2e727f.js → mindmap-definition-beec6740-c33c8ea6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-dbbf0591-9d3ea93d.js → pieDiagram-dbbf0591-a8d03059.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-4d7f4fd6-06a178a2.js → quadrantDiagram-4d7f4fd6-6a0e56b2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-6fc4c22a-0bfedffc.js → requirementDiagram-6fc4c22a-2dc7c7bd.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-8f13d901-d76d0a04.js → sankeyDiagram-8f13d901-2360fe39.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-b655622a-37bb4341.js → sequenceDiagram-b655622a-41b9f9ad.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-59f0c015-f52f7f57.js → stateDiagram-59f0c015-0aad326f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-2b26beab-4a986a20.js → stateDiagram-v2-2b26beab-9847d984.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-080da4f6-7dd9ae12.js → styles-080da4f6-564d890e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-3dcbcfbf-46e1ca14.js → styles-3dcbcfbf-38957613.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9c745c82-4a97439a.js → styles-9c745c82-f0fc6921.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-4835440b-823917a3.js → svgDrawCommon-4835440b-ef3c5a77.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-5b62e21b-9ea72896.js → timeline-definition-5b62e21b-bf3e91c1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-2b33534f-b631a8b6.js → xychartDiagram-2b33534f-4d4026c0.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/src/components/DiagramFlow.tsx +10 -0
- rasa/core/channels/inspector/src/helpers/formatters.test.ts +4 -7
- rasa/core/channels/inspector/src/helpers/formatters.ts +3 -2
- rasa/core/channels/rest.py +36 -21
- rasa/core/channels/rocketchat.py +0 -1
- rasa/core/channels/socketio.py +1 -1
- rasa/core/channels/telegram.py +3 -3
- rasa/core/channels/webexteams.py +0 -1
- rasa/core/concurrent_lock_store.py +1 -1
- rasa/core/evaluation/marker_base.py +1 -3
- rasa/core/evaluation/marker_stats.py +1 -2
- rasa/core/featurizers/single_state_featurizer.py +2 -4
- rasa/core/featurizers/tracker_featurizers.py +0 -7
- rasa/core/information_retrieval/__init__.py +7 -0
- rasa/core/information_retrieval/faiss.py +9 -4
- rasa/core/information_retrieval/information_retrieval.py +64 -7
- rasa/core/information_retrieval/milvus.py +7 -14
- rasa/core/information_retrieval/qdrant.py +8 -15
- rasa/core/lock_store.py +0 -1
- rasa/core/migrate.py +1 -2
- rasa/core/nlg/callback.py +3 -4
- rasa/core/policies/enterprise_search_policy.py +86 -22
- rasa/core/policies/enterprise_search_prompt_template.jinja2 +4 -41
- rasa/core/policies/enterprise_search_prompt_with_citation_template.jinja2 +60 -0
- rasa/core/policies/flows/flow_executor.py +104 -2
- rasa/core/policies/intentless_policy.py +7 -9
- rasa/core/policies/memoization.py +3 -3
- rasa/core/policies/policy.py +18 -9
- rasa/core/policies/rule_policy.py +8 -11
- rasa/core/policies/ted_policy.py +28 -30
- rasa/core/policies/unexpected_intent_policy.py +1 -2
- rasa/core/processor.py +136 -47
- rasa/core/run.py +41 -25
- rasa/core/secrets_manager/endpoints.py +2 -2
- rasa/core/secrets_manager/vault.py +6 -8
- rasa/core/test.py +3 -5
- rasa/core/tracker_store.py +49 -14
- rasa/core/train.py +1 -3
- rasa/core/training/interactive.py +9 -6
- rasa/core/utils.py +5 -10
- rasa/dialogue_understanding/coexistence/intent_based_router.py +11 -4
- rasa/dialogue_understanding/coexistence/llm_based_router.py +2 -3
- rasa/dialogue_understanding/commands/__init__.py +4 -0
- rasa/dialogue_understanding/commands/can_not_handle_command.py +9 -0
- rasa/dialogue_understanding/commands/cancel_flow_command.py +9 -0
- rasa/dialogue_understanding/commands/change_flow_command.py +38 -0
- rasa/dialogue_understanding/commands/chit_chat_answer_command.py +9 -0
- rasa/dialogue_understanding/commands/clarify_command.py +9 -0
- rasa/dialogue_understanding/commands/correct_slots_command.py +9 -0
- rasa/dialogue_understanding/commands/error_command.py +12 -0
- rasa/dialogue_understanding/commands/handle_code_change_command.py +9 -0
- rasa/dialogue_understanding/commands/human_handoff_command.py +9 -0
- rasa/dialogue_understanding/commands/knowledge_answer_command.py +9 -0
- rasa/dialogue_understanding/commands/noop_command.py +9 -0
- rasa/dialogue_understanding/commands/set_slot_command.py +34 -3
- rasa/dialogue_understanding/commands/skip_question_command.py +9 -0
- rasa/dialogue_understanding/commands/start_flow_command.py +9 -0
- rasa/dialogue_understanding/generator/__init__.py +16 -1
- rasa/dialogue_understanding/generator/command_generator.py +92 -6
- rasa/dialogue_understanding/generator/constants.py +18 -0
- rasa/dialogue_understanding/generator/flow_retrieval.py +7 -5
- rasa/dialogue_understanding/generator/llm_based_command_generator.py +467 -0
- rasa/dialogue_understanding/generator/llm_command_generator.py +39 -609
- rasa/dialogue_understanding/generator/multi_step/__init__.py +0 -0
- rasa/dialogue_understanding/generator/multi_step/fill_slots_prompt.jinja2 +62 -0
- rasa/dialogue_understanding/generator/multi_step/handle_flows_prompt.jinja2 +38 -0
- rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +827 -0
- rasa/dialogue_understanding/generator/nlu_command_adapter.py +69 -8
- rasa/dialogue_understanding/generator/single_step/__init__.py +0 -0
- rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +345 -0
- rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +44 -39
- rasa/dialogue_understanding/processor/command_processor.py +111 -3
- rasa/e2e_test/constants.py +1 -0
- rasa/e2e_test/e2e_test_case.py +44 -0
- rasa/e2e_test/e2e_test_runner.py +114 -11
- rasa/e2e_test/e2e_test_schema.yml +18 -0
- rasa/engine/caching.py +0 -1
- rasa/engine/graph.py +18 -6
- rasa/engine/recipes/config_files/default_config.yml +3 -3
- rasa/engine/recipes/default_components.py +1 -1
- rasa/engine/recipes/default_recipe.py +4 -5
- rasa/engine/recipes/recipe.py +1 -1
- rasa/engine/runner/dask.py +3 -9
- rasa/engine/storage/local_model_storage.py +0 -2
- rasa/engine/validation.py +179 -145
- rasa/exceptions.py +2 -2
- rasa/graph_components/validators/default_recipe_validator.py +3 -5
- rasa/hooks.py +0 -1
- rasa/model.py +1 -1
- rasa/model_training.py +1 -0
- rasa/nlu/classifiers/diet_classifier.py +8 -14
- rasa/nlu/extractors/crf_entity_extractor.py +4 -4
- rasa/nlu/extractors/duckling_entity_extractor.py +1 -1
- rasa/nlu/featurizers/dense_featurizer/convert_featurizer.py +1 -5
- rasa/nlu/featurizers/dense_featurizer/lm_featurizer.py +0 -4
- rasa/nlu/featurizers/featurizer.py +1 -1
- rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py +2 -4
- rasa/nlu/featurizers/sparse_featurizer/lexical_syntactic_featurizer.py +9 -12
- rasa/nlu/persistor.py +68 -26
- rasa/nlu/selectors/response_selector.py +7 -10
- rasa/nlu/test.py +0 -3
- rasa/nlu/utils/hugging_face/registry.py +1 -1
- rasa/nlu/utils/spacy_utils.py +1 -3
- rasa/server.py +22 -7
- rasa/shared/constants.py +12 -1
- rasa/shared/core/command_payload_reader.py +109 -0
- rasa/shared/core/constants.py +4 -5
- rasa/shared/core/domain.py +57 -56
- rasa/shared/core/events.py +4 -7
- rasa/shared/core/flows/flow.py +9 -0
- rasa/shared/core/flows/flows_list.py +12 -0
- rasa/shared/core/flows/steps/action.py +7 -2
- rasa/shared/core/generator.py +12 -11
- rasa/shared/core/slot_mappings.py +315 -24
- rasa/shared/core/slots.py +4 -2
- rasa/shared/core/trackers.py +32 -14
- rasa/shared/core/training_data/loading.py +0 -1
- rasa/shared/core/training_data/story_reader/story_reader.py +3 -3
- rasa/shared/core/training_data/story_reader/yaml_story_reader.py +11 -11
- rasa/shared/core/training_data/story_writer/yaml_story_writer.py +5 -3
- rasa/shared/core/training_data/structures.py +1 -1
- rasa/shared/core/training_data/visualization.py +1 -1
- rasa/shared/data.py +58 -1
- rasa/shared/exceptions.py +36 -2
- rasa/shared/importers/importer.py +1 -2
- rasa/shared/importers/rasa.py +0 -1
- rasa/shared/nlu/constants.py +2 -0
- rasa/shared/nlu/training_data/entities_parser.py +1 -2
- rasa/shared/nlu/training_data/formats/dialogflow.py +3 -2
- rasa/shared/nlu/training_data/formats/rasa_yaml.py +3 -5
- rasa/shared/nlu/training_data/formats/readerwriter.py +0 -1
- rasa/shared/nlu/training_data/message.py +13 -0
- rasa/shared/nlu/training_data/training_data.py +0 -2
- rasa/shared/providers/openai/session_handler.py +2 -2
- rasa/shared/utils/constants.py +3 -0
- rasa/shared/utils/io.py +11 -0
- rasa/shared/utils/llm.py +1 -2
- rasa/shared/utils/pykwalify_extensions.py +1 -0
- rasa/shared/utils/schemas/domain.yml +3 -0
- rasa/shared/utils/yaml.py +44 -35
- rasa/studio/auth.py +26 -10
- rasa/studio/constants.py +2 -0
- rasa/studio/data_handler.py +114 -107
- rasa/studio/download.py +160 -27
- rasa/studio/results_logger.py +137 -0
- rasa/studio/train.py +6 -7
- rasa/studio/upload.py +159 -134
- rasa/telemetry.py +188 -34
- rasa/tracing/config.py +18 -3
- rasa/tracing/constants.py +26 -2
- rasa/tracing/instrumentation/attribute_extractors.py +50 -41
- rasa/tracing/instrumentation/instrumentation.py +290 -44
- rasa/tracing/instrumentation/intentless_policy_instrumentation.py +7 -5
- rasa/tracing/instrumentation/metrics.py +109 -21
- rasa/tracing/metric_instrument_provider.py +83 -3
- rasa/utils/cli.py +2 -1
- rasa/utils/common.py +1 -1
- rasa/utils/endpoints.py +1 -2
- rasa/utils/io.py +6 -6
- rasa/utils/licensing.py +246 -31
- rasa/utils/ml_utils.py +1 -1
- rasa/utils/tensorflow/data_generator.py +1 -1
- rasa/utils/tensorflow/environment.py +1 -1
- rasa/utils/tensorflow/model_data.py +9 -11
- rasa/utils/tensorflow/model_data_utils.py +499 -500
- rasa/utils/tensorflow/models.py +5 -6
- rasa/utils/tensorflow/rasa_layers.py +15 -15
- rasa/utils/train_utils.py +1 -1
- rasa/utils/url_tools.py +53 -0
- rasa/validator.py +305 -3
- rasa/version.py +1 -1
- {rasa_pro-3.8.17.dist-info → rasa_pro-3.9.14.dist-info}/METADATA +22 -22
- {rasa_pro-3.8.17.dist-info → rasa_pro-3.9.14.dist-info}/RECORD +271 -253
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-85583a23.js +0 -1
- /rasa/dialogue_understanding/generator/{command_prompt_template.jinja2 → single_step/command_prompt_template.jinja2} +0 -0
- {rasa_pro-3.8.17.dist-info → rasa_pro-3.9.14.dist-info}/NOTICE +0 -0
- {rasa_pro-3.8.17.dist-info → rasa_pro-3.9.14.dist-info}/WHEEL +0 -0
- {rasa_pro-3.8.17.dist-info → rasa_pro-3.9.14.dist-info}/entry_points.txt +0 -0
|
@@ -13,7 +13,6 @@ from typing import (
|
|
|
13
13
|
Dict,
|
|
14
14
|
List,
|
|
15
15
|
Optional,
|
|
16
|
-
TYPE_CHECKING,
|
|
17
16
|
Text,
|
|
18
17
|
Type,
|
|
19
18
|
TypeVar,
|
|
@@ -21,15 +20,19 @@ from typing import (
|
|
|
21
20
|
|
|
22
21
|
from multidict import MultiDict
|
|
23
22
|
from opentelemetry.context import Context
|
|
24
|
-
|
|
25
|
-
import rasa.shared.utils.io
|
|
26
23
|
from opentelemetry.sdk.trace import TracerProvider
|
|
27
24
|
from opentelemetry.trace import SpanKind, Tracer
|
|
28
25
|
from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator
|
|
29
|
-
|
|
26
|
+
|
|
27
|
+
from rasa.core.actions.action import Action, RemoteAction, CustomActionExecutor
|
|
28
|
+
from rasa.core.actions.custom_action_executor import RetryCustomActionExecutor
|
|
29
|
+
from rasa.core.actions.grpc_custom_action_executor import GRPCCustomActionExecutor
|
|
30
30
|
from rasa.core.agent import Agent
|
|
31
31
|
from rasa.core.channels import OutputChannel
|
|
32
|
-
from rasa.core.information_retrieval.information_retrieval import
|
|
32
|
+
from rasa.core.information_retrieval.information_retrieval import (
|
|
33
|
+
InformationRetrieval,
|
|
34
|
+
SearchResultList,
|
|
35
|
+
)
|
|
33
36
|
from rasa.core.lock_store import LockStore
|
|
34
37
|
from rasa.core.nlg import NaturalLanguageGenerator
|
|
35
38
|
from rasa.core.policies.flows.flow_step_result import FlowActionPrediction
|
|
@@ -37,16 +40,21 @@ from rasa.core.policies.policy import Policy, PolicyPrediction
|
|
|
37
40
|
from rasa.core.processor import MessageProcessor
|
|
38
41
|
from rasa.core.tracker_store import TrackerStore
|
|
39
42
|
from rasa.dialogue_understanding.commands import Command
|
|
40
|
-
from rasa.dialogue_understanding.generator
|
|
43
|
+
from rasa.dialogue_understanding.generator import (
|
|
41
44
|
LLMCommandGenerator,
|
|
45
|
+
MultiStepLLMCommandGenerator,
|
|
46
|
+
SingleStepLLMCommandGenerator,
|
|
42
47
|
)
|
|
43
48
|
from rasa.dialogue_understanding.generator.nlu_command_adapter import NLUCommandAdapter
|
|
44
49
|
from rasa.engine.graph import GraphNode
|
|
45
50
|
from rasa.engine.training.graph_trainer import GraphTrainer
|
|
46
|
-
from rasa.shared.
|
|
51
|
+
from rasa.shared.core.domain import Domain
|
|
47
52
|
from rasa.shared.core.flows import FlowsList
|
|
48
53
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
54
|
+
from rasa.shared.nlu.constants import SET_SLOT_COMMAND
|
|
49
55
|
from rasa.shared.nlu.training_data.message import Message
|
|
56
|
+
from rasa.tracing.constants import REQUEST_BODY_SIZE_IN_BYTES_ATTRIBUTE_NAME
|
|
57
|
+
from rasa.tracing.instrumentation import attribute_extractors
|
|
50
58
|
from rasa.tracing.instrumentation.intentless_policy_instrumentation import (
|
|
51
59
|
_instrument_extract_ai_responses,
|
|
52
60
|
_instrument_generate_answer,
|
|
@@ -55,15 +63,12 @@ from rasa.tracing.instrumentation.intentless_policy_instrumentation import (
|
|
|
55
63
|
)
|
|
56
64
|
from rasa.tracing.instrumentation.metrics import (
|
|
57
65
|
record_llm_command_generator_metrics,
|
|
66
|
+
record_single_step_llm_command_generator_metrics,
|
|
67
|
+
record_multi_step_llm_command_generator_metrics,
|
|
58
68
|
record_callable_duration_metrics,
|
|
59
69
|
record_request_size_in_bytes,
|
|
60
70
|
)
|
|
61
|
-
from rasa.utils.endpoints import EndpointConfig
|
|
62
|
-
|
|
63
|
-
from rasa.tracing.instrumentation import attribute_extractors
|
|
64
|
-
|
|
65
|
-
if TYPE_CHECKING:
|
|
66
|
-
from langchain.schema import Document
|
|
71
|
+
from rasa.utils.endpoints import concat_url, EndpointConfig
|
|
67
72
|
|
|
68
73
|
# The `TypeVar` representing the return type for a function to be wrapped.
|
|
69
74
|
S = TypeVar("S")
|
|
@@ -272,6 +277,12 @@ GraphNodeType = TypeVar("GraphNodeType", bound=GraphNode)
|
|
|
272
277
|
LockStoreType = TypeVar("LockStoreType", bound=LockStore)
|
|
273
278
|
GraphTrainerType = TypeVar("GraphTrainerType", bound=GraphTrainer)
|
|
274
279
|
LLMCommandGeneratorType = TypeVar("LLMCommandGeneratorType", bound=LLMCommandGenerator)
|
|
280
|
+
SingleStepLLMCommandGeneratorType = TypeVar(
|
|
281
|
+
"SingleStepLLMCommandGeneratorType", bound=SingleStepLLMCommandGenerator
|
|
282
|
+
)
|
|
283
|
+
MultiStepLLMCommandGeneratorType = TypeVar(
|
|
284
|
+
"MultiStepLLMCommandGeneratorType", bound=MultiStepLLMCommandGenerator
|
|
285
|
+
)
|
|
275
286
|
CommandType = TypeVar("CommandType", bound=Command)
|
|
276
287
|
PolicyType = TypeVar("PolicyType", bound=Policy)
|
|
277
288
|
InformationRetrievalType = TypeVar(
|
|
@@ -296,6 +307,16 @@ def instrument(
|
|
|
296
307
|
vector_store_subclasses: Optional[List[Type[InformationRetrievalType]]] = None,
|
|
297
308
|
nlu_command_adapter_class: Optional[Type[NLUCommandAdapterType]] = None,
|
|
298
309
|
endpoint_config_class: Optional[Type[EndpointConfigType]] = None,
|
|
310
|
+
grpc_custom_action_executor_class: Optional[Type[GRPCCustomActionExecutor]] = None,
|
|
311
|
+
single_step_llm_command_generator_class: Optional[
|
|
312
|
+
Type[SingleStepLLMCommandGeneratorType]
|
|
313
|
+
] = None,
|
|
314
|
+
multi_step_llm_command_generator_class: Optional[
|
|
315
|
+
Type[MultiStepLLMCommandGeneratorType]
|
|
316
|
+
] = None,
|
|
317
|
+
custom_action_executor_subclasses: Optional[
|
|
318
|
+
List[Type[CustomActionExecutor]]
|
|
319
|
+
] = None,
|
|
299
320
|
) -> None:
|
|
300
321
|
"""Substitute methods to be traced by their traced counterparts.
|
|
301
322
|
|
|
@@ -333,6 +354,18 @@ def instrument(
|
|
|
333
354
|
`None` is given, no `NLUCommandAdapter` will be instrumented.
|
|
334
355
|
:param endpoint_config_class: The `EndpointConfig` to be instrumented. If
|
|
335
356
|
`None` is given, no `EndpointConfig` will be instrumented.
|
|
357
|
+
:param grpc_custom_action_executor_class: The `GRPCCustomActionExecution` to be
|
|
358
|
+
instrumented. If `None` is given, no `GRPCCustomActionExecution`
|
|
359
|
+
will be instrumented.
|
|
360
|
+
:param single_step_llm_command_generator_class: The `SingleStepLLMCommandGenerator`
|
|
361
|
+
to be instrumented. If `None` is given, no `SingleStepLLMCommandGenerator` will
|
|
362
|
+
be instrumented.
|
|
363
|
+
:param multi_step_llm_command_generator_class: The `MultiStepLLMCommandGenerator`
|
|
364
|
+
to be instrumented. If `None` is given, no `MultiStepLLMCommandGenerator` will
|
|
365
|
+
be instrumented.
|
|
366
|
+
:param custom_action_executor_subclasses: The subclasses of `CustomActionExecutor`
|
|
367
|
+
to be instrumented. If `None` is given, no subclass of `CustomActionExecutor`
|
|
368
|
+
will be instrumented.
|
|
336
369
|
"""
|
|
337
370
|
if agent_class is not None and not class_is_instrumented(agent_class):
|
|
338
371
|
_instrument_method(
|
|
@@ -379,7 +412,7 @@ def instrument(
|
|
|
379
412
|
tracer_provider.get_tracer(lock_store_class.__module__),
|
|
380
413
|
attribute_extractors.extract_attrs_for_lock_store,
|
|
381
414
|
)
|
|
382
|
-
lock_store_class.lock = contextlib.asynccontextmanager(traced_lock_method) # type: ignore[assignment]
|
|
415
|
+
lock_store_class.lock = contextlib.asynccontextmanager(traced_lock_method) # type: ignore[assignment]
|
|
383
416
|
|
|
384
417
|
logger.debug(f"Instrumented '{lock_store_class.__name__}.lock'.")
|
|
385
418
|
|
|
@@ -402,8 +435,8 @@ def instrument(
|
|
|
402
435
|
_instrument_method(
|
|
403
436
|
tracer_provider.get_tracer(llm_command_generator_class.__module__),
|
|
404
437
|
llm_command_generator_class,
|
|
405
|
-
"
|
|
406
|
-
attribute_extractors.
|
|
438
|
+
"invoke_llm",
|
|
439
|
+
attribute_extractors.extract_attrs_for_llm_based_command_generator,
|
|
407
440
|
metrics_recorder=record_llm_command_generator_metrics,
|
|
408
441
|
)
|
|
409
442
|
_instrument_method(
|
|
@@ -414,6 +447,49 @@ def instrument(
|
|
|
414
447
|
)
|
|
415
448
|
mark_class_as_instrumented(llm_command_generator_class)
|
|
416
449
|
|
|
450
|
+
if (
|
|
451
|
+
single_step_llm_command_generator_class is not None
|
|
452
|
+
and not class_is_instrumented(single_step_llm_command_generator_class)
|
|
453
|
+
):
|
|
454
|
+
_instrument_method(
|
|
455
|
+
tracer_provider.get_tracer(
|
|
456
|
+
single_step_llm_command_generator_class.__module__
|
|
457
|
+
),
|
|
458
|
+
single_step_llm_command_generator_class,
|
|
459
|
+
"invoke_llm",
|
|
460
|
+
attribute_extractors.extract_attrs_for_llm_based_command_generator,
|
|
461
|
+
metrics_recorder=record_single_step_llm_command_generator_metrics,
|
|
462
|
+
)
|
|
463
|
+
_instrument_method(
|
|
464
|
+
tracer_provider.get_tracer(
|
|
465
|
+
single_step_llm_command_generator_class.__module__
|
|
466
|
+
),
|
|
467
|
+
single_step_llm_command_generator_class,
|
|
468
|
+
"_check_commands_against_startable_flows",
|
|
469
|
+
attribute_extractors.extract_attrs_for_check_commands_against_startable_flows,
|
|
470
|
+
)
|
|
471
|
+
mark_class_as_instrumented(single_step_llm_command_generator_class)
|
|
472
|
+
|
|
473
|
+
if multi_step_llm_command_generator_class is not None and not class_is_instrumented(
|
|
474
|
+
multi_step_llm_command_generator_class
|
|
475
|
+
):
|
|
476
|
+
_instrument_method(
|
|
477
|
+
tracer_provider.get_tracer(
|
|
478
|
+
multi_step_llm_command_generator_class.__module__
|
|
479
|
+
),
|
|
480
|
+
multi_step_llm_command_generator_class,
|
|
481
|
+
"invoke_llm",
|
|
482
|
+
attribute_extractors.extract_attrs_for_llm_based_command_generator,
|
|
483
|
+
metrics_recorder=record_multi_step_llm_command_generator_metrics,
|
|
484
|
+
)
|
|
485
|
+
_instrument_multi_step_llm_command_generator_parse_commands(
|
|
486
|
+
tracer_provider.get_tracer(
|
|
487
|
+
multi_step_llm_command_generator_class.__module__
|
|
488
|
+
),
|
|
489
|
+
multi_step_llm_command_generator_class,
|
|
490
|
+
)
|
|
491
|
+
mark_class_as_instrumented(multi_step_llm_command_generator_class)
|
|
492
|
+
|
|
417
493
|
if command_subclasses:
|
|
418
494
|
for command_subclass in command_subclasses:
|
|
419
495
|
if command_subclass is not None and not class_is_instrumented(
|
|
@@ -503,14 +579,48 @@ def instrument(
|
|
|
503
579
|
if endpoint_config_class is not None and not class_is_instrumented(
|
|
504
580
|
endpoint_config_class
|
|
505
581
|
):
|
|
506
|
-
|
|
582
|
+
_instrument_endpoint_config(
|
|
507
583
|
tracer_provider.get_tracer(endpoint_config_class.__module__),
|
|
508
584
|
endpoint_config_class,
|
|
509
|
-
"request",
|
|
510
|
-
attribute_extractors.extract_attrs_for_endpoint_config,
|
|
511
|
-
metrics_recorder=record_request_size_in_bytes,
|
|
512
585
|
)
|
|
513
586
|
|
|
587
|
+
if grpc_custom_action_executor_class is not None and not class_is_instrumented(
|
|
588
|
+
grpc_custom_action_executor_class
|
|
589
|
+
):
|
|
590
|
+
_instrument_grpc_custom_action_executor(
|
|
591
|
+
tracer_provider.get_tracer(grpc_custom_action_executor_class.__module__),
|
|
592
|
+
grpc_custom_action_executor_class,
|
|
593
|
+
)
|
|
594
|
+
|
|
595
|
+
if custom_action_executor_subclasses:
|
|
596
|
+
for custom_action_executor_subclass in custom_action_executor_subclasses:
|
|
597
|
+
if (
|
|
598
|
+
custom_action_executor_subclass is not None
|
|
599
|
+
and not class_is_instrumented(custom_action_executor_subclass)
|
|
600
|
+
):
|
|
601
|
+
_instrument_method(
|
|
602
|
+
tracer_provider.get_tracer(
|
|
603
|
+
custom_action_executor_subclass.__module__
|
|
604
|
+
),
|
|
605
|
+
custom_action_executor_subclass,
|
|
606
|
+
"run",
|
|
607
|
+
attribute_extractors.extract_attrs_for_custom_action_executor_run,
|
|
608
|
+
)
|
|
609
|
+
|
|
610
|
+
if issubclass(
|
|
611
|
+
custom_action_executor_subclass, GRPCCustomActionExecutor
|
|
612
|
+
):
|
|
613
|
+
_instrument_method(
|
|
614
|
+
tracer=tracer_provider.get_tracer(
|
|
615
|
+
custom_action_executor_subclass.__module__
|
|
616
|
+
),
|
|
617
|
+
instrumented_class=custom_action_executor_subclass,
|
|
618
|
+
method_name="_request",
|
|
619
|
+
attr_extractor=attribute_extractors.extract_attrs_for_grpc_custom_action_executor_request,
|
|
620
|
+
)
|
|
621
|
+
|
|
622
|
+
mark_class_as_instrumented(custom_action_executor_subclass)
|
|
623
|
+
|
|
514
624
|
|
|
515
625
|
def _instrument_nlu_command_adapter_predict_commands(
|
|
516
626
|
tracer: Tracer, nlu_command_adapter_class: Type[NLUCommandAdapterType]
|
|
@@ -522,11 +632,12 @@ def _instrument_nlu_command_adapter_predict_commands(
|
|
|
522
632
|
message: Message,
|
|
523
633
|
flows: FlowsList,
|
|
524
634
|
tracker: Optional[DialogueStateTracker] = None,
|
|
635
|
+
**kwargs: Any,
|
|
525
636
|
) -> List[Command]:
|
|
526
637
|
with tracer.start_as_current_span(
|
|
527
638
|
f"{self.__class__.__name__}.{fn.__name__}"
|
|
528
639
|
) as span:
|
|
529
|
-
commands = await fn(self, message, flows, tracker)
|
|
640
|
+
commands = await fn(self, message, flows, tracker, **kwargs)
|
|
530
641
|
|
|
531
642
|
span.set_attributes(
|
|
532
643
|
{
|
|
@@ -540,8 +651,10 @@ def _instrument_nlu_command_adapter_predict_commands(
|
|
|
540
651
|
|
|
541
652
|
return wrapper
|
|
542
653
|
|
|
543
|
-
nlu_command_adapter_class.predict_commands =
|
|
544
|
-
|
|
654
|
+
nlu_command_adapter_class.predict_commands = ( # type: ignore[assignment]
|
|
655
|
+
tracing_nlu_command_adapter_predict_commands_wrapper(
|
|
656
|
+
nlu_command_adapter_class.predict_commands
|
|
657
|
+
)
|
|
545
658
|
)
|
|
546
659
|
|
|
547
660
|
logger.debug(
|
|
@@ -549,23 +662,71 @@ def _instrument_nlu_command_adapter_predict_commands(
|
|
|
549
662
|
)
|
|
550
663
|
|
|
551
664
|
|
|
665
|
+
def _instrument_multi_step_llm_command_generator_parse_commands(
|
|
666
|
+
tracer: Tracer,
|
|
667
|
+
multi_step_llm_command_generator_class: Type[MultiStepLLMCommandGeneratorType],
|
|
668
|
+
) -> None:
|
|
669
|
+
def tracing_multi_step_llm_command_generator_parse_commands_wrapper(
|
|
670
|
+
fn: Callable,
|
|
671
|
+
) -> Callable:
|
|
672
|
+
@functools.wraps(fn)
|
|
673
|
+
def wrapper(
|
|
674
|
+
cls: MultiStepLLMCommandGenerator,
|
|
675
|
+
actions: Optional[str],
|
|
676
|
+
tracker: DialogueStateTracker,
|
|
677
|
+
flows: FlowsList,
|
|
678
|
+
is_start_or_end_prompt: bool = False,
|
|
679
|
+
) -> List[Command]:
|
|
680
|
+
with tracer.start_as_current_span(
|
|
681
|
+
f"{cls.__class__.__name__}.{fn.__name__}"
|
|
682
|
+
) as span:
|
|
683
|
+
commands = fn(actions, tracker, flows, is_start_or_end_prompt)
|
|
684
|
+
|
|
685
|
+
commands_list = []
|
|
686
|
+
for command in commands:
|
|
687
|
+
command_as_dict = command.as_dict()
|
|
688
|
+
command_type = command.command()
|
|
689
|
+
|
|
690
|
+
if command_type == SET_SLOT_COMMAND:
|
|
691
|
+
slot_value = command_as_dict.pop("value", None)
|
|
692
|
+
command_as_dict["is_slot_value_missing_or_none"] = (
|
|
693
|
+
slot_value is None
|
|
694
|
+
)
|
|
695
|
+
|
|
696
|
+
commands_list.append(command_as_dict)
|
|
697
|
+
|
|
698
|
+
span.set_attributes({"commands": json.dumps(commands_list)})
|
|
699
|
+
return commands
|
|
700
|
+
|
|
701
|
+
return wrapper
|
|
702
|
+
|
|
703
|
+
multi_step_llm_command_generator_class.parse_commands = ( # type: ignore[assignment]
|
|
704
|
+
tracing_multi_step_llm_command_generator_parse_commands_wrapper(
|
|
705
|
+
multi_step_llm_command_generator_class.parse_commands
|
|
706
|
+
)
|
|
707
|
+
)
|
|
708
|
+
|
|
709
|
+
|
|
552
710
|
def _instrument_information_retrieval_search(
|
|
553
711
|
tracer: Tracer, vector_store_class: Type[InformationRetrievalType]
|
|
554
712
|
) -> None:
|
|
555
713
|
def tracing_information_retrieval_search_wrapper(fn: Callable) -> Callable:
|
|
556
714
|
@functools.wraps(fn)
|
|
557
715
|
async def wrapper(
|
|
558
|
-
self: InformationRetrieval,
|
|
559
|
-
|
|
716
|
+
self: InformationRetrieval,
|
|
717
|
+
query: Text,
|
|
718
|
+
tracker_state: Dict[str, Any],
|
|
719
|
+
threshold: float = 0.0,
|
|
720
|
+
) -> SearchResultList:
|
|
560
721
|
with tracer.start_as_current_span(
|
|
561
722
|
f"{self.__class__.__name__}.{fn.__name__}"
|
|
562
723
|
) as span:
|
|
563
|
-
documents = await fn(self, query, threshold)
|
|
724
|
+
documents = await fn(self, query, tracker_state, threshold)
|
|
564
725
|
span.set_attributes(
|
|
565
726
|
{
|
|
566
727
|
"query": query,
|
|
567
728
|
"document_metadata": json.dumps(
|
|
568
|
-
[document.metadata for document in documents]
|
|
729
|
+
[document.metadata for document in documents.results]
|
|
569
730
|
),
|
|
570
731
|
}
|
|
571
732
|
)
|
|
@@ -573,7 +734,7 @@ def _instrument_information_retrieval_search(
|
|
|
573
734
|
|
|
574
735
|
return wrapper
|
|
575
736
|
|
|
576
|
-
vector_store_class.search = tracing_information_retrieval_search_wrapper( # type: ignore[assignment]
|
|
737
|
+
vector_store_class.search = tracing_information_retrieval_search_wrapper( # type: ignore[assignment]
|
|
577
738
|
vector_store_class.search
|
|
578
739
|
)
|
|
579
740
|
|
|
@@ -682,7 +843,7 @@ def _instrument_get_tracker(
|
|
|
682
843
|
|
|
683
844
|
return wrapper
|
|
684
845
|
|
|
685
|
-
processor_class.get_tracker = tracing_get_tracker_wrapper( # type: ignore[assignment]
|
|
846
|
+
processor_class.get_tracker = tracing_get_tracker_wrapper( # type: ignore[assignment]
|
|
686
847
|
processor_class.get_tracker
|
|
687
848
|
)
|
|
688
849
|
|
|
@@ -862,37 +1023,122 @@ def _instrument_run_action(
|
|
|
862
1023
|
attrs = {
|
|
863
1024
|
"action_name": action.name(),
|
|
864
1025
|
"sender_id": tracker.sender_id,
|
|
865
|
-
"message_id": tracker.latest_message.message_id or "default", # type: ignore[union-attr]
|
|
1026
|
+
"message_id": tracker.latest_message.message_id or "default", # type: ignore[union-attr]
|
|
866
1027
|
}
|
|
1028
|
+
if isinstance(action, RemoteAction):
|
|
1029
|
+
if isinstance(action.executor, RetryCustomActionExecutor):
|
|
1030
|
+
attrs["executor_class_name"] = type(
|
|
1031
|
+
action.executor._custom_action_executor
|
|
1032
|
+
).__name__
|
|
1033
|
+
else:
|
|
1034
|
+
attrs["executor_class_name"] = type(action.executor).__name__
|
|
867
1035
|
with tracer.start_as_current_span(
|
|
868
1036
|
f"{self.__class__.__name__}.{fn.__name__}",
|
|
869
1037
|
kind=SpanKind.CLIENT,
|
|
870
1038
|
attributes=attrs,
|
|
871
1039
|
):
|
|
872
|
-
if isinstance(action, RemoteAction):
|
|
873
|
-
if not isinstance(action.action_endpoint, EndpointConfig):
|
|
874
|
-
rasa.shared.utils.io.raise_warning(
|
|
875
|
-
f"No endpoint is configured to propagate the trace of this "
|
|
876
|
-
f"custom action {action.name()}. Please take a look at "
|
|
877
|
-
f"the docs and set an endpoint configuration in the "
|
|
878
|
-
f"endpoints.yml file",
|
|
879
|
-
docs=f"{DOCS_BASE_URL}/custom-actions",
|
|
880
|
-
)
|
|
881
|
-
else:
|
|
882
|
-
propagator = TraceContextTextMapPropagator()
|
|
883
|
-
propagator.inject(action.action_endpoint.headers)
|
|
884
|
-
|
|
885
1040
|
return await fn(self, action, tracker, output_channel, nlg, prediction)
|
|
886
1041
|
|
|
887
1042
|
return wrapper
|
|
888
1043
|
|
|
889
|
-
processor_class._run_action = tracing_run_action_wrapper( # type: ignore[assignment]
|
|
1044
|
+
processor_class._run_action = tracing_run_action_wrapper( # type: ignore[assignment]
|
|
890
1045
|
processor_class._run_action
|
|
891
1046
|
)
|
|
892
1047
|
|
|
893
1048
|
logger.debug(f"Instrumented '{processor_class.__name__}._run_action'.")
|
|
894
1049
|
|
|
895
1050
|
|
|
1051
|
+
def _instrument_endpoint_config(
|
|
1052
|
+
tracer: Tracer, endpoint_config_class: Type[EndpointConfigType]
|
|
1053
|
+
) -> None:
|
|
1054
|
+
"""Instrument the `request` method of the `EndpointConfig` class.
|
|
1055
|
+
|
|
1056
|
+
Args:
|
|
1057
|
+
tracer: The `Tracer` that shall be used for tracing.
|
|
1058
|
+
endpoint_config_class: The `EndpointConfig` to be instrumented.
|
|
1059
|
+
"""
|
|
1060
|
+
|
|
1061
|
+
def tracing_endpoint_config_wrapper(fn: Callable) -> Callable:
|
|
1062
|
+
@functools.wraps(fn)
|
|
1063
|
+
async def wrapper(
|
|
1064
|
+
self: Type[EndpointConfigType],
|
|
1065
|
+
method: Text = "post",
|
|
1066
|
+
subpath: Optional[Text] = None,
|
|
1067
|
+
content_type: Optional[Text] = "application/json",
|
|
1068
|
+
compress: bool = False,
|
|
1069
|
+
**kwargs: Any,
|
|
1070
|
+
) -> bool:
|
|
1071
|
+
request_body = kwargs.get("json")
|
|
1072
|
+
attrs: Dict[str, Any] = {"url": concat_url(self.url, subpath)}
|
|
1073
|
+
|
|
1074
|
+
if not request_body:
|
|
1075
|
+
attrs.update({REQUEST_BODY_SIZE_IN_BYTES_ATTRIBUTE_NAME: 0})
|
|
1076
|
+
else:
|
|
1077
|
+
attrs.update(
|
|
1078
|
+
{
|
|
1079
|
+
REQUEST_BODY_SIZE_IN_BYTES_ATTRIBUTE_NAME: len(
|
|
1080
|
+
json.dumps(request_body).encode("utf-8")
|
|
1081
|
+
)
|
|
1082
|
+
}
|
|
1083
|
+
)
|
|
1084
|
+
with tracer.start_as_current_span(
|
|
1085
|
+
f"{self.__class__.__name__}.{fn.__name__}",
|
|
1086
|
+
attributes=attrs,
|
|
1087
|
+
):
|
|
1088
|
+
TraceContextTextMapPropagator().inject(self.headers)
|
|
1089
|
+
|
|
1090
|
+
start_time = time.perf_counter_ns()
|
|
1091
|
+
result = await fn(
|
|
1092
|
+
self, method, subpath, content_type, compress, **kwargs
|
|
1093
|
+
)
|
|
1094
|
+
end_time = time.perf_counter_ns()
|
|
1095
|
+
|
|
1096
|
+
record_callable_duration_metrics(self, start_time, end_time)
|
|
1097
|
+
record_request_size_in_bytes(attrs)
|
|
1098
|
+
|
|
1099
|
+
return result
|
|
1100
|
+
|
|
1101
|
+
return wrapper
|
|
1102
|
+
|
|
1103
|
+
endpoint_config_class.request = tracing_endpoint_config_wrapper( # type: ignore[assignment]
|
|
1104
|
+
endpoint_config_class.request
|
|
1105
|
+
)
|
|
1106
|
+
|
|
1107
|
+
logger.debug(f"Instrumented '{endpoint_config_class.__name__}.request'.")
|
|
1108
|
+
|
|
1109
|
+
|
|
1110
|
+
def _instrument_grpc_custom_action_executor(
|
|
1111
|
+
tracer: Tracer, grpc_custom_action_executor_class: Type[GRPCCustomActionExecutor]
|
|
1112
|
+
) -> None:
|
|
1113
|
+
"""Instrument the `run` method of the `GRPCCustomActionExecutor` class.
|
|
1114
|
+
|
|
1115
|
+
Args:
|
|
1116
|
+
tracer: The `Tracer` that shall be used for tracing.
|
|
1117
|
+
grpc_custom_action_executor_class: The `GRPCCustomActionExecutor` to
|
|
1118
|
+
be instrumented.
|
|
1119
|
+
"""
|
|
1120
|
+
|
|
1121
|
+
def tracing_grpc_custom_action_executor_wrapper(fn: Callable) -> Callable:
|
|
1122
|
+
@functools.wraps(fn)
|
|
1123
|
+
async def wrapper(
|
|
1124
|
+
self: Type[GRPCCustomActionExecutor],
|
|
1125
|
+
tracker: Type[DialogueStateTracker],
|
|
1126
|
+
domain: Type[Domain],
|
|
1127
|
+
include_domain: bool = False,
|
|
1128
|
+
) -> bool:
|
|
1129
|
+
TraceContextTextMapPropagator().inject(self.action_endpoint.headers)
|
|
1130
|
+
result = await fn(self, tracker, domain, include_domain)
|
|
1131
|
+
return result
|
|
1132
|
+
|
|
1133
|
+
return wrapper
|
|
1134
|
+
|
|
1135
|
+
grpc_custom_action_executor_class.run = tracing_grpc_custom_action_executor_wrapper( # type: ignore[assignment]
|
|
1136
|
+
grpc_custom_action_executor_class.run
|
|
1137
|
+
)
|
|
1138
|
+
|
|
1139
|
+
logger.debug(f"Instrumented '{grpc_custom_action_executor_class.__name__}.run.")
|
|
1140
|
+
|
|
1141
|
+
|
|
896
1142
|
def _mangled_instrumented_boolean_attribute_name(instrumented_class: Type) -> Text:
|
|
897
1143
|
# see https://peps.python.org/pep-0008/#method-names-and-instance-variables
|
|
898
1144
|
# and https://stackoverflow.com/a/50401073
|
|
@@ -37,7 +37,7 @@ def _instrument_select_response_examples(
|
|
|
37
37
|
|
|
38
38
|
return wrapper
|
|
39
39
|
|
|
40
|
-
policy_class.select_response_examples = tracing_select_response_examples_wrapper( # type: ignore[assignment]
|
|
40
|
+
policy_class.select_response_examples = tracing_select_response_examples_wrapper( # type: ignore[assignment]
|
|
41
41
|
policy_class.select_response_examples
|
|
42
42
|
)
|
|
43
43
|
|
|
@@ -72,8 +72,10 @@ def _instrument_select_few_shot_conversations(
|
|
|
72
72
|
|
|
73
73
|
return wrapper
|
|
74
74
|
|
|
75
|
-
policy_class.select_few_shot_conversations =
|
|
76
|
-
|
|
75
|
+
policy_class.select_few_shot_conversations = ( # type: ignore[assignment]
|
|
76
|
+
tracing_select_few_shot_conversations_wrapper(
|
|
77
|
+
policy_class.select_few_shot_conversations
|
|
78
|
+
)
|
|
77
79
|
)
|
|
78
80
|
|
|
79
81
|
logger.debug(
|
|
@@ -102,7 +104,7 @@ def _instrument_extract_ai_responses(
|
|
|
102
104
|
|
|
103
105
|
return wrapper
|
|
104
106
|
|
|
105
|
-
policy_class.extract_ai_responses = tracing_extract_ai_responses_wrapper( # type: ignore[assignment]
|
|
107
|
+
policy_class.extract_ai_responses = tracing_extract_ai_responses_wrapper( # type: ignore[assignment]
|
|
106
108
|
policy_class.extract_ai_responses
|
|
107
109
|
)
|
|
108
110
|
|
|
@@ -135,7 +137,7 @@ def _instrument_generate_answer(
|
|
|
135
137
|
|
|
136
138
|
return wrapper
|
|
137
139
|
|
|
138
|
-
policy_class.generate_answer = tracing_generate_answer_wrapper( # type: ignore[assignment]
|
|
140
|
+
policy_class.generate_answer = tracing_generate_answer_wrapper( # type: ignore[assignment]
|
|
139
141
|
policy_class.generate_answer
|
|
140
142
|
)
|
|
141
143
|
|