rasa-pro 3.12.2.dev4__py3-none-any.whl → 3.12.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.

Files changed (65) hide show
  1. rasa/core/actions/action.py +28 -38
  2. rasa/core/actions/action_run_slot_rejections.py +1 -1
  3. rasa/core/brokers/kafka.py +59 -20
  4. rasa/core/channels/development_inspector.py +4 -2
  5. rasa/core/channels/inspector/dist/assets/{arc-9f1365dc.js → arc-c7691751.js} +1 -1
  6. rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-e0f81b12.js → blockDiagram-38ab4fdb-ab99dff7.js} +1 -1
  7. rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-9deaee1c.js → c4Diagram-3d4e48cf-08c35a6b.js} +1 -1
  8. rasa/core/channels/inspector/dist/assets/channel-11268142.js +1 -0
  9. rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-20450a96.js → classDiagram-70f12bd4-9e9c71c9.js} +1 -1
  10. rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-749d2abf.js → classDiagram-v2-f2320105-15e7e2bf.js} +1 -1
  11. rasa/core/channels/inspector/dist/assets/clone-ff7f2ce7.js +1 -0
  12. rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-bef0b38c.js → createText-2e5e7dd3-9c105cb1.js} +1 -1
  13. rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-943801a7.js → edges-e0da2a9e-77e89e48.js} +1 -1
  14. rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-d523a948.js → erDiagram-9861fffd-7a011646.js} +1 -1
  15. rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-54e4cf19.js → flowDb-956e92f1-b6f105ac.js} +1 -1
  16. rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-48bfbbe8.js → flowDiagram-66a62f08-ce4f18c2.js} +1 -1
  17. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-cba7ae20.js +1 -0
  18. rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-17c30827.js → flowchart-elk-definition-4a651766-cb5f6da4.js} +1 -1
  19. rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-43086f2d.js → ganttDiagram-c361ad54-e4d19e28.js} +1 -1
  20. rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-5c8b693e.js → gitGraphDiagram-72cf32ee-727b1c33.js} +1 -1
  21. rasa/core/channels/inspector/dist/assets/{graph-41a90d26.js → graph-6e2ab9a7.js} +1 -1
  22. rasa/core/channels/inspector/dist/assets/{index-e8affe45.js → index-098a1a24.js} +3 -3
  23. rasa/core/channels/inspector/dist/assets/{index-3862675e-b43eeae9.js → index-3862675e-84ec700f.js} +1 -1
  24. rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-0b20676b.js → infoDiagram-f8f76790-78dda442.js} +1 -1
  25. rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-39bce7b5.js → journeyDiagram-49397b02-f1cc6dd1.js} +1 -1
  26. rasa/core/channels/inspector/dist/assets/{layout-dc8eeea4.js → layout-d98dcd0c.js} +1 -1
  27. rasa/core/channels/inspector/dist/assets/{line-c4d2e756.js → line-838e3d82.js} +1 -1
  28. rasa/core/channels/inspector/dist/assets/{linear-86f6f2d9.js → linear-eae72406.js} +1 -1
  29. rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-4216f771.js → mindmap-definition-fc14e90a-c96fd84b.js} +1 -1
  30. rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-1a0cfa96.js → pieDiagram-8a3498a8-c936d4e2.js} +1 -1
  31. rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-f91e67cf.js → quadrantDiagram-120e2f19-b338eb8f.js} +1 -1
  32. rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-d4046bed.js → requirementDiagram-deff3bca-c6b6c0d5.js} +1 -1
  33. rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-2cf6d1d7.js → sankeyDiagram-04a897e0-b9372e19.js} +1 -1
  34. rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-751ac4f5.js → sequenceDiagram-704730f1-479e0a3f.js} +1 -1
  35. rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-f734f4d4.js → stateDiagram-587899a1-fd26eebc.js} +1 -1
  36. rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-91c65710.js → stateDiagram-v2-d93cdb3a-3233e0ae.js} +1 -1
  37. rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-e0cff7be.js → styles-6aaf32cf-1fdd392b.js} +1 -1
  38. rasa/core/channels/inspector/dist/assets/{styles-9a916d00-c8029e5d.js → styles-9a916d00-6d7bfa1b.js} +1 -1
  39. rasa/core/channels/inspector/dist/assets/{styles-c10674c1-114f312a.js → styles-c10674c1-f86aab11.js} +1 -1
  40. rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-b7b9dc00.js → svgDrawCommon-08f97a94-e3e49d7a.js} +1 -1
  41. rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-9536d189.js → timeline-definition-85554ec2-6fe08b4d.js} +1 -1
  42. rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-bf3b0f36.js → xychartDiagram-e933f94c-c2e06fd6.js} +1 -1
  43. rasa/core/channels/inspector/dist/index.html +1 -1
  44. rasa/core/channels/inspector/src/helpers/utils.ts +4 -0
  45. rasa/core/channels/studio_chat.py +43 -16
  46. rasa/core/nlg/contextual_response_rephraser.py +6 -7
  47. rasa/core/nlg/generator.py +21 -5
  48. rasa/core/nlg/response.py +43 -6
  49. rasa/core/nlg/translate.py +8 -0
  50. rasa/model_manager/model_api.py +1 -1
  51. rasa/model_manager/socket_bridge.py +7 -0
  52. rasa/shared/core/constants.py +2 -0
  53. rasa/shared/core/events.py +67 -0
  54. rasa/shared/core/slots.py +1 -1
  55. rasa/shared/core/trackers.py +10 -4
  56. rasa/shared/utils/schemas/events.py +2 -2
  57. rasa/version.py +1 -1
  58. {rasa_pro-3.12.2.dev4.dist-info → rasa_pro-3.12.4.dist-info}/METADATA +6 -7
  59. {rasa_pro-3.12.2.dev4.dist-info → rasa_pro-3.12.4.dist-info}/RECORD +62 -62
  60. rasa/core/channels/inspector/dist/assets/channel-44956714.js +0 -1
  61. rasa/core/channels/inspector/dist/assets/clone-a9475142.js +0 -1
  62. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-43fa749a.js +0 -1
  63. {rasa_pro-3.12.2.dev4.dist-info → rasa_pro-3.12.4.dist-info}/NOTICE +0 -0
  64. {rasa_pro-3.12.2.dev4.dist-info → rasa_pro-3.12.4.dist-info}/WHEEL +0 -0
  65. {rasa_pro-3.12.2.dev4.dist-info → rasa_pro-3.12.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,C 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-e8affe45.js";import{c as Qt}from"./createText-2e5e7dd3-bef0b38c.js";import{i as Kt}from"./init-77b53fdd.js";import{o as Zt}from"./ordinal-ba9b4969.js";import{l as ft}from"./linear-86f6f2d9.js";import{l as pt}from"./line-c4d2e756.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,Wt=a.slice.call(arguments,1),k=Object.create(this.lexer),W={yy:{}};for(var J in this.yy)Object.prototype.hasOwnProperty.call(this.yy,J)&&(W.yy[J]=this.yy[J]);k.setInput(r,W.yy),W.yy.lexer=k,W.yy.parser=this,typeof k.yylloc>"u"&&(k.yylloc={});var tt=k.yylloc;a.push(tt);var Bt=k.options&&k.options.ranges;typeof W.yy.parseError=="function"?this.parseError=W.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,B,v,it,O={},q,M,dt,j;;){if(B=u[u.length-1],this.defaultActions[B]?v=this.defaultActions[B]:((D===null||typeof D>"u")&&(D=Ot()),v=F[B]&&F[B][D]),typeof v>"u"||!v.length||!v[0]){var et="";j=[];for(q in F[B])this.terminals_[q]&&q>Vt&&j.push("'"+this.terminals_[q]+"'");k.showPosition?et="Parse error on line "+(U+1)+`:
1
+ import{Z as zt,_ as ot,X as wt,W as Ft,s as Nt,g as Xt,C 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-098a1a24.js";import{c as Qt}from"./createText-2e5e7dd3-9c105cb1.js";import{i as Kt}from"./init-77b53fdd.js";import{o as Zt}from"./ordinal-ba9b4969.js";import{l as ft}from"./linear-eae72406.js";import{l as pt}from"./line-838e3d82.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,Wt=a.slice.call(arguments,1),k=Object.create(this.lexer),W={yy:{}};for(var J in this.yy)Object.prototype.hasOwnProperty.call(this.yy,J)&&(W.yy[J]=this.yy[J]);k.setInput(r,W.yy),W.yy.lexer=k,W.yy.parser=this,typeof k.yylloc>"u"&&(k.yylloc={});var tt=k.yylloc;a.push(tt);var Bt=k.options&&k.options.ranges;typeof W.yy.parseError=="function"?this.parseError=W.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,B,v,it,O={},q,M,dt,j;;){if(B=u[u.length-1],this.defaultActions[B]?v=this.defaultActions[B]:((D===null||typeof D>"u")&&(D=Ot()),v=F[B]&&F[B][D]),typeof v>"u"||!v.length||!v[0]){var et="";j=[];for(q in F[B])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: "+B+", 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},Bt&&(O._$.range=[a[a.length-(M||1)].range[0],a[a.length-1].range[1]]),it=this.performAction.apply(O,[x,gt,U,W.yy,v[1],b,a].concat(Wt)),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-e8affe45.js"></script>
9
+ <script type="module" crossorigin src="./assets/index-098a1a24.js"></script>
10
10
  <link rel="stylesheet" href="./assets/index-3ee28881.css">
11
11
  </head>
12
12
 
@@ -2,6 +2,10 @@ import { SelectedStack, Stack, Event } from "../types";
2
2
  import { immutableJSONPatch} from 'immutable-json-patch'
3
3
 
4
4
  export const shouldShowTooltip = (text: string) => {
5
+ if (!text) {
6
+ return false;
7
+ }
8
+
5
9
  const textLength = text.length;
6
10
 
7
11
  if (textLength > 10 && textLength < 89) {
@@ -120,6 +120,13 @@ class StudioChatInput(SocketIOInput):
120
120
 
121
121
  self._register_tracker_update_hook()
122
122
 
123
+ async def emit(self, event: str, data: Dict, room: str) -> None:
124
+ """Emits an event to the websocket."""
125
+ if not self.sio:
126
+ structlogger.error("studio_chat.emit.sio_not_initialized")
127
+ return
128
+ await self.sio.emit(event, data, room=room)
129
+
123
130
  def _register_tracker_update_hook(self) -> None:
124
131
  plugin_manager().register(StudioTrackerUpdatePlugin(self))
125
132
 
@@ -129,10 +136,7 @@ class StudioChatInput(SocketIOInput):
129
136
 
130
137
  async def publish_tracker_update(self, sender_id: str, tracker_dump: Dict) -> None:
131
138
  """Publishes a tracker update notification to the websocket."""
132
- if not self.sio:
133
- structlogger.error("studio_chat.on_tracker_updated.sio_not_initialized")
134
- return
135
- await self.sio.emit("tracker", tracker_dump, room=sender_id)
139
+ await self.emit("tracker", tracker_dump, room=sender_id)
136
140
 
137
141
  async def on_message_proxy(
138
142
  self,
@@ -172,22 +176,45 @@ class StudioChatInput(SocketIOInput):
172
176
  structlogger.error("studio_chat.sio.domain_not_initialized")
173
177
  return None
174
178
 
175
- async with self.agent.lock_store.lock(data["sender_id"]):
176
- tracker = DialogueStateTracker.from_dict(
177
- data["sender_id"], data["events"], domain.slots
178
- )
179
-
180
- # will override an existing tracker with the same id!
181
- await self.agent.tracker_store.save(tracker)
179
+ tracker: Optional[DialogueStateTracker] = None
182
180
 
183
- processor = self.agent.processor
184
- if processor and does_need_action_prediction(tracker):
185
- output_channel = self.get_output_channel()
181
+ async with self.agent.lock_store.lock(data["sender_id"]):
182
+ try:
183
+ tracker = DialogueStateTracker.from_dict(
184
+ data["sender_id"], data["events"], domain.slots
185
+ )
186
186
 
187
- await processor._run_prediction_loop(output_channel, tracker)
188
- await processor.run_anonymization_pipeline(tracker)
187
+ # will override an existing tracker with the same id!
189
188
  await self.agent.tracker_store.save(tracker)
190
189
 
190
+ processor = self.agent.processor
191
+ if processor and does_need_action_prediction(tracker):
192
+ output_channel = self.get_output_channel()
193
+
194
+ await processor._run_prediction_loop(output_channel, tracker)
195
+ await processor.run_anonymization_pipeline(tracker)
196
+ await self.agent.tracker_store.save(tracker)
197
+ except Exception as e:
198
+ structlogger.error(
199
+ "studio_chat.sio.handle_tracker_update.error",
200
+ error=e,
201
+ sender_id=data["sender_id"],
202
+ )
203
+ await self.emit(
204
+ "error",
205
+ {
206
+ "message": "An error occurred while updating the conversation.",
207
+ "error": str(e),
208
+ "exception": str(type(e).__name__),
209
+ },
210
+ room=sid,
211
+ )
212
+ if not tracker:
213
+ # in case the tracker couldn't be updated, we retrieve the prior
214
+ # version and use that to populate the update
215
+ tracker = await self.agent.tracker_store.get_or_create_tracker(
216
+ data["sender_id"]
217
+ )
191
218
  await self.on_tracker_updated(tracker)
192
219
 
193
220
  def blueprint(
@@ -200,8 +200,10 @@ class ContextualResponseRephraser(
200
200
 
201
201
  @measure_llm_latency
202
202
  async def _generate_llm_response(self, prompt: str) -> Optional[LLMResponse]:
203
- """Use LLM to generate a response, returning an LLMResponse object
204
- containing both the generated text (choices) and metadata.
203
+ """Use LLM to generate a response.
204
+
205
+ Returns an LLMResponse object containing both the generated text
206
+ (choices) and metadata.
205
207
 
206
208
  Args:
207
209
  prompt: The prompt to send to the LLM.
@@ -367,12 +369,9 @@ class ContextualResponseRephraser(
367
369
  Returns:
368
370
  The generated response.
369
371
  """
370
- filled_slots = tracker.current_slot_values()
371
- stack_context = tracker.stack.current_context()
372
- templated_response = self.generate_from_slots(
372
+ templated_response = await super().generate(
373
373
  utter_action=utter_action,
374
- filled_slots=filled_slots,
375
- stack_context=stack_context,
374
+ tracker=tracker,
376
375
  output_channel=output_channel,
377
376
  **kwargs,
378
377
  )
@@ -6,6 +6,8 @@ from pypred import Predicate
6
6
 
7
7
  import rasa.shared.utils.common
8
8
  import rasa.shared.utils.io
9
+ from rasa.core.nlg.translate import has_translation
10
+ from rasa.engine.language import Language
9
11
  from rasa.shared.constants import CHANNEL, RESPONSE_CONDITION
10
12
  from rasa.shared.core.domain import Domain
11
13
  from rasa.shared.core.trackers import DialogueStateTracker
@@ -131,11 +133,23 @@ class ResponseVariationFilter:
131
133
 
132
134
  return True
133
135
 
136
+ def _filter_by_language(
137
+ self, responses: List[Dict[Text, Any]], language: Optional[Language] = None
138
+ ) -> List[Dict[Text, Any]]:
139
+ if not language:
140
+ return responses
141
+
142
+ if filtered := [r for r in responses if has_translation(r, language)]:
143
+ return filtered
144
+ # if no translation is found, return the original response variations
145
+ return responses
146
+
134
147
  def responses_for_utter_action(
135
148
  self,
136
149
  utter_action: Text,
137
150
  output_channel: Text,
138
151
  filled_slots: Dict[Text, Any],
152
+ language: Optional[Language] = None,
139
153
  ) -> List[Dict[Text, Any]]:
140
154
  """Returns array of responses that fit the channel, action and condition."""
141
155
  # filter responses without a condition
@@ -176,16 +190,16 @@ class ResponseVariationFilter:
176
190
  )
177
191
 
178
192
  if conditional_channel:
179
- return conditional_channel
193
+ return self._filter_by_language(conditional_channel, language)
180
194
 
181
195
  if default_channel:
182
- return default_channel
196
+ return self._filter_by_language(default_channel, language)
183
197
 
184
198
  if conditional_no_channel:
185
- return conditional_no_channel
199
+ return self._filter_by_language(conditional_no_channel, language)
186
200
 
187
201
  if default_no_channel:
188
- return default_no_channel
202
+ return self._filter_by_language(default_no_channel, language)
189
203
 
190
204
  # if there is no response variation selected,
191
205
  # return the internal error response to prevent
@@ -198,7 +212,9 @@ class ResponseVariationFilter:
198
212
  f"a default variation and that all the conditions are valid. "
199
213
  f"Returning the internal error response.",
200
214
  )
201
- return self.responses.get("utter_internal_error_rasa", [])
215
+ return self._filter_by_language(
216
+ self.responses.get("utter_internal_error_rasa", []), language
217
+ )
202
218
 
203
219
  def get_response_variation_id(
204
220
  self,
rasa/core/nlg/response.py CHANGED
@@ -5,8 +5,11 @@ from typing import Any, Dict, List, Optional, Text
5
5
  from rasa.core.constants import DEFAULT_TEMPLATE_ENGINE, TEMPLATE_ENGINE_CONFIG_KEY
6
6
  from rasa.core.nlg import interpolator
7
7
  from rasa.core.nlg.generator import NaturalLanguageGenerator, ResponseVariationFilter
8
- from rasa.shared.constants import RESPONSE_CONDITION
8
+ from rasa.core.nlg.translate import get_translated_buttons, get_translated_text
9
+ from rasa.engine.language import Language
10
+ from rasa.shared.constants import BUTTONS, RESPONSE_CONDITION, TEXT
9
11
  from rasa.shared.core.domain import RESPONSE_KEYS_TO_INTERPOLATE
12
+ from rasa.shared.core.flows.constants import KEY_TRANSLATION
10
13
  from rasa.shared.core.trackers import DialogueStateTracker
11
14
  from rasa.shared.nlu.constants import METADATA
12
15
 
@@ -30,7 +33,11 @@ class TemplatedNaturalLanguageGenerator(NaturalLanguageGenerator):
30
33
 
31
34
  # noinspection PyUnusedLocal
32
35
  def _random_response_for(
33
- self, utter_action: Text, output_channel: Text, filled_slots: Dict[Text, Any]
36
+ self,
37
+ utter_action: Text,
38
+ output_channel: Text,
39
+ filled_slots: Dict[Text, Any],
40
+ language: Optional[Language] = None,
34
41
  ) -> Optional[Dict[Text, Any]]:
35
42
  """Select random response for the utter action from available ones.
36
43
 
@@ -42,7 +49,7 @@ class TemplatedNaturalLanguageGenerator(NaturalLanguageGenerator):
42
49
  if utter_action in self.responses:
43
50
  response_filter = ResponseVariationFilter(self.responses)
44
51
  suitable_responses = response_filter.responses_for_utter_action(
45
- utter_action, output_channel, filled_slots
52
+ utter_action, output_channel, filled_slots, language
46
53
  )
47
54
 
48
55
  if suitable_responses:
@@ -75,9 +82,36 @@ class TemplatedNaturalLanguageGenerator(NaturalLanguageGenerator):
75
82
  """Generate a response for the requested utter action."""
76
83
  filled_slots = tracker.current_slot_values()
77
84
  stack_context = tracker.stack.current_context()
78
- return self.generate_from_slots(
79
- utter_action, filled_slots, stack_context, output_channel, **kwargs
85
+ response = self.generate_from_slots(
86
+ utter_action,
87
+ filled_slots,
88
+ stack_context,
89
+ output_channel,
90
+ tracker.current_language,
91
+ **kwargs,
80
92
  )
93
+ if response is not None:
94
+ return self.translate_response(response, tracker.current_language)
95
+ return None
96
+
97
+ def translate_response(
98
+ self, response: Dict[Text, Any], language: Optional[Language] = None
99
+ ) -> Dict[Text, Any]:
100
+ message_copy = copy.deepcopy(response)
101
+
102
+ text = get_translated_text(
103
+ text=message_copy.pop(TEXT, None),
104
+ translation=message_copy.pop(KEY_TRANSLATION, {}),
105
+ language=language,
106
+ )
107
+
108
+ buttons = get_translated_buttons(
109
+ buttons=message_copy.pop(BUTTONS, None), language=language
110
+ )
111
+ message_copy[TEXT] = text
112
+ if buttons:
113
+ message_copy[BUTTONS] = buttons
114
+ return message_copy
81
115
 
82
116
  def generate_from_slots(
83
117
  self,
@@ -85,12 +119,15 @@ class TemplatedNaturalLanguageGenerator(NaturalLanguageGenerator):
85
119
  filled_slots: Dict[Text, Any],
86
120
  stack_context: Dict[Text, Any],
87
121
  output_channel: Text,
122
+ language: Optional[Language] = None,
88
123
  **kwargs: Any,
89
124
  ) -> Optional[Dict[Text, Any]]:
90
125
  """Generate a response for the requested utter action."""
91
126
  # Fetching a random response for the passed utter action
92
127
  r = copy.deepcopy(
93
- self._random_response_for(utter_action, output_channel, filled_slots)
128
+ self._random_response_for(
129
+ utter_action, output_channel, filled_slots, language
130
+ )
94
131
  )
95
132
  # Filling the slots in the response with placeholders and returning the response
96
133
  if r is not None:
@@ -23,6 +23,14 @@ def get_translated_text(
23
23
  return translation.get(language_code, text)
24
24
 
25
25
 
26
+ def has_translation(
27
+ message: Dict[Text, Any], language: Optional[Language] = None
28
+ ) -> bool:
29
+ """Check if the message has a translation for the given language."""
30
+ language_code = language.code if language else None
31
+ return language_code in message.get(KEY_TRANSLATION, {})
32
+
33
+
26
34
  def get_translated_buttons(
27
35
  buttons: Optional[List[Dict[Text, Any]]], language: Optional[Language] = None
28
36
  ) -> Optional[List[Dict[Text, Any]]]:
@@ -483,7 +483,7 @@ def external_blueprint() -> Blueprint:
483
483
  """Create a blueprint for the model manager API."""
484
484
  from rasa.core.channels.socketio import SocketBlueprint
485
485
 
486
- sio = AsyncServer(async_mode="sanic", cors_allowed_origins=[])
486
+ sio = AsyncServer(async_mode="sanic", cors_allowed_origins="*")
487
487
  bp = SocketBlueprint(sio, "", "model_api_external")
488
488
 
489
489
  create_bridge_server(sio, running_bots)
@@ -131,6 +131,13 @@ async def create_bridge_client(
131
131
  structlogger.debug("model_runner.bot_message", deployment_id=deployment_id)
132
132
  await sio.emit("bot_message", data, room=sid)
133
133
 
134
+ @client.event # type: ignore[misc]
135
+ async def error(data: Dict[str, Any]) -> None:
136
+ structlogger.debug(
137
+ "model_runner.bot_error", deployment_id=deployment_id, data=data
138
+ )
139
+ await sio.emit("error", data, room=sid)
140
+
134
141
  @client.event # type: ignore[misc]
135
142
  async def tracker(data: Dict[str, Any]) -> None:
136
143
  await sio.emit("tracker", json.loads(data), room=sid)
@@ -208,3 +208,5 @@ POLICIES_THAT_EXTRACT_ENTITIES = {"TEDPolicy"}
208
208
  # digression constants
209
209
  KEY_ASK_CONFIRM_DIGRESSIONS = "ask_confirm_digressions"
210
210
  KEY_BLOCK_DIGRESSIONS = "block_digressions"
211
+
212
+ ERROR_CODE_KEY = "error_code"
@@ -36,6 +36,7 @@ from rasa.shared.core.constants import (
36
36
  ACTION_NAME_SENDER_ID_CONNECTOR_STR,
37
37
  ACTION_SESSION_START_NAME,
38
38
  ENTITY_LABEL_SEPARATOR,
39
+ ERROR_CODE_KEY,
39
40
  EXTERNAL_MESSAGE_PREFIX,
40
41
  IS_EXTERNAL,
41
42
  LOOP_INTERRUPTED,
@@ -2578,3 +2579,69 @@ class SessionEnded(AlwaysEqualEventMixin):
2578
2579
  """Applies event to current conversation state."""
2579
2580
  # noinspection PyProtectedMember
2580
2581
  tracker._reset()
2582
+
2583
+
2584
+ class ErrorHandled(Event):
2585
+ """An error occurred during the conversation.
2586
+
2587
+ The error message is stored in the metadata of the event.
2588
+ """
2589
+
2590
+ type_name = "error"
2591
+
2592
+ def __init__(
2593
+ self,
2594
+ error_code: int,
2595
+ timestamp: Optional[float] = None,
2596
+ metadata: Optional[Dict[str, Any]] = None,
2597
+ ) -> None:
2598
+ """Creates event for an error.
2599
+
2600
+ Args:
2601
+ error_code: Error int code.
2602
+ timestamp: When the event was created.
2603
+ metadata: Additional event metadata.
2604
+ """
2605
+ self.error_code = error_code
2606
+ super().__init__(timestamp, metadata)
2607
+
2608
+ def __str__(self) -> Text:
2609
+ """Returns text representation of event."""
2610
+ return f"ErrorHandled({self.error_code})"
2611
+
2612
+ def __repr__(self) -> Text:
2613
+ """Returns event as string for debugging."""
2614
+ return f"ErrorHandled({self.error_code}, {self.timestamp}, {self.metadata})"
2615
+
2616
+ def __hash__(self) -> int:
2617
+ """Returns unique hash for event."""
2618
+ return hash(self.error_code)
2619
+
2620
+ def __eq__(self, other: Any) -> bool:
2621
+ """Compares object with other object."""
2622
+ if not isinstance(other, ErrorHandled):
2623
+ return NotImplemented
2624
+
2625
+ return self.error_code == other.error_code
2626
+
2627
+ def as_story_string(self) -> Text:
2628
+ """Returns text representation of event."""
2629
+ props = json.dumps({ERROR_CODE_KEY: self.error_code})
2630
+ return f"{ErrorHandled.type_name}{props}"
2631
+
2632
+ @classmethod
2633
+ def _from_story_string(cls, parameters: Dict[Text, Any]) -> List["ErrorHandled"]:
2634
+ """Called to convert a parsed story line into an event."""
2635
+ return [
2636
+ ErrorHandled(
2637
+ parameters.get(ERROR_CODE_KEY),
2638
+ parameters.get("timestamp"),
2639
+ parameters.get("metadata"),
2640
+ )
2641
+ ]
2642
+
2643
+ def as_dict(self) -> Dict[Text, Any]:
2644
+ """Returns serialized event."""
2645
+ serialized = super().as_dict()
2646
+ serialized.update({ERROR_CODE_KEY: self.error_code})
2647
+ return serialized
rasa/shared/core/slots.py CHANGED
@@ -787,7 +787,7 @@ class StrictCategoricalSlot(CategoricalSlot):
787
787
  def coerce_value(self, value: Any) -> Any:
788
788
  """Coerce the value to one of the allowed ones or raise an error if invalid."""
789
789
  if value is None:
790
- return value
790
+ return self.initial_value
791
791
 
792
792
  for allowed_value in self.values:
793
793
  # Allowed values are always stored as strings, so we can use casefold().
@@ -1123,10 +1123,16 @@ class DialogueStateTracker:
1123
1123
  f"Please update the slot configuration accordingly."
1124
1124
  )
1125
1125
 
1126
- return [
1127
- Language.from_language_code(language_code)
1128
- for language_code in language_slot.values
1129
- ]
1126
+ supported_languages = []
1127
+ for language_code in language_slot.values:
1128
+ is_default = language_code == language_slot.initial_value
1129
+ language = Language.from_language_code(
1130
+ language_code=language_code,
1131
+ is_default=is_default,
1132
+ )
1133
+ supported_languages.append(language)
1134
+
1135
+ return supported_languages
1130
1136
 
1131
1137
  @property
1132
1138
  def current_language(self) -> Optional[Language]:
@@ -165,8 +165,7 @@ DIALOGUE_STACK_UPDATED = {
165
165
  }
166
166
  ROUTING_SESSION_ENDED = {"properties": {"event": {"const": "routing_session_ended"}}}
167
167
 
168
-
169
- ROUTING_SESSION_ENDED = {"properties": {"event": {"const": "routing_session_ended"}}}
168
+ ERROR_HANDLED = {"properties": {"event": {"const": "error"}}}
170
169
 
171
170
  EVENT_SCHEMA = {
172
171
  "type": "object",
@@ -208,6 +207,7 @@ EVENT_SCHEMA = {
208
207
  DIALOGUE_STACK_UPDATED,
209
208
  ROUTING_SESSION_ENDED,
210
209
  SESSION_ENDED,
210
+ ERROR_HANDLED,
211
211
  ],
212
212
  }
213
213
 
rasa/version.py CHANGED
@@ -1,3 +1,3 @@
1
1
  # this file will automatically be changed,
2
2
  # do not add anything but the version number here!
3
- __version__ = "3.12.1"
3
+ __version__ = "3.12.4"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rasa-pro
3
- Version: 3.12.2.dev4
3
+ Version: 3.12.4
4
4
  Summary: State-of-the-art open-core Conversational AI framework for Enterprises that natively leverages generative AI for effortless assistant development.
5
5
  Home-page: https://rasa.com
6
6
  Keywords: nlp,machine-learning,machine-learning-library,bot,bots,botkit,rasa conversational-agents,conversational-ai,chatbot,chatbot-framework,bot-framework
@@ -8,11 +8,10 @@ Author: Rasa Technologies GmbH
8
8
  Author-email: hi@rasa.com
9
9
  Maintainer: Tom Bocklisch
10
10
  Maintainer-email: tom@rasa.com
11
- Requires-Python: >=3.9,<3.12
11
+ Requires-Python: >=3.9.2,<3.12
12
12
  Classifier: Development Status :: 5 - Production/Stable
13
13
  Classifier: Intended Audience :: Developers
14
14
  Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.9
16
15
  Classifier: Programming Language :: Python :: 3.10
17
16
  Classifier: Programming Language :: Python :: 3.11
18
17
  Classifier: Topic :: Software Development :: Libraries
@@ -40,7 +39,7 @@ Requires-Dist: colorclass (>=2.2,<2.3)
40
39
  Requires-Dist: coloredlogs (>=15,<16)
41
40
  Requires-Dist: colorhash (>=2.0,<2.1.0)
42
41
  Requires-Dist: confluent-kafka (>=2.3.0,<3.0.0)
43
- Requires-Dist: cryptography (>=43.0.1)
42
+ Requires-Dist: cryptography (>=44.0.1)
44
43
  Requires-Dist: cvg-python-sdk (>=0.5.1,<0.6.0)
45
44
  Requires-Dist: dask (>=2024.7.0,<2024.8.0)
46
45
  Requires-Dist: demoji (>=1.1.0,<2.0.0)
@@ -57,13 +56,13 @@ Requires-Dist: hvac (>=1.2.1,<2.0.0)
57
56
  Requires-Dist: importlib-metadata (>=8.5.0,<8.6.0)
58
57
  Requires-Dist: importlib-resources (==6.1.3)
59
58
  Requires-Dist: jieba (>=0.42.1,<0.43) ; extra == "jieba" or extra == "full"
60
- Requires-Dist: jinja2 (>=3.1.4,<4.0.0)
59
+ Requires-Dist: jinja2 (>=3.1.6,<3.2.0)
61
60
  Requires-Dist: jsonpatch (>=1.33,<2.0)
62
61
  Requires-Dist: jsonpickle (>=3.3.0,<3.4)
63
62
  Requires-Dist: jsonschema (>=4.22)
64
63
  Requires-Dist: keras (==2.14.0)
65
- Requires-Dist: langchain (>=0.2.0,<0.3.0)
66
- Requires-Dist: langchain-community (>=0.2.0,<0.3.0)
64
+ Requires-Dist: langchain (>=0.2.17,<0.3.0)
65
+ Requires-Dist: langchain-community (>=0.2.19,<0.3.0)
67
66
  Requires-Dist: langcodes (>=3.5.0,<4.0.0)
68
67
  Requires-Dist: litellm (>=1.52.6,<1.53.0)
69
68
  Requires-Dist: matplotlib (>=3.7,<3.8)