rasa-pro 3.11.3a1.dev7__py3-none-any.whl → 3.11.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rasa-pro might be problematic. Click here for more details.
- rasa/core/actions/action.py +7 -16
- rasa/core/actions/direct_custom_actions_executor.py +0 -1
- rasa/core/channels/__init__.py +0 -2
- rasa/core/channels/inspector/dist/assets/{arc-861ddd57.js → arc-632a63ec.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-d0fbc5ce-921f02db.js → c4Diagram-d0fbc5ce-081e0df4.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-936ed81e-b436c4f8.js → classDiagram-936ed81e-3df0afc2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-c3cb15f1-511a23cb.js → classDiagram-v2-c3cb15f1-8c5ed31e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{createText-62fc7601-ef476ecd.js → createText-62fc7601-89c73b31.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-f2ad444c-f1878e0a.js → edges-f2ad444c-4fc48c3e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9d236eb7-fac75185.js → erDiagram-9d236eb7-907e0440.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-1972c806-201c5bbc.js → flowDb-1972c806-9ec53a3c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-7ea5b25a-f904ae41.js → flowDiagram-7ea5b25a-41da787a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-8bea338b.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-abe16c3d-1813da66.js → flowchart-elk-definition-abe16c3d-ce370633.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-9b5ea136-872af172.js → ganttDiagram-9b5ea136-90a36523.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-99d0ae7c-34a0af5a.js → gitGraphDiagram-99d0ae7c-41e1aa3f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-2c4b9a3b-42ba3e3d.js → index-2c4b9a3b-e6f2af62.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-37817b51.js → index-e793d777.js} +3 -3
- rasa/core/channels/inspector/dist/assets/{infoDiagram-736b4530-6b731386.js → infoDiagram-736b4530-8ceba4db.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-df861f2b-e8579ac6.js → journeyDiagram-df861f2b-960d3809.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-89e6403a.js → layout-498807d8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-dc73d3fc.js → line-eeccc4e2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-f5b1d2bc.js → linear-8a078617.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-beec6740-82cb74fa.js → mindmap-definition-beec6740-396d17dd.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-dbbf0591-bdf5f29b.js → pieDiagram-dbbf0591-dc9b5e1b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-4d7f4fd6-c7a0cbe4.js → quadrantDiagram-4d7f4fd6-a08cba6d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-6fc4c22a-7ec5410f.js → requirementDiagram-6fc4c22a-87242b9e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-8f13d901-caee5554.js → sankeyDiagram-8f13d901-53f6f391.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-b655622a-2935f8db.js → sequenceDiagram-b655622a-715c9c20.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-59f0c015-8f5d9693.js → stateDiagram-59f0c015-2e8fb31f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-2b26beab-d565d1de.js → stateDiagram-v2-2b26beab-7e2d2aa0.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-080da4f6-75ad421d.js → styles-080da4f6-4420cea6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-3dcbcfbf-7e764226.js → styles-3dcbcfbf-28676cf4.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9c745c82-7a4e0e61.js → styles-9c745c82-cef936a6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-4835440b-4019d1bf.js → svgDrawCommon-4835440b-151251e9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-5b62e21b-01ea12df.js → timeline-definition-5b62e21b-0d39bdb2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-2b33534f-89407137.js → xychartDiagram-2b33534f-a03fa445.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +3 -1
- rasa/core/channels/inspector/index.html +2 -0
- rasa/core/channels/inspector/src/App.tsx +1 -4
- rasa/core/channels/socketio.py +23 -2
- rasa/core/nlg/contextual_response_rephraser.py +9 -62
- rasa/core/policies/enterprise_search_policy.py +12 -77
- rasa/core/policies/flows/flow_executor.py +2 -26
- rasa/core/processor.py +8 -11
- rasa/dialogue_understanding/generator/command_generator.py +5 -120
- rasa/dialogue_understanding/generator/llm_based_command_generator.py +5 -5
- rasa/dialogue_understanding/generator/llm_command_generator.py +1 -2
- rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +4 -50
- rasa/dialogue_understanding/generator/nlu_command_adapter.py +0 -3
- rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +3 -16
- rasa/dialogue_understanding/patterns/continue_interrupted.py +9 -0
- rasa/dialogue_understanding/stack/utils.py +1 -0
- rasa/e2e_test/e2e_test_case.py +1 -2
- rasa/e2e_test/utils/e2e_yaml_utils.py +1 -1
- rasa/e2e_test/utils/io.py +1 -1
- rasa/e2e_test/utils/validation.py +2 -100
- rasa/engine/recipes/default_recipe.py +49 -63
- rasa/engine/recipes/graph_recipe.py +7 -8
- rasa/hooks.py +9 -14
- rasa/model_manager/socket_bridge.py +2 -7
- rasa/model_manager/warm_rasa_process.py +4 -9
- rasa/model_training.py +1 -2
- rasa/nlu/classifiers/fallback_classifier.py +0 -3
- rasa/plugin.py +0 -11
- rasa/server.py +37 -1
- rasa/shared/constants.py +6 -26
- rasa/shared/core/events.py +8 -8
- rasa/shared/core/flows/flow.py +4 -4
- rasa/shared/core/flows/flow_step.py +15 -10
- rasa/shared/core/flows/flow_step_links.py +20 -12
- rasa/shared/core/flows/flow_step_sequence.py +5 -3
- rasa/shared/core/flows/steps/action.py +3 -2
- rasa/shared/core/flows/steps/call.py +3 -3
- rasa/shared/core/flows/steps/collect.py +6 -3
- rasa/shared/core/flows/steps/continuation.py +3 -1
- rasa/shared/core/flows/steps/end.py +3 -1
- rasa/shared/core/flows/steps/internal.py +2 -1
- rasa/shared/core/flows/steps/link.py +5 -3
- rasa/shared/core/flows/steps/no_operation.py +5 -3
- rasa/shared/core/flows/steps/set_slots.py +3 -2
- rasa/shared/core/flows/steps/start.py +3 -1
- rasa/shared/nlu/constants.py +0 -7
- rasa/shared/providers/llm/llm_response.py +1 -42
- rasa/shared/utils/llm.py +1 -1
- rasa/shared/utils/schemas/events.py +1 -1
- rasa/shared/utils/yaml.py +5 -6
- rasa/studio/upload.py +5 -19
- rasa/telemetry.py +33 -40
- rasa/tracing/instrumentation/attribute_extractors.py +9 -12
- rasa/validator.py +41 -32
- rasa/version.py +1 -1
- {rasa_pro-3.11.3a1.dev7.dist-info → rasa_pro-3.11.4.dist-info}/METADATA +7 -7
- {rasa_pro-3.11.3a1.dev7.dist-info → rasa_pro-3.11.4.dist-info}/RECORD +97 -104
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-b080d6f2.js +0 -1
- rasa/core/channels/studio_chat.py +0 -192
- rasa/dialogue_understanding/constants.py +0 -1
- rasa/dialogue_understanding/utils.py +0 -21
- rasa/dialogue_understanding_test/__init__.py +0 -0
- rasa/dialogue_understanding_test/constants.py +0 -15
- rasa/dialogue_understanding_test/du_test_case.py +0 -118
- rasa/dialogue_understanding_test/du_test_result.py +0 -11
- {rasa_pro-3.11.3a1.dev7.dist-info → rasa_pro-3.11.4.dist-info}/NOTICE +0 -0
- {rasa_pro-3.11.3a1.dev7.dist-info → rasa_pro-3.11.4.dist-info}/WHEEL +0 -0
- {rasa_pro-3.11.3a1.dev7.dist-info → rasa_pro-3.11.4.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-e793d777.js";import{c as Qt}from"./createText-62fc7601-89c73b31.js";import{i as Kt}from"./init-77b53fdd.js";import{o as Zt}from"./ordinal-ba9b4969.js";import{l as ft}from"./linear-8a078617.js";import{l as pt}from"./line-eeccc4e2.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-e793d777.js"></script>
|
|
10
10
|
<link rel="stylesheet" href="./assets/index-3ee28881.css">
|
|
11
11
|
</head>
|
|
12
12
|
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
if (window.location.pathname.includes("socketio")) {
|
|
20
20
|
const chatDiv = document.getElementById("rasa-chat-widget");
|
|
21
21
|
const websocketUrl = window.location.origin.replace("http", "ws");
|
|
22
|
+
const initialPayload = "/session_start";
|
|
22
23
|
const maxHeight = document.documentElement.scrollHeight - 130;
|
|
23
24
|
// 21 and 25 are the rem number we're using for the columns. We add 0.75rem for the padding
|
|
24
25
|
// A potential improvement would be to add a onresize event for both width and height
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
const columnWidth = remReference * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
31
32
|
|
|
32
33
|
chatDiv.setAttribute("data-websocket-url", websocketUrl);
|
|
34
|
+
chatDiv.setAttribute("data-initial-payload", initialPayload);
|
|
33
35
|
chatDiv.setAttribute("data-close-on-outside-click", false);
|
|
34
36
|
chatDiv.setAttribute("data-height", maxHeight);
|
|
35
37
|
chatDiv.setAttribute("data-width", columnWidth);
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
if (window.location.pathname.includes("socketio")) {
|
|
18
18
|
const chatDiv = document.getElementById("rasa-chat-widget");
|
|
19
19
|
const websocketUrl = window.location.origin.replace("http", "ws");
|
|
20
|
+
const initialPayload = "/session_start";
|
|
20
21
|
const maxHeight = document.documentElement.scrollHeight - 130;
|
|
21
22
|
// 21 and 25 are the rem number we're using for the columns. We add 0.75rem for the padding
|
|
22
23
|
// A potential improvement would be to add a onresize event for both width and height
|
|
@@ -28,6 +29,7 @@
|
|
|
28
29
|
const columnWidth = remReference * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
29
30
|
|
|
30
31
|
chatDiv.setAttribute("data-websocket-url", websocketUrl);
|
|
32
|
+
chatDiv.setAttribute("data-initial-payload", initialPayload);
|
|
31
33
|
chatDiv.setAttribute("data-close-on-outside-click", false);
|
|
32
34
|
chatDiv.setAttribute("data-height", maxHeight);
|
|
33
35
|
chatDiv.setAttribute("data-width", columnWidth);
|
|
@@ -131,6 +131,7 @@ export function App() {
|
|
|
131
131
|
setStack(updatedStack);
|
|
132
132
|
setFrame(updatedActiveFrame(frame, updatedStack, lastJsonMessage.events));
|
|
133
133
|
setRasaChatSessionId(lastJsonMessage.sender_id);
|
|
134
|
+
fetchStory();
|
|
134
135
|
} else if (
|
|
135
136
|
rasaChatSessionId &&
|
|
136
137
|
lastJsonMessage.sender_id !== rasaChatSessionId
|
|
@@ -140,10 +141,6 @@ export function App() {
|
|
|
140
141
|
}
|
|
141
142
|
}, [lastJsonMessage, rasaChatSessionId]);
|
|
142
143
|
|
|
143
|
-
useEffect(() => {
|
|
144
|
-
fetchStory();
|
|
145
|
-
}, [rasaChatSessionId]);
|
|
146
|
-
|
|
147
144
|
const borderRadiusSx = {
|
|
148
145
|
borderRadius: rasaRadii.normal,
|
|
149
146
|
};
|
rasa/core/channels/socketio.py
CHANGED
|
@@ -54,9 +54,31 @@ class SocketIOOutput(OutputChannel):
|
|
|
54
54
|
super().__init__()
|
|
55
55
|
self.sio = sio
|
|
56
56
|
self.bot_message_evt = bot_message_evt
|
|
57
|
+
self.last_event_timestamp = (
|
|
58
|
+
-1
|
|
59
|
+
) # Initialize with -1 to send all events on first message
|
|
60
|
+
|
|
61
|
+
def _get_new_events(self) -> List[Dict[Text, Any]]:
|
|
62
|
+
"""Get events that are newer than the last sent event."""
|
|
63
|
+
events = self.tracker_state.get("events", []) if self.tracker_state else []
|
|
64
|
+
new_events = [
|
|
65
|
+
event for event in events if event["timestamp"] > self.last_event_timestamp
|
|
66
|
+
]
|
|
67
|
+
if new_events:
|
|
68
|
+
self.last_event_timestamp = new_events[-1]["timestamp"]
|
|
69
|
+
return new_events
|
|
57
70
|
|
|
58
71
|
async def _send_message(self, socket_id: Text, response: Any) -> None:
|
|
59
72
|
"""Sends a message to the recipient using the bot event."""
|
|
73
|
+
# send tracker state (contains stack, slots and more)
|
|
74
|
+
await self.sio.emit("tracker_state", self.tracker_state, room=socket_id)
|
|
75
|
+
|
|
76
|
+
# send new events
|
|
77
|
+
new_events = self._get_new_events()
|
|
78
|
+
if new_events:
|
|
79
|
+
await self.sio.emit("rasa_events", new_events, room=socket_id)
|
|
80
|
+
|
|
81
|
+
# send bot response
|
|
60
82
|
await self.sio.emit(self.bot_message_evt, response, room=socket_id)
|
|
61
83
|
|
|
62
84
|
async def send_text_message(
|
|
@@ -192,7 +214,7 @@ class SocketIOInput(InputChannel):
|
|
|
192
214
|
|
|
193
215
|
def blueprint(
|
|
194
216
|
self, on_new_message: Callable[[UserMessage], Awaitable[Any]]
|
|
195
|
-
) ->
|
|
217
|
+
) -> Blueprint:
|
|
196
218
|
"""Defines a Sanic blueprint."""
|
|
197
219
|
# Workaround so that socketio works with requests from other origins.
|
|
198
220
|
# https://github.com/miguelgrinberg/python-socketio/issues/205#issuecomment-493769183
|
|
@@ -267,7 +289,6 @@ class SocketIOInput(InputChannel):
|
|
|
267
289
|
metadata = data.get(self.metadata_key, {})
|
|
268
290
|
if isinstance(metadata, Text):
|
|
269
291
|
metadata = json.loads(metadata)
|
|
270
|
-
|
|
271
292
|
message = UserMessage(
|
|
272
293
|
data.get("message", ""),
|
|
273
294
|
output_channel,
|
|
@@ -2,7 +2,6 @@ from typing import Any, Dict, Optional, Text
|
|
|
2
2
|
|
|
3
3
|
import structlog
|
|
4
4
|
from jinja2 import Template
|
|
5
|
-
|
|
6
5
|
from rasa import telemetry
|
|
7
6
|
from rasa.core.nlg.response import TemplatedNaturalLanguageGenerator
|
|
8
7
|
from rasa.core.nlg.summarize import summarize_conversation
|
|
@@ -19,14 +18,6 @@ from rasa.shared.constants import (
|
|
|
19
18
|
from rasa.shared.core.domain import KEY_RESPONSES_TEXT, Domain
|
|
20
19
|
from rasa.shared.core.events import BotUttered, UserUttered
|
|
21
20
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
22
|
-
from rasa.shared.nlu.constants import (
|
|
23
|
-
PROMPTS,
|
|
24
|
-
KEY_USER_PROMPT,
|
|
25
|
-
KEY_LLM_RESPONSE_METADATA,
|
|
26
|
-
KEY_PROMPT_NAME,
|
|
27
|
-
KEY_COMPONENT_NAME,
|
|
28
|
-
)
|
|
29
|
-
from rasa.shared.providers.llm.llm_response import LLMResponse
|
|
30
21
|
from rasa.shared.utils.health_check.llm_health_check_mixin import LLMHealthCheckMixin
|
|
31
22
|
from rasa.shared.utils.llm import (
|
|
32
23
|
DEFAULT_OPENAI_GENERATE_MODEL_NAME,
|
|
@@ -133,39 +124,6 @@ class ContextualResponseRephraser(
|
|
|
133
124
|
ContextualResponseRephraser.__name__,
|
|
134
125
|
)
|
|
135
126
|
|
|
136
|
-
@classmethod
|
|
137
|
-
def _add_prompt_and_llm_metadata_to_response(
|
|
138
|
-
cls,
|
|
139
|
-
response: Dict[str, Any],
|
|
140
|
-
prompt_name: str,
|
|
141
|
-
user_prompt: str,
|
|
142
|
-
llm_response: Optional["LLMResponse"] = None,
|
|
143
|
-
) -> Dict[str, Any]:
|
|
144
|
-
"""Stores the prompt and LLMResponse metadata to response.
|
|
145
|
-
|
|
146
|
-
Args:
|
|
147
|
-
response: The response to add the prompt and LLMResponse metadata to.
|
|
148
|
-
prompt_name: A name identifying prompt usage.
|
|
149
|
-
user_prompt: The user prompt that was sent to the LLM.
|
|
150
|
-
llm_response: The response object from the LLM (None if no response).
|
|
151
|
-
"""
|
|
152
|
-
from rasa.dialogue_understanding.utils import record_commands_and_prompts
|
|
153
|
-
|
|
154
|
-
if not record_commands_and_prompts:
|
|
155
|
-
return response
|
|
156
|
-
|
|
157
|
-
prompt_data: Dict[Text, Any] = {
|
|
158
|
-
KEY_COMPONENT_NAME: cls.__name__,
|
|
159
|
-
KEY_PROMPT_NAME: prompt_name,
|
|
160
|
-
KEY_USER_PROMPT: user_prompt,
|
|
161
|
-
KEY_LLM_RESPONSE_METADATA: llm_response.to_dict() if llm_response else None,
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
prompts = response.get(PROMPTS, [])
|
|
165
|
-
prompts.append(prompt_data)
|
|
166
|
-
response[PROMPTS] = prompts
|
|
167
|
-
return response
|
|
168
|
-
|
|
169
127
|
def _last_message_if_human(self, tracker: DialogueStateTracker) -> Optional[str]:
|
|
170
128
|
"""Returns the latest message from the tracker.
|
|
171
129
|
|
|
@@ -184,21 +142,20 @@ class ContextualResponseRephraser(
|
|
|
184
142
|
return None
|
|
185
143
|
return None
|
|
186
144
|
|
|
187
|
-
async def _generate_llm_response(self, prompt: str) -> Optional[
|
|
188
|
-
"""
|
|
189
|
-
Use LLM to generate a response, returning an LLMResponse object
|
|
190
|
-
containing both the generated text (choices) and metadata.
|
|
145
|
+
async def _generate_llm_response(self, prompt: str) -> Optional[str]:
|
|
146
|
+
"""Use LLM to generate a response.
|
|
191
147
|
|
|
192
148
|
Args:
|
|
193
|
-
prompt:
|
|
149
|
+
prompt: the prompt to send to the LLM
|
|
194
150
|
|
|
195
151
|
Returns:
|
|
196
|
-
|
|
152
|
+
generated text
|
|
197
153
|
"""
|
|
198
154
|
llm = llm_factory(self.llm_config, DEFAULT_LLM_CONFIG)
|
|
199
155
|
|
|
200
156
|
try:
|
|
201
|
-
|
|
157
|
+
llm_response = await llm.acompletion(prompt)
|
|
158
|
+
return llm_response.choices[0]
|
|
202
159
|
except Exception as e:
|
|
203
160
|
# unfortunately, langchain does not wrap LLM exceptions which means
|
|
204
161
|
# we have to catch all exceptions here
|
|
@@ -298,21 +255,11 @@ class ContextualResponseRephraser(
|
|
|
298
255
|
or self.llm_property(MODEL_NAME_CONFIG_KEY),
|
|
299
256
|
llm_model_group_id=self.llm_property(MODEL_GROUP_ID_CONFIG_KEY),
|
|
300
257
|
)
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
response = self._add_prompt_and_llm_metadata_to_response(
|
|
305
|
-
response=response,
|
|
306
|
-
prompt_name="rephrase_prompt",
|
|
307
|
-
user_prompt=prompt,
|
|
308
|
-
llm_response=llm_response,
|
|
309
|
-
)
|
|
310
|
-
|
|
311
|
-
if not (llm_response and llm_response.choices and llm_response.choices[0]):
|
|
312
|
-
# If the LLM fails to generate a response, return the original response.
|
|
258
|
+
if not (updated_text := await self._generate_llm_response(prompt)):
|
|
259
|
+
# If the LLM fails to generate a response, we
|
|
260
|
+
# return the original response.
|
|
313
261
|
return response
|
|
314
262
|
|
|
315
|
-
updated_text = llm_response.choices[0]
|
|
316
263
|
structlogger.debug(
|
|
317
264
|
"nlg.rewrite.complete",
|
|
318
265
|
response_text=response_text,
|
|
@@ -2,7 +2,6 @@ import importlib.resources
|
|
|
2
2
|
import json
|
|
3
3
|
import re
|
|
4
4
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Text
|
|
5
|
-
|
|
6
5
|
import dotenv
|
|
7
6
|
import structlog
|
|
8
7
|
from jinja2 import Template
|
|
@@ -64,19 +63,11 @@ from rasa.shared.core.events import Event, UserUttered, BotUttered
|
|
|
64
63
|
from rasa.shared.core.generator import TrackerWithCachedStates
|
|
65
64
|
from rasa.shared.core.trackers import DialogueStateTracker, EventVerbosity
|
|
66
65
|
from rasa.shared.exceptions import RasaException, FileIOException
|
|
67
|
-
from rasa.shared.nlu.constants import (
|
|
68
|
-
PROMPTS,
|
|
69
|
-
KEY_USER_PROMPT,
|
|
70
|
-
KEY_LLM_RESPONSE_METADATA,
|
|
71
|
-
KEY_PROMPT_NAME,
|
|
72
|
-
KEY_COMPONENT_NAME,
|
|
73
|
-
)
|
|
74
66
|
from rasa.shared.nlu.training_data.training_data import TrainingData
|
|
75
67
|
from rasa.shared.providers.embedding._langchain_embedding_client_adapter import (
|
|
76
68
|
_LangchainEmbeddingClientAdapter,
|
|
77
69
|
)
|
|
78
70
|
from rasa.shared.providers.llm.llm_client import LLMClient
|
|
79
|
-
from rasa.shared.providers.llm.llm_response import LLMResponse
|
|
80
71
|
from rasa.shared.utils.cli import print_error_and_exit
|
|
81
72
|
from rasa.shared.utils.health_check.embeddings_health_check_mixin import (
|
|
82
73
|
EmbeddingsHealthCheckMixin,
|
|
@@ -281,43 +272,6 @@ class EnterpriseSearchPolicy(LLMHealthCheckMixin, EmbeddingsHealthCheckMixin, Po
|
|
|
281
272
|
# Wrap the embedding client in the adapter
|
|
282
273
|
return _LangchainEmbeddingClientAdapter(client)
|
|
283
274
|
|
|
284
|
-
@classmethod
|
|
285
|
-
def _add_prompt_and_llm_response_to_latest_message(
|
|
286
|
-
cls,
|
|
287
|
-
tracker: DialogueStateTracker,
|
|
288
|
-
prompt_name: str,
|
|
289
|
-
user_prompt: str,
|
|
290
|
-
llm_response: Optional[LLMResponse] = None,
|
|
291
|
-
) -> None:
|
|
292
|
-
"""Stores the prompt and LLMResponse metadata in the tracker.
|
|
293
|
-
|
|
294
|
-
Args:
|
|
295
|
-
tracker: The DialogueStateTracker containing the current conversation state.
|
|
296
|
-
prompt_name: A name identifying prompt usage.
|
|
297
|
-
user_prompt: The user prompt that was sent to the LLM.
|
|
298
|
-
llm_response: The response object from the LLM (None if no response).
|
|
299
|
-
"""
|
|
300
|
-
from rasa.dialogue_understanding.utils import record_commands_and_prompts
|
|
301
|
-
|
|
302
|
-
if not record_commands_and_prompts:
|
|
303
|
-
return
|
|
304
|
-
|
|
305
|
-
if not tracker.latest_message:
|
|
306
|
-
return
|
|
307
|
-
|
|
308
|
-
parse_data = tracker.latest_message.parse_data
|
|
309
|
-
if PROMPTS not in parse_data:
|
|
310
|
-
parse_data[PROMPTS] = [] # type: ignore[literal-required]
|
|
311
|
-
|
|
312
|
-
prompt_data: Dict[Text, Any] = {
|
|
313
|
-
KEY_COMPONENT_NAME: cls.__name__,
|
|
314
|
-
KEY_PROMPT_NAME: prompt_name,
|
|
315
|
-
KEY_USER_PROMPT: user_prompt,
|
|
316
|
-
KEY_LLM_RESPONSE_METADATA: llm_response.to_dict() if llm_response else None,
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
parse_data[PROMPTS].append(prompt_data) # type: ignore[literal-required]
|
|
320
|
-
|
|
321
275
|
def train( # type: ignore[override]
|
|
322
276
|
self,
|
|
323
277
|
training_trackers: List[TrackerWithCachedStates],
|
|
@@ -544,27 +498,13 @@ class EnterpriseSearchPolicy(LLMHealthCheckMixin, EmbeddingsHealthCheckMixin, Po
|
|
|
544
498
|
|
|
545
499
|
if self.use_llm:
|
|
546
500
|
prompt = self._render_prompt(tracker, documents.results)
|
|
547
|
-
|
|
548
|
-
llm_response = LLMResponse.ensure_llm_response(llm_response)
|
|
549
|
-
|
|
550
|
-
self._add_prompt_and_llm_response_to_latest_message(
|
|
551
|
-
tracker=tracker,
|
|
552
|
-
prompt_name="enterprise_search_prompt",
|
|
553
|
-
user_prompt=prompt,
|
|
554
|
-
llm_response=llm_response,
|
|
555
|
-
)
|
|
501
|
+
llm_answer = await self._generate_llm_answer(llm, prompt)
|
|
556
502
|
|
|
557
|
-
if
|
|
558
|
-
|
|
559
|
-
response = None
|
|
560
|
-
else:
|
|
561
|
-
llm_answer = llm_response.choices[0]
|
|
503
|
+
if self.citation_enabled:
|
|
504
|
+
llm_answer = self.post_process_citations(llm_answer)
|
|
562
505
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
logger.debug(f"{logger_key}.llm_answer", llm_answer=llm_answer)
|
|
567
|
-
response = llm_answer
|
|
506
|
+
logger.debug(f"{logger_key}.llm_answer", llm_answer=llm_answer)
|
|
507
|
+
response = llm_answer
|
|
568
508
|
else:
|
|
569
509
|
response = documents.results[0].metadata.get("answer", None)
|
|
570
510
|
if not response:
|
|
@@ -576,6 +516,7 @@ class EnterpriseSearchPolicy(LLMHealthCheckMixin, EmbeddingsHealthCheckMixin, Po
|
|
|
576
516
|
"enterprise_search_policy.predict_action_probabilities.no_llm",
|
|
577
517
|
search_results=documents,
|
|
578
518
|
)
|
|
519
|
+
|
|
579
520
|
if response is None:
|
|
580
521
|
return self._create_prediction_internal_error(domain, tracker)
|
|
581
522
|
|
|
@@ -640,18 +581,10 @@ class EnterpriseSearchPolicy(LLMHealthCheckMixin, EmbeddingsHealthCheckMixin, Po
|
|
|
640
581
|
|
|
641
582
|
async def _generate_llm_answer(
|
|
642
583
|
self, llm: LLMClient, prompt: Text
|
|
643
|
-
) -> Optional[
|
|
644
|
-
"""Fetches an LLM completion for the provided prompt.
|
|
645
|
-
|
|
646
|
-
Args:
|
|
647
|
-
llm: The LLM client used to get the completion.
|
|
648
|
-
prompt: The prompt text to send to the model.
|
|
649
|
-
|
|
650
|
-
Returns:
|
|
651
|
-
An LLMResponse object, or None if the call fails.
|
|
652
|
-
"""
|
|
584
|
+
) -> Optional[Text]:
|
|
653
585
|
try:
|
|
654
|
-
|
|
586
|
+
llm_response = await llm.acompletion(prompt)
|
|
587
|
+
llm_answer = llm_response.choices[0]
|
|
655
588
|
except Exception as e:
|
|
656
589
|
# unfortunately, langchain does not wrap LLM exceptions which means
|
|
657
590
|
# we have to catch all exceptions here
|
|
@@ -659,7 +592,9 @@ class EnterpriseSearchPolicy(LLMHealthCheckMixin, EmbeddingsHealthCheckMixin, Po
|
|
|
659
592
|
"enterprise_search_policy._generate_llm_answer.llm_error",
|
|
660
593
|
error=e,
|
|
661
594
|
)
|
|
662
|
-
|
|
595
|
+
llm_answer = None
|
|
596
|
+
|
|
597
|
+
return llm_answer
|
|
663
598
|
|
|
664
599
|
def _create_prediction(
|
|
665
600
|
self,
|
|
@@ -82,7 +82,6 @@ from rasa.shared.core.flows.steps import (
|
|
|
82
82
|
NoOperationFlowStep,
|
|
83
83
|
)
|
|
84
84
|
from rasa.shared.core.flows.steps.collect import SlotRejection
|
|
85
|
-
from rasa.shared.core.flows.steps.constants import START_STEP
|
|
86
85
|
from rasa.shared.core.slots import Slot
|
|
87
86
|
from rasa.shared.core.trackers import (
|
|
88
87
|
DialogueStateTracker,
|
|
@@ -317,7 +316,7 @@ def reset_scoped_slots(
|
|
|
317
316
|
def _reset_slot(slot_name: Text, dialogue_tracker: DialogueStateTracker) -> None:
|
|
318
317
|
slot = dialogue_tracker.slots.get(slot_name, None)
|
|
319
318
|
initial_value = slot.initial_value if slot else None
|
|
320
|
-
events.append(SlotSet(slot_name, initial_value
|
|
319
|
+
events.append(SlotSet(slot_name, initial_value))
|
|
321
320
|
|
|
322
321
|
if (
|
|
323
322
|
isinstance(current_frame, UserFlowStackFrame)
|
|
@@ -449,7 +448,6 @@ def advance_flows_until_next_action(
|
|
|
449
448
|
tracker,
|
|
450
449
|
available_actions,
|
|
451
450
|
flows,
|
|
452
|
-
previous_step_id,
|
|
453
451
|
)
|
|
454
452
|
new_events = step_result.events
|
|
455
453
|
if (
|
|
@@ -466,9 +464,6 @@ def advance_flows_until_next_action(
|
|
|
466
464
|
new_events.insert(
|
|
467
465
|
idx, FlowCompleted(active_frame.flow_id, previous_step_id)
|
|
468
466
|
)
|
|
469
|
-
attach_stack_metadata_to_events(
|
|
470
|
-
next_step.id, current_flow.id, new_events
|
|
471
|
-
)
|
|
472
467
|
tracker.update_stack(step_stack)
|
|
473
468
|
tracker.update_with_events(new_events)
|
|
474
469
|
|
|
@@ -572,17 +567,6 @@ def validate_custom_slot_mappings(
|
|
|
572
567
|
return True
|
|
573
568
|
|
|
574
569
|
|
|
575
|
-
def attach_stack_metadata_to_events(
|
|
576
|
-
step_id: str,
|
|
577
|
-
flow_id: str,
|
|
578
|
-
events: List[Event],
|
|
579
|
-
) -> None:
|
|
580
|
-
"""Attach the stack metadata to the events."""
|
|
581
|
-
for event in events:
|
|
582
|
-
event.metadata[STEP_ID_METADATA_KEY] = step_id
|
|
583
|
-
event.metadata[ACTIVE_FLOW_METADATA_KEY] = flow_id
|
|
584
|
-
|
|
585
|
-
|
|
586
570
|
def run_step(
|
|
587
571
|
step: FlowStep,
|
|
588
572
|
flow: Flow,
|
|
@@ -590,7 +574,6 @@ def run_step(
|
|
|
590
574
|
tracker: DialogueStateTracker,
|
|
591
575
|
available_actions: List[str],
|
|
592
576
|
flows: FlowsList,
|
|
593
|
-
previous_step_id: str,
|
|
594
577
|
) -> FlowStepResult:
|
|
595
578
|
"""Run a single step of a flow.
|
|
596
579
|
|
|
@@ -608,19 +591,12 @@ def run_step(
|
|
|
608
591
|
tracker: The tracker to run the step on.
|
|
609
592
|
available_actions: The actions that are available in the domain.
|
|
610
593
|
flows: All flows.
|
|
611
|
-
previous_step_id: The ID of the previous step.
|
|
612
594
|
|
|
613
595
|
Returns:
|
|
614
596
|
A result of running the step describing where to transition to.
|
|
615
597
|
"""
|
|
616
598
|
initial_events: List[Event] = []
|
|
617
|
-
if
|
|
618
|
-
# if the previous step id is the start step, we need to add a flow
|
|
619
|
-
# started event to the initial events.
|
|
620
|
-
# we can't use the current step to check this, as the current step is the
|
|
621
|
-
# first step in the flow -> other steps might link to this flow, so the
|
|
622
|
-
# only reliable way to check if we are starting a new flow is checking for
|
|
623
|
-
# the START_STEP meta step
|
|
599
|
+
if step == flow.first_step_in_flow():
|
|
624
600
|
initial_events.append(FlowStarted(flow.id, metadata=stack.current_context()))
|
|
625
601
|
|
|
626
602
|
if isinstance(step, CollectInformationFlowStep):
|
rasa/core/processor.py
CHANGED
|
@@ -818,9 +818,8 @@ class MessageProcessor:
|
|
|
818
818
|
return parse_data
|
|
819
819
|
|
|
820
820
|
def _sanitize_message(self, message: UserMessage) -> UserMessage:
|
|
821
|
-
"""Sanitize user
|
|
822
|
-
|
|
823
|
-
Removes prepended slashes before the actual content.
|
|
821
|
+
"""Sanitize user message by removing prepended slashes before the
|
|
822
|
+
actual content.
|
|
824
823
|
"""
|
|
825
824
|
# Regex pattern to match leading slashes and any whitespace before
|
|
826
825
|
# actual content
|
|
@@ -922,7 +921,9 @@ class MessageProcessor:
|
|
|
922
921
|
return [command.as_dict() for command in commands]
|
|
923
922
|
|
|
924
923
|
def _contains_undefined_intent(self, message: Message) -> bool:
|
|
925
|
-
"""Checks if the message contains an undefined
|
|
924
|
+
"""Checks if the message contains an intent that is undefined
|
|
925
|
+
in the domain.
|
|
926
|
+
"""
|
|
926
927
|
intent_name = message.get(INTENT, {}).get("name")
|
|
927
928
|
return intent_name is not None and intent_name not in self.domain.intents
|
|
928
929
|
|
|
@@ -986,8 +987,6 @@ class MessageProcessor:
|
|
|
986
987
|
if parse_data["entities"]:
|
|
987
988
|
self._log_slots(tracker)
|
|
988
989
|
|
|
989
|
-
plugin_manager().hook.after_new_user_message(tracker=tracker)
|
|
990
|
-
|
|
991
990
|
logger.debug(
|
|
992
991
|
f"Logged UserUtterance - tracker now has {len(tracker.events)} events."
|
|
993
992
|
)
|
|
@@ -1306,7 +1305,7 @@ class MessageProcessor:
|
|
|
1306
1305
|
self._log_slots(tracker)
|
|
1307
1306
|
|
|
1308
1307
|
await self.execute_side_effects(events, tracker, output_channel)
|
|
1309
|
-
|
|
1308
|
+
|
|
1310
1309
|
return self.should_predict_another_action(action.name())
|
|
1311
1310
|
|
|
1312
1311
|
def _log_action_on_tracker(
|
|
@@ -1442,10 +1441,8 @@ class MessageProcessor:
|
|
|
1442
1441
|
return len(filtered_commands) > 0
|
|
1443
1442
|
|
|
1444
1443
|
def _is_calm_assistant(self) -> bool:
|
|
1445
|
-
"""Inspects the nodes of the graph schema to
|
|
1446
|
-
|
|
1447
|
-
To determine whether we are in CALM mode, we check if any node is
|
|
1448
|
-
associated with the `FlowPolicy`, which is indicative of a
|
|
1444
|
+
"""Inspects the nodes of the graph schema to determine whether
|
|
1445
|
+
any node is associated with the `FlowPolicy`, which is indicative of a
|
|
1449
1446
|
CALM assistant setup.
|
|
1450
1447
|
|
|
1451
1448
|
Returns:
|