chainlit 0.6.3__py3-none-any.whl → 0.6.401__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 chainlit might be problematic. Click here for more details.
- chainlit/__init__.py +38 -1
- chainlit/cache.py +6 -9
- chainlit/cli/deploy.py +2 -2
- chainlit/client/base.py +2 -1
- chainlit/client/cloud.py +10 -8
- chainlit/client/local.py +4 -1
- chainlit/client/utils.py +4 -2
- chainlit/config.py +22 -1
- chainlit/context.py +1 -1
- chainlit/db/prisma/schema.prisma +2 -1
- chainlit/element.py +6 -1
- chainlit/emitter.py +6 -1
- chainlit/frontend/dist/assets/index-69562d52.js +543 -0
- chainlit/frontend/dist/assets/{index-34600e45.js → index-ace9588d.js} +1 -1
- chainlit/frontend/dist/index.html +1 -1
- chainlit/haystack/__init__.py +5 -10
- chainlit/input_widget.py +35 -0
- chainlit/langchain/__init__.py +5 -10
- chainlit/langchain/callbacks.py +98 -30
- chainlit/langflow/__init__.py +5 -10
- chainlit/llama_index/__init__.py +5 -10
- chainlit/llama_index/callbacks.py +16 -8
- chainlit/message.py +17 -4
- chainlit/playground/config.py +14 -14
- chainlit/playground/providers/__init__.py +1 -0
- chainlit/playground/providers/huggingface.py +3 -1
- chainlit/playground/providers/langchain.py +87 -0
- chainlit/playground/providers/openai.py +2 -2
- chainlit/prompt.py +8 -1
- chainlit/server.py +9 -8
- chainlit/socket.py +16 -1
- chainlit/sync.py +3 -1
- chainlit/types.py +12 -7
- chainlit/utils.py +23 -0
- {chainlit-0.6.3.dist-info → chainlit-0.6.401.dist-info}/METADATA +6 -5
- chainlit-0.6.401.dist-info/RECORD +61 -0
- chainlit/frontend/dist/assets/index-87533cb5.js +0 -533
- chainlit-0.6.3.dist-info/RECORD +0 -60
- {chainlit-0.6.3.dist-info → chainlit-0.6.401.dist-info}/WHEEL +0 -0
- {chainlit-0.6.3.dist-info → chainlit-0.6.401.dist-info}/entry_points.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as me,g as Xc}from"./index-87533cb5.js";function Qc(e,t){for(var r=0;r<t.length;r++){const a=t[r];if(typeof a!="string"&&!Array.isArray(a)){for(const n in a)if(n!=="default"&&!(n in e)){const i=Object.getOwnPropertyDescriptor(a,n);i&&Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:()=>a[n]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var Jc=tp,ep=Object.prototype.hasOwnProperty;function tp(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var a in r)ep.call(r,a)&&(e[a]=r[a])}return e}var yc=Tc,ki=Tc.prototype;ki.space=null;ki.normal={};ki.property={};function Tc(e,t,r){this.property=e,this.normal=t,r&&(this.space=r)}var eo=Jc,rp=yc,ap=np;function np(e){for(var t=e.length,r=[],a=[],n=-1,i,s;++n<t;)i=e[n],r.push(i.property),a.push(i.normal),s=i.space;return new rp(eo.apply(null,r),eo.apply(null,a),s)}var Oi=ip;function ip(e){return e.toLowerCase()}var vc=Ac,W=Ac.prototype;W.space=null;W.attribute=null;W.property=null;W.boolean=!1;W.booleanish=!1;W.overloadedBoolean=!1;W.number=!1;W.commaSeparated=!1;W.spaceSeparated=!1;W.commaOrSpaceSeparated=!1;W.mustUseProperty=!1;W.defined=!1;function Ac(e,t){this.property=e,this.attribute=t}var K={},op=0;K.boolean=re();K.booleanish=re();K.overloadedBoolean=re();K.number=re();K.spaceSeparated=re();K.commaSeparated=re();K.commaOrSpaceSeparated=re();function re(){return Math.pow(2,++op)}var Rc=vc,to=K,_c=Li;Li.prototype=new Rc;Li.prototype.defined=!0;var Ic=["boolean","booleanish","overloadedBoolean","number","commaSeparated","spaceSeparated","commaOrSpaceSeparated"],sp=Ic.length;function Li(e,t,r,a){var n=-1,i;for(ro(this,"space",a),Rc.call(this,e,t);++n<sp;)i=Ic[n],ro(this,i,(r&to[i])===to[i])}function ro(e,t,r){r&&(e[t]=r)}var ao=Oi,lp=yc,up=_c,de=dp;function dp(e){var t=e.space,r=e.mustUseProperty||[],a=e.attributes||{},n=e.properties,i=e.transform,s={},l={},u,c;for(u in n)c=new up(u,i(a,u),n[u],t),r.indexOf(u)!==-1&&(c.mustUseProperty=!0),s[u]=c,l[ao(u)]=u,l[ao(c.attribute)]=u;return new lp(s,l,t)}var cp=de,pp=cp({space:"xlink",transform:gp,properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}});function gp(e,t){return"xlink:"+t.slice(5).toLowerCase()}var bp=de,mp=bp({space:"xml",transform:fp,properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function fp(e,t){return"xml:"+t.slice(3).toLowerCase()}var Ep=hp;function hp(e,t){return t in e?e[t]:t}var Sp=Ep,Nc=yp;function yp(e,t){return Sp(e,t.toLowerCase())}var Tp=de,vp=Nc,Ap=Tp({space:"xmlns",attributes:{xmlnsxlink:"xmlns:xlink"},transform:vp,properties:{xmlns:null,xmlnsXLink:null}}),Di=K,Rp=de,H=Di.booleanish,j=Di.number,te=Di.spaceSeparated,_p=Rp({transform:Ip,properties:{ariaActiveDescendant:null,ariaAtomic:H,ariaAutoComplete:null,ariaBusy:H,ariaChecked:H,ariaColCount:j,ariaColIndex:j,ariaColSpan:j,ariaControls:te,ariaCurrent:null,ariaDescribedBy:te,ariaDetails:null,ariaDisabled:H,ariaDropEffect:te,ariaErrorMessage:null,ariaExpanded:H,ariaFlowTo:te,ariaGrabbed:H,ariaHasPopup:null,ariaHidden:H,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:te,ariaLevel:j,ariaLive:null,ariaModal:H,ariaMultiLine:H,ariaMultiSelectable:H,ariaOrientation:null,ariaOwns:te,ariaPlaceholder:null,ariaPosInSet:j,ariaPressed:H,ariaReadOnly:H,ariaRelevant:null,ariaRequired:H,ariaRoleDescription:te,ariaRowCount:j,ariaRowIndex:j,ariaRowSpan:j,ariaSelected:H,ariaSetSize:j,ariaSort:null,ariaValueMax:j,ariaValueMin:j,ariaValueNow:j,ariaValueText:null,role:null}});function Ip(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}var oe=K,Np=de,wp=Nc,w=oe.boolean,Cp=oe.overloadedBoolean,se=oe.booleanish,D=oe.number,$=oe.spaceSeparated,ge=oe.commaSeparated,kp=Np({space:"html",attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},transform:wp,mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ge,acceptCharset:$,accessKey:$,action:null,allow:null,allowFullScreen:w,allowPaymentRequest:w,allowUserMedia:w,alt:null,as:null,async:w,autoCapitalize:null,autoComplete:$,autoFocus:w,autoPlay:w,capture:w,charSet:null,checked:w,cite:null,className:$,cols:D,colSpan:null,content:null,contentEditable:se,controls:w,controlsList:$,coords:D|ge,crossOrigin:null,data:null,dateTime:null,decoding:null,default:w,defer:w,dir:null,dirName:null,disabled:w,download:Cp,draggable:se,encType:null,enterKeyHint:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:w,formTarget:null,headers:$,height:D,hidden:w,high:D,href:null,hrefLang:null,htmlFor:$,httpEquiv:$,id:null,imageSizes:null,imageSrcSet:ge,inputMode:null,integrity:null,is:null,isMap:w,itemId:null,itemProp:$,itemRef:$,itemScope:w,itemType:$,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:w,low:D,manifest:null,max:null,maxLength:D,media:null,method:null,min:null,minLength:D,multiple:w,muted:w,name:null,nonce:null,noModule:w,noValidate:w,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforePrint:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextMenu:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:w,optimum:D,pattern:null,ping:$,placeholder:null,playsInline:w,poster:null,preload:null,readOnly:w,referrerPolicy:null,rel:$,required:w,reversed:w,rows:D,rowSpan:D,sandbox:$,scope:null,scoped:w,seamless:w,selected:w,shape:null,size:D,sizes:null,slot:null,span:D,spellCheck:se,src:null,srcDoc:null,srcLang:null,srcSet:ge,start:D,step:null,style:null,tabIndex:D,target:null,title:null,translate:null,type:null,typeMustMatch:w,useMap:null,value:se,width:D,wrap:null,align:null,aLink:null,archive:$,axis:null,background:null,bgColor:null,border:D,borderColor:null,bottomMargin:D,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:w,declare:w,event:null,face:null,frame:null,frameBorder:null,hSpace:D,leftMargin:D,link:null,longDesc:null,lowSrc:null,marginHeight:D,marginWidth:D,noResize:w,noHref:w,noShade:w,noWrap:w,object:null,profile:null,prompt:null,rev:null,rightMargin:D,rules:null,scheme:null,scrolling:se,standby:null,summary:null,text:null,topMargin:D,valueType:null,version:null,vAlign:null,vLink:null,vSpace:D,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:w,disableRemotePlayback:w,prefix:null,property:null,results:D,security:null,unselectable:null}}),Op=ap,Lp=pp,Dp=mp,xp=Ap,Mp=_p,Fp=kp,Up=Op([Dp,Lp,xp,Mp,Fp]),Bp=Oi,Pp=_c,Gp=vc,xi="data",$p=zp,qp=/^data[-\w.:]+$/i,wc=/-[a-z]/g,Hp=/[A-Z]/g;function zp(e,t){var r=Bp(t),a=t,n=Gp;return r in e.normal?e.property[e.normal[r]]:(r.length>4&&r.slice(0,4)===xi&&qp.test(t)&&(t.charAt(4)==="-"?a=Vp(t):t=jp(t),n=Pp),new n(a,t))}function Vp(e){var t=e.slice(5).replace(wc,Yp);return xi+t.charAt(0).toUpperCase()+t.slice(1)}function jp(e){var t=e.slice(4);return wc.test(t)?e:(t=t.replace(Hp,Wp),t.charAt(0)!=="-"&&(t="-"+t),xi+t)}function Wp(e){return"-"+e.toLowerCase()}function Yp(e){return e.charAt(1).toUpperCase()}var Kp=Zp,no=/[#.]/g;function Zp(e,t){for(var r=e||"",a=t||"div",n={},i=0,s,l,u;i<r.length;)no.lastIndex=i,u=no.exec(r),s=r.slice(i,u?u.index:r.length),s&&(l?l==="#"?n.id=s:n.className?n.className.push(s):n.className=[s]:a=s,i+=s.length),u&&(l=u[0],i++);return{type:"element",tagName:a,properties:n,children:[]}}var Mi={};Mi.parse=Jp;Mi.stringify=eg;var io="",Xp=" ",Qp=/[ \t\n\r\f]+/g;function Jp(e){var t=String(e||io).trim();return t===io?[]:t.split(Qp)}function eg(e){return e.join(Xp).trim()}var Fi={};Fi.parse=tg;Fi.stringify=rg;var wi=",",oo=" ",le="";function tg(e){for(var t=[],r=String(e||le),a=r.indexOf(wi),n=0,i=!1,s;!i;)a===-1&&(a=r.length,i=!0),s=r.slice(n,a).trim(),(s||!i)&&t.push(s),n=a+1,a=r.indexOf(wi,n);return t}function rg(e,t){var r=t||{},a=r.padLeft===!1?le:oo,n=r.padRight?oo:le;return e[e.length-1]===le&&(e=e.concat(le)),e.join(n+wi+a).trim()}var ag=$p,so=Oi,ng=Kp,lo=Mi.parse,uo=Fi.parse,ig=sg,og={}.hasOwnProperty;function sg(e,t,r){var a=r?pg(r):null;return n;function n(s,l){var u=ng(s,t),c=Array.prototype.slice.call(arguments,2),d=u.tagName.toLowerCase(),b;if(u.tagName=a&&og.call(a,d)?a[d]:d,l&&lg(l,u)&&(c.unshift(l),l=null),l)for(b in l)i(u.properties,b,l[b]);return Cc(u.children,c),u.tagName==="template"&&(u.content={type:"root",children:u.children},u.children=[]),u}function i(s,l,u){var c,d,b;u==null||u!==u||(c=ag(e,l),d=c.property,b=u,typeof b=="string"&&(c.spaceSeparated?b=lo(b):c.commaSeparated?b=uo(b):c.commaOrSpaceSeparated&&(b=lo(uo(b).join(" ")))),d==="style"&&typeof u!="string"&&(b=cg(b)),d==="className"&&s.className&&(b=s.className.concat(b)),s[d]=dg(c,d,b))}}function lg(e,t){return typeof e=="string"||"length"in e||ug(t.tagName,e)}function ug(e,t){var r=t.type;return e==="input"||!r||typeof r!="string"?!1:typeof t.children=="object"&&"length"in t.children?!0:(r=r.toLowerCase(),e==="button"?r!=="menu"&&r!=="submit"&&r!=="reset"&&r!=="button":"value"in t)}function Cc(e,t){var r,a;if(typeof t=="string"||typeof t=="number"){e.push({type:"text",value:String(t)});return}if(typeof t=="object"&&"length"in t){for(r=-1,a=t.length;++r<a;)Cc(e,t[r]);return}if(typeof t!="object"||!("type"in t))throw new Error("Expected node, nodes, or string, got `"+t+"`");e.push(t)}function dg(e,t,r){var a,n,i;if(typeof r!="object"||!("length"in r))return co(e,t,r);for(n=r.length,a=-1,i=[];++a<n;)i[a]=co(e,t,r[a]);return i}function co(e,t,r){var a=r;return e.number||e.positiveNumber?!isNaN(a)&&a!==""&&(a=Number(a)):(e.boolean||e.overloadedBoolean)&&typeof a=="string"&&(a===""||so(r)===so(t))&&(a=!0),a}function cg(e){var t=[],r;for(r in e)t.push([r,e[r]].join(": "));return t.join("; ")}function pg(e){for(var t=e.length,r=-1,a={},n;++r<t;)n=e[r],a[n.toLowerCase()]=n;return a}var gg=Up,bg=ig,kc=bg(gg,"div");kc.displayName="html";var mg=kc,fg=mg;const Eg="Æ",hg="&",Sg="Á",yg="Â",Tg="À",vg="Å",Ag="Ã",Rg="Ä",_g="©",Ig="Ç",Ng="Ð",wg="É",Cg="Ê",kg="È",Og="Ë",Lg=">",Dg="Í",xg="Î",Mg="Ì",Fg="Ï",Ug="<",Bg="Ñ",Pg="Ó",Gg="Ô",$g="Ò",qg="Ø",Hg="Õ",zg="Ö",Vg='"',jg="®",Wg="Þ",Yg="Ú",Kg="Û",Zg="Ù",Xg="Ü",Qg="Ý",Jg="á",eb="â",tb="´",rb="æ",ab="à",nb="&",ib="å",ob="ã",sb="ä",lb="¦",ub="ç",db="¸",cb="¢",pb="©",gb="¤",bb="°",mb="÷",fb="é",Eb="ê",hb="è",Sb="ð",yb="ë",Tb="½",vb="¼",Ab="¾",Rb=">",_b="í",Ib="î",Nb="¡",wb="ì",Cb="¿",kb="ï",Ob="«",Lb="<",Db="¯",xb="µ",Mb="·",Fb=" ",Ub="¬",Bb="ñ",Pb="ó",Gb="ô",$b="ò",qb="ª",Hb="º",zb="ø",Vb="õ",jb="ö",Wb="¶",Yb="±",Kb="£",Zb='"',Xb="»",Qb="®",Jb="§",em="",tm="¹",rm="²",am="³",nm="ß",im="þ",om="×",sm="ú",lm="û",um="ù",dm="¨",cm="ü",pm="ý",gm="¥",bm="ÿ",mm={AElig:Eg,AMP:hg,Aacute:Sg,Acirc:yg,Agrave:Tg,Aring:vg,Atilde:Ag,Auml:Rg,COPY:_g,Ccedil:Ig,ETH:Ng,Eacute:wg,Ecirc:Cg,Egrave:kg,Euml:Og,GT:Lg,Iacute:Dg,Icirc:xg,Igrave:Mg,Iuml:Fg,LT:Ug,Ntilde:Bg,Oacute:Pg,Ocirc:Gg,Ograve:$g,Oslash:qg,Otilde:Hg,Ouml:zg,QUOT:Vg,REG:jg,THORN:Wg,Uacute:Yg,Ucirc:Kg,Ugrave:Zg,Uuml:Xg,Yacute:Qg,aacute:Jg,acirc:eb,acute:tb,aelig:rb,agrave:ab,amp:nb,aring:ib,atilde:ob,auml:sb,brvbar:lb,ccedil:ub,cedil:db,cent:cb,copy:pb,curren:gb,deg:bb,divide:mb,eacute:fb,ecirc:Eb,egrave:hb,eth:Sb,euml:yb,frac12:Tb,frac14:vb,frac34:Ab,gt:Rb,iacute:_b,icirc:Ib,iexcl:Nb,igrave:wb,iquest:Cb,iuml:kb,laquo:Ob,lt:Lb,macr:Db,micro:xb,middot:Mb,nbsp:Fb,not:Ub,ntilde:Bb,oacute:Pb,ocirc:Gb,ograve:$b,ordf:qb,ordm:Hb,oslash:zb,otilde:Vb,ouml:jb,para:Wb,plusmn:Yb,pound:Kb,quot:Zb,raquo:Xb,reg:Qb,sect:Jb,shy:em,sup1:tm,sup2:rm,sup3:am,szlig:nm,thorn:im,times:om,uacute:sm,ucirc:lm,ugrave:um,uml:dm,uuml:cm,yacute:pm,yen:gm,yuml:bm},fm={0:"�",128:"€",130:"‚",131:"ƒ",132:"„",133:"…",134:"†",135:"‡",136:"ˆ",137:"‰",138:"Š",139:"‹",140:"Œ",142:"Ž",145:"‘",146:"’",147:"“",148:"”",149:"•",150:"–",151:"—",152:"˜",153:"™",154:"š",155:"›",156:"œ",158:"ž",159:"Ÿ"};var Oc=Em;function Em(e){var t=typeof e=="string"?e.charCodeAt(0):e;return t>=48&&t<=57}var hm=Sm;function Sm(e){var t=typeof e=="string"?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}var ym=Tm;function Tm(e){var t=typeof e=="string"?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}var vm=ym,Am=Oc,Rm=_m;function _m(e){return vm(e)||Am(e)}var be,Im=59,Nm=wm;function wm(e){var t="&"+e+";",r;return be=be||document.createElement("i"),be.innerHTML=t,r=be.textContent,r.charCodeAt(r.length-1)===Im&&e!=="semi"||r===t?!1:r}var po=mm,go=fm,Cm=Oc,km=hm,Lc=Rm,Om=Nm,Lm=Vm,Dm={}.hasOwnProperty,ne=String.fromCharCode,xm=Function.prototype,bo={warning:null,reference:null,text:null,warningContext:null,referenceContext:null,textContext:null,position:{},additional:null,attribute:!1,nonTerminated:!0},Mm=9,mo=10,Fm=12,Um=32,fo=38,Bm=59,Pm=60,Gm=61,$m=35,qm=88,Hm=120,zm=65533,ie="named",Ui="hexadecimal",Bi="decimal",Pi={};Pi[Ui]=16;Pi[Bi]=10;var fe={};fe[ie]=Lc;fe[Bi]=Cm;fe[Ui]=km;var Dc=1,xc=2,Mc=3,Fc=4,Uc=5,Ci=6,Bc=7,J={};J[Dc]="Named character references must be terminated by a semicolon";J[xc]="Numeric character references must be terminated by a semicolon";J[Mc]="Named character references cannot be empty";J[Fc]="Numeric character references cannot be empty";J[Uc]="Named character references must be known";J[Ci]="Numeric character references cannot be disallowed";J[Bc]="Numeric character references cannot be outside the permissible Unicode range";function Vm(e,t){var r={},a,n;t||(t={});for(n in bo)a=t[n],r[n]=a??bo[n];return(r.position.indent||r.position.start)&&(r.indent=r.position.indent||[],r.position=r.position.start),jm(e,r)}function jm(e,t){var r=t.additional,a=t.nonTerminated,n=t.text,i=t.reference,s=t.warning,l=t.textContext,u=t.referenceContext,c=t.warningContext,d=t.position,b=t.indent||[],h=e.length,S=0,_=-1,y=d.column||1,R=d.line||1,v="",g=[],p,m,E,f,A,I,T,N,C,U,B,q,P,G,Y,O,M,x,k;for(typeof r=="string"&&(r=r.charCodeAt(0)),O=L(),N=s?Z:xm,S--,h++;++S<h;)if(A===mo&&(y=b[_]||1),A=e.charCodeAt(S),A===fo){if(T=e.charCodeAt(S+1),T===Mm||T===mo||T===Fm||T===Um||T===fo||T===Pm||T!==T||r&&T===r){v+=ne(A),y++;continue}for(P=S+1,q=P,k=P,T===$m?(k=++q,T=e.charCodeAt(k),T===qm||T===Hm?(G=Ui,k=++q):G=Bi):G=ie,p="",B="",f="",Y=fe[G],k--;++k<h&&(T=e.charCodeAt(k),!!Y(T));)f+=ne(T),G===ie&&Dm.call(po,f)&&(p=f,B=po[f]);E=e.charCodeAt(k)===Bm,E&&(k++,m=G===ie?Om(f):!1,m&&(p=f,B=m)),x=1+k-P,!E&&!a||(f?G===ie?(E&&!B?N(Uc,1):(p!==f&&(k=q+p.length,x=1+k-q,E=!1),E||(C=p?Dc:Mc,t.attribute?(T=e.charCodeAt(k),T===Gm?(N(C,x),B=null):Lc(T)?B=null:N(C,x)):N(C,x))),I=B):(E||N(xc,x),I=parseInt(f,Pi[G]),Wm(I)?(N(Bc,x),I=ne(zm)):I in go?(N(Ci,x),I=go[I]):(U="",Ym(I)&&N(Ci,x),I>65535&&(I-=65536,U+=ne(I>>>10|55296),I=56320|I&1023),I=U+ne(I))):G!==ie&&N(Fc,x)),I?(V(),O=L(),S=k-1,y+=k-P+1,g.push(I),M=L(),M.offset++,i&&i.call(u,I,{start:O,end:M},e.slice(P-1,k)),O=M):(f=e.slice(P-1,k),v+=f,y+=f.length,S=k-1)}else A===10&&(R++,_++,y=0),A===A?(v+=ne(A),y++):V();return g.join("");function L(){return{line:R,column:y,offset:S+(d.offset||0)}}function Z(X,ee){var Q=L();Q.column+=ee,Q.offset+=ee,s.call(c,J[X],Q,X)}function V(){v&&(g.push(v),n&&n.call(l,v,{start:O,end:L()}),v="")}}function Wm(e){return e>=55296&&e<=57343||e>1114111}function Ym(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)===65535||(e&65535)===65534}var Pc={exports:{}};(function(e){var t=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};/**
|
|
1
|
+
import{c as me,g as Xc}from"./index-69562d52.js";function Qc(e,t){for(var r=0;r<t.length;r++){const a=t[r];if(typeof a!="string"&&!Array.isArray(a)){for(const n in a)if(n!=="default"&&!(n in e)){const i=Object.getOwnPropertyDescriptor(a,n);i&&Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:()=>a[n]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var Jc=tp,ep=Object.prototype.hasOwnProperty;function tp(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var a in r)ep.call(r,a)&&(e[a]=r[a])}return e}var yc=Tc,ki=Tc.prototype;ki.space=null;ki.normal={};ki.property={};function Tc(e,t,r){this.property=e,this.normal=t,r&&(this.space=r)}var eo=Jc,rp=yc,ap=np;function np(e){for(var t=e.length,r=[],a=[],n=-1,i,s;++n<t;)i=e[n],r.push(i.property),a.push(i.normal),s=i.space;return new rp(eo.apply(null,r),eo.apply(null,a),s)}var Oi=ip;function ip(e){return e.toLowerCase()}var vc=Ac,W=Ac.prototype;W.space=null;W.attribute=null;W.property=null;W.boolean=!1;W.booleanish=!1;W.overloadedBoolean=!1;W.number=!1;W.commaSeparated=!1;W.spaceSeparated=!1;W.commaOrSpaceSeparated=!1;W.mustUseProperty=!1;W.defined=!1;function Ac(e,t){this.property=e,this.attribute=t}var K={},op=0;K.boolean=re();K.booleanish=re();K.overloadedBoolean=re();K.number=re();K.spaceSeparated=re();K.commaSeparated=re();K.commaOrSpaceSeparated=re();function re(){return Math.pow(2,++op)}var Rc=vc,to=K,_c=Li;Li.prototype=new Rc;Li.prototype.defined=!0;var Ic=["boolean","booleanish","overloadedBoolean","number","commaSeparated","spaceSeparated","commaOrSpaceSeparated"],sp=Ic.length;function Li(e,t,r,a){var n=-1,i;for(ro(this,"space",a),Rc.call(this,e,t);++n<sp;)i=Ic[n],ro(this,i,(r&to[i])===to[i])}function ro(e,t,r){r&&(e[t]=r)}var ao=Oi,lp=yc,up=_c,de=dp;function dp(e){var t=e.space,r=e.mustUseProperty||[],a=e.attributes||{},n=e.properties,i=e.transform,s={},l={},u,c;for(u in n)c=new up(u,i(a,u),n[u],t),r.indexOf(u)!==-1&&(c.mustUseProperty=!0),s[u]=c,l[ao(u)]=u,l[ao(c.attribute)]=u;return new lp(s,l,t)}var cp=de,pp=cp({space:"xlink",transform:gp,properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}});function gp(e,t){return"xlink:"+t.slice(5).toLowerCase()}var bp=de,mp=bp({space:"xml",transform:fp,properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function fp(e,t){return"xml:"+t.slice(3).toLowerCase()}var Ep=hp;function hp(e,t){return t in e?e[t]:t}var Sp=Ep,Nc=yp;function yp(e,t){return Sp(e,t.toLowerCase())}var Tp=de,vp=Nc,Ap=Tp({space:"xmlns",attributes:{xmlnsxlink:"xmlns:xlink"},transform:vp,properties:{xmlns:null,xmlnsXLink:null}}),Di=K,Rp=de,H=Di.booleanish,j=Di.number,te=Di.spaceSeparated,_p=Rp({transform:Ip,properties:{ariaActiveDescendant:null,ariaAtomic:H,ariaAutoComplete:null,ariaBusy:H,ariaChecked:H,ariaColCount:j,ariaColIndex:j,ariaColSpan:j,ariaControls:te,ariaCurrent:null,ariaDescribedBy:te,ariaDetails:null,ariaDisabled:H,ariaDropEffect:te,ariaErrorMessage:null,ariaExpanded:H,ariaFlowTo:te,ariaGrabbed:H,ariaHasPopup:null,ariaHidden:H,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:te,ariaLevel:j,ariaLive:null,ariaModal:H,ariaMultiLine:H,ariaMultiSelectable:H,ariaOrientation:null,ariaOwns:te,ariaPlaceholder:null,ariaPosInSet:j,ariaPressed:H,ariaReadOnly:H,ariaRelevant:null,ariaRequired:H,ariaRoleDescription:te,ariaRowCount:j,ariaRowIndex:j,ariaRowSpan:j,ariaSelected:H,ariaSetSize:j,ariaSort:null,ariaValueMax:j,ariaValueMin:j,ariaValueNow:j,ariaValueText:null,role:null}});function Ip(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}var oe=K,Np=de,wp=Nc,w=oe.boolean,Cp=oe.overloadedBoolean,se=oe.booleanish,D=oe.number,$=oe.spaceSeparated,ge=oe.commaSeparated,kp=Np({space:"html",attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},transform:wp,mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ge,acceptCharset:$,accessKey:$,action:null,allow:null,allowFullScreen:w,allowPaymentRequest:w,allowUserMedia:w,alt:null,as:null,async:w,autoCapitalize:null,autoComplete:$,autoFocus:w,autoPlay:w,capture:w,charSet:null,checked:w,cite:null,className:$,cols:D,colSpan:null,content:null,contentEditable:se,controls:w,controlsList:$,coords:D|ge,crossOrigin:null,data:null,dateTime:null,decoding:null,default:w,defer:w,dir:null,dirName:null,disabled:w,download:Cp,draggable:se,encType:null,enterKeyHint:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:w,formTarget:null,headers:$,height:D,hidden:w,high:D,href:null,hrefLang:null,htmlFor:$,httpEquiv:$,id:null,imageSizes:null,imageSrcSet:ge,inputMode:null,integrity:null,is:null,isMap:w,itemId:null,itemProp:$,itemRef:$,itemScope:w,itemType:$,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:w,low:D,manifest:null,max:null,maxLength:D,media:null,method:null,min:null,minLength:D,multiple:w,muted:w,name:null,nonce:null,noModule:w,noValidate:w,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforePrint:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextMenu:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:w,optimum:D,pattern:null,ping:$,placeholder:null,playsInline:w,poster:null,preload:null,readOnly:w,referrerPolicy:null,rel:$,required:w,reversed:w,rows:D,rowSpan:D,sandbox:$,scope:null,scoped:w,seamless:w,selected:w,shape:null,size:D,sizes:null,slot:null,span:D,spellCheck:se,src:null,srcDoc:null,srcLang:null,srcSet:ge,start:D,step:null,style:null,tabIndex:D,target:null,title:null,translate:null,type:null,typeMustMatch:w,useMap:null,value:se,width:D,wrap:null,align:null,aLink:null,archive:$,axis:null,background:null,bgColor:null,border:D,borderColor:null,bottomMargin:D,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:w,declare:w,event:null,face:null,frame:null,frameBorder:null,hSpace:D,leftMargin:D,link:null,longDesc:null,lowSrc:null,marginHeight:D,marginWidth:D,noResize:w,noHref:w,noShade:w,noWrap:w,object:null,profile:null,prompt:null,rev:null,rightMargin:D,rules:null,scheme:null,scrolling:se,standby:null,summary:null,text:null,topMargin:D,valueType:null,version:null,vAlign:null,vLink:null,vSpace:D,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:w,disableRemotePlayback:w,prefix:null,property:null,results:D,security:null,unselectable:null}}),Op=ap,Lp=pp,Dp=mp,xp=Ap,Mp=_p,Fp=kp,Up=Op([Dp,Lp,xp,Mp,Fp]),Bp=Oi,Pp=_c,Gp=vc,xi="data",$p=zp,qp=/^data[-\w.:]+$/i,wc=/-[a-z]/g,Hp=/[A-Z]/g;function zp(e,t){var r=Bp(t),a=t,n=Gp;return r in e.normal?e.property[e.normal[r]]:(r.length>4&&r.slice(0,4)===xi&&qp.test(t)&&(t.charAt(4)==="-"?a=Vp(t):t=jp(t),n=Pp),new n(a,t))}function Vp(e){var t=e.slice(5).replace(wc,Yp);return xi+t.charAt(0).toUpperCase()+t.slice(1)}function jp(e){var t=e.slice(4);return wc.test(t)?e:(t=t.replace(Hp,Wp),t.charAt(0)!=="-"&&(t="-"+t),xi+t)}function Wp(e){return"-"+e.toLowerCase()}function Yp(e){return e.charAt(1).toUpperCase()}var Kp=Zp,no=/[#.]/g;function Zp(e,t){for(var r=e||"",a=t||"div",n={},i=0,s,l,u;i<r.length;)no.lastIndex=i,u=no.exec(r),s=r.slice(i,u?u.index:r.length),s&&(l?l==="#"?n.id=s:n.className?n.className.push(s):n.className=[s]:a=s,i+=s.length),u&&(l=u[0],i++);return{type:"element",tagName:a,properties:n,children:[]}}var Mi={};Mi.parse=Jp;Mi.stringify=eg;var io="",Xp=" ",Qp=/[ \t\n\r\f]+/g;function Jp(e){var t=String(e||io).trim();return t===io?[]:t.split(Qp)}function eg(e){return e.join(Xp).trim()}var Fi={};Fi.parse=tg;Fi.stringify=rg;var wi=",",oo=" ",le="";function tg(e){for(var t=[],r=String(e||le),a=r.indexOf(wi),n=0,i=!1,s;!i;)a===-1&&(a=r.length,i=!0),s=r.slice(n,a).trim(),(s||!i)&&t.push(s),n=a+1,a=r.indexOf(wi,n);return t}function rg(e,t){var r=t||{},a=r.padLeft===!1?le:oo,n=r.padRight?oo:le;return e[e.length-1]===le&&(e=e.concat(le)),e.join(n+wi+a).trim()}var ag=$p,so=Oi,ng=Kp,lo=Mi.parse,uo=Fi.parse,ig=sg,og={}.hasOwnProperty;function sg(e,t,r){var a=r?pg(r):null;return n;function n(s,l){var u=ng(s,t),c=Array.prototype.slice.call(arguments,2),d=u.tagName.toLowerCase(),b;if(u.tagName=a&&og.call(a,d)?a[d]:d,l&&lg(l,u)&&(c.unshift(l),l=null),l)for(b in l)i(u.properties,b,l[b]);return Cc(u.children,c),u.tagName==="template"&&(u.content={type:"root",children:u.children},u.children=[]),u}function i(s,l,u){var c,d,b;u==null||u!==u||(c=ag(e,l),d=c.property,b=u,typeof b=="string"&&(c.spaceSeparated?b=lo(b):c.commaSeparated?b=uo(b):c.commaOrSpaceSeparated&&(b=lo(uo(b).join(" ")))),d==="style"&&typeof u!="string"&&(b=cg(b)),d==="className"&&s.className&&(b=s.className.concat(b)),s[d]=dg(c,d,b))}}function lg(e,t){return typeof e=="string"||"length"in e||ug(t.tagName,e)}function ug(e,t){var r=t.type;return e==="input"||!r||typeof r!="string"?!1:typeof t.children=="object"&&"length"in t.children?!0:(r=r.toLowerCase(),e==="button"?r!=="menu"&&r!=="submit"&&r!=="reset"&&r!=="button":"value"in t)}function Cc(e,t){var r,a;if(typeof t=="string"||typeof t=="number"){e.push({type:"text",value:String(t)});return}if(typeof t=="object"&&"length"in t){for(r=-1,a=t.length;++r<a;)Cc(e,t[r]);return}if(typeof t!="object"||!("type"in t))throw new Error("Expected node, nodes, or string, got `"+t+"`");e.push(t)}function dg(e,t,r){var a,n,i;if(typeof r!="object"||!("length"in r))return co(e,t,r);for(n=r.length,a=-1,i=[];++a<n;)i[a]=co(e,t,r[a]);return i}function co(e,t,r){var a=r;return e.number||e.positiveNumber?!isNaN(a)&&a!==""&&(a=Number(a)):(e.boolean||e.overloadedBoolean)&&typeof a=="string"&&(a===""||so(r)===so(t))&&(a=!0),a}function cg(e){var t=[],r;for(r in e)t.push([r,e[r]].join(": "));return t.join("; ")}function pg(e){for(var t=e.length,r=-1,a={},n;++r<t;)n=e[r],a[n.toLowerCase()]=n;return a}var gg=Up,bg=ig,kc=bg(gg,"div");kc.displayName="html";var mg=kc,fg=mg;const Eg="Æ",hg="&",Sg="Á",yg="Â",Tg="À",vg="Å",Ag="Ã",Rg="Ä",_g="©",Ig="Ç",Ng="Ð",wg="É",Cg="Ê",kg="È",Og="Ë",Lg=">",Dg="Í",xg="Î",Mg="Ì",Fg="Ï",Ug="<",Bg="Ñ",Pg="Ó",Gg="Ô",$g="Ò",qg="Ø",Hg="Õ",zg="Ö",Vg='"',jg="®",Wg="Þ",Yg="Ú",Kg="Û",Zg="Ù",Xg="Ü",Qg="Ý",Jg="á",eb="â",tb="´",rb="æ",ab="à",nb="&",ib="å",ob="ã",sb="ä",lb="¦",ub="ç",db="¸",cb="¢",pb="©",gb="¤",bb="°",mb="÷",fb="é",Eb="ê",hb="è",Sb="ð",yb="ë",Tb="½",vb="¼",Ab="¾",Rb=">",_b="í",Ib="î",Nb="¡",wb="ì",Cb="¿",kb="ï",Ob="«",Lb="<",Db="¯",xb="µ",Mb="·",Fb=" ",Ub="¬",Bb="ñ",Pb="ó",Gb="ô",$b="ò",qb="ª",Hb="º",zb="ø",Vb="õ",jb="ö",Wb="¶",Yb="±",Kb="£",Zb='"',Xb="»",Qb="®",Jb="§",em="",tm="¹",rm="²",am="³",nm="ß",im="þ",om="×",sm="ú",lm="û",um="ù",dm="¨",cm="ü",pm="ý",gm="¥",bm="ÿ",mm={AElig:Eg,AMP:hg,Aacute:Sg,Acirc:yg,Agrave:Tg,Aring:vg,Atilde:Ag,Auml:Rg,COPY:_g,Ccedil:Ig,ETH:Ng,Eacute:wg,Ecirc:Cg,Egrave:kg,Euml:Og,GT:Lg,Iacute:Dg,Icirc:xg,Igrave:Mg,Iuml:Fg,LT:Ug,Ntilde:Bg,Oacute:Pg,Ocirc:Gg,Ograve:$g,Oslash:qg,Otilde:Hg,Ouml:zg,QUOT:Vg,REG:jg,THORN:Wg,Uacute:Yg,Ucirc:Kg,Ugrave:Zg,Uuml:Xg,Yacute:Qg,aacute:Jg,acirc:eb,acute:tb,aelig:rb,agrave:ab,amp:nb,aring:ib,atilde:ob,auml:sb,brvbar:lb,ccedil:ub,cedil:db,cent:cb,copy:pb,curren:gb,deg:bb,divide:mb,eacute:fb,ecirc:Eb,egrave:hb,eth:Sb,euml:yb,frac12:Tb,frac14:vb,frac34:Ab,gt:Rb,iacute:_b,icirc:Ib,iexcl:Nb,igrave:wb,iquest:Cb,iuml:kb,laquo:Ob,lt:Lb,macr:Db,micro:xb,middot:Mb,nbsp:Fb,not:Ub,ntilde:Bb,oacute:Pb,ocirc:Gb,ograve:$b,ordf:qb,ordm:Hb,oslash:zb,otilde:Vb,ouml:jb,para:Wb,plusmn:Yb,pound:Kb,quot:Zb,raquo:Xb,reg:Qb,sect:Jb,shy:em,sup1:tm,sup2:rm,sup3:am,szlig:nm,thorn:im,times:om,uacute:sm,ucirc:lm,ugrave:um,uml:dm,uuml:cm,yacute:pm,yen:gm,yuml:bm},fm={0:"�",128:"€",130:"‚",131:"ƒ",132:"„",133:"…",134:"†",135:"‡",136:"ˆ",137:"‰",138:"Š",139:"‹",140:"Œ",142:"Ž",145:"‘",146:"’",147:"“",148:"”",149:"•",150:"–",151:"—",152:"˜",153:"™",154:"š",155:"›",156:"œ",158:"ž",159:"Ÿ"};var Oc=Em;function Em(e){var t=typeof e=="string"?e.charCodeAt(0):e;return t>=48&&t<=57}var hm=Sm;function Sm(e){var t=typeof e=="string"?e.charCodeAt(0):e;return t>=97&&t<=102||t>=65&&t<=70||t>=48&&t<=57}var ym=Tm;function Tm(e){var t=typeof e=="string"?e.charCodeAt(0):e;return t>=97&&t<=122||t>=65&&t<=90}var vm=ym,Am=Oc,Rm=_m;function _m(e){return vm(e)||Am(e)}var be,Im=59,Nm=wm;function wm(e){var t="&"+e+";",r;return be=be||document.createElement("i"),be.innerHTML=t,r=be.textContent,r.charCodeAt(r.length-1)===Im&&e!=="semi"||r===t?!1:r}var po=mm,go=fm,Cm=Oc,km=hm,Lc=Rm,Om=Nm,Lm=Vm,Dm={}.hasOwnProperty,ne=String.fromCharCode,xm=Function.prototype,bo={warning:null,reference:null,text:null,warningContext:null,referenceContext:null,textContext:null,position:{},additional:null,attribute:!1,nonTerminated:!0},Mm=9,mo=10,Fm=12,Um=32,fo=38,Bm=59,Pm=60,Gm=61,$m=35,qm=88,Hm=120,zm=65533,ie="named",Ui="hexadecimal",Bi="decimal",Pi={};Pi[Ui]=16;Pi[Bi]=10;var fe={};fe[ie]=Lc;fe[Bi]=Cm;fe[Ui]=km;var Dc=1,xc=2,Mc=3,Fc=4,Uc=5,Ci=6,Bc=7,J={};J[Dc]="Named character references must be terminated by a semicolon";J[xc]="Numeric character references must be terminated by a semicolon";J[Mc]="Named character references cannot be empty";J[Fc]="Numeric character references cannot be empty";J[Uc]="Named character references must be known";J[Ci]="Numeric character references cannot be disallowed";J[Bc]="Numeric character references cannot be outside the permissible Unicode range";function Vm(e,t){var r={},a,n;t||(t={});for(n in bo)a=t[n],r[n]=a??bo[n];return(r.position.indent||r.position.start)&&(r.indent=r.position.indent||[],r.position=r.position.start),jm(e,r)}function jm(e,t){var r=t.additional,a=t.nonTerminated,n=t.text,i=t.reference,s=t.warning,l=t.textContext,u=t.referenceContext,c=t.warningContext,d=t.position,b=t.indent||[],h=e.length,S=0,_=-1,y=d.column||1,R=d.line||1,v="",g=[],p,m,E,f,A,I,T,N,C,U,B,q,P,G,Y,O,M,x,k;for(typeof r=="string"&&(r=r.charCodeAt(0)),O=L(),N=s?Z:xm,S--,h++;++S<h;)if(A===mo&&(y=b[_]||1),A=e.charCodeAt(S),A===fo){if(T=e.charCodeAt(S+1),T===Mm||T===mo||T===Fm||T===Um||T===fo||T===Pm||T!==T||r&&T===r){v+=ne(A),y++;continue}for(P=S+1,q=P,k=P,T===$m?(k=++q,T=e.charCodeAt(k),T===qm||T===Hm?(G=Ui,k=++q):G=Bi):G=ie,p="",B="",f="",Y=fe[G],k--;++k<h&&(T=e.charCodeAt(k),!!Y(T));)f+=ne(T),G===ie&&Dm.call(po,f)&&(p=f,B=po[f]);E=e.charCodeAt(k)===Bm,E&&(k++,m=G===ie?Om(f):!1,m&&(p=f,B=m)),x=1+k-P,!E&&!a||(f?G===ie?(E&&!B?N(Uc,1):(p!==f&&(k=q+p.length,x=1+k-q,E=!1),E||(C=p?Dc:Mc,t.attribute?(T=e.charCodeAt(k),T===Gm?(N(C,x),B=null):Lc(T)?B=null:N(C,x)):N(C,x))),I=B):(E||N(xc,x),I=parseInt(f,Pi[G]),Wm(I)?(N(Bc,x),I=ne(zm)):I in go?(N(Ci,x),I=go[I]):(U="",Ym(I)&&N(Ci,x),I>65535&&(I-=65536,U+=ne(I>>>10|55296),I=56320|I&1023),I=U+ne(I))):G!==ie&&N(Fc,x)),I?(V(),O=L(),S=k-1,y+=k-P+1,g.push(I),M=L(),M.offset++,i&&i.call(u,I,{start:O,end:M},e.slice(P-1,k)),O=M):(f=e.slice(P-1,k),v+=f,y+=f.length,S=k-1)}else A===10&&(R++,_++,y=0),A===A?(v+=ne(A),y++):V();return g.join("");function L(){return{line:R,column:y,offset:S+(d.offset||0)}}function Z(X,ee){var Q=L();Q.column+=ee,Q.offset+=ee,s.call(c,J[X],Q,X)}function V(){v&&(g.push(v),n&&n.call(l,v,{start:O,end:L()}),v="")}}function Wm(e){return e>=55296&&e<=57343||e>1114111}function Ym(e){return e>=1&&e<=8||e===11||e>=13&&e<=31||e>=127&&e<=159||e>=64976&&e<=65007||(e&65535)===65535||(e&65535)===65534}var Pc={exports:{}};(function(e){var t=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};/**
|
|
2
2
|
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
3
3
|
*
|
|
4
4
|
* @license MIT <https://opensource.org/licenses/MIT>
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<script>
|
|
16
16
|
const global = globalThis;
|
|
17
17
|
</script>
|
|
18
|
-
<script type="module" crossorigin src="/assets/index-
|
|
18
|
+
<script type="module" crossorigin src="/assets/index-69562d52.js"></script>
|
|
19
19
|
<link rel="stylesheet" href="/assets/index-a6e13df6.css">
|
|
20
20
|
</head>
|
|
21
21
|
<body>
|
chainlit/haystack/__init__.py
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import haystack
|
|
1
|
+
from chainlit.utils import check_module_version
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
HAYSTACK_INSTALLED = True
|
|
10
|
-
except ImportError:
|
|
11
|
-
HAYSTACK_INSTALLED = False
|
|
3
|
+
if not check_module_version("haystack", "1.18.0"):
|
|
4
|
+
raise ValueError(
|
|
5
|
+
"Expected Haystack version >= 1.18.0. Run `pip install farm-haystack --upgrade`"
|
|
6
|
+
)
|
chainlit/input_widget.py
CHANGED
|
@@ -198,6 +198,41 @@ class TextInput(InputWidget):
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
|
|
201
|
+
@dataclass
|
|
202
|
+
class NumberInput(InputWidget):
|
|
203
|
+
"""Useful to create a number input."""
|
|
204
|
+
|
|
205
|
+
type: InputWidgetType = "numberinput"
|
|
206
|
+
initial: Optional[float] = None
|
|
207
|
+
placeholder: Optional[str] = None
|
|
208
|
+
|
|
209
|
+
def __init__(
|
|
210
|
+
self,
|
|
211
|
+
id: str,
|
|
212
|
+
label: str,
|
|
213
|
+
initial: Optional[float] = None,
|
|
214
|
+
placeholder: Optional[str] = None,
|
|
215
|
+
tooltip: Optional[str] = None,
|
|
216
|
+
description: Optional[str] = None,
|
|
217
|
+
) -> None:
|
|
218
|
+
self.id = id
|
|
219
|
+
self.label = label
|
|
220
|
+
self.initial = initial
|
|
221
|
+
self.placeholder = placeholder
|
|
222
|
+
super().__post_init__(tooltip, description)
|
|
223
|
+
|
|
224
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
225
|
+
return {
|
|
226
|
+
"type": self.type,
|
|
227
|
+
"id": self.id,
|
|
228
|
+
"label": self.label,
|
|
229
|
+
"initial": self.initial,
|
|
230
|
+
"placeholder": self.placeholder,
|
|
231
|
+
"tooltip": self.tooltip,
|
|
232
|
+
"description": self.description,
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
|
|
201
236
|
@dataclass
|
|
202
237
|
class Tags(InputWidget):
|
|
203
238
|
"""Useful to create an input for an array of strings."""
|
chainlit/langchain/__init__.py
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import langchain
|
|
1
|
+
from chainlit.utils import check_module_version
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
LANGCHAIN_INSTALLED = True
|
|
10
|
-
except ImportError:
|
|
11
|
-
LANGCHAIN_INSTALLED = False
|
|
3
|
+
if not check_module_version("langchain", "0.0.198"):
|
|
4
|
+
raise ValueError(
|
|
5
|
+
"Expected LangChain version >= 0.0.198. Run `pip install langchain --upgrade`"
|
|
6
|
+
)
|
chainlit/langchain/callbacks.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import json
|
|
1
2
|
from typing import Any, Dict, List, Optional, Union
|
|
2
3
|
|
|
3
4
|
from langchain.callbacks.base import AsyncCallbackHandler, BaseCallbackHandler
|
|
@@ -9,11 +10,11 @@ from chainlit.message import ErrorMessage, Message
|
|
|
9
10
|
from chainlit.prompt import Prompt, PromptMessage
|
|
10
11
|
from chainlit.sync import run_sync
|
|
11
12
|
|
|
12
|
-
IGNORE_LIST = [
|
|
13
|
+
IGNORE_LIST = [] # type: List[str]
|
|
13
14
|
DEFAULT_ANSWER_PREFIX_TOKENS = ["Final", "Answer", ":"]
|
|
14
15
|
|
|
15
16
|
|
|
16
|
-
def get_llm_settings(invocation_params: Union[Dict, None]):
|
|
17
|
+
def get_llm_settings(invocation_params: Union[Dict, None], serialized: Dict[str, Any]):
|
|
17
18
|
if invocation_params is None:
|
|
18
19
|
return None, None
|
|
19
20
|
|
|
@@ -23,42 +24,64 @@ def get_llm_settings(invocation_params: Union[Dict, None]):
|
|
|
23
24
|
model_name = invocation_params.pop("model_name")
|
|
24
25
|
invocation_params["model"] = model_name
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
model_kwargs = invocation_params.pop("model_kwargs", {})
|
|
28
|
+
|
|
29
|
+
merged = {
|
|
30
|
+
**invocation_params,
|
|
31
|
+
**model_kwargs,
|
|
32
|
+
**serialized.get("kwargs", {}),
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
# make sure there is no api key specification
|
|
36
|
+
settings = {k: v for k, v in merged.items() if not k.endswith("_api_key")}
|
|
37
|
+
|
|
38
|
+
return provider, settings
|
|
27
39
|
|
|
28
40
|
|
|
29
41
|
def build_prompt(serialized: Dict[str, Any], inputs: Dict[str, Any]):
|
|
30
|
-
inputs = {k: str(v) for (k, v) in inputs.items()}
|
|
31
42
|
prompt_params = serialized.get("kwargs", {}).get("prompt", {}).get("kwargs", {})
|
|
32
|
-
|
|
33
43
|
_messages = prompt_params.get("messages")
|
|
34
44
|
|
|
35
45
|
if _messages:
|
|
36
46
|
messages = []
|
|
37
47
|
for m in _messages:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
class_name = m["id"][-1]
|
|
49
|
+
# A placeholder holds a variable that itself is a list of messages, like chat_history
|
|
50
|
+
if class_name == "MessagesPlaceholder":
|
|
51
|
+
variable_name = m.get("kwargs", {}).get("variable_name") # type: str
|
|
52
|
+
variable = inputs.get(variable_name, [])
|
|
53
|
+
placeholder_size = len(variable)
|
|
54
|
+
if placeholder_size:
|
|
55
|
+
messages += [PromptMessage(placeholder_size=placeholder_size)]
|
|
56
|
+
else:
|
|
57
|
+
m_prompt_params = (
|
|
58
|
+
m.get("kwargs", {}).get("prompt", {}).get("kwargs", {})
|
|
46
59
|
)
|
|
47
|
-
|
|
60
|
+
m_template = m_prompt_params.get("template")
|
|
61
|
+
m_template_format = m_prompt_params.get("template_format")
|
|
62
|
+
messages += [
|
|
63
|
+
PromptMessage(
|
|
64
|
+
template=m_template,
|
|
65
|
+
template_format=m_template_format,
|
|
66
|
+
role=convert_role(class_name),
|
|
67
|
+
)
|
|
68
|
+
]
|
|
48
69
|
else:
|
|
49
70
|
messages = None
|
|
50
71
|
|
|
51
72
|
template = prompt_params.get("template")
|
|
52
73
|
template_format = prompt_params.get("template_format")
|
|
53
74
|
|
|
75
|
+
stringified_inputs = inputs = {k: str(v) for (k, v) in inputs.items()}
|
|
76
|
+
|
|
54
77
|
if template:
|
|
55
78
|
return Prompt(
|
|
56
79
|
template=template,
|
|
57
80
|
template_format=template_format,
|
|
58
|
-
inputs=
|
|
81
|
+
inputs=stringified_inputs,
|
|
59
82
|
)
|
|
60
83
|
elif messages:
|
|
61
|
-
return Prompt(inputs=
|
|
84
|
+
return Prompt(inputs=stringified_inputs, messages=messages)
|
|
62
85
|
|
|
63
86
|
|
|
64
87
|
def convert_role(role: str):
|
|
@@ -74,6 +97,20 @@ def convert_role(role: str):
|
|
|
74
97
|
raise ValueError(f"Unsupported role {role}")
|
|
75
98
|
|
|
76
99
|
|
|
100
|
+
def convert_message(message: BaseMessage, template: Optional[str] = None):
|
|
101
|
+
function_call = message.additional_kwargs.get("function_call")
|
|
102
|
+
if function_call:
|
|
103
|
+
content = json.dumps(function_call, indent=4)
|
|
104
|
+
else:
|
|
105
|
+
content = message.content
|
|
106
|
+
return PromptMessage(
|
|
107
|
+
name=getattr(message, "name", None),
|
|
108
|
+
role=convert_role(message.type),
|
|
109
|
+
template=template,
|
|
110
|
+
formatted=content,
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
|
|
77
114
|
class BaseLangchainCallbackHandler(BaseCallbackHandler):
|
|
78
115
|
# Keep track of the prompt sequence
|
|
79
116
|
prompt_sequence: List[Prompt]
|
|
@@ -244,30 +281,61 @@ def _on_chat_model_start(
|
|
|
244
281
|
**kwargs: Any,
|
|
245
282
|
):
|
|
246
283
|
invocation_params = kwargs.get("invocation_params")
|
|
247
|
-
provider, settings = get_llm_settings(invocation_params)
|
|
284
|
+
provider, settings = get_llm_settings(invocation_params, serialized)
|
|
285
|
+
|
|
286
|
+
formatted_messages = messages[0]
|
|
248
287
|
|
|
249
288
|
if self.current_prompt:
|
|
250
289
|
self.current_prompt.provider = provider
|
|
251
290
|
self.current_prompt.settings = settings
|
|
291
|
+
# Chat mode
|
|
252
292
|
if self.current_prompt.messages:
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
293
|
+
# This is needed to compute the correct message index to read
|
|
294
|
+
placeholder_offset = 0
|
|
295
|
+
# The final list of messages
|
|
296
|
+
prompt_messages = []
|
|
297
|
+
# Looping the messages built in build_prompt
|
|
298
|
+
# They only contain the template
|
|
299
|
+
for templated_index, templated_message in enumerate(
|
|
300
|
+
self.current_prompt.messages
|
|
301
|
+
):
|
|
302
|
+
# If a message has a placeholder size, we need to replace it
|
|
303
|
+
# With the N following messages, where N is the placeholder size
|
|
304
|
+
if templated_message.placeholder_size:
|
|
305
|
+
for _ in range(templated_message.placeholder_size):
|
|
306
|
+
formatted_message = formatted_messages[
|
|
307
|
+
templated_index + placeholder_offset
|
|
308
|
+
]
|
|
309
|
+
prompt_messages += [convert_message(formatted_message)]
|
|
310
|
+
# Increment the placeholder offset
|
|
311
|
+
placeholder_offset += 1
|
|
312
|
+
# Finally, decrement the placeholder offset by one
|
|
313
|
+
# Because the message representing the placeholder is now consumed
|
|
314
|
+
placeholder_offset -= 1
|
|
315
|
+
# The current message is not a placeholder
|
|
316
|
+
else:
|
|
317
|
+
formatted_message = formatted_messages[
|
|
318
|
+
templated_index + placeholder_offset
|
|
319
|
+
]
|
|
320
|
+
# Update the role and formatted value, keep the template
|
|
321
|
+
prompt_messages += [
|
|
322
|
+
convert_message(
|
|
323
|
+
formatted_message, template=templated_message.template
|
|
324
|
+
)
|
|
325
|
+
]
|
|
326
|
+
# Finally set the prompt messages
|
|
327
|
+
self.current_prompt.messages = prompt_messages
|
|
328
|
+
# Non chat mode
|
|
257
329
|
elif self.current_prompt.template:
|
|
258
330
|
unique_message = messages[0][0]
|
|
259
|
-
prompt_message =
|
|
260
|
-
template=self.current_prompt.template
|
|
261
|
-
formatted=unique_message.content,
|
|
262
|
-
role=convert_role(unique_message.type),
|
|
331
|
+
prompt_message = convert_message(
|
|
332
|
+
unique_message, template=self.current_prompt.template
|
|
263
333
|
)
|
|
264
334
|
self.current_prompt.messages = [prompt_message]
|
|
265
335
|
self.current_prompt.template = None
|
|
336
|
+
# No current prompt, create it (formatted only)
|
|
266
337
|
else:
|
|
267
|
-
prompt_messages = [
|
|
268
|
-
PromptMessage(formatted=m.content, role=convert_role(m.type))
|
|
269
|
-
for m in messages[0]
|
|
270
|
-
]
|
|
338
|
+
prompt_messages = [convert_message(m) for m in messages[0]]
|
|
271
339
|
self.prompt_sequence.append(
|
|
272
340
|
Prompt(
|
|
273
341
|
messages=prompt_messages,
|
|
@@ -284,7 +352,7 @@ def _on_llm_start(
|
|
|
284
352
|
**kwargs: Any,
|
|
285
353
|
) -> None:
|
|
286
354
|
invocation_params = kwargs.get("invocation_params")
|
|
287
|
-
provider, settings = get_llm_settings(invocation_params)
|
|
355
|
+
provider, settings = get_llm_settings(invocation_params, serialized)
|
|
288
356
|
|
|
289
357
|
if self.current_prompt:
|
|
290
358
|
self.current_prompt.formatted = prompts[0]
|
chainlit/langflow/__init__.py
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import langflow
|
|
1
|
+
from chainlit.utils import check_module_version
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
LANGFLOW_INSTALLED = True
|
|
10
|
-
except ImportError:
|
|
11
|
-
LANGFLOW_INSTALLED = False
|
|
3
|
+
if not check_module_version("langflow", "0.1.4"):
|
|
4
|
+
raise ValueError(
|
|
5
|
+
"Expected Langflow version >= 0.1.4. Run `pip install langflow --upgrade`"
|
|
6
|
+
)
|
|
12
7
|
|
|
13
8
|
from typing import Dict, Optional, Union
|
|
14
9
|
|
chainlit/llama_index/__init__.py
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import llama_index
|
|
1
|
+
from chainlit.utils import check_module_version
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
LLAMA_INDEX_INSTALLED = True
|
|
10
|
-
except ImportError:
|
|
11
|
-
LLAMA_INDEX_INSTALLED = False
|
|
3
|
+
if not check_module_version("llama_index", "0.8.3"):
|
|
4
|
+
raise ValueError(
|
|
5
|
+
"Expected LlamaIndex version >= 0.8.3. Run `pip install llama_index --upgrade`"
|
|
6
|
+
)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import asyncio
|
|
1
2
|
from typing import Any, Dict, List, Optional
|
|
2
3
|
|
|
3
4
|
from llama_index.callbacks.base import BaseCallbackHandler
|
|
@@ -8,7 +9,6 @@ from chainlit.context import context_var
|
|
|
8
9
|
from chainlit.element import Text
|
|
9
10
|
from chainlit.message import Message
|
|
10
11
|
from chainlit.prompt import Prompt, PromptMessage
|
|
11
|
-
from chainlit.sync import run_sync
|
|
12
12
|
|
|
13
13
|
DEFAULT_IGNORE = [
|
|
14
14
|
CBEventType.CHUNKING,
|
|
@@ -52,17 +52,25 @@ class LlamaIndexCallbackHandler(BaseCallbackHandler):
|
|
|
52
52
|
return root_message.id
|
|
53
53
|
return None
|
|
54
54
|
|
|
55
|
-
def
|
|
55
|
+
def on_event_start(
|
|
56
|
+
self,
|
|
57
|
+
event_type: CBEventType,
|
|
58
|
+
payload: Optional[Dict[str, Any]] = None,
|
|
59
|
+
event_id: str = "",
|
|
60
|
+
**kwargs: Any,
|
|
61
|
+
) -> str:
|
|
56
62
|
"""Run when an event starts and return id of event."""
|
|
57
63
|
self._restore_context()
|
|
58
|
-
|
|
64
|
+
asyncio.run(
|
|
59
65
|
Message(
|
|
60
|
-
author=trace_id or "llama_index",
|
|
61
|
-
parent_id=self._get_parent_id(),
|
|
62
66
|
content="",
|
|
67
|
+
author=event_type,
|
|
68
|
+
parent_id=self._get_parent_id(),
|
|
63
69
|
).send()
|
|
64
70
|
)
|
|
65
71
|
|
|
72
|
+
return event_id
|
|
73
|
+
|
|
66
74
|
def on_event_end(
|
|
67
75
|
self,
|
|
68
76
|
event_type: CBEventType,
|
|
@@ -88,7 +96,7 @@ class LlamaIndexCallbackHandler(BaseCallbackHandler):
|
|
|
88
96
|
)
|
|
89
97
|
content = f"Retrieved the following sources: {source_refs}"
|
|
90
98
|
|
|
91
|
-
|
|
99
|
+
asyncio.run(
|
|
92
100
|
Message(
|
|
93
101
|
content=content,
|
|
94
102
|
author=event_type,
|
|
@@ -119,7 +127,7 @@ class LlamaIndexCallbackHandler(BaseCallbackHandler):
|
|
|
119
127
|
else:
|
|
120
128
|
content = ""
|
|
121
129
|
|
|
122
|
-
|
|
130
|
+
asyncio.run(
|
|
123
131
|
Message(
|
|
124
132
|
content=content,
|
|
125
133
|
author=event_type,
|
|
@@ -135,5 +143,5 @@ class LlamaIndexCallbackHandler(BaseCallbackHandler):
|
|
|
135
143
|
def _noop(self, *args, **kwargs):
|
|
136
144
|
pass
|
|
137
145
|
|
|
138
|
-
|
|
146
|
+
start_trace = _noop
|
|
139
147
|
end_trace = _noop
|
chainlit/message.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import json
|
|
1
2
|
import uuid
|
|
2
3
|
from abc import ABC, abstractmethod
|
|
3
4
|
from datetime import datetime, timezone
|
|
@@ -125,7 +126,7 @@ class Message(MessageBase):
|
|
|
125
126
|
If a project ID is configured, the message will be persisted in the cloud.
|
|
126
127
|
|
|
127
128
|
Args:
|
|
128
|
-
content (str): The content of the message.
|
|
129
|
+
content (Union[str, Dict]): The content of the message.
|
|
129
130
|
author (str, optional): The author of the message, this will be used in the UI. Defaults to the chatbot name (see config).
|
|
130
131
|
prompt (Prompt, optional): The prompt used to generate the message. If provided, enables the prompt playground for this message.
|
|
131
132
|
language (str, optional): Language of the code is the content is code. See https://react-code-blocks-rajinwonderland.vercel.app/?path=/story/codeblock--supported-languages for a list of supported languages.
|
|
@@ -137,7 +138,7 @@ class Message(MessageBase):
|
|
|
137
138
|
|
|
138
139
|
def __init__(
|
|
139
140
|
self,
|
|
140
|
-
content: str,
|
|
141
|
+
content: Union[str, Dict],
|
|
141
142
|
author: str = config.ui.name,
|
|
142
143
|
prompt: Optional[Prompt] = None,
|
|
143
144
|
language: Optional[str] = None,
|
|
@@ -146,10 +147,21 @@ class Message(MessageBase):
|
|
|
146
147
|
actions: Optional[List[Action]] = None,
|
|
147
148
|
elements: Optional[List[ElementBased]] = None,
|
|
148
149
|
):
|
|
149
|
-
self.
|
|
150
|
+
self.language = language
|
|
151
|
+
|
|
152
|
+
if isinstance(content, dict):
|
|
153
|
+
self.content = json.dumps(content, indent=4)
|
|
154
|
+
self.language = "json"
|
|
155
|
+
elif isinstance(content, str):
|
|
156
|
+
self.content = content
|
|
157
|
+
else:
|
|
158
|
+
logger.warn(
|
|
159
|
+
f"Unsupported type {type(content)} for message content. Attempting to stringify it"
|
|
160
|
+
)
|
|
161
|
+
self.content = str(content)
|
|
162
|
+
|
|
150
163
|
self.author = author
|
|
151
164
|
self.prompt = prompt
|
|
152
|
-
self.language = language
|
|
153
165
|
self.parent_id = parent_id
|
|
154
166
|
self.indent = indent
|
|
155
167
|
self.actions = actions if actions is not None else []
|
|
@@ -183,6 +195,7 @@ class Message(MessageBase):
|
|
|
183
195
|
"language": self.language,
|
|
184
196
|
"parentId": self.parent_id,
|
|
185
197
|
"indent": self.indent,
|
|
198
|
+
"streaming": self.streaming,
|
|
186
199
|
}
|
|
187
200
|
|
|
188
201
|
if self.prompt:
|
chainlit/playground/config.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import List
|
|
1
|
+
from typing import Dict, List
|
|
2
2
|
|
|
3
3
|
from chainlit.playground.provider import BaseProvider
|
|
4
4
|
from chainlit.playground.providers import (
|
|
@@ -10,15 +10,17 @@ from chainlit.playground.providers import (
|
|
|
10
10
|
OpenAI,
|
|
11
11
|
)
|
|
12
12
|
|
|
13
|
-
providers =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
providers = {
|
|
14
|
+
AzureChatOpenAI.id: AzureChatOpenAI,
|
|
15
|
+
AzureOpenAI.id: AzureOpenAI,
|
|
16
|
+
ChatOpenAI.id: ChatOpenAI,
|
|
17
|
+
OpenAI.id: OpenAI,
|
|
18
|
+
Anthropic.id: Anthropic,
|
|
19
|
+
} # type: Dict[str, BaseProvider]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def has_llm_provider(id: str):
|
|
23
|
+
return id in providers
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
def add_llm_provider(provider: BaseProvider):
|
|
@@ -26,10 +28,8 @@ def add_llm_provider(provider: BaseProvider):
|
|
|
26
28
|
raise ValueError(
|
|
27
29
|
f"{provider.name} LLM provider requires the following environment variables: {', '.join(provider.env_vars.values())}"
|
|
28
30
|
)
|
|
29
|
-
providers.
|
|
31
|
+
providers[provider.id] = provider
|
|
30
32
|
|
|
31
33
|
|
|
32
34
|
def get_llm_providers():
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return [provider for provider in list if provider.is_configured()]
|
|
35
|
+
return [provider for provider in providers.values() if provider.is_configured()]
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
1
3
|
from fastapi import HTTPException
|
|
2
4
|
from fastapi.responses import StreamingResponse
|
|
3
5
|
from pydantic.dataclasses import dataclass
|
|
@@ -9,7 +11,7 @@ from chainlit.sync import make_async
|
|
|
9
11
|
|
|
10
12
|
@dataclass
|
|
11
13
|
class BaseHuggingFaceProvider(BaseProvider):
|
|
12
|
-
repo_id: str
|
|
14
|
+
repo_id: Optional[str] = None
|
|
13
15
|
task = "text2text-generation"
|
|
14
16
|
|
|
15
17
|
async def create_completion(self, request):
|