-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchunk-JDU6QR2W.js
More file actions
1 lines (1 loc) · 874 Bytes
/
chunk-JDU6QR2W.js
File metadata and controls
1 lines (1 loc) · 874 Bytes
1
import{a as g}from"./chunk-7HJH2R4C.js";import{Ba as u,Vc as a}from"./chunk-VI5VUYIC.js";import{a as o,b as r}from"./chunk-OW75ZOQB.js";var c=0,p=class{config;requestingMap=u({});isRequesting=a(()=>Object.keys(this.requestingMap()).length>0);constructor(t){this.config=t}finishRequest(t){this.requestingMap.update(n=>{let i=o({},n);return delete i[t],i})}request=(t,n,i)=>{let{request:h=g({baseURL:this.config.baseURL,model:this.config.model,dangerouslyApiKey:this.config.dangerouslyApiKey}).create}=this.config,{onUpdate:q,onSuccess:d,onError:f,onStream:M}=n,s=c;c+=1,this.requestingMap.update(e=>r(o({},e),{[s]:!0})),h?.(t,{onStream:e=>{this.requestingMap()[s]&&M?.(e)},onUpdate:e=>{this.requestingMap()[s]&&q(e)},onSuccess:e=>{this.requestingMap()[s]&&(d(e),this.finishRequest(s))},onError:e=>{this.requestingMap()[s]&&(f(e),this.finishRequest(s))}},i)}};export{p as a};