rasa-pro 3.8.18__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 +6 -42
- 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/constants.py +1 -1
- 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 +3 -26
- rasa/core/featurizers/tracker_featurizers.py +18 -122
- 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 +61 -88
- rasa/core/policies/unexpected_intent_policy.py +8 -17
- 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 +33 -52
- 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 +54 -97
- 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 +18 -49
- rasa/nlu/featurizers/sparse_featurizer/lexical_syntactic_featurizer.py +26 -64
- rasa/nlu/featurizers/sparse_featurizer/regex_featurizer.py +3 -5
- 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/features.py +2 -120
- 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 -1
- 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 +72 -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 +201 -12
- 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.18.dist-info → rasa_pro-3.9.14.dist-info}/METADATA +25 -61
- {rasa_pro-3.8.18.dist-info → rasa_pro-3.9.14.dist-info}/RECORD +276 -259
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-85583a23.js +0 -1
- rasa/utils/tensorflow/feature_array.py +0 -370
- /rasa/dialogue_understanding/generator/{command_prompt_template.jinja2 → single_step/command_prompt_template.jinja2} +0 -0
- {rasa_pro-3.8.18.dist-info → rasa_pro-3.9.14.dist-info}/NOTICE +0 -0
- {rasa_pro-3.8.18.dist-info → rasa_pro-3.9.14.dist-info}/WHEEL +0 -0
- {rasa_pro-3.8.18.dist-info → rasa_pro-3.9.14.dist-info}/entry_points.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Z as zt,$ as ot,X as wt,W as Ft,s as Nt,g as Xt,B as Yt,D as St,a as Ht,b as $t,E as Ut,l as Ct,U as qt,i as jt,d as Gt}from"./index-
|
|
1
|
+
import{Z as zt,$ as ot,X as wt,W as Ft,s as Nt,g as Xt,B as Yt,D as St,a as Ht,b as $t,E as Ut,l as Ct,U as qt,i as jt,d as Gt}from"./index-a5d3e69d.js";import{c as Qt}from"./createText-62fc7601-8b6fcc2a.js";import{i as Kt}from"./init-77b53fdd.js";import{o as Zt}from"./ordinal-ba9b4969.js";import{l as ft}from"./linear-c4fc4098.js";import{l as pt}from"./line-5038b469.js";import"./array-9f3ba611.js";import"./path-53f90ab3.js";function Jt(e,t,i){e=+e,t=+t,i=(n=arguments.length)<2?(t=e,e=0,1):n<3?1:+i;for(var s=-1,n=Math.max(0,Math.ceil((t-e)/i))|0,o=new Array(n);++s<n;)o[s]=e+s*i;return o}function st(){var e=Zt().unknown(void 0),t=e.domain,i=e.range,s=0,n=1,o,c,f=!1,d=0,R=0,_=.5;delete e.unknown;function A(){var m=t().length,T=n<s,S=T?n:s,P=T?s:n;o=(P-S)/Math.max(1,m-d+R*2),f&&(o=Math.floor(o)),S+=(P-S-o*(m-d))*_,c=o*(1-d),f&&(S=Math.round(S),c=Math.round(c));var p=Jt(m).map(function(C){return S+o*C});return i(T?p.reverse():p)}return e.domain=function(m){return arguments.length?(t(m),A()):t()},e.range=function(m){return arguments.length?([s,n]=m,s=+s,n=+n,A()):[s,n]},e.rangeRound=function(m){return[s,n]=m,s=+s,n=+n,f=!0,A()},e.bandwidth=function(){return c},e.step=function(){return o},e.round=function(m){return arguments.length?(f=!!m,A()):f},e.padding=function(m){return arguments.length?(d=Math.min(1,R=+m),A()):d},e.paddingInner=function(m){return arguments.length?(d=Math.min(1,m),A()):d},e.paddingOuter=function(m){return arguments.length?(R=+m,A()):R},e.align=function(m){return arguments.length?(_=Math.max(0,Math.min(1,m)),A()):_},e.copy=function(){return st(t(),[s,n]).round(f).paddingInner(d).paddingOuter(R).align(_)},Kt.apply(A(),arguments)}var nt=function(){var e=function(V,r,l,u){for(l=l||{},u=V.length;u--;l[V[u]]=r);return l},t=[1,10,12,14,16,18,19,21,23],i=[2,6],s=[1,3],n=[1,5],o=[1,6],c=[1,7],f=[1,5,10,12,14,16,18,19,21,23,34,35,36],d=[1,25],R=[1,26],_=[1,28],A=[1,29],m=[1,30],T=[1,31],S=[1,32],P=[1,33],p=[1,34],C=[1,35],h=[1,36],L=[1,37],z=[1,43],lt=[1,42],ct=[1,47],$=[1,50],w=[1,10,12,14,16,18,19,21,23,34,35,36],Q=[1,10,12,14,16,18,19,21,23,24,26,27,28,34,35,36],E=[1,10,12,14,16,18,19,21,23,24,26,27,28,34,35,36,41,42,43,44,45,46,47,48,49,50],ut=[1,64],K={trace:function(){},yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,commaSeparatedNumbers:25,SQUARE_BRACES_END:26,NUMBER_WITH_DECIMAL:27,COMMA:28,xAxisData:29,bandData:30,ARROW_DELIMITER:31,commaSeparatedTexts:32,yAxisData:33,NEWLINE:34,SEMI:35,EOF:36,alphaNum:37,STR:38,MD_STR:39,alphaNumToken:40,AMP:41,NUM:42,ALPHA:43,PLUS:44,EQUALS:45,MULT:46,DOT:47,BRKT:48,MINUS:49,UNDERSCORE:50,$accept:0,$end:1},terminals_:{2:"error",5:"XYCHART",8:"CHART_ORIENTATION",10:"title",12:"X_AXIS",14:"Y_AXIS",16:"LINE",18:"BAR",19:"acc_title",20:"acc_title_value",21:"acc_descr",22:"acc_descr_value",23:"acc_descr_multiline_value",24:"SQUARE_BRACES_START",26:"SQUARE_BRACES_END",27:"NUMBER_WITH_DECIMAL",28:"COMMA",31:"ARROW_DELIMITER",34:"NEWLINE",35:"SEMI",36:"EOF",38:"STR",39:"MD_STR",41:"AMP",42:"NUM",43:"ALPHA",44:"PLUS",45:"EQUALS",46:"MULT",47:"DOT",48:"BRKT",49:"MINUS",50:"UNDERSCORE"},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[13,1],[13,2],[13,1],[29,1],[29,3],[30,3],[32,3],[32,1],[15,1],[15,2],[15,1],[33,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[37,1],[37,2],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1]],performAction:function(r,l,u,g,b,a,F){var x=a.length-1;switch(b){case 5:g.setOrientation(a[x]);break;case 9:g.setDiagramTitle(a[x].text.trim());break;case 12:g.setLineData({text:"",type:"text"},a[x]);break;case 13:g.setLineData(a[x-1],a[x]);break;case 14:g.setBarData({text:"",type:"text"},a[x]);break;case 15:g.setBarData(a[x-1],a[x]);break;case 16:this.$=a[x].trim(),g.setAccTitle(this.$);break;case 17:case 18:this.$=a[x].trim(),g.setAccDescription(this.$);break;case 19:this.$=a[x-1];break;case 20:this.$=[Number(a[x-2]),...a[x]];break;case 21:this.$=[Number(a[x])];break;case 22:g.setXAxisTitle(a[x]);break;case 23:g.setXAxisTitle(a[x-1]);break;case 24:g.setXAxisTitle({type:"text",text:""});break;case 25:g.setXAxisBand(a[x]);break;case 26:g.setXAxisRangeData(Number(a[x-2]),Number(a[x]));break;case 27:this.$=a[x-1];break;case 28:this.$=[a[x-2],...a[x]];break;case 29:this.$=[a[x]];break;case 30:g.setYAxisTitle(a[x]);break;case 31:g.setYAxisTitle(a[x-1]);break;case 32:g.setYAxisTitle({type:"text",text:""});break;case 33:g.setYAxisRangeData(Number(a[x-2]),Number(a[x]));break;case 37:this.$={text:a[x],type:"text"};break;case 38:this.$={text:a[x],type:"text"};break;case 39:this.$={text:a[x],type:"markdown"};break;case 40:this.$=a[x];break;case 41:this.$=a[x-1]+""+a[x];break}},table:[e(t,i,{3:1,4:2,7:4,5:s,34:n,35:o,36:c}),{1:[3]},e(t,i,{4:2,7:4,3:8,5:s,34:n,35:o,36:c}),e(t,i,{4:2,7:4,6:9,3:10,5:s,8:[1,11],34:n,35:o,36:c}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},e(f,[2,34]),e(f,[2,35]),e(f,[2,36]),{1:[2,1]},e(t,i,{4:2,7:4,3:21,5:s,34:n,35:o,36:c}),{1:[2,3]},e(f,[2,5]),e(t,[2,7],{4:22,34:n,35:o,36:c}),{11:23,37:24,38:d,39:R,40:27,41:_,42:A,43:m,44:T,45:S,46:P,47:p,48:C,49:h,50:L},{11:39,13:38,24:z,27:lt,29:40,30:41,37:24,38:d,39:R,40:27,41:_,42:A,43:m,44:T,45:S,46:P,47:p,48:C,49:h,50:L},{11:45,15:44,27:ct,33:46,37:24,38:d,39:R,40:27,41:_,42:A,43:m,44:T,45:S,46:P,47:p,48:C,49:h,50:L},{11:49,17:48,24:$,37:24,38:d,39:R,40:27,41:_,42:A,43:m,44:T,45:S,46:P,47:p,48:C,49:h,50:L},{11:52,17:51,24:$,37:24,38:d,39:R,40:27,41:_,42:A,43:m,44:T,45:S,46:P,47:p,48:C,49:h,50:L},{20:[1,53]},{22:[1,54]},e(w,[2,18]),{1:[2,2]},e(w,[2,8]),e(w,[2,9]),e(Q,[2,37],{40:55,41:_,42:A,43:m,44:T,45:S,46:P,47:p,48:C,49:h,50:L}),e(Q,[2,38]),e(Q,[2,39]),e(E,[2,40]),e(E,[2,42]),e(E,[2,43]),e(E,[2,44]),e(E,[2,45]),e(E,[2,46]),e(E,[2,47]),e(E,[2,48]),e(E,[2,49]),e(E,[2,50]),e(E,[2,51]),e(w,[2,10]),e(w,[2,22],{30:41,29:56,24:z,27:lt}),e(w,[2,24]),e(w,[2,25]),{31:[1,57]},{11:59,32:58,37:24,38:d,39:R,40:27,41:_,42:A,43:m,44:T,45:S,46:P,47:p,48:C,49:h,50:L},e(w,[2,11]),e(w,[2,30],{33:60,27:ct}),e(w,[2,32]),{31:[1,61]},e(w,[2,12]),{17:62,24:$},{25:63,27:ut},e(w,[2,14]),{17:65,24:$},e(w,[2,16]),e(w,[2,17]),e(E,[2,41]),e(w,[2,23]),{27:[1,66]},{26:[1,67]},{26:[2,29],28:[1,68]},e(w,[2,31]),{27:[1,69]},e(w,[2,13]),{26:[1,70]},{26:[2,21],28:[1,71]},e(w,[2,15]),e(w,[2,26]),e(w,[2,27]),{11:59,32:72,37:24,38:d,39:R,40:27,41:_,42:A,43:m,44:T,45:S,46:P,47:p,48:C,49:h,50:L},e(w,[2,33]),e(w,[2,19]),{25:73,27:ut},{26:[2,28]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],72:[2,28],73:[2,20]},parseError:function(r,l){if(l.recoverable)this.trace(r);else{var u=new Error(r);throw u.hash=l,u}},parse:function(r){var l=this,u=[0],g=[],b=[null],a=[],F=this.table,x="",U=0,gt=0,Vt=2,xt=1,Bt=a.slice.call(arguments,1),k=Object.create(this.lexer),B={yy:{}};for(var J in this.yy)Object.prototype.hasOwnProperty.call(this.yy,J)&&(B.yy[J]=this.yy[J]);k.setInput(r,B.yy),B.yy.lexer=k,B.yy.parser=this,typeof k.yylloc>"u"&&(k.yylloc={});var tt=k.yylloc;a.push(tt);var Wt=k.options&&k.options.ranges;typeof B.yy.parseError=="function"?this.parseError=B.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function Ot(){var I;return I=g.pop()||k.lex()||xt,typeof I!="number"&&(I instanceof Array&&(g=I,I=g.pop()),I=l.symbols_[I]||I),I}for(var D,W,v,it,O={},q,M,dt,j;;){if(W=u[u.length-1],this.defaultActions[W]?v=this.defaultActions[W]:((D===null||typeof D>"u")&&(D=Ot()),v=F[W]&&F[W][D]),typeof v>"u"||!v.length||!v[0]){var et="";j=[];for(q in F[W])this.terminals_[q]&&q>Vt&&j.push("'"+this.terminals_[q]+"'");k.showPosition?et="Parse error on line "+(U+1)+`:
|
|
2
2
|
`+k.showPosition()+`
|
|
3
3
|
Expecting `+j.join(", ")+", got '"+(this.terminals_[D]||D)+"'":et="Parse error on line "+(U+1)+": Unexpected "+(D==xt?"end of input":"'"+(this.terminals_[D]||D)+"'"),this.parseError(et,{text:k.match,token:this.terminals_[D]||D,line:k.yylineno,loc:tt,expected:j})}if(v[0]instanceof Array&&v.length>1)throw new Error("Parse Error: multiple actions possible at state: "+W+", token: "+D);switch(v[0]){case 1:u.push(D),b.push(k.yytext),a.push(k.yylloc),u.push(v[1]),D=null,gt=k.yyleng,x=k.yytext,U=k.yylineno,tt=k.yylloc;break;case 2:if(M=this.productions_[v[1]][1],O.$=b[b.length-M],O._$={first_line:a[a.length-(M||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(M||1)].first_column,last_column:a[a.length-1].last_column},Wt&&(O._$.range=[a[a.length-(M||1)].range[0],a[a.length-1].range[1]]),it=this.performAction.apply(O,[x,gt,U,B.yy,v[1],b,a].concat(Bt)),typeof it<"u")return it;M&&(u=u.slice(0,-1*M*2),b=b.slice(0,-1*M),a=a.slice(0,-1*M)),u.push(this.productions_[v[1]][0]),b.push(O.$),a.push(O._$),dt=F[u[u.length-2]][u[u.length-1]],u.push(dt);break;case 3:return!0}}return!0}},It=function(){var V={EOF:1,parseError:function(l,u){if(this.yy.parser)this.yy.parser.parseError(l,u);else throw new Error(l)},setInput:function(r,l){return this.yy=l||this.yy||{},this._input=r,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var r=this._input[0];this.yytext+=r,this.yyleng++,this.offset++,this.match+=r,this.matched+=r;var l=r.match(/(?:\r\n?|\n).*/g);return l?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),r},unput:function(r){var l=r.length,u=r.split(/(?:\r\n?|\n)/g);this._input=r+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-l),this.offset-=l;var g=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),u.length-1&&(this.yylineno-=u.length-1);var b=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:u?(u.length===g.length?this.yylloc.first_column:0)+g[g.length-u.length].length-u[0].length:this.yylloc.first_column-l},this.options.ranges&&(this.yylloc.range=[b[0],b[0]+this.yyleng-l]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
4
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},less:function(r){this.unput(this.match.slice(r))},pastInput:function(){var r=this.matched.substr(0,this.matched.length-this.match.length);return(r.length>20?"...":"")+r.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var r=this.match;return r.length<20&&(r+=this._input.substr(0,20-r.length)),(r.substr(0,20)+(r.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var r=this.pastInput(),l=new Array(r.length+1).join("-");return r+this.upcomingInput()+`
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<link rel="icon" href="data:image/x-icon;base64,AAABAAEAICAQAAEABADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAAAIAAOwAAADsAAAAEAAAABAAAABxaUwAwoyZAMOJmADBi5kAwoyZAMKMmQDCjJkAwoyZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAAAAAAAAAAAAAAACV3AAAAAAAAAAAAAAAAAAYXdwAAAAAAAAAAAAAAAANHd3cAAAAAAAEREREREREXd3d3ERAAAAAHd3d3d3d3d3FXd3dwAAAAB3d3d3d3d3dDB3d3cAAAAAd3IiIiIiIiAAIid3AAAAAHdwAAAAAAAAAAAHdwAAAAB3cAAAAAAAAAAAB3cAAAAAd3AAd3AABnd0AAd3AAAAAHdwAHdwADF3QgAHdwAAAAB3cAB3dTMXcSAAB3cAAAAAd3AAd3dxdxMAAAd3AAAAAHdwAHd3d3dGAAAHdwAAAAB3cAB3dHd3dxUAB3cAAAAAd3AAd3A1F3d3AAd3AAAAAHdwAHdwAANXdwAHdwAAAAB3cAB3cAAAAXcAB3cAAAAAd3AAd3d3d3d3AAd3AAAAAHdwAHd3d3d3dwAHdwAAAAB3cAB3d3d3d3cAB3cAAAAAd3AAAAAAAAAAAAd3AAAAAHdwAAAAAAAAAAAHdwAAAAB3cAAAAAAAAAAAB3cAAAAAd3d3d3d3d3d3d3d3AAAAAHd3d3d3d3d3d3d3dwAAAAB3d3d3d3d3d3d3d3cAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///5////4f///8H///8B/8AAAD/AAAA/wAAQP8AAcD/H//4/x//+P8ceDj/HHA4/xwAeP8cAPj/HAD4/xwAOP8cQDj/HHg4/xx+OP8cADj/HAA4/xwAOP8f//j/H//4/x//+P8AAAD/AAAA/wAAAP/////////////////////w==" sizes="32x32">
|
|
8
8
|
<title>Rasa inspector</title>
|
|
9
|
-
<script type="module" crossorigin src="./assets/index-
|
|
9
|
+
<script type="module" crossorigin src="./assets/index-a5d3e69d.js"></script>
|
|
10
10
|
<link rel="stylesheet" href="./assets/index-3ee28881.css">
|
|
11
11
|
</head>
|
|
12
12
|
|
|
@@ -25,6 +25,9 @@ export const DiagramFlow = (props: Props) => {
|
|
|
25
25
|
const config = {
|
|
26
26
|
startOnLoad: true,
|
|
27
27
|
logLevel: 'info',
|
|
28
|
+
flowchart: {
|
|
29
|
+
useMaxWidth: false,
|
|
30
|
+
},
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
useEffect(() => {
|
|
@@ -37,6 +40,13 @@ export const DiagramFlow = (props: Props) => {
|
|
|
37
40
|
// attribute prevents it. We need to remove it each time `text` changes
|
|
38
41
|
mermaidRef.current?.removeAttribute("data-processed");
|
|
39
42
|
mermaid.contentLoaded();
|
|
43
|
+
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
const active = document.querySelectorAll(".active")[0];
|
|
46
|
+
if (active) {
|
|
47
|
+
active.scrollIntoView({ behavior: "smooth"});
|
|
48
|
+
}
|
|
49
|
+
}, 0);
|
|
40
50
|
}, [text]);
|
|
41
51
|
|
|
42
52
|
useEffect(() => {
|
|
@@ -89,9 +89,6 @@ describe("helpers", () => {
|
|
|
89
89
|
},
|
|
90
90
|
{
|
|
91
91
|
event: "bot",
|
|
92
|
-
metadata: {
|
|
93
|
-
utter_action: "utter_ask_book_restaurant_number_of_people",
|
|
94
|
-
},
|
|
95
92
|
text: "How many people are we talking?",
|
|
96
93
|
},
|
|
97
94
|
{
|
|
@@ -111,11 +108,11 @@ describe("helpers", () => {
|
|
|
111
108
|
expect(result).toEqual(`test_cases:
|
|
112
109
|
- test_case: ${sessionId}
|
|
113
110
|
steps:
|
|
114
|
-
- user: book a restaurant
|
|
111
|
+
- user: "book a restaurant"
|
|
115
112
|
- utter: utter_ask_book_restaurant_name_of_restaurant
|
|
116
|
-
- user: simsim
|
|
117
|
-
-
|
|
118
|
-
- user: 100
|
|
113
|
+
- user: "simsim"
|
|
114
|
+
- bot: "How many people are we talking?"
|
|
115
|
+
- user: "100"
|
|
119
116
|
- utter: utter_ask_book_restaurant_date`);
|
|
120
117
|
});
|
|
121
118
|
});
|
|
@@ -23,13 +23,14 @@ export const formatTestCases = (events: Event[], sessionId: string) => {
|
|
|
23
23
|
|
|
24
24
|
const steps = events
|
|
25
25
|
.map((event) => {
|
|
26
|
+
const escapedText = JSON.stringify(event.text);
|
|
26
27
|
if (event.event === "user") {
|
|
27
|
-
return ` - user: ${
|
|
28
|
+
return ` - user: ${escapedText}`;
|
|
28
29
|
} else if (event.event === "bot") {
|
|
29
30
|
return `${
|
|
30
31
|
event.metadata?.utter_action
|
|
31
32
|
? ` - utter: ${event.metadata.utter_action}`
|
|
32
|
-
: ` -
|
|
33
|
+
: ` - bot: ${escapedText}`
|
|
33
34
|
}`;
|
|
34
35
|
}
|
|
35
36
|
})
|
rasa/core/channels/rest.py
CHANGED
|
@@ -3,12 +3,23 @@ import copy
|
|
|
3
3
|
import inspect
|
|
4
4
|
import json
|
|
5
5
|
import logging
|
|
6
|
+
from functools import partial
|
|
7
|
+
|
|
6
8
|
import structlog
|
|
7
9
|
from asyncio import Queue, CancelledError
|
|
8
10
|
from sanic import Blueprint, response
|
|
9
11
|
from sanic.request import Request
|
|
10
12
|
from sanic.response import HTTPResponse, ResponseStream
|
|
11
|
-
from typing import
|
|
13
|
+
from typing import (
|
|
14
|
+
Text,
|
|
15
|
+
Dict,
|
|
16
|
+
Any,
|
|
17
|
+
Optional,
|
|
18
|
+
Callable,
|
|
19
|
+
Awaitable,
|
|
20
|
+
NoReturn,
|
|
21
|
+
Union,
|
|
22
|
+
)
|
|
12
23
|
|
|
13
24
|
import rasa.utils.endpoints
|
|
14
25
|
from rasa.core.channels.channel import (
|
|
@@ -77,14 +88,15 @@ class RestInput(InputChannel):
|
|
|
77
88
|
"""
|
|
78
89
|
return request.json.get("metadata", None)
|
|
79
90
|
|
|
80
|
-
def stream_response(
|
|
91
|
+
async def stream_response(
|
|
81
92
|
self,
|
|
82
93
|
on_new_message: Callable[[UserMessage], Awaitable[None]],
|
|
83
94
|
text: Text,
|
|
84
95
|
sender_id: Text,
|
|
85
96
|
input_channel: Text,
|
|
86
97
|
metadata: Optional[Dict[Text, Any]],
|
|
87
|
-
|
|
98
|
+
resp: ResponseStream,
|
|
99
|
+
) -> None:
|
|
88
100
|
"""Streams response to the client.
|
|
89
101
|
|
|
90
102
|
If the stream option is enabled, this method will be called to
|
|
@@ -96,27 +108,25 @@ class RestInput(InputChannel):
|
|
|
96
108
|
sender_id: message sender_id
|
|
97
109
|
input_channel: input channel name
|
|
98
110
|
metadata: optional metadata sent with the message
|
|
111
|
+
resp: response stream
|
|
99
112
|
|
|
100
113
|
Returns:
|
|
101
114
|
Sanic stream
|
|
102
115
|
"""
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
self.on_message_wrapper(
|
|
108
|
-
on_new_message, text, q, sender_id, input_channel, metadata
|
|
109
|
-
)
|
|
116
|
+
q: Queue = Queue()
|
|
117
|
+
task = asyncio.ensure_future(
|
|
118
|
+
self.on_message_wrapper(
|
|
119
|
+
on_new_message, text, q, sender_id, input_channel, metadata
|
|
110
120
|
)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
)
|
|
122
|
+
while True:
|
|
123
|
+
result = await q.get()
|
|
124
|
+
if result == "DONE":
|
|
125
|
+
break
|
|
126
|
+
else:
|
|
127
|
+
await resp.write(json.dumps(result) + "\n")
|
|
118
128
|
|
|
119
|
-
|
|
129
|
+
await task
|
|
120
130
|
|
|
121
131
|
def blueprint(
|
|
122
132
|
self, on_new_message: Callable[[UserMessage], Awaitable[None]]
|
|
@@ -149,9 +159,14 @@ class RestInput(InputChannel):
|
|
|
149
159
|
metadata = self.get_metadata(request)
|
|
150
160
|
|
|
151
161
|
if should_use_stream:
|
|
152
|
-
return
|
|
153
|
-
|
|
154
|
-
|
|
162
|
+
return ResponseStream(
|
|
163
|
+
partial(
|
|
164
|
+
self.stream_response,
|
|
165
|
+
on_new_message,
|
|
166
|
+
text,
|
|
167
|
+
sender_id,
|
|
168
|
+
input_channel,
|
|
169
|
+
metadata,
|
|
155
170
|
),
|
|
156
171
|
content_type="text/event-stream",
|
|
157
172
|
)
|
rasa/core/channels/rocketchat.py
CHANGED
rasa/core/channels/socketio.py
CHANGED
|
@@ -178,7 +178,7 @@ class SocketIOInput(InputChannel):
|
|
|
178
178
|
rasa.shared.utils.io.raise_warning(
|
|
179
179
|
"SocketIO output channel cannot be recreated. "
|
|
180
180
|
"This is expected behavior when using multiple Sanic "
|
|
181
|
-
"workers or multiple Rasa
|
|
181
|
+
"workers or multiple Rasa Pro instances. "
|
|
182
182
|
"Please use a different channel for external events in these "
|
|
183
183
|
"scenarios."
|
|
184
184
|
)
|
rasa/core/channels/telegram.py
CHANGED
|
@@ -97,8 +97,9 @@ class TelegramOutput(Bot, OutputChannel):
|
|
|
97
97
|
reply_markup.add(KeyboardButton(button["title"]))
|
|
98
98
|
else:
|
|
99
99
|
logger.error(
|
|
100
|
-
"Trying to send text with buttons for unknown "
|
|
101
|
-
|
|
100
|
+
"Trying to send text with buttons for unknown button type {}".format(
|
|
101
|
+
button_type
|
|
102
|
+
)
|
|
102
103
|
)
|
|
103
104
|
return
|
|
104
105
|
|
|
@@ -215,7 +216,6 @@ class TelegramInput(InputChannel):
|
|
|
215
216
|
@telegram_webhook.route("/webhook", methods=["GET", "POST"])
|
|
216
217
|
async def message(request: Request) -> Any:
|
|
217
218
|
if request.method == "POST":
|
|
218
|
-
|
|
219
219
|
request_dict = request.json
|
|
220
220
|
if isinstance(request_dict, Text):
|
|
221
221
|
request_dict = json.loads(request_dict)
|
rasa/core/channels/webexteams.py
CHANGED
|
@@ -134,7 +134,7 @@ class ConcurrentRedisLockStore(LockStore):
|
|
|
134
134
|
lock = self.get_or_create_lock(conversation_id)
|
|
135
135
|
lock.remove_expired_tickets()
|
|
136
136
|
ticket_number = self.increment_ticket_number(lock)
|
|
137
|
-
ticket = lock.concurrent_issue_ticket(lock_lifetime, ticket_number) # type: ignore[attr-defined]
|
|
137
|
+
ticket = lock.concurrent_issue_ticket(lock_lifetime, ticket_number) # type: ignore[attr-defined]
|
|
138
138
|
self.save_lock(lock)
|
|
139
139
|
|
|
140
140
|
return ticket
|
|
@@ -48,9 +48,7 @@ class MarkerRegistry:
|
|
|
48
48
|
"""Keeps track of tags that can be used to configure markers."""
|
|
49
49
|
|
|
50
50
|
all_tags: Set[Text] = set() # noqa: RUF012
|
|
51
|
-
condition_tag_to_marker_class: Dict[
|
|
52
|
-
Text, Type[ConditionMarker]
|
|
53
|
-
] = {} # noqa: RUF012
|
|
51
|
+
condition_tag_to_marker_class: Dict[Text, Type[ConditionMarker]] = {} # noqa: RUF012
|
|
54
52
|
operator_tag_to_marker_class: Dict[Text, Type[OperatorMarker]] = {} # noqa: RUF012
|
|
55
53
|
marker_class_to_tag: Dict[Type[Marker], Text] = {} # noqa: RUF012
|
|
56
54
|
negated_tag_to_tag: Dict[Text, Text] = {} # noqa: RUF012
|
|
@@ -12,7 +12,7 @@ from rasa.core.evaluation.marker_base import EventMetaData
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def compute_statistics(
|
|
15
|
-
values: List[Union[float, int]]
|
|
15
|
+
values: List[Union[float, int]],
|
|
16
16
|
) -> Dict[Text, Union[int, float, np.floating]]:
|
|
17
17
|
"""Computes some statistics over the given numbers."""
|
|
18
18
|
return {
|
|
@@ -138,7 +138,6 @@ class MarkerStatistics:
|
|
|
138
138
|
self.session_identifier.append((sender_id, session_idx))
|
|
139
139
|
|
|
140
140
|
for marker_name, meta_data in meta_data_on_relevant_events_per_marker.items():
|
|
141
|
-
|
|
142
141
|
num_preceding_user_turns = [
|
|
143
142
|
event_meta_data.preceding_user_turns for event_meta_data in meta_data
|
|
144
143
|
]
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import logging
|
|
2
|
-
from typing import List, Optional, Dict, Text, Set, Any
|
|
3
|
-
|
|
4
2
|
import numpy as np
|
|
5
3
|
import scipy.sparse
|
|
4
|
+
from typing import List, Optional, Dict, Text, Set, Any
|
|
6
5
|
|
|
7
6
|
from rasa.core.featurizers.precomputation import MessageContainerForCoreFeaturization
|
|
8
7
|
from rasa.nlu.extractors.extractor import EntityTagSpec
|
|
@@ -92,6 +91,7 @@ class SingleStateFeaturizer:
|
|
|
92
91
|
domain: An instance of :class:`rasa.shared.core.domain.Domain`.
|
|
93
92
|
bilou_tagging: indicates whether BILOU tagging should be used or not
|
|
94
93
|
"""
|
|
94
|
+
|
|
95
95
|
# store feature states for each attribute in order to create binary features
|
|
96
96
|
def convert_to_dict(feature_states: List[Text]) -> Dict[Text, int]:
|
|
97
97
|
return {
|
|
@@ -117,7 +117,7 @@ class SingleStateFeaturizer:
|
|
|
117
117
|
if attribute in {INTENT, ACTION_NAME}:
|
|
118
118
|
return {sub_state[attribute]: 1} # type: ignore[dict-item]
|
|
119
119
|
elif attribute == ENTITIES:
|
|
120
|
-
return {entity: 1 for entity in sub_state.get(ENTITIES, [])} # type: ignore[misc]
|
|
120
|
+
return {entity: 1 for entity in sub_state.get(ENTITIES, [])} # type: ignore[misc]
|
|
121
121
|
elif attribute == ACTIVE_LOOP:
|
|
122
122
|
return {sub_state["name"]: 1} # type: ignore[dict-item]
|
|
123
123
|
elif attribute == SLOTS:
|
|
@@ -186,14 +186,12 @@ class SingleStateFeaturizer:
|
|
|
186
186
|
precomputations: Optional[MessageContainerForCoreFeaturization],
|
|
187
187
|
sparse: bool = False,
|
|
188
188
|
) -> Dict[Text, List[Features]]:
|
|
189
|
-
|
|
190
189
|
# Remove entities from possible attributes
|
|
191
190
|
attributes = set(
|
|
192
191
|
attribute for attribute in sub_state.keys() if attribute != ENTITIES
|
|
193
192
|
)
|
|
194
193
|
|
|
195
194
|
if precomputations is not None:
|
|
196
|
-
|
|
197
195
|
# Collect features for all those attributes
|
|
198
196
|
attributes_to_features = precomputations.collect_features(
|
|
199
197
|
sub_state, attributes=attributes
|
|
@@ -263,7 +261,6 @@ class SingleStateFeaturizer:
|
|
|
263
261
|
# featurize user only if it is "real" user input,
|
|
264
262
|
# i.e. input from a turn after action_listen
|
|
265
263
|
if state_type == USER and is_prev_action_listen_in_state(state):
|
|
266
|
-
|
|
267
264
|
state_features.update(
|
|
268
265
|
self._extract_state_features(
|
|
269
266
|
sub_state, precomputations=precomputations, sparse=True
|
|
@@ -363,26 +360,6 @@ class SingleStateFeaturizer:
|
|
|
363
360
|
for action in domain.action_names_or_texts
|
|
364
361
|
]
|
|
365
362
|
|
|
366
|
-
def to_dict(self) -> Dict[str, Any]:
|
|
367
|
-
return {
|
|
368
|
-
"action_texts": self.action_texts,
|
|
369
|
-
"entity_tag_specs": self.entity_tag_specs,
|
|
370
|
-
"feature_states": self._default_feature_states,
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
@classmethod
|
|
374
|
-
def create_from_dict(
|
|
375
|
-
cls, data: Dict[str, Any]
|
|
376
|
-
) -> Optional["SingleStateFeaturizer"]:
|
|
377
|
-
if not data:
|
|
378
|
-
return None
|
|
379
|
-
|
|
380
|
-
featurizer = SingleStateFeaturizer()
|
|
381
|
-
featurizer.action_texts = data["action_texts"]
|
|
382
|
-
featurizer._default_feature_states = data["feature_states"]
|
|
383
|
-
featurizer.entity_tag_specs = data["entity_tag_specs"]
|
|
384
|
-
return featurizer
|
|
385
|
-
|
|
386
363
|
|
|
387
364
|
class IntentTokenizerSingleStateFeaturizer(SingleStateFeaturizer):
|
|
388
365
|
"""A SingleStateFeaturizer for use with policies that predict intent labels."""
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import logging
|
|
4
|
-
from abc import abstractmethod
|
|
5
|
-
from collections import defaultdict
|
|
6
2
|
from pathlib import Path
|
|
3
|
+
from collections import defaultdict
|
|
4
|
+
from abc import abstractmethod
|
|
5
|
+
import jsonpickle
|
|
6
|
+
import logging
|
|
7
|
+
|
|
8
|
+
from tqdm import tqdm
|
|
7
9
|
from typing import (
|
|
8
10
|
Tuple,
|
|
9
11
|
List,
|
|
@@ -16,30 +18,25 @@ from typing import (
|
|
|
16
18
|
Set,
|
|
17
19
|
DefaultDict,
|
|
18
20
|
cast,
|
|
19
|
-
Type,
|
|
20
|
-
Callable,
|
|
21
|
-
ClassVar,
|
|
22
21
|
)
|
|
23
|
-
|
|
24
22
|
import numpy as np
|
|
25
|
-
from tqdm import tqdm
|
|
26
23
|
|
|
24
|
+
from rasa.core.featurizers.single_state_featurizer import SingleStateFeaturizer
|
|
25
|
+
from rasa.core.featurizers.precomputation import MessageContainerForCoreFeaturization
|
|
26
|
+
from rasa.core.exceptions import InvalidTrackerFeaturizerUsageError
|
|
27
27
|
import rasa.shared.core.trackers
|
|
28
28
|
import rasa.shared.utils.io
|
|
29
|
-
from rasa.
|
|
30
|
-
from rasa.
|
|
31
|
-
from rasa.core.
|
|
29
|
+
from rasa.shared.nlu.constants import TEXT, INTENT, ENTITIES, ACTION_NAME
|
|
30
|
+
from rasa.shared.nlu.training_data.features import Features
|
|
31
|
+
from rasa.shared.core.trackers import DialogueStateTracker
|
|
32
|
+
from rasa.shared.core.domain import State, Domain
|
|
33
|
+
from rasa.shared.core.events import Event, ActionExecuted, UserUttered
|
|
32
34
|
from rasa.shared.core.constants import (
|
|
33
35
|
USER,
|
|
34
36
|
ACTION_UNLIKELY_INTENT_NAME,
|
|
35
37
|
PREVIOUS_ACTION,
|
|
36
38
|
)
|
|
37
|
-
from rasa.shared.core.domain import State, Domain
|
|
38
|
-
from rasa.shared.core.events import Event, ActionExecuted, UserUttered
|
|
39
|
-
from rasa.shared.core.trackers import DialogueStateTracker
|
|
40
39
|
from rasa.shared.exceptions import RasaException
|
|
41
|
-
from rasa.shared.nlu.constants import TEXT, INTENT, ENTITIES, ACTION_NAME
|
|
42
|
-
from rasa.shared.nlu.training_data.features import Features
|
|
43
40
|
from rasa.utils.tensorflow.constants import LABEL_PAD_ID
|
|
44
41
|
from rasa.utils.tensorflow.model_data import ragged_array_to_ndarray
|
|
45
42
|
|
|
@@ -67,10 +64,6 @@ class InvalidStory(RasaException):
|
|
|
67
64
|
class TrackerFeaturizer:
|
|
68
65
|
"""Base class for actual tracker featurizers."""
|
|
69
66
|
|
|
70
|
-
# Class registry to store all subclasses
|
|
71
|
-
_registry: ClassVar[Dict[str, Type["TrackerFeaturizer"]]] = {}
|
|
72
|
-
_featurizer_type: str = "TrackerFeaturizer"
|
|
73
|
-
|
|
74
67
|
def __init__(
|
|
75
68
|
self, state_featurizer: Optional[SingleStateFeaturizer] = None
|
|
76
69
|
) -> None:
|
|
@@ -81,36 +74,6 @@ class TrackerFeaturizer:
|
|
|
81
74
|
"""
|
|
82
75
|
self.state_featurizer = state_featurizer
|
|
83
76
|
|
|
84
|
-
@classmethod
|
|
85
|
-
def register(cls, featurizer_type: str) -> Callable:
|
|
86
|
-
"""Decorator to register featurizer subclasses."""
|
|
87
|
-
|
|
88
|
-
def wrapper(subclass: Type["TrackerFeaturizer"]) -> Type["TrackerFeaturizer"]:
|
|
89
|
-
cls._registry[featurizer_type] = subclass
|
|
90
|
-
# Store the type identifier in the class for serialization
|
|
91
|
-
subclass._featurizer_type = featurizer_type
|
|
92
|
-
return subclass
|
|
93
|
-
|
|
94
|
-
return wrapper
|
|
95
|
-
|
|
96
|
-
@classmethod
|
|
97
|
-
def from_dict(cls, data: Dict[str, Any]) -> "TrackerFeaturizer":
|
|
98
|
-
"""Create featurizer instance from dictionary."""
|
|
99
|
-
featurizer_type = data.pop("type")
|
|
100
|
-
|
|
101
|
-
if featurizer_type not in cls._registry:
|
|
102
|
-
raise ValueError(f"Unknown featurizer type: {featurizer_type}")
|
|
103
|
-
|
|
104
|
-
# Get the correct subclass and instantiate it
|
|
105
|
-
subclass = cls._registry[featurizer_type]
|
|
106
|
-
return subclass.create_from_dict(data)
|
|
107
|
-
|
|
108
|
-
@classmethod
|
|
109
|
-
@abstractmethod
|
|
110
|
-
def create_from_dict(cls, data: Dict[str, Any]) -> "TrackerFeaturizer":
|
|
111
|
-
"""Each subclass must implement its own creation from dict method."""
|
|
112
|
-
pass
|
|
113
|
-
|
|
114
77
|
@staticmethod
|
|
115
78
|
def _create_states(
|
|
116
79
|
tracker: DialogueStateTracker,
|
|
@@ -502,7 +465,9 @@ class TrackerFeaturizer:
|
|
|
502
465
|
self.state_featurizer.entity_tag_specs = []
|
|
503
466
|
|
|
504
467
|
# noinspection PyTypeChecker
|
|
505
|
-
rasa.shared.utils.io.
|
|
468
|
+
rasa.shared.utils.io.write_text_file(
|
|
469
|
+
str(jsonpickle.encode(self)), featurizer_file
|
|
470
|
+
)
|
|
506
471
|
|
|
507
472
|
@staticmethod
|
|
508
473
|
def load(path: Union[Text, Path]) -> Optional[TrackerFeaturizer]:
|
|
@@ -516,17 +481,7 @@ class TrackerFeaturizer:
|
|
|
516
481
|
"""
|
|
517
482
|
featurizer_file = Path(path) / FEATURIZER_FILE
|
|
518
483
|
if featurizer_file.is_file():
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
if "type" not in data:
|
|
522
|
-
logger.error(
|
|
523
|
-
f"Couldn't load featurizer for policy. "
|
|
524
|
-
f"File '{featurizer_file}' does not contain all "
|
|
525
|
-
f"necessary information. 'type' is missing."
|
|
526
|
-
)
|
|
527
|
-
return None
|
|
528
|
-
|
|
529
|
-
return TrackerFeaturizer.from_dict(data)
|
|
484
|
+
return jsonpickle.decode(rasa.shared.utils.io.read_file(featurizer_file))
|
|
530
485
|
|
|
531
486
|
logger.error(
|
|
532
487
|
f"Couldn't load featurizer for policy. "
|
|
@@ -553,16 +508,7 @@ class TrackerFeaturizer:
|
|
|
553
508
|
)
|
|
554
509
|
]
|
|
555
510
|
|
|
556
|
-
def to_dict(self) -> Dict[str, Any]:
|
|
557
|
-
return {
|
|
558
|
-
"type": self.__class__._featurizer_type,
|
|
559
|
-
"state_featurizer": (
|
|
560
|
-
self.state_featurizer.to_dict() if self.state_featurizer else None
|
|
561
|
-
),
|
|
562
|
-
}
|
|
563
511
|
|
|
564
|
-
|
|
565
|
-
@TrackerFeaturizer.register("FullDialogueTrackerFeaturizer")
|
|
566
512
|
class FullDialogueTrackerFeaturizer(TrackerFeaturizer):
|
|
567
513
|
"""Creates full dialogue training data for time distributed architectures.
|
|
568
514
|
|
|
@@ -700,20 +646,7 @@ class FullDialogueTrackerFeaturizer(TrackerFeaturizer):
|
|
|
700
646
|
|
|
701
647
|
return trackers_as_states
|
|
702
648
|
|
|
703
|
-
def to_dict(self) -> Dict[str, Any]:
|
|
704
|
-
return super().to_dict()
|
|
705
|
-
|
|
706
|
-
@classmethod
|
|
707
|
-
def create_from_dict(cls, data: Dict[str, Any]) -> "FullDialogueTrackerFeaturizer":
|
|
708
|
-
state_featurizer = SingleStateFeaturizer.create_from_dict(
|
|
709
|
-
data["state_featurizer"]
|
|
710
|
-
)
|
|
711
|
-
return cls(
|
|
712
|
-
state_featurizer,
|
|
713
|
-
)
|
|
714
|
-
|
|
715
649
|
|
|
716
|
-
@TrackerFeaturizer.register("MaxHistoryTrackerFeaturizer")
|
|
717
650
|
class MaxHistoryTrackerFeaturizer(TrackerFeaturizer):
|
|
718
651
|
"""Truncates the tracker history into `max_history` long sequences.
|
|
719
652
|
|
|
@@ -820,14 +753,12 @@ class MaxHistoryTrackerFeaturizer(TrackerFeaturizer):
|
|
|
820
753
|
disable=rasa.shared.utils.io.is_logging_disabled(),
|
|
821
754
|
)
|
|
822
755
|
for tracker in pbar:
|
|
823
|
-
|
|
824
756
|
for states, label, entities in self._extract_examples(
|
|
825
757
|
tracker,
|
|
826
758
|
domain,
|
|
827
759
|
omit_unset_slots=omit_unset_slots,
|
|
828
760
|
ignore_action_unlikely_intent=ignore_action_unlikely_intent,
|
|
829
761
|
):
|
|
830
|
-
|
|
831
762
|
if self.remove_duplicates:
|
|
832
763
|
hashed = self._hash_example(states, label)
|
|
833
764
|
if hashed in hashed_examples:
|
|
@@ -883,7 +814,6 @@ class MaxHistoryTrackerFeaturizer(TrackerFeaturizer):
|
|
|
883
814
|
entity_data = self._entity_data(event)
|
|
884
815
|
|
|
885
816
|
elif isinstance(event, ActionExecuted):
|
|
886
|
-
|
|
887
817
|
label_index += 1
|
|
888
818
|
|
|
889
819
|
# use only actions which can be predicted at a stories start
|
|
@@ -954,25 +884,7 @@ class MaxHistoryTrackerFeaturizer(TrackerFeaturizer):
|
|
|
954
884
|
|
|
955
885
|
return trackers_as_states
|
|
956
886
|
|
|
957
|
-
def to_dict(self) -> Dict[str, Any]:
|
|
958
|
-
data = super().to_dict()
|
|
959
|
-
data.update(
|
|
960
|
-
{
|
|
961
|
-
"remove_duplicates": self.remove_duplicates,
|
|
962
|
-
"max_history": self.max_history,
|
|
963
|
-
}
|
|
964
|
-
)
|
|
965
|
-
return data
|
|
966
|
-
|
|
967
|
-
@classmethod
|
|
968
|
-
def create_from_dict(cls, data: Dict[str, Any]) -> "MaxHistoryTrackerFeaturizer":
|
|
969
|
-
state_featurizer = SingleStateFeaturizer.create_from_dict(
|
|
970
|
-
data["state_featurizer"]
|
|
971
|
-
)
|
|
972
|
-
return cls(state_featurizer, data["max_history"], data["remove_duplicates"])
|
|
973
|
-
|
|
974
887
|
|
|
975
|
-
@TrackerFeaturizer.register("IntentMaxHistoryTrackerFeaturizer")
|
|
976
888
|
class IntentMaxHistoryTrackerFeaturizer(MaxHistoryTrackerFeaturizer):
|
|
977
889
|
"""Truncates the tracker history into `max_history` long sequences.
|
|
978
890
|
|
|
@@ -1077,14 +989,12 @@ class IntentMaxHistoryTrackerFeaturizer(MaxHistoryTrackerFeaturizer):
|
|
|
1077
989
|
disable=rasa.shared.utils.io.is_logging_disabled(),
|
|
1078
990
|
)
|
|
1079
991
|
for tracker in pbar:
|
|
1080
|
-
|
|
1081
992
|
for states, label, entities in self._extract_examples(
|
|
1082
993
|
tracker,
|
|
1083
994
|
domain,
|
|
1084
995
|
omit_unset_slots=omit_unset_slots,
|
|
1085
996
|
ignore_action_unlikely_intent=ignore_action_unlikely_intent,
|
|
1086
997
|
):
|
|
1087
|
-
|
|
1088
998
|
if self.remove_duplicates:
|
|
1089
999
|
hashed = self._hash_example(states, label)
|
|
1090
1000
|
if hashed in hashed_examples:
|
|
@@ -1150,12 +1060,10 @@ class IntentMaxHistoryTrackerFeaturizer(MaxHistoryTrackerFeaturizer):
|
|
|
1150
1060
|
|
|
1151
1061
|
label_index = 0
|
|
1152
1062
|
for event in events:
|
|
1153
|
-
|
|
1154
1063
|
if isinstance(event, ActionExecuted):
|
|
1155
1064
|
label_index += 1
|
|
1156
1065
|
|
|
1157
1066
|
elif isinstance(event, UserUttered):
|
|
1158
|
-
|
|
1159
1067
|
sliced_states = self.slice_state_history(
|
|
1160
1068
|
tracker_states[:label_index], self.max_history
|
|
1161
1069
|
)
|
|
@@ -1251,18 +1159,6 @@ class IntentMaxHistoryTrackerFeaturizer(MaxHistoryTrackerFeaturizer):
|
|
|
1251
1159
|
|
|
1252
1160
|
return trackers_as_states
|
|
1253
1161
|
|
|
1254
|
-
def to_dict(self) -> Dict[str, Any]:
|
|
1255
|
-
return super().to_dict()
|
|
1256
|
-
|
|
1257
|
-
@classmethod
|
|
1258
|
-
def create_from_dict(
|
|
1259
|
-
cls, data: Dict[str, Any]
|
|
1260
|
-
) -> "IntentMaxHistoryTrackerFeaturizer":
|
|
1261
|
-
state_featurizer = SingleStateFeaturizer.create_from_dict(
|
|
1262
|
-
data["state_featurizer"]
|
|
1263
|
-
)
|
|
1264
|
-
return cls(state_featurizer, data["max_history"], data["remove_duplicates"])
|
|
1265
|
-
|
|
1266
1162
|
|
|
1267
1163
|
def _is_prev_action_unlikely_intent_in_state(state: State) -> bool:
|
|
1268
1164
|
prev_action_name = state.get(PREVIOUS_ACTION, {}).get(ACTION_NAME)
|