rasa-pro 3.11.3__py3-none-any.whl → 3.11.3a1.dev4__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/direct_custom_actions_executor.py +31 -2
- rasa/core/channels/development_inspector.py +3 -0
- rasa/core/channels/inspector/dist/assets/{arc-632a63ec.js → arc-861ddd57.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-d0fbc5ce-081e0df4.js → c4Diagram-d0fbc5ce-921f02db.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-936ed81e-3df0afc2.js → classDiagram-936ed81e-b436c4f8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-c3cb15f1-8c5ed31e.js → classDiagram-v2-c3cb15f1-511a23cb.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{createText-62fc7601-89c73b31.js → createText-62fc7601-ef476ecd.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-f2ad444c-4fc48c3e.js → edges-f2ad444c-f1878e0a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9d236eb7-907e0440.js → erDiagram-9d236eb7-fac75185.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-1972c806-9ec53a3c.js → flowDb-1972c806-201c5bbc.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-7ea5b25a-41da787a.js → flowDiagram-7ea5b25a-f904ae41.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-b080d6f2.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-abe16c3d-ce370633.js → flowchart-elk-definition-abe16c3d-1813da66.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-9b5ea136-90a36523.js → ganttDiagram-9b5ea136-872af172.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-99d0ae7c-41e1aa3f.js → gitGraphDiagram-99d0ae7c-34a0af5a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-2c4b9a3b-e6f2af62.js → index-2c4b9a3b-42ba3e3d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-e793d777.js → index-37817b51.js} +3 -3
- rasa/core/channels/inspector/dist/assets/{infoDiagram-736b4530-8ceba4db.js → infoDiagram-736b4530-6b731386.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-df861f2b-960d3809.js → journeyDiagram-df861f2b-e8579ac6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-498807d8.js → layout-89e6403a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-eeccc4e2.js → line-dc73d3fc.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-8a078617.js → linear-f5b1d2bc.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-beec6740-396d17dd.js → mindmap-definition-beec6740-82cb74fa.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-dbbf0591-dc9b5e1b.js → pieDiagram-dbbf0591-bdf5f29b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-4d7f4fd6-a08cba6d.js → quadrantDiagram-4d7f4fd6-c7a0cbe4.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-6fc4c22a-87242b9e.js → requirementDiagram-6fc4c22a-7ec5410f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-8f13d901-53f6f391.js → sankeyDiagram-8f13d901-caee5554.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-b655622a-715c9c20.js → sequenceDiagram-b655622a-2935f8db.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-59f0c015-2e8fb31f.js → stateDiagram-59f0c015-8f5d9693.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-2b26beab-7e2d2aa0.js → stateDiagram-v2-2b26beab-d565d1de.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-080da4f6-4420cea6.js → styles-080da4f6-75ad421d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-3dcbcfbf-28676cf4.js → styles-3dcbcfbf-7e764226.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9c745c82-cef936a6.js → styles-9c745c82-7a4e0e61.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-4835440b-151251e9.js → svgDrawCommon-4835440b-4019d1bf.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-5b62e21b-0d39bdb2.js → timeline-definition-5b62e21b-01ea12df.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-2b33534f-a03fa445.js → xychartDiagram-2b33534f-89407137.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -3
- rasa/core/channels/inspector/index.html +0 -2
- rasa/core/channels/inspector/src/App.tsx +4 -1
- rasa/core/channels/socketio.py +40 -0
- rasa/core/policies/flows/flow_executor.py +26 -2
- rasa/dialogue_understanding/generator/command_generator.py +126 -5
- rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +28 -1
- rasa/dialogue_understanding/generator/nlu_command_adapter.py +3 -0
- rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +9 -1
- rasa/dialogue_understanding/utils.py +14 -0
- rasa/dialogue_understanding_test/__init__.py +0 -0
- rasa/dialogue_understanding_test/constants.py +15 -0
- rasa/dialogue_understanding_test/du_test_case.py +118 -0
- rasa/dialogue_understanding_test/du_test_result.py +11 -0
- rasa/e2e_test/e2e_test_case.py +2 -1
- rasa/e2e_test/utils/e2e_yaml_utils.py +1 -1
- rasa/e2e_test/utils/io.py +1 -1
- rasa/e2e_test/utils/validation.py +100 -2
- rasa/engine/recipes/default_recipe.py +63 -49
- rasa/engine/recipes/graph_recipe.py +8 -7
- rasa/model_manager/runner_service.py +1 -0
- rasa/model_manager/socket_bridge.py +8 -2
- rasa/model_training.py +2 -1
- rasa/server.py +1 -37
- rasa/shared/constants.py +17 -6
- rasa/shared/nlu/constants.py +4 -0
- rasa/shared/utils/llm.py +1 -1
- rasa/shared/utils/yaml.py +6 -5
- rasa/studio/upload.py +19 -5
- rasa/telemetry.py +40 -33
- rasa/tracing/instrumentation/attribute_extractors.py +10 -9
- rasa/validator.py +32 -41
- rasa/version.py +1 -1
- {rasa_pro-3.11.3.dist-info → rasa_pro-3.11.3a1.dev4.dist-info}/METADATA +6 -6
- {rasa_pro-3.11.3.dist-info → rasa_pro-3.11.3a1.dev4.dist-info}/RECORD +74 -69
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-8bea338b.js +0 -1
- {rasa_pro-3.11.3.dist-info → rasa_pro-3.11.3a1.dev4.dist-info}/NOTICE +0 -0
- {rasa_pro-3.11.3.dist-info → rasa_pro-3.11.3a1.dev4.dist-info}/WHEEL +0 -0
- {rasa_pro-3.11.3.dist-info → rasa_pro-3.11.3a1.dev4.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-37817b51.js";import{c as Qt}from"./createText-62fc7601-ef476ecd.js";import{i as Kt}from"./init-77b53fdd.js";import{o as Zt}from"./ordinal-ba9b4969.js";import{l as ft}from"./linear-f5b1d2bc.js";import{l as pt}from"./line-dc73d3fc.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-37817b51.js"></script>
|
|
10
10
|
<link rel="stylesheet" href="./assets/index-3ee28881.css">
|
|
11
11
|
</head>
|
|
12
12
|
|
|
@@ -19,7 +19,6 @@
|
|
|
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";
|
|
23
22
|
const maxHeight = document.documentElement.scrollHeight - 130;
|
|
24
23
|
// 21 and 25 are the rem number we're using for the columns. We add 0.75rem for the padding
|
|
25
24
|
// A potential improvement would be to add a onresize event for both width and height
|
|
@@ -31,7 +30,6 @@
|
|
|
31
30
|
const columnWidth = remReference * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
32
31
|
|
|
33
32
|
chatDiv.setAttribute("data-websocket-url", websocketUrl);
|
|
34
|
-
chatDiv.setAttribute("data-initial-payload", initialPayload);
|
|
35
33
|
chatDiv.setAttribute("data-close-on-outside-click", false);
|
|
36
34
|
chatDiv.setAttribute("data-height", maxHeight);
|
|
37
35
|
chatDiv.setAttribute("data-width", columnWidth);
|
|
@@ -17,7 +17,6 @@
|
|
|
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";
|
|
21
20
|
const maxHeight = document.documentElement.scrollHeight - 130;
|
|
22
21
|
// 21 and 25 are the rem number we're using for the columns. We add 0.75rem for the padding
|
|
23
22
|
// A potential improvement would be to add a onresize event for both width and height
|
|
@@ -29,7 +28,6 @@
|
|
|
29
28
|
const columnWidth = remReference * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
30
29
|
|
|
31
30
|
chatDiv.setAttribute("data-websocket-url", websocketUrl);
|
|
32
|
-
chatDiv.setAttribute("data-initial-payload", initialPayload);
|
|
33
31
|
chatDiv.setAttribute("data-close-on-outside-click", false);
|
|
34
32
|
chatDiv.setAttribute("data-height", maxHeight);
|
|
35
33
|
chatDiv.setAttribute("data-width", columnWidth);
|
|
@@ -131,7 +131,6 @@ export function App() {
|
|
|
131
131
|
setStack(updatedStack);
|
|
132
132
|
setFrame(updatedActiveFrame(frame, updatedStack, lastJsonMessage.events));
|
|
133
133
|
setRasaChatSessionId(lastJsonMessage.sender_id);
|
|
134
|
-
fetchStory();
|
|
135
134
|
} else if (
|
|
136
135
|
rasaChatSessionId &&
|
|
137
136
|
lastJsonMessage.sender_id !== rasaChatSessionId
|
|
@@ -141,6 +140,10 @@ export function App() {
|
|
|
141
140
|
}
|
|
142
141
|
}, [lastJsonMessage, rasaChatSessionId]);
|
|
143
142
|
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
fetchStory();
|
|
145
|
+
}, [rasaChatSessionId]);
|
|
146
|
+
|
|
144
147
|
const borderRadiusSx = {
|
|
145
148
|
borderRadius: rasaRadii.normal,
|
|
146
149
|
};
|
rasa/core/channels/socketio.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import asyncio
|
|
1
2
|
import inspect
|
|
2
3
|
import logging
|
|
3
4
|
import uuid
|
|
@@ -6,6 +7,7 @@ from typing import Any, Awaitable, Callable, Dict, Iterable, List, Optional, Tex
|
|
|
6
7
|
|
|
7
8
|
import rasa.core.channels.channel
|
|
8
9
|
from rasa.core.channels.channel import InputChannel, OutputChannel, UserMessage
|
|
10
|
+
from rasa.shared.core.trackers import EventVerbosity
|
|
9
11
|
import rasa.shared.utils.io
|
|
10
12
|
from sanic import Blueprint, response, Sanic
|
|
11
13
|
from sanic.request import Request
|
|
@@ -188,6 +190,8 @@ class SocketIOInput(InputChannel):
|
|
|
188
190
|
metadata_key: Optional[Text] = "metadata",
|
|
189
191
|
):
|
|
190
192
|
"""Creates a ``SocketIOInput`` object."""
|
|
193
|
+
from rasa.core.agent import Agent
|
|
194
|
+
|
|
191
195
|
self.bot_message_evt = bot_message_evt
|
|
192
196
|
self.session_persistence = session_persistence
|
|
193
197
|
self.user_message_evt = user_message_evt
|
|
@@ -199,6 +203,8 @@ class SocketIOInput(InputChannel):
|
|
|
199
203
|
self.jwt_key = jwt_key
|
|
200
204
|
self.jwt_algorithm = jwt_method
|
|
201
205
|
|
|
206
|
+
self.agent: Optional[Agent] = None
|
|
207
|
+
|
|
202
208
|
def get_output_channel(self) -> Optional["OutputChannel"]:
|
|
203
209
|
"""Creates socket.io output channel object."""
|
|
204
210
|
if self.sio is None:
|
|
@@ -212,6 +218,10 @@ class SocketIOInput(InputChannel):
|
|
|
212
218
|
return None
|
|
213
219
|
return SocketIOOutput(self.sio, self.bot_message_evt)
|
|
214
220
|
|
|
221
|
+
async def on_new_tracker_dump(self, sender_id: str, tracker_dump: str):
|
|
222
|
+
if self.sio:
|
|
223
|
+
await self.sio.emit("tracker", tracker_dump, room=sender_id)
|
|
224
|
+
|
|
215
225
|
def blueprint(
|
|
216
226
|
self, on_new_message: Callable[[UserMessage], Awaitable[Any]]
|
|
217
227
|
) -> Blueprint:
|
|
@@ -223,6 +233,11 @@ class SocketIOInput(InputChannel):
|
|
|
223
233
|
sio, self.socketio_path, "socketio_webhook", __name__
|
|
224
234
|
)
|
|
225
235
|
|
|
236
|
+
@socketio_webhook.listener("after_server_start") # type: ignore[misc]
|
|
237
|
+
async def after_server_start(app: Sanic, _: asyncio.AbstractEventLoop) -> None:
|
|
238
|
+
"""Prints a message after the server has started with inspect URL."""
|
|
239
|
+
self.agent = app.ctx.agent
|
|
240
|
+
|
|
226
241
|
# make sio object static to use in get_output_channel
|
|
227
242
|
self.sio = sio
|
|
228
243
|
|
|
@@ -268,6 +283,30 @@ class SocketIOInput(InputChannel):
|
|
|
268
283
|
await sio.emit("session_confirm", data["session_id"], room=sid)
|
|
269
284
|
logger.debug(f"User {sid} connected to socketIO endpoint.")
|
|
270
285
|
|
|
286
|
+
@sio.on("tracker", namespace=self.namespace)
|
|
287
|
+
async def handle_tracker(sid: Text, data: Dict) -> None:
|
|
288
|
+
from rasa.shared.core.trackers import DialogueStateTracker
|
|
289
|
+
|
|
290
|
+
if self.agent is None:
|
|
291
|
+
raise ValueError("Agent is not initialized")
|
|
292
|
+
|
|
293
|
+
async with self.agent.lock_store.lock(data["sender_id"]):
|
|
294
|
+
tracker = DialogueStateTracker.from_dict(
|
|
295
|
+
data["sender_id"], data["events"], self.agent.domain.slots
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
# will override an existing tracker with the same id!
|
|
299
|
+
await self.agent.tracker_store.save(tracker)
|
|
300
|
+
|
|
301
|
+
# TODO: rather figure out how to trigger the on_tracker_updated
|
|
302
|
+
# of the development inspector channel
|
|
303
|
+
state = tracker.current_state(EventVerbosity.AFTER_RESTART)
|
|
304
|
+
await sio.emit(
|
|
305
|
+
"tracker",
|
|
306
|
+
json.dumps(state),
|
|
307
|
+
room=sid,
|
|
308
|
+
)
|
|
309
|
+
|
|
271
310
|
@sio.on(self.user_message_evt, namespace=self.namespace)
|
|
272
311
|
async def handle_message(sid: Text, data: Dict) -> None:
|
|
273
312
|
output_channel = SocketIOOutput(sio, self.bot_message_evt)
|
|
@@ -289,6 +328,7 @@ class SocketIOInput(InputChannel):
|
|
|
289
328
|
metadata = data.get(self.metadata_key, {})
|
|
290
329
|
if isinstance(metadata, Text):
|
|
291
330
|
metadata = json.loads(metadata)
|
|
331
|
+
|
|
292
332
|
message = UserMessage(
|
|
293
333
|
data.get("message", ""),
|
|
294
334
|
output_channel,
|
|
@@ -82,6 +82,7 @@ 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
|
|
85
86
|
from rasa.shared.core.slots import Slot
|
|
86
87
|
from rasa.shared.core.trackers import (
|
|
87
88
|
DialogueStateTracker,
|
|
@@ -316,7 +317,7 @@ def reset_scoped_slots(
|
|
|
316
317
|
def _reset_slot(slot_name: Text, dialogue_tracker: DialogueStateTracker) -> None:
|
|
317
318
|
slot = dialogue_tracker.slots.get(slot_name, None)
|
|
318
319
|
initial_value = slot.initial_value if slot else None
|
|
319
|
-
events.append(SlotSet(slot_name, initial_value))
|
|
320
|
+
events.append(SlotSet(slot_name, initial_value, metadata={"reset": True}))
|
|
320
321
|
|
|
321
322
|
if (
|
|
322
323
|
isinstance(current_frame, UserFlowStackFrame)
|
|
@@ -448,6 +449,7 @@ def advance_flows_until_next_action(
|
|
|
448
449
|
tracker,
|
|
449
450
|
available_actions,
|
|
450
451
|
flows,
|
|
452
|
+
previous_step_id,
|
|
451
453
|
)
|
|
452
454
|
new_events = step_result.events
|
|
453
455
|
if (
|
|
@@ -464,6 +466,9 @@ def advance_flows_until_next_action(
|
|
|
464
466
|
new_events.insert(
|
|
465
467
|
idx, FlowCompleted(active_frame.flow_id, previous_step_id)
|
|
466
468
|
)
|
|
469
|
+
attach_stack_metadata_to_events(
|
|
470
|
+
next_step.id, current_flow.id, new_events
|
|
471
|
+
)
|
|
467
472
|
tracker.update_stack(step_stack)
|
|
468
473
|
tracker.update_with_events(new_events)
|
|
469
474
|
|
|
@@ -567,6 +572,17 @@ def validate_custom_slot_mappings(
|
|
|
567
572
|
return True
|
|
568
573
|
|
|
569
574
|
|
|
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
|
+
|
|
570
586
|
def run_step(
|
|
571
587
|
step: FlowStep,
|
|
572
588
|
flow: Flow,
|
|
@@ -574,6 +590,7 @@ def run_step(
|
|
|
574
590
|
tracker: DialogueStateTracker,
|
|
575
591
|
available_actions: List[str],
|
|
576
592
|
flows: FlowsList,
|
|
593
|
+
previous_step_id: str,
|
|
577
594
|
) -> FlowStepResult:
|
|
578
595
|
"""Run a single step of a flow.
|
|
579
596
|
|
|
@@ -591,12 +608,19 @@ def run_step(
|
|
|
591
608
|
tracker: The tracker to run the step on.
|
|
592
609
|
available_actions: The actions that are available in the domain.
|
|
593
610
|
flows: All flows.
|
|
611
|
+
previous_step_id: The ID of the previous step.
|
|
594
612
|
|
|
595
613
|
Returns:
|
|
596
614
|
A result of running the step describing where to transition to.
|
|
597
615
|
"""
|
|
598
616
|
initial_events: List[Event] = []
|
|
599
|
-
if
|
|
617
|
+
if previous_step_id == START_STEP:
|
|
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
|
|
600
624
|
initial_events.append(FlowStarted(flow.id, metadata=stack.current_context()))
|
|
601
625
|
|
|
602
626
|
if isinstance(step, CollectInformationFlowStep):
|
|
@@ -10,18 +10,25 @@ from rasa.dialogue_understanding.commands import (
|
|
|
10
10
|
ErrorCommand,
|
|
11
11
|
)
|
|
12
12
|
from rasa.dialogue_understanding.commands.set_slot_command import SetSlotExtractor
|
|
13
|
+
from rasa.shared.constants import (
|
|
14
|
+
RASA_PATTERN_INTERNAL_ERROR_USER_INPUT_TOO_LONG,
|
|
15
|
+
RASA_PATTERN_INTERNAL_ERROR_USER_INPUT_EMPTY,
|
|
16
|
+
)
|
|
13
17
|
from rasa.shared.core.constants import SlotMappingType
|
|
14
18
|
from rasa.shared.core.domain import Domain
|
|
15
19
|
from rasa.shared.core.flows import FlowsList
|
|
16
20
|
from rasa.shared.core.slot_mappings import SlotFillingManager
|
|
17
21
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
22
|
+
from rasa.shared.nlu.constants import (
|
|
23
|
+
COMMANDS,
|
|
24
|
+
TEXT,
|
|
25
|
+
PREDICTED_COMMANDS,
|
|
26
|
+
PROMPTS,
|
|
27
|
+
KEY_USER_PROMPT,
|
|
28
|
+
KEY_SYSTEM_PROMPT,
|
|
29
|
+
)
|
|
18
30
|
from rasa.shared.nlu.training_data.message import Message
|
|
19
|
-
from rasa.shared.nlu.constants import COMMANDS, TEXT
|
|
20
31
|
from rasa.shared.utils.llm import DEFAULT_MAX_USER_INPUT_CHARACTERS
|
|
21
|
-
from rasa.shared.constants import (
|
|
22
|
-
RASA_PATTERN_INTERNAL_ERROR_USER_INPUT_TOO_LONG,
|
|
23
|
-
RASA_PATTERN_INTERNAL_ERROR_USER_INPUT_EMPTY,
|
|
24
|
-
)
|
|
25
32
|
|
|
26
33
|
structlogger = structlog.get_logger()
|
|
27
34
|
|
|
@@ -193,6 +200,7 @@ class CommandGenerator:
|
|
|
193
200
|
flows: The flows to use for command prediction.
|
|
194
201
|
tracker: The tracker containing the conversation history up to now.
|
|
195
202
|
**kwargs: Keyword arguments for forward compatibility.
|
|
203
|
+
|
|
196
204
|
Returns:
|
|
197
205
|
The predicted commands.
|
|
198
206
|
"""
|
|
@@ -341,3 +349,116 @@ class CommandGenerator:
|
|
|
341
349
|
]
|
|
342
350
|
|
|
343
351
|
return filtered_commands
|
|
352
|
+
|
|
353
|
+
@staticmethod
|
|
354
|
+
def _add_commands_to_message_parse_data(
|
|
355
|
+
message: Message, component_name: str, commands: List[Command]
|
|
356
|
+
) -> None:
|
|
357
|
+
"""Add commands to the message parse data.
|
|
358
|
+
|
|
359
|
+
Commands are only added in case the flag 'record_commands_and_prompts' is set.
|
|
360
|
+
Example of predicted commands in the message parse data:
|
|
361
|
+
Message(data={
|
|
362
|
+
PREDICTED_COMMANDS: {
|
|
363
|
+
"MultiStepLLMCommandGenerator": [
|
|
364
|
+
{"command": "set_slot", "name": "slot_name", "value": "slot_value"},
|
|
365
|
+
],
|
|
366
|
+
"NLUCommandAdapter": [
|
|
367
|
+
{"command": "start_flow", "name": "test_flow"},
|
|
368
|
+
]
|
|
369
|
+
}
|
|
370
|
+
})
|
|
371
|
+
"""
|
|
372
|
+
from rasa.dialogue_understanding.utils import record_commands_and_prompts
|
|
373
|
+
|
|
374
|
+
# only set commands if the flag "record_commands_and_prompts" is set to True
|
|
375
|
+
if not record_commands_and_prompts:
|
|
376
|
+
return
|
|
377
|
+
|
|
378
|
+
commands_as_dict = [command.as_dict() for command in commands]
|
|
379
|
+
|
|
380
|
+
if message.get(PREDICTED_COMMANDS) is not None:
|
|
381
|
+
predicted_commands = message.get(PREDICTED_COMMANDS)
|
|
382
|
+
if component_name in predicted_commands:
|
|
383
|
+
predicted_commands[component_name].extend(commands_as_dict)
|
|
384
|
+
else:
|
|
385
|
+
predicted_commands[component_name] = commands_as_dict
|
|
386
|
+
else:
|
|
387
|
+
predicted_commands = {component_name: commands_as_dict}
|
|
388
|
+
|
|
389
|
+
message.set(
|
|
390
|
+
PREDICTED_COMMANDS,
|
|
391
|
+
predicted_commands,
|
|
392
|
+
add_to_output=True,
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
@staticmethod
|
|
396
|
+
def _add_prompt_to_message_parse_data(
|
|
397
|
+
message: Message,
|
|
398
|
+
component_name: str,
|
|
399
|
+
prompt_name: str,
|
|
400
|
+
user_prompt: str,
|
|
401
|
+
system_prompt: Optional[str] = None,
|
|
402
|
+
) -> None:
|
|
403
|
+
"""Add prompt to the message parse data.
|
|
404
|
+
|
|
405
|
+
Prompt is only added in case the flag 'record_commands_and_prompts' is set.
|
|
406
|
+
Example of prompts in the message parse data:
|
|
407
|
+
Message(data={
|
|
408
|
+
PROMPTS: {
|
|
409
|
+
"MultiStepLLMCommandGenerator": [
|
|
410
|
+
(
|
|
411
|
+
"fill_slots_prompt",
|
|
412
|
+
{
|
|
413
|
+
"user_prompt": <prompt content>",
|
|
414
|
+
"system_prompt": <prompt content>"
|
|
415
|
+
}
|
|
416
|
+
),
|
|
417
|
+
(
|
|
418
|
+
"handle_flows_prompt",
|
|
419
|
+
{
|
|
420
|
+
"user_prompt": <prompt content>",
|
|
421
|
+
"system_prompt": <prompt content>"
|
|
422
|
+
}
|
|
423
|
+
),
|
|
424
|
+
],
|
|
425
|
+
"SingleStepLLMCommandGenerator": [
|
|
426
|
+
(
|
|
427
|
+
"prompt_template",
|
|
428
|
+
{
|
|
429
|
+
"user_prompt": <prompt content>",
|
|
430
|
+
"system_prompt": <prompt content>"
|
|
431
|
+
}
|
|
432
|
+
),
|
|
433
|
+
]
|
|
434
|
+
}
|
|
435
|
+
})
|
|
436
|
+
"""
|
|
437
|
+
from rasa.dialogue_understanding.utils import record_commands_and_prompts
|
|
438
|
+
|
|
439
|
+
# only set prompt if the flag "record_commands_and_prompts" is set to True
|
|
440
|
+
if not record_commands_and_prompts:
|
|
441
|
+
return
|
|
442
|
+
|
|
443
|
+
prompt_tuple = (
|
|
444
|
+
prompt_name,
|
|
445
|
+
{
|
|
446
|
+
KEY_USER_PROMPT: user_prompt,
|
|
447
|
+
**({KEY_SYSTEM_PROMPT: system_prompt} if system_prompt else {}),
|
|
448
|
+
},
|
|
449
|
+
)
|
|
450
|
+
|
|
451
|
+
if message.get(PROMPTS) is not None:
|
|
452
|
+
prompts = message.get(PROMPTS)
|
|
453
|
+
if component_name in prompts:
|
|
454
|
+
prompts[component_name].append(prompt_tuple)
|
|
455
|
+
else:
|
|
456
|
+
prompts[component_name] = [prompt_tuple]
|
|
457
|
+
else:
|
|
458
|
+
prompts = {component_name: [prompt_tuple]}
|
|
459
|
+
|
|
460
|
+
message.set(
|
|
461
|
+
PROMPTS,
|
|
462
|
+
prompts,
|
|
463
|
+
add_to_output=True,
|
|
464
|
+
)
|
|
@@ -144,7 +144,6 @@ class MultiStepLLMCommandGenerator(LLMBasedCommandGenerator):
|
|
|
144
144
|
**kwargs: Any,
|
|
145
145
|
) -> "MultiStepLLMCommandGenerator":
|
|
146
146
|
"""Loads trained component (see parent class for full docstring)."""
|
|
147
|
-
|
|
148
147
|
# Perform health check of the LLM client config
|
|
149
148
|
llm_config = resolve_model_client_config(config.get(LLM_CONFIG_KEY, {}))
|
|
150
149
|
cls.perform_llm_health_check(
|
|
@@ -200,6 +199,9 @@ class MultiStepLLMCommandGenerator(LLMBasedCommandGenerator):
|
|
|
200
199
|
message, flows, tracker
|
|
201
200
|
)
|
|
202
201
|
commands = self._clean_up_commands(commands)
|
|
202
|
+
self._add_commands_to_message_parse_data(
|
|
203
|
+
message, MultiStepLLMCommandGenerator.__name__, commands
|
|
204
|
+
)
|
|
203
205
|
except ProviderClientAPIException:
|
|
204
206
|
# if any step resulted in API exception, the command prediction cannot
|
|
205
207
|
# be completed, "predict" the ErrorCommand
|
|
@@ -542,6 +544,15 @@ class MultiStepLLMCommandGenerator(LLMBasedCommandGenerator):
|
|
|
542
544
|
)
|
|
543
545
|
|
|
544
546
|
commands = self.parse_commands(actions, tracker, available_flows)
|
|
547
|
+
|
|
548
|
+
if commands:
|
|
549
|
+
self._add_prompt_to_message_parse_data(
|
|
550
|
+
message,
|
|
551
|
+
MultiStepLLMCommandGenerator.__name__,
|
|
552
|
+
"fill_slots_for_active_flow_prompt",
|
|
553
|
+
prompt,
|
|
554
|
+
)
|
|
555
|
+
|
|
545
556
|
return commands
|
|
546
557
|
|
|
547
558
|
async def _predict_commands_for_handling_flows(
|
|
@@ -585,6 +596,14 @@ class MultiStepLLMCommandGenerator(LLMBasedCommandGenerator):
|
|
|
585
596
|
# filter out flows that are already started and active
|
|
586
597
|
commands = self._filter_redundant_start_flow_commands(tracker, commands)
|
|
587
598
|
|
|
599
|
+
if commands:
|
|
600
|
+
self._add_prompt_to_message_parse_data(
|
|
601
|
+
message,
|
|
602
|
+
MultiStepLLMCommandGenerator.__name__,
|
|
603
|
+
"handle_flows_prompt",
|
|
604
|
+
prompt,
|
|
605
|
+
)
|
|
606
|
+
|
|
588
607
|
return commands
|
|
589
608
|
|
|
590
609
|
@staticmethod
|
|
@@ -674,6 +693,14 @@ class MultiStepLLMCommandGenerator(LLMBasedCommandGenerator):
|
|
|
674
693
|
commands=commands,
|
|
675
694
|
)
|
|
676
695
|
|
|
696
|
+
if commands:
|
|
697
|
+
self._add_prompt_to_message_parse_data(
|
|
698
|
+
message,
|
|
699
|
+
MultiStepLLMCommandGenerator.__name__,
|
|
700
|
+
"fill_slots_for_new_flow_prompt",
|
|
701
|
+
prompt,
|
|
702
|
+
)
|
|
703
|
+
|
|
677
704
|
return commands
|
|
678
705
|
|
|
679
706
|
def _prepare_inputs(
|
|
@@ -137,7 +137,6 @@ class SingleStepLLMCommandGenerator(LLMBasedCommandGenerator):
|
|
|
137
137
|
**kwargs: Any,
|
|
138
138
|
) -> "SingleStepLLMCommandGenerator":
|
|
139
139
|
"""Loads trained component (see parent class for full docstring)."""
|
|
140
|
-
|
|
141
140
|
# Perform health check of the LLM API endpoint
|
|
142
141
|
llm_config = resolve_model_client_config(config.get(LLM_CONFIG_KEY, {}))
|
|
143
142
|
cls.perform_llm_health_check(
|
|
@@ -282,6 +281,15 @@ class SingleStepLLMCommandGenerator(LLMBasedCommandGenerator):
|
|
|
282
281
|
commands = self.parse_commands(action_list, tracker, flows)
|
|
283
282
|
|
|
284
283
|
self._update_message_parse_data_for_fine_tuning(message, commands, flow_prompt)
|
|
284
|
+
self._add_commands_to_message_parse_data(
|
|
285
|
+
message, SingleStepLLMCommandGenerator.__name__, commands
|
|
286
|
+
)
|
|
287
|
+
self._add_prompt_to_message_parse_data(
|
|
288
|
+
message,
|
|
289
|
+
SingleStepLLMCommandGenerator.__name__,
|
|
290
|
+
"command_generator_prompt",
|
|
291
|
+
flow_prompt,
|
|
292
|
+
)
|
|
285
293
|
|
|
286
294
|
return commands
|
|
287
295
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from contextlib import contextmanager
|
|
2
|
+
from typing import Generator
|
|
3
|
+
|
|
4
|
+
record_commands_and_prompts = False
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@contextmanager
|
|
8
|
+
def set_record_commands_and_prompts() -> Generator:
|
|
9
|
+
global record_commands_and_prompts
|
|
10
|
+
record_commands_and_prompts = True
|
|
11
|
+
try:
|
|
12
|
+
yield
|
|
13
|
+
finally:
|
|
14
|
+
record_commands_and_prompts = False
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import rasa.e2e_test.constants as constants
|
|
2
|
+
|
|
3
|
+
KEY_FIXTURES = constants.KEY_FIXTURES
|
|
4
|
+
KEY_METADATA = constants.KEY_METADATA
|
|
5
|
+
KEY_STUB_CUSTOM_ACTIONS = constants.KEY_STUB_CUSTOM_ACTIONS
|
|
6
|
+
KEY_USER_INPUT = constants.KEY_USER_INPUT
|
|
7
|
+
KEY_BOT_INPUT = constants.KEY_BOT_INPUT
|
|
8
|
+
KEY_BOT_UTTERED = constants.KEY_BOT_UTTERED
|
|
9
|
+
KEY_STEPS = constants.KEY_STEPS
|
|
10
|
+
KEY_TEST_CASE = constants.KEY_TEST_CASE
|
|
11
|
+
KEY_TEST_CASES = constants.KEY_TEST_CASES
|
|
12
|
+
KEY_COMMANDS = "commands"
|
|
13
|
+
|
|
14
|
+
ACTOR_USER = "user"
|
|
15
|
+
ACTOR_BOT = "bot"
|