librechat-data-provider 0.6.2 → 0.6.3
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.
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react-query/index.es.js +1 -1
- package/dist/react-query/index.es.js.map +1 -1
- package/package.json +1 -1
- package/src/config.ts +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{z as e,ZodArray as t,ZodIssueCode as n,ZodError as o}from"zod";import i from"axios";import{URL as a}from"url";import r from"crypto";import{load as s}from"js-yaml";var l,u,p,c,d,m,f,g,h=function(){return h=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},h.apply(this,arguments)};function v(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function b(e,t,n,o){return new(n||(n=Promise))((function(i,a){function r(e){try{l(o.next(e))}catch(e){a(e)}}function s(e){try{l(o.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,s)}l((o=o.apply(e,t||[])).next())}))}function y(e,t){var n,o,i,a,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(r=0)),r;)try{if(n=1,o&&(i=2&s[0]?o.return:s[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;switch(o=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return r.label++,{value:s[1],done:!1};case 5:r.label++,o=s[1],s=[0];continue;case 7:s=r.ops.pop(),r.trys.pop();continue;default:if(!(i=r.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){r=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){r.label=s[1];break}if(6===s[0]&&r.label<i[1]){r.label=i[1],i=s;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(s);break}i[2]&&r.ops.pop(),r.trys.pop();continue}s=t.call(e,r)}catch(e){s=[6,e],o=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function x(e,t,n){if(n||2===arguments.length)for(var o,i=0,a=t.length;i<a;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError,function(e){e.code_interpreter="code_interpreter",e.retrieval="retrieval",e.function="function"}(l||(l={})),function(e){e.FILE_CITATION="file_citation",e.FILE_PATH="file_path"}(u||(u={})),function(e){e.TEXT="text",e.TOOL_CALL="tool_call",e.IMAGE_FILE="image_file",e.ERROR="error"}(p||(p={})),function(e){e.TOOL_CALLS="tool_calls",e.MESSAGE_CREATION="message_creation"}(c||(c={})),function(e){e.FUNCTION="function",e.RETRIEVAL="retrieval",e.CODE_INTERPRETER="code_interpreter"}(d||(d={})),function(e){e.IN_PROGRESS="in_progress",e.CANCELLED="cancelled",e.FAILED="failed",e.COMPLETED="completed",e.EXPIRED="expired"}(m||(m={})),function(e){e.TEXT="text",e.IMAGE_FILE="image_file"}(f||(f={})),function(e){e.QUEUED="queued",e.IN_PROGRESS="in_progress",e.REQUIRES_ACTION="requires_action",e.CANCELLING="cancelling",e.CANCELLED="cancelled",e.FAILED="failed",e.COMPLETED="completed",e.EXPIRED="expired"}(g||(g={}));var _,T,E,I,O="_action_",A="---",k="_host_copy",L="host_copy_";!function(e){e.ServiceHttp="service_http",e.OAuth="oauth",e.None="none"}(_||(_={})),function(e){e.Bearer="bearer",e.Basic="basic",e.Custom="custom"}(T||(T={})),function(e){e.DefaultPost="default_post",e.BasicAuthHeader="basic_auth_header"}(E||(E={})),function(e){e.FineTune="fine-tune",e.FineTuneResults="fine-tune-results",e.Assistants="assistants",e.AssistantsOutput="assistants_output"}(I||(I={}));var P,S,C,w,N={order:"desc",limit:100};!function(e){e.ThreadCreated="thread.created",e.ThreadRunCreated="thread.run.created",e.ThreadRunQueued="thread.run.queued",e.ThreadRunInProgress="thread.run.in_progress",e.ThreadRunRequiresAction="thread.run.requires_action",e.ThreadRunCompleted="thread.run.completed",e.ThreadRunFailed="thread.run.failed",e.ThreadRunCancelling="thread.run.cancelling",e.ThreadRunCancelled="thread.run.cancelled",e.ThreadRunExpired="thread.run.expired",e.ThreadRunStepCreated="thread.run.step.created",e.ThreadRunStepInProgress="thread.run.step.in_progress",e.ThreadRunStepCompleted="thread.run.step.completed",e.ThreadRunStepFailed="thread.run.step.failed",e.ThreadRunStepCancelled="thread.run.step.cancelled",e.ThreadRunStepExpired="thread.run.step.expired",e.ThreadRunStepDelta="thread.run.step.delta",e.ThreadMessageCreated="thread.message.created",e.ThreadMessageInProgress="thread.message.in_progress",e.ThreadMessageCompleted="thread.message.completed",e.ThreadMessageIncomplete="thread.message.incomplete",e.ThreadMessageDelta="thread.message.delta",e.ErrorEvent="error"}(P||(P={}));var R,M=e.string().uuid();!function(e){e.OVERRIDE_AUTH="override_auth",e.USER_PROVIDED="user_provided",e.SYSTEM_DEFINED="SYSTEM_DEFINED"}(R||(R={}));var j,U,G=e.nativeEnum(R);!function(e){e.azureOpenAI="azureOpenAI",e.openAI="openAI",e.bingAI="bingAI",e.chatGPTBrowser="chatGPTBrowser",e.google="google",e.gptPlugins="gptPlugins",e.anthropic="anthropic",e.assistants="assistants",e.custom="custom"}(j||(j={})),function(e){e.low="low",e.auto="auto",e.high="high"}(U||(U={}));var D,z=((S={})[U.low]=0,S[U.auto]=1,S[U.high]=2,S),F={0:U.low,1:U.auto,2:U.high},q=e.nativeEnum(U),B={assistant:"",id:"",name:"",description:"",instructions:"",model:"",functions:[],code_interpreter:!1,image_vision:!1,retrieval:!1},K=((C={type:l.function})[l.function]={name:"image_vision",description:"Get detailed text descriptions for all current image attachments.",parameters:{type:"object",properties:{},required:[]}},C),H=function(e){var t,n;return"function"===e.type&&(null===(t=e.function)||void 0===t?void 0:t.name)===(null===(n=null==K?void 0:K.function)||void 0===n?void 0:n.name)},V={model:{default:"gpt-3.5-turbo"},temperature:{min:0,max:1,step:.01,default:1},top_p:{min:0,max:1,step:.01,default:1},presence_penalty:{min:0,max:2,step:.01,default:0},frequency_penalty:{min:0,max:2,step:.01,default:0},resendFiles:{default:!0},maxContextTokens:{default:void 0},max_tokens:{default:void 0},imageDetail:{default:U.auto}},Y={model:{default:"chat-bison"},maxOutputTokens:{min:1,max:2048,step:1,default:1024,maxGemini:8192,defaultGemini:8192},temperature:{min:0,max:1,step:.01,default:.2},topP:{min:0,max:1,step:.01,default:.8},topK:{min:1,max:40,step:.01,default:40}},$=((w={})[j.openAI]=V,w[j.google]=Y,w),Z=$[j.google],Q=e.nativeEnum(j),W=e.union([Q,e.string()]),X=e.object({authField:e.string(),label:e.string(),description:e.string()}),J=e.object({name:e.string(),pluginKey:e.string(),description:e.string(),icon:e.string(),authConfig:e.array(X),authenticated:e.boolean().optional(),isButton:e.boolean().optional()}),ee=e.object({input:e.object({content:e.string()}),output:e.object({content:e.string()})});!function(e){e.functions="functions",e.classic="classic"}(D||(D={}));var te={model:{default:"gpt-4-turbo"},temperature:{min:0,max:1,step:.01,default:0},agent:{default:D.functions,options:[D.functions,D.classic]},skipCompletion:{default:!0}},ne=e.nativeEnum(D),oe=e.object({agent:e.string().default(D.functions),skipCompletion:e.boolean().default(te.skipCompletion.default),model:e.string(),temperature:e.number().default(te.temperature.default)}),ie=e.object({messageId:e.string(),endpoint:e.string().optional(),clientId:e.string().nullable().optional(),conversationId:e.string().nullable(),parentMessageId:e.string().nullable(),responseMessageId:e.string().nullable().optional(),overrideParentMessageId:e.string().nullable().optional(),bg:e.string().nullable().optional(),model:e.string().nullable().optional(),title:e.string().nullable().or(e.literal("New Chat")).default("New Chat"),sender:e.string(),text:e.string(),generation:e.string().nullable().optional(),isEdited:e.boolean().optional(),isCreatedByUser:e.boolean(),error:e.boolean(),createdAt:e.string().optional().default((function(){return(new Date).toISOString()})),updatedAt:e.string().optional().default((function(){return(new Date).toISOString()})),current:e.boolean().optional(),unfinished:e.boolean().optional(),searchResult:e.boolean().optional(),finish_reason:e.string().optional(),thread_id:e.string().optional(),iconURL:e.string().optional()}),ae=e.union([e.number(),e.string()]).transform((function(e){return"string"==typeof e?""===e.trim()?void 0:parseFloat(e):e})),re=e.object({conversationId:e.string().nullable(),title:e.string().nullable().or(e.literal("New Chat")).default("New Chat"),user:e.string().optional(),endpoint:Q.nullable(),endpointType:Q.optional(),suggestions:e.array(e.string()).optional(),messages:e.array(e.string()).optional(),tools:e.union([e.array(J),e.array(e.string())]).optional(),createdAt:e.string(),updatedAt:e.string(),systemMessage:e.string().nullable().optional(),modelLabel:e.string().nullable().optional(),examples:e.array(ee).optional(),chatGptLabel:e.string().nullable().optional(),userLabel:e.string().optional(),model:e.string().nullable().optional(),promptPrefix:e.string().nullable().optional(),temperature:e.number().optional(),topP:e.number().optional(),topK:e.number().optional(),context:e.string().nullable().optional(),top_p:e.number().optional(),frequency_penalty:e.number().optional(),presence_penalty:e.number().optional(),jailbreak:e.boolean().optional(),jailbreakConversationId:e.string().nullable().optional(),conversationSignature:e.string().nullable().optional(),parentMessageId:e.string().optional(),clientId:e.string().nullable().optional(),invocationId:e.number().nullable().optional(),toneStyle:e.string().nullable().optional(),maxOutputTokens:e.number().optional(),agentOptions:oe.nullable().optional(),file_ids:e.array(e.string()).optional(),maxContextTokens:ae.optional(),max_tokens:ae.optional(),resendImages:e.boolean().optional(),resendFiles:e.boolean().optional(),imageDetail:q.optional(),assistant_id:e.string().optional(),instructions:e.string().optional(),presetOverride:e.record(e.unknown()).optional(),stop:e.array(e.string()).optional(),iconURL:e.string().optional(),greeting:e.string().optional(),spec:e.string().optional()}),se=re.omit({conversationId:!0,createdAt:!0,updatedAt:!0,title:!0}).merge(e.object({conversationId:e.string().nullable().optional(),presetId:e.string().nullable().optional(),title:e.string().nullable().optional(),defaultPreset:e.boolean().optional(),order:e.number().optional(),endpoint:W.nullable()})),le=re.merge(e.object({endpoint:W.nullable()})),ue=re.merge(e.object({endpoint:W.nullable()})),pe=re.pick({model:!0,modelLabel:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,resendFiles:!0,imageDetail:!0,stop:!0,iconURL:!0,greeting:!0,spec:!0,maxContextTokens:!0,max_tokens:!0}).transform((function(e){var t,n,o,i,a,r,s,l,u,p,c,d,m,f,g;return h(h({},e),{model:null!==(t=e.model)&&void 0!==t?t:V.model.default,chatGptLabel:null!==(o=null!==(n=e.modelLabel)&&void 0!==n?n:e.chatGptLabel)&&void 0!==o?o:null,promptPrefix:null!==(i=e.promptPrefix)&&void 0!==i?i:null,temperature:null!==(a=e.temperature)&&void 0!==a?a:V.temperature.default,top_p:null!==(r=e.top_p)&&void 0!==r?r:V.top_p.default,presence_penalty:null!==(s=e.presence_penalty)&&void 0!==s?s:V.presence_penalty.default,frequency_penalty:null!==(l=e.frequency_penalty)&&void 0!==l?l:V.frequency_penalty.default,resendFiles:"boolean"==typeof e.resendFiles?e.resendFiles:V.resendFiles.default,imageDetail:null!==(u=e.imageDetail)&&void 0!==u?u:V.imageDetail.default,stop:null!==(p=e.stop)&&void 0!==p?p:void 0,iconURL:null!==(c=e.iconURL)&&void 0!==c?c:void 0,greeting:null!==(d=e.greeting)&&void 0!==d?d:void 0,spec:null!==(m=e.spec)&&void 0!==m?m:void 0,maxContextTokens:null!==(f=e.maxContextTokens)&&void 0!==f?f:void 0,max_tokens:null!==(g=e.max_tokens)&&void 0!==g?g:void 0})})).catch((function(){return{model:V.model.default,chatGptLabel:null,promptPrefix:null,temperature:V.temperature.default,top_p:V.top_p.default,presence_penalty:V.presence_penalty.default,frequency_penalty:V.frequency_penalty.default,resendFiles:V.resendFiles.default,imageDetail:V.imageDetail.default,stop:void 0,iconURL:void 0,greeting:void 0,spec:void 0,maxContextTokens:void 0,max_tokens:void 0}})),ce=re.pick({model:!0,modelLabel:!0,promptPrefix:!0,examples:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0,iconURL:!0,greeting:!0,spec:!0,maxContextTokens:!0}).transform((function(e){var t,n,o,i,a,r,s,l,u,p,c,d,m,f,g=null===(n=null===(t=null==e?void 0:e.model)||void 0===t?void 0:t.toLowerCase())||void 0===n?void 0:n.includes("gemini"),v=g?Z.maxOutputTokens.maxGemini:Z.maxOutputTokens.max,b=g?Z.maxOutputTokens.defaultGemini:Z.maxOutputTokens.default,y=null!==(o=e.maxOutputTokens)&&void 0!==o?o:b;return y=Math.min(y,v),h(h({},e),{model:null!==(i=e.model)&&void 0!==i?i:Z.model.default,modelLabel:null!==(a=e.modelLabel)&&void 0!==a?a:null,promptPrefix:null!==(r=e.promptPrefix)&&void 0!==r?r:null,examples:null!==(s=e.examples)&&void 0!==s?s:[{input:{content:""},output:{content:""}}],temperature:null!==(l=e.temperature)&&void 0!==l?l:Z.temperature.default,maxOutputTokens:y,topP:null!==(u=e.topP)&&void 0!==u?u:Z.topP.default,topK:null!==(p=e.topK)&&void 0!==p?p:Z.topK.default,iconURL:null!==(c=e.iconURL)&&void 0!==c?c:void 0,greeting:null!==(d=e.greeting)&&void 0!==d?d:void 0,spec:null!==(m=e.spec)&&void 0!==m?m:void 0,maxContextTokens:null!==(f=e.maxContextTokens)&&void 0!==f?f:void 0})})).catch((function(){return{model:Z.model.default,modelLabel:null,promptPrefix:null,examples:[{input:{content:""},output:{content:""}}],temperature:Z.temperature.default,maxOutputTokens:Z.maxOutputTokens.default,topP:Z.topP.default,topK:Z.topK.default,iconURL:void 0,greeting:void 0,spec:void 0,maxContextTokens:void 0}})),de=re.pick({jailbreak:!0,systemMessage:!0,context:!0,toneStyle:!0,jailbreakConversationId:!0,conversationSignature:!0,clientId:!0,invocationId:!0}).transform((function(e){var t,n,o,i,a,r,s,l;return h(h({},e),{model:"",jailbreak:null!==(t=e.jailbreak)&&void 0!==t&&t,systemMessage:null!==(n=e.systemMessage)&&void 0!==n?n:null,context:null!==(o=e.context)&&void 0!==o?o:null,toneStyle:null!==(i=e.toneStyle)&&void 0!==i?i:"creative",jailbreakConversationId:null!==(a=e.jailbreakConversationId)&&void 0!==a?a:null,conversationSignature:null!==(r=e.conversationSignature)&&void 0!==r?r:null,clientId:null!==(s=e.clientId)&&void 0!==s?s:null,invocationId:null!==(l=e.invocationId)&&void 0!==l?l:1})})).catch((function(){return{model:"",jailbreak:!1,systemMessage:null,context:null,toneStyle:"creative",jailbreakConversationId:null,conversationSignature:null,clientId:null,invocationId:1}})),me=re.pick({model:!0,modelLabel:!0,promptPrefix:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0,resendFiles:!0,iconURL:!0,greeting:!0,spec:!0,maxContextTokens:!0}).transform((function(e){var t,n,o,i,a,r,s,l,u,p,c;return h(h({},e),{model:null!==(t=e.model)&&void 0!==t?t:"claude-1",modelLabel:null!==(n=e.modelLabel)&&void 0!==n?n:null,promptPrefix:null!==(o=e.promptPrefix)&&void 0!==o?o:null,temperature:null!==(i=e.temperature)&&void 0!==i?i:1,maxOutputTokens:null!==(a=e.maxOutputTokens)&&void 0!==a?a:4e3,topP:null!==(r=e.topP)&&void 0!==r?r:.7,topK:null!==(s=e.topK)&&void 0!==s?s:5,resendFiles:"boolean"!=typeof e.resendFiles||e.resendFiles,iconURL:null!==(l=e.iconURL)&&void 0!==l?l:void 0,greeting:null!==(u=e.greeting)&&void 0!==u?u:void 0,spec:null!==(p=e.spec)&&void 0!==p?p:void 0,maxContextTokens:null!==(c=e.maxContextTokens)&&void 0!==c?c:void 0})})).catch((function(){return{model:"claude-1",modelLabel:null,promptPrefix:null,temperature:1,maxOutputTokens:4e3,topP:.7,topK:5,resendFiles:!0,iconURL:void 0,greeting:void 0,spec:void 0,maxContextTokens:void 0}})),fe=re.pick({model:!0}).transform((function(e){var t;return h(h({},e),{model:null!==(t=e.model)&&void 0!==t?t:"text-davinci-002-render-sha"})})).catch((function(){return{model:"text-davinci-002-render-sha"}})),ge=re.pick({model:!0,modelLabel:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,tools:!0,agentOptions:!0,iconURL:!0,greeting:!0,spec:!0,maxContextTokens:!0}).transform((function(e){var t,n,o,i,a,r,s,l,u,p,c,d,m,f;return h(h({},e),{model:null!==(t=e.model)&&void 0!==t?t:"gpt-3.5-turbo",chatGptLabel:null!==(o=null!==(n=e.modelLabel)&&void 0!==n?n:e.chatGptLabel)&&void 0!==o?o:null,promptPrefix:null!==(i=e.promptPrefix)&&void 0!==i?i:null,temperature:null!==(a=e.temperature)&&void 0!==a?a:.8,top_p:null!==(r=e.top_p)&&void 0!==r?r:1,presence_penalty:null!==(s=e.presence_penalty)&&void 0!==s?s:0,frequency_penalty:null!==(l=e.frequency_penalty)&&void 0!==l?l:0,tools:null!==(u=e.tools)&&void 0!==u?u:[],agentOptions:null!==(p=e.agentOptions)&&void 0!==p?p:{agent:D.functions,skipCompletion:!0,model:"gpt-3.5-turbo",temperature:0},iconURL:null!==(c=e.iconURL)&&void 0!==c?c:void 0,greeting:null!==(d=e.greeting)&&void 0!==d?d:void 0,spec:null!==(m=e.spec)&&void 0!==m?m:void 0,maxContextTokens:null!==(f=e.maxContextTokens)&&void 0!==f?f:void 0})})).catch((function(){return{model:"gpt-3.5-turbo",chatGptLabel:null,promptPrefix:null,temperature:.8,top_p:1,presence_penalty:0,frequency_penalty:0,tools:[],agentOptions:{agent:D.functions,skipCompletion:!0,model:"gpt-3.5-turbo",temperature:0},iconURL:void 0,greeting:void 0,spec:void 0,maxContextTokens:void 0}}));function he(e){var t=h({},e);return Object.keys(t).forEach((function(e){void 0!==t[e]&&null!==t[e]&&""!==t[e]||delete t[e]})),t}var ve,be,ye=re.pick({model:!0,assistant_id:!0,instructions:!0,promptPrefix:!0,iconURL:!0,greeting:!0,spec:!0}).transform((function(e){var t,n,o,i,a,r,s;return h(h({},e),{model:null!==(t=e.model)&&void 0!==t?t:V.model.default,assistant_id:null!==(n=e.assistant_id)&&void 0!==n?n:void 0,instructions:null!==(o=e.instructions)&&void 0!==o?o:void 0,promptPrefix:null!==(i=e.promptPrefix)&&void 0!==i?i:null,iconURL:null!==(a=e.iconURL)&&void 0!==a?a:void 0,greeting:null!==(r=e.greeting)&&void 0!==r?r:void 0,spec:null!==(s=e.spec)&&void 0!==s?s:void 0})})).catch((function(){return{model:V.model.default,assistant_id:void 0,instructions:void 0,promptPrefix:null,iconURL:void 0,greeting:void 0,spec:void 0}})),xe=re.pick({model:!0,assistant_id:!0,instructions:!0,promptPrefix:!0,iconURL:!0,greeting:!0,spec:!0}).transform(he).catch((function(){return{}})),_e=re.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,resendFiles:!0,imageDetail:!0,stop:!0,iconURL:!0,greeting:!0,spec:!0,maxContextTokens:!0,max_tokens:!0}).transform((function(e){var t=h({},e);return 1===t.temperature&&delete t.temperature,1===t.top_p&&delete t.top_p,0===t.presence_penalty&&delete t.presence_penalty,0===t.frequency_penalty&&delete t.frequency_penalty,!0===t.resendFiles&&delete t.resendFiles,t.imageDetail===U.auto&&delete t.imageDetail,he(t)})).catch((function(){return{}})),Te=re.pick({model:!0,modelLabel:!0,promptPrefix:!0,examples:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0,iconURL:!0,greeting:!0,spec:!0,maxContextTokens:!0}).transform((function(e){var t=h({},e);return t.temperature===Z.temperature.default&&delete t.temperature,t.maxOutputTokens===Z.maxOutputTokens.default&&delete t.maxOutputTokens,t.topP===Z.topP.default&&delete t.topP,t.topK===Z.topK.default&&delete t.topK,he(t)})).catch((function(){return{}})),Ee=re.pick({model:!0,modelLabel:!0,promptPrefix:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0,resendFiles:!0,iconURL:!0,greeting:!0,spec:!0,maxContextTokens:!0}).transform((function(e){var t=h({},e);return 1===t.temperature&&delete t.temperature,4e3===t.maxOutputTokens&&delete t.maxOutputTokens,.7===t.topP&&delete t.topP,5===t.topK&&delete t.topK,!0===t.resendFiles&&delete t.resendFiles,he(t)})).catch((function(){return{}})),Ie=re.pick({model:!0}).transform((function(e){return he(h({},e))})).catch((function(){return{}})),Oe=re.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,tools:!0,agentOptions:!0,iconURL:!0,greeting:!0,spec:!0,maxContextTokens:!0}).transform((function(e){var t,n=h({},e);return null===n.chatGptLabel&&delete n.chatGptLabel,null===n.promptPrefix&&delete n.promptPrefix,.8===n.temperature&&delete n.temperature,1===n.top_p&&delete n.top_p,0===n.presence_penalty&&delete n.presence_penalty,0===n.frequency_penalty&&delete n.frequency_penalty,0===(null===(t=n.tools)||void 0===t?void 0:t.length)&&delete n.tools,n.agentOptions&&n.agentOptions.agent===D.functions&&!0===n.agentOptions.skipCompletion&&"gpt-3.5-turbo"===n.agentOptions.model&&0===n.agentOptions.temperature&&delete n.agentOptions,he(n)})).catch((function(){return{}})),Ae=((ve={})[j.openAI]=!0,ve[j.google]=!0,ve[j.assistants]=!0,ve[j.azureOpenAI]=!0,ve[j.anthropic]=!0,ve[j.custom]=!0,ve),ke=["application/vnd.ms-excel","application/msexcel","application/x-msexcel","application/x-ms-excel","application/x-excel","application/x-dos_ms_excel","application/xls","application/x-xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],Le=x(["text/x-c","text/x-c++","application/csv","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/html","text/x-java","application/json","text/markdown","application/pdf","text/x-php","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/x-python","text/x-script.python","text/x-ruby","text/x-tex","text/plain","text/css","image/jpeg","text/javascript","image/gif","image/png","application/x-tar","application/typescript","application/xml","application/zip"],ke,!0),Pe=x(["text/x-c","text/x-c++","application/csv","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/html","text/x-java","application/json","text/markdown","application/pdf","text/x-php","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/x-python","text/x-script.python","text/x-ruby","text/x-tex","text/plain","text/css","image/jpeg","text/javascript","image/gif","image/png","application/x-tar","application/typescript","application/xml","application/zip"],ke,!0),Se=["text/x-c","text/x-c++","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/html","text/x-java","application/json","text/markdown","application/pdf","text/x-php","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/x-python","text/x-script.python","text/x-ruby","text/x-tex","text/plain"],Ce=/\.(jpg|jpeg|png|gif|webp)$/i,we=/^application\/(vnd\.ms-excel|msexcel|x-msexcel|x-ms-excel|x-excel|x-dos_ms_excel|xls|x-xls|vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet)$/,Ne=/^(text\/(x-c|x-c\+\+|x-java|html|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|css|javascript|csv))$/,Re=/^(application\/(epub\+zip|csv|json|pdf|x-tar|typescript|vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation|spreadsheetml\.sheet)|xml|zip))$/,Me=/^image\/(jpeg|gif|png|webp)$/,je=[Ne,we,Re,Me],Ue=[Ne,we,Re,Me],Ge={c:"text/x-c",cs:"text/x-csharp",cpp:"text/x-c++",md:"text/markdown",php:"text/x-php",py:"text/x-python",rb:"text/x-ruby",tex:"text/x-tex",js:"text/javascript",sh:"application/x-sh",ts:"application/typescript",tar:"application/x-tar",zip:"application/zip"},De=[/^(text\/(x-c|x-c\+\+|html|x-java|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|xml))$/,/^(application\/(json|pdf|vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation)))$/],ze=1048576,Fe=function(e){return e*ze},qe={endpoints:(be={},be[j.assistants]={fileLimit:10,fileSizeLimit:Fe(512),totalSizeLimit:Fe(512),supportedMimeTypes:je,disabled:!1},be.default={fileLimit:10,fileSizeLimit:Fe(512),totalSizeLimit:Fe(512),supportedMimeTypes:je,disabled:!1},be),serverFileSizeLimit:Fe(512),avatarSizeLimit:Fe(2),checkType:function(e,t){return void 0===t&&(t=je),t.some((function(t){return t.test(e)}))}},Be=e.array(e.any()).optional().refine((function(e){return!e||e.every((function(e){return e instanceof RegExp||"string"==typeof e}))}),{message:"Each mimeType must be a string or a RegExp object."}),Ke=e.object({disabled:e.boolean().optional(),fileLimit:e.number().min(0).optional(),fileSizeLimit:e.number().min(0).optional(),totalSizeLimit:e.number().min(0).optional(),supportedMimeTypes:Be.optional()}),He=e.object({endpoints:e.record(Ke).optional(),serverFileSizeLimit:e.number().min(0).optional(),avatarSizeLimit:e.number().min(0).optional()}),Ve=function(e){return e.reduce((function(e,t){try{var n=new RegExp(t);e.push(n)}catch(e){console.error('Invalid regex pattern "'.concat(t,'" skipped.'))}return e}),[])};function Ye(e){var t=qe;if(!e)return t;if(void 0!==e.serverFileSizeLimit&&(t.serverFileSizeLimit=Fe(e.serverFileSizeLimit)),void 0!==e.avatarSizeLimit&&(t.avatarSizeLimit=Fe(e.avatarSizeLimit)),!e.endpoints)return t;var n=function(n){var o=e.endpoints[n];t.endpoints[n]||(t.endpoints[n]={});var i=t.endpoints[n];if(!0===o.disabled)return i.disabled=!0,i.fileLimit=0,i.fileSizeLimit=0,i.totalSizeLimit=0,i.supportedMimeTypes=[],"continue";void 0!==o.fileSizeLimit&&(i.fileSizeLimit=Fe(o.fileSizeLimit)),void 0!==o.totalSizeLimit&&(i.totalSizeLimit=Fe(o.totalSizeLimit));["fileLimit"].forEach((function(e){void 0!==o[e]&&(i[e]=o[e])})),o.supportedMimeTypes&&(i.supportedMimeTypes=Ve(o.supportedMimeTypes))};for(var o in e.endpoints)n(o);return t}var $e,Ze,Qe,We,Xe,Je,et,tt,nt=e.object({name:e.string(),label:e.string(),preset:se,order:e.number().optional(),default:e.boolean().optional(),description:e.string().optional(),showIconInMenu:e.boolean().optional(),showIconInHeader:e.boolean().optional(),iconURL:e.union([e.string(),Q]).optional(),authType:G.optional()}),ot=e.object({enforce:e.boolean().default(!1),prioritize:e.boolean().default(!0),list:e.array(nt).optional()});!function(e){e.local="local",e.firebase="firebase",e.openai="openai",e.s3="s3",e.vectordb="vectordb"}($e||($e={})),function(e){e.avatar="avatar",e.unknown="unknown",e.assistants="assistants",e.image_generation="image_generation",e.assistants_output="assistants_output",e.message_attachment="message_attachment",e.filename="filename",e.updatedAt="updatedAt",e.source="source",e.context="context",e.bytes="bytes"}(Ze||(Ze={}));var it,at=["google","facebook","openid","github","discord"],rt=["gpt-4-turbo-preview","gpt-3.5-turbo-0125","gpt-4-0125-preview","gpt-4-1106-preview","gpt-3.5-turbo-1106","gpt-3.5-turbo-0125","gpt-4-turbo","gpt-4-0125","gpt-4-1106"];!function(e){e.default="default",e.advanced="advanced"}(it||(it={}));var st=e.nativeEnum($e);function lt(t){var n=t.shape,o=Object.entries(n).map((function(t){var n=t[0],o=t[1];return o instanceof e.ZodDefault?[n,o._def.defaultValue()]:[n,void 0]}));return Object.fromEntries(o)}var ut,pt=e.object({deploymentName:e.string().optional(),version:e.string().optional(),assistants:e.boolean().optional()}).or(e.boolean()),ct=e.object({apiKey:e.string(),serverless:e.boolean().optional(),instanceName:e.string().optional(),deploymentName:e.string().optional(),assistants:e.boolean().optional(),addParams:e.record(e.any()).optional(),dropParams:e.array(e.string()).optional(),forcePrompt:e.boolean().optional(),version:e.string().optional(),baseURL:e.string().optional(),additionalHeaders:e.record(e.any()).optional()}),dt=e.object({group:e.string(),models:e.record(e.string(),pt)}).required().and(ct),mt=e.array(dt).min(1);!function(e){e.code_interpreter="code_interpreter",e.image_vision="image_vision",e.retrieval="retrieval",e.actions="actions",e.tools="tools"}(ut||(ut={}));var ft,gt=e.object({disableBuilder:e.boolean().optional(),pollIntervalMs:e.number().optional(),timeoutMs:e.number().optional(),supportedIds:e.array(e.string()).min(1).optional(),excludedIds:e.array(e.string()).min(1).optional(),retrievalModels:e.array(e.string()).min(1).optional().default(rt),capabilities:e.array(e.nativeEnum(ut)).optional().default([ut.code_interpreter,ut.image_vision,ut.retrieval,ut.actions,ut.tools]),apiKey:e.string().optional(),baseURL:e.string().optional(),models:e.object({default:e.array(e.string()).min(1),fetch:e.boolean().optional(),userIdQuery:e.boolean().optional()}).optional(),titleConvo:e.boolean().optional(),titleMethod:e.union([e.literal("completion"),e.literal("functions")]).optional(),titleModel:e.string().optional(),headers:e.record(e.any()).optional()}),ht=e.object({name:e.string().refine((function(e){return!Q.safeParse(e).success}),{message:"Value cannot be one of the default endpoint (EModelEndpoint) values: ".concat(Object.values(j).join(", "))}),apiKey:e.string(),baseURL:e.string(),models:e.object({default:e.array(e.string()).min(1),fetch:e.boolean().optional(),userIdQuery:e.boolean().optional()}),titleConvo:e.boolean().optional(),titleMethod:e.union([e.literal("completion"),e.literal("functions")]).optional(),titleModel:e.string().optional(),summarize:e.boolean().optional(),summaryModel:e.string().optional(),forcePrompt:e.boolean().optional(),modelDisplayLabel:e.string().optional(),headers:e.record(e.any()).optional(),addParams:e.record(e.any()).optional(),dropParams:e.array(e.string()).optional(),customOrder:e.number().optional()}),vt=e.object({groups:mt,plugins:e.boolean().optional(),assistants:e.boolean().optional()}).and(ht.pick({titleConvo:!0,titleMethod:!0,titleModel:!0,summarize:!0,summaryModel:!0,customOrder:!0}).partial()),bt=e.object({fileUploads:e.object({ipMax:e.number().optional(),ipWindowInMinutes:e.number().optional(),userMax:e.number().optional(),userWindowInMinutes:e.number().optional()}).optional(),conversationsImport:e.object({ipMax:e.number().optional(),ipWindowInMinutes:e.number().optional(),userMax:e.number().optional(),userWindowInMinutes:e.number().optional()}).optional()});!function(e){e.PNG="png",e.WEBP="webp",e.JPEG="jpeg"}(ft||(ft={}));var yt,xt,_t=e.object({version:e.string(),cache:e.boolean().default(!0),secureImageLinks:e.boolean().optional(),imageOutputType:e.nativeEnum(ft).default(ft.PNG),filteredTools:e.array(e.string()).optional(),interface:e.object({privacyPolicy:e.object({externalUrl:e.string().optional(),openNewTab:e.boolean().optional()}).optional(),termsOfService:e.object({externalUrl:e.string().optional(),openNewTab:e.boolean().optional()}).optional(),endpointsMenu:e.boolean().optional(),modelSelect:e.boolean().optional(),parameters:e.boolean().optional(),sidePanel:e.boolean().optional(),presets:e.boolean().optional()}).default({endpointsMenu:!0,modelSelect:!0,parameters:!0,sidePanel:!0,presets:!0}),fileStrategy:st.default($e.local),registration:e.object({socialLogins:e.array(e.string()).optional(),allowedDomains:e.array(e.string()).optional()}).default({socialLogins:at}),rateLimits:bt.optional(),fileConfig:He.optional(),modelSpecs:ot.optional(),endpoints:e.object((Qe={},Qe[j.azureOpenAI]=vt.optional(),Qe[j.assistants]=gt.optional(),Qe.custom=e.array(ht.partial()).optional(),Qe)).strict().refine((function(e){return Object.keys(e).length>0}),{message:"At least one `endpoints` field must be provided."}).optional()}),Tt=function(){return lt(_t)};!function(e){e.anyscale="anyscale",e.apipie="apipie",e.cohere="cohere",e.fireworks="fireworks",e.groq="groq",e.huggingface="huggingface",e.mistral="mistral",e.mlx="mlx",e.ollama="ollama",e.openrouter="openrouter",e.perplexity="perplexity",e.shuttleai="shuttleai",e["together.ai"]="together.ai"}(yt||(yt={})),function(e){e.openrouter="openrouter"}(xt||(xt={}));var Et,It=[j.openAI,j.assistants,j.azureOpenAI,j.bingAI,j.chatGPTBrowser,j.gptPlugins,j.google,j.anthropic,j.custom],Ot=((We={})[j.openAI]="OpenAI",We[j.assistants]="Assistants",We[j.azureOpenAI]="Azure OpenAI",We[j.bingAI]="Bing",We[j.chatGPTBrowser]="ChatGPT",We[j.gptPlugins]="Plugins",We[j.google]="Google",We[j.anthropic]="Anthropic",We[j.custom]="Custom",We),At=((Xe={})[j.assistants]=["gpt-3.5-turbo","gpt-3.5-turbo-0125","gpt-4-turbo","gpt-4-turbo-2024-04-09","gpt-4-0125-preview","gpt-4-turbo-preview","gpt-4-1106-preview","gpt-3.5-turbo-1106","gpt-3.5-turbo-16k-0613","gpt-3.5-turbo-16k","gpt-4","gpt-4-0314","gpt-4-32k-0314","gpt-4-0613","gpt-3.5-turbo-0613"],Xe[j.google]=["gemini-pro","gemini-pro-vision","chat-bison","chat-bison-32k","codechat-bison","codechat-bison-32k","text-bison","text-bison-32k","text-unicorn","code-gecko","code-bison","code-bison-32k"],Xe[j.anthropic]=["claude-3-opus-20240229","claude-3-sonnet-20240229","claude-3-haiku-20240307","claude-2.1","claude-2","claude-1.2","claude-1","claude-1-100k","claude-instant-1","claude-instant-1-100k"],Xe[j.openAI]=["gpt-3.5-turbo-0125","gpt-4-turbo","gpt-4-turbo-2024-04-09","gpt-3.5-turbo-16k-0613","gpt-3.5-turbo-16k","gpt-4-turbo-preview","gpt-4-0125-preview","gpt-4-1106-preview","gpt-3.5-turbo","gpt-3.5-turbo-1106","gpt-4-vision-preview","gpt-4","gpt-3.5-turbo-instruct-0914","gpt-3.5-turbo-0613","gpt-3.5-turbo-0301","gpt-3.5-turbo-instruct","gpt-4-0613","text-davinci-003","gpt-4-0314"],Xe),kt=At[j.openAI],Lt=((Je={initial:[]})[j.openAI]=kt,Je[j.assistants]=kt.filter((function(e){return/gpt-4|gpt-3\\.5/i.test(e)&&!/vision|instruct/i.test(e)})),Je[j.gptPlugins]=kt,Je[j.azureOpenAI]=kt,Je[j.bingAI]=["BingAI","Sydney"],Je[j.chatGPTBrowser]=["text-davinci-002-render-sha"],Je[j.google]=At[j.google],Je[j.anthropic]=At[j.anthropic],Je),Pt=((et={})[j.openAI]="/api/ask/".concat(j.openAI),et[j.bingAI]="/api/ask/".concat(j.bingAI),et[j.google]="/api/ask/".concat(j.google),et[j.custom]="/api/ask/".concat(j.custom),et[j.anthropic]="/api/ask/".concat(j.anthropic),et[j.gptPlugins]="/api/ask/".concat(j.gptPlugins),et[j.azureOpenAI]="/api/ask/".concat(j.azureOpenAI),et[j.chatGPTBrowser]="/api/ask/".concat(j.chatGPTBrowser),et[j.assistants]="/api/assistants/chat",et),St=new Set([j.gptPlugins,j.anthropic,j.google,j.openAI,j.azureOpenAI,j.custom]),Ct=((tt={})[j.custom]=!0,tt[j.openAI]=!0,tt[j.anthropic]=!0,tt[j.gptPlugins]=!0,tt[j.assistants]=!0,tt[j.azureOpenAI]=!0,tt),wt=["gpt-4-turbo","gpt-4-vision","llava","llava-13b","gemini-pro-vision","claude-3","gemini-1.5"];function Nt(e){var t=e.model,n=e.additionalModels,o=void 0===n?[]:n,i=e.availableModels;return!!t&&("gpt-4-turbo-preview"!==t&&(!(i&&!i.includes(t))&&wt.concat(o).some((function(e){return t.includes(e)}))))}!function(e){e.generative="generative"}(Et||(Et={}));var Rt,Mt,jt,Ut,Gt,Dt,zt,Ft,qt,Bt,Kt,Ht,Vt=new Set(["dalle","dall-e","stable-diffusion"]);!function(e){e.CONFIG_STORE="configStore",e.PLUGINS="plugins",e.GEN_TITLE="genTitle",e.TOOLS="tools",e.MODELS_CONFIG="modelsConfig",e.MODEL_QUERIES="modelQueries",e.ENDPOINT_CONFIG="endpointsConfig",e.TOKEN_CONFIG="tokenConfig",e.CUSTOM_CONFIG="customConfig",e.ABORT_KEYS="abortKeys",e.OVERRIDE_CONFIG="overrideConfig",e.BANS="bans",e.ENCODED_DOMAINS="encoded_domains"}(Rt||(Rt={})),function(e){e.FILE_UPLOAD_LIMIT="file_upload_limit",e.ILLEGAL_MODEL_REQUEST="illegal_model_request",e.TOKEN_BALANCE="token_balance",e.BAN="ban"}(Mt||(Mt={})),function(e){e.NO_USER_KEY="no_user_key",e.EXPIRED_USER_KEY="expired_user_key",e.INVALID_USER_KEY="invalid_user_key",e.NO_BASE_URL="no_base_url",e.MODERATION="moderation"}(jt||(jt={})),function(e){e.GOOGLE_SERVICE_KEY="GOOGLE_SERVICE_KEY",e.GOOGLE_API_KEY="GOOGLE_API_KEY"}(Ut||(Ut={})),function(e){e[e.LOW=85]="LOW",e[e.HIGH=170]="HIGH",e[e.ADDITIONAL=85]="ADDITIONAL"}(Gt||(Gt={})),function(e){e.GENERAL="general",e.MESSAGES="messages",e.BETA="beta",e.DATA="data",e.ACCOUNT="account"}(Dt||(Dt={})),function(e){e.VERSION="v0.7.1",e.CONFIG_VERSION="1.0.9",e.NO_PARENT="00000000-0000-0000-0000-000000000000",e[e.ENCODED_DOMAIN_LENGTH=10]="ENCODED_DOMAIN_LENGTH",e.CURRENT_MODEL="current_model"}(zt||(zt={})),function(e){e.APP_TITLE="appTitle",e.LAST_CONVO_SETUP="lastConversationSetup",e.LAST_BING="lastBingSettings",e.LAST_MODEL="lastSelectedModel",e.LAST_TOOLS="lastSelectedTools",e.LAST_SPEC="lastSelectedSpec",e.FILES_TO_DELETE="filesToDelete",e.ASST_ID_PREFIX="assistant_id__",e.FORK_SETTING="forkSetting",e.REMEMBER_FORK_OPTION="rememberForkOption",e.FORK_SPLIT_AT_TARGET="splitAtTarget"}(Ft||(Ft={})),function(e){e.DIRECT_PATH="directPath",e.INCLUDE_BRANCHES="includeBranches",e.TARGET_LEVEL=""}(qt||(qt={})),function(e){e.API_URL="https://api.cohere.ai/v1",e.ROLE_USER="USER",e.ROLE_SYSTEM="SYSTEM",e.ROLE_CHATBOT="CHATBOT",e.TITLE_MESSAGE="TITLE:"}(Bt||(Bt={}));var Yt=((Kt={})[j.openAI]=pe,Kt[j.azureOpenAI]=pe,Kt[j.custom]=pe,Kt[j.google]=ce,Kt[j.bingAI]=de,Kt[j.anthropic]=me,Kt[j.chatGPTBrowser]=fe,Kt[j.gptPlugins]=ge,Kt[j.assistants]=ye,Kt);function $t(){var e=[j.openAI,j.assistants,j.azureOpenAI,j.google,j.bingAI,j.chatGPTBrowser,j.gptPlugins,j.anthropic],t=process.env.ENDPOINTS||"",n=e;return t&&(n=t.split(",").filter((function(e){return null==e?void 0:e.trim()})).map((function(e){return e.trim()}))),n}function Zt(e){if(!e)return{};var t=$t(),n=Object.keys(e),o=t.indexOf(j.custom);return n.reduce((function(n,i){var a=!(i in j);if(!t.includes(i)&&!a)return n;var r=t.indexOf(i);return a?n[i]=h({order:o>=0?o:9999},e[i]):e[i]&&(n[i]=h(h({},e[i]),{order:r})),n}),{})}function Qt(e){return e.map((function(e){var t=e.path.join("."),n=e.message;return"".concat(t,": ").concat(n)})).join(" ")}var Wt=/^\${(.+)}$/;function Xt(e){var t=e.match(Wt);return t&&process.env[t[1]]||e}function Jt(e){var t=h({},null!=e?e:{});return e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).forEach((function(n){t[n]=Xt(e[n])})),t}function en(e){for(var t,n=0,o=e;n<o.length;n++){var i=o[n];if(i){t=i;break}}return t}var tn,nn,on,an=function(e){var t,n,o=e.endpoint,i=e.endpointType,a=e.conversation,r=e.possibleValues,s=Yt[o];if(!s&&!i)throw new Error("Unknown endpoint: ".concat(o));!s&&i&&(s=Yt[i]);var l=s.parse(a),u=null!=r?r:{},p=u.models,c=u.secondaryModels;return p&&l&&(l.model=null!==(t=en(p))&&void 0!==t?t:l.model),c&&l.agentOptions&&(l.agentOptions.model=null!==(n=en(c))&&void 0!==n?n:l.agentOptions.model),l},rn=function(e){var t,n=e.model,o=e.endpoint,i=e.endpointType,a=e.modelDisplayLabel,r=e.chatGptLabel,s=e.modelLabel,l=e.jailbreak;return[j.openAI,j.azureOpenAI,j.gptPlugins,j.chatGPTBrowser].includes(o)?r||(n&&n.includes("gpt-3")?"GPT-3.5":n&&n.includes("gpt-4")?"GPT-4":n&&n.includes("mistral")?"Mistral":null!==(t=Ot[o])&&void 0!==t?t:"ChatGPT"):o===j.bingAI?l?"Sydney":"BingAI":o===j.anthropic?null!=s?s:"Claude":o===j.google?s||(n&&n.includes("gemini")?"Gemini":n&&n.includes("code")?"Codey":"PaLM2"):o===j.custom||i===j.custom?s||(r||(n&&n.includes("mistral")?"Mistral":n&&n.includes("gpt-3")?"GPT-3.5":n&&n.includes("gpt-4")?"GPT-4":a||"AI")):""},sn=((Ht={})[j.openAI]=_e,Ht[j.azureOpenAI]=_e,Ht[j.custom]=_e,Ht[j.assistants]=xe,Ht[j.google]=Te,Ht[j.bingAI]=de,Ht[j.anthropic]=Ee,Ht[j.chatGPTBrowser]=Ie,Ht[j.gptPlugins]=Oe,Ht),ln=function(e){var t,n=e.endpoint,o=e.endpointType,i=e.conversation,a=e.possibleValues;if(!n)throw new Error("undefined endpoint: ".concat(n));var r=sn[n];if(!r&&!o)throw new Error("Unknown endpoint: ".concat(n));!r&&o&&(r=sn[o]);var s=r.parse(i),l=(null!=a?a:{}).models;return l&&s&&(s.model=null!==(t=en(l))&&void 0!==t?t:s.model),s},un=[{key:"AZURE_OPENAI_DEFAULT_MODEL",description:"setting a default model"},{key:"AZURE_OPENAI_MODELS",description:"setting models"},{key:"AZURE_USE_MODEL_AS_DEPLOYMENT_NAME",description:"using model names as deployment names"},{key:"AZURE_API_KEY",description:"setting a single Azure API key"},{key:"AZURE_OPENAI_API_INSTANCE_NAME",description:"setting a single Azure instance name"},{key:"AZURE_OPENAI_API_DEPLOYMENT_NAME",description:"setting a single Azure deployment name"},{key:"AZURE_OPENAI_API_VERSION",description:"setting a single Azure API version"},{key:"AZURE_OPENAI_API_COMPLETIONS_DEPLOYMENT_NAME",description:"setting a single Azure completions deployment name"},{key:"AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME",description:"setting a single Azure embeddings deployment name"},{key:"PLUGINS_USE_AZURE",description:"using Azure for Plugins"}],pn=[{key:"INSTANCE_NAME"},{key:"DEPLOYMENT_NAME"}];function cn(e){var t=!0,n=[],o={},i={},a=[],r=mt.safeParse(e);if(r.success)for(var s=0,l=r.data;s<l.length;s++){var u=l[s],p=u.group,c=u.apiKey,d=u.instanceName,m=u.deploymentName,f=u.version,g=u.baseURL,b=u.additionalHeaders,y=u.models,x=u.serverless,_=v(u,["group","apiKey","instanceName","deploymentName","version","baseURL","additionalHeaders","models","serverless"]);if(i[p])return a.push('Duplicate group name detected: "'.concat(p,'". Group names must be unique.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:a};if(x&&!g)return a.push('Group "'.concat(p,'" is serverless but missing mandatory "baseURL."')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:a};if(!d&&!x)return a.push('Group "'.concat(p,'" is missing an "instanceName" for non-serverless configuration.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:a};for(var T in i[p]=h({apiKey:c,instanceName:d,deploymentName:m,version:f,baseURL:g,additionalHeaders:b,models:y,serverless:x},_),u.models){n.push(T);var E=u.models[T];if(o[T])return a.push('Duplicate model name detected: "'.concat(T,'". Model names must be unique across groups.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:a};if(x)o[T]={group:p};else if("boolean"==typeof E){if(!u.deploymentName||!u.version)return a.push('Model "'.concat(T,'" in group "').concat(p,'" is missing a deploymentName or version.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:a};o[T]={group:p}}else{if(!E.deploymentName&&!u.deploymentName||!E.version&&!u.version)return a.push('Model "'.concat(T,'" in group "').concat(p,'" is missing a required deploymentName or version.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:a};o[T]={group:p}}}}else t=!1,a.push(Qt(r.error.errors));return{isValid:t,modelNames:n,modelGroupMap:o,groupMap:i,errors:a}}function dn(e){var t=e.modelName,n=e.modelGroupMap,o=e.groupMap,i=n[t];if(!i)throw new Error('Model named "'.concat(t,'" not found in configuration.'));var a=o[i.group];if(!a)throw new Error('Group "'.concat(i.group,'" for model "').concat(t,'" not found in configuration.'));var r=a.instanceName;if(!r&&!a.serverless)throw new Error('Group "'.concat(i.group,'" is missing an instanceName for non-serverless configuration.'));if(a.serverless&&!a.baseURL)throw new Error('Group "'.concat(i.group,'" is missing the required base URL for serverless configuration.'));if(a.serverless){var s={azureOptions:{azureOpenAIApiKey:Xt(a.apiKey)},baseURL:Xt(a.baseURL),serverless:!0},l=s.azureOptions.azureOpenAIApiKey;if("string"==typeof l&&Wt.test(l))throw new Error('Azure configuration environment variable "'.concat(l,'" was not found.'));return a.additionalHeaders&&(s.headers=a.additionalHeaders),s}if(!r)throw new Error('Group "'.concat(i.group,'" is missing an instanceName for non-serverless configuration.'));var u=a.models[t],p="object"==typeof u?{deploymentName:u.deploymentName||a.deploymentName,version:u.version||a.version}:{deploymentName:a.deploymentName,version:a.version},c=p.deploymentName,d=p.version;if(!c||!d)throw new Error('Model "'.concat(t,'" in group "').concat(i.group,'" is missing a deploymentName ("').concat(c,'") or version ("').concat(d,'").'));for(var m={azureOpenAIApiKey:Xt(a.apiKey),azureOpenAIApiInstanceName:Xt(r),azureOpenAIApiDeploymentName:Xt(c),azureOpenAIApiVersion:Xt(d)},f=0,g=Object.values(m);f<g.length;f++){var h=g[f];if("string"==typeof h&&Wt.test(h))throw new Error('Azure configuration environment variable "'.concat(h,'" was not found.'))}var v={azureOptions:m};return a.baseURL&&(v.baseURL=Xt(a.baseURL)),a.additionalHeaders&&(v.headers=a.additionalHeaders),v}function mn(e){var t,n=e.groupName,o=e.groupMap[n];if(!o)throw new Error('Group named "'.concat(n,'" not found in configuration.'));var i=o.instanceName;if(!i&&!o.serverless)throw new Error('Group "'.concat(n,'" is missing an instanceName for non-serverless configuration.'));if(o.serverless&&!o.baseURL)throw new Error('Group "'.concat(n,'" is missing the required base URL for serverless configuration.'));var a=Object.keys(o.models);if(0===a.length)throw new Error('Group "'.concat(n,'" does not have any models configured.'));var r=a[0],s=o.models[r],l={azureOpenAIApiKey:Xt(o.apiKey),azureOpenAIApiInstanceName:Xt(i)};if(o.serverless)return h({azureOptions:l,baseURL:Xt(null!==(t=o.baseURL)&&void 0!==t?t:""),serverless:!0},o.additionalHeaders&&{headers:o.additionalHeaders});var u="object"==typeof s?{deploymentName:s.deploymentName||o.deploymentName,version:s.version||o.version}:{deploymentName:o.deploymentName,version:o.version},p=u.deploymentName,c=u.version;if(!p||!c)throw new Error('Model "'.concat(r,'" in group "').concat(n,'" or the group itself is missing a deploymentName ("').concat(p,'") or version ("').concat(c,'").'));l.azureOpenAIApiDeploymentName=Xt(p),l.azureOpenAIApiVersion=Xt(c);var d={azureOptions:l};return o.baseURL&&(d.baseURL=Xt(o.baseURL)),o.additionalHeaders&&(d.headers=o.additionalHeaders),d}!function(e){e.Input="input",e.Textarea="textarea",e.Slider="slider",e.Checkbox="checkbox",e.Switch="switch",e.Dropdown="dropdown",e.Tags="tags"}(tn||(tn={})),function(e){e.Number="number",e.Boolean="boolean",e.String="string",e.Enum="enum",e.Array="array"}(nn||(nn={})),function(e){e.Conversation="conversation",e.Model="model",e.Custom="custom"}(on||(on={}));var fn=["key","type","component"];function gn(n){for(var o={},i=0,a=n;i<a.length;i++){var r=a[i],s=r.key,l=r.type,u=r.default,p=r.range,c=r.options,d=r.minText,m=r.maxText,f=r.minTags,g=r.maxTags;if(l!==nn.Number)if(l!==nn.Boolean)if(l!==nn.String)if(l!==nn.Enum)if(l!==nn.Array)console.warn("Unsupported setting type: ".concat(l));else{h=e.array(e.string().or(e.number()));f&&h instanceof t&&(h=h.min(f)),g&&h instanceof t&&(h=h.max(g)),u&&Array.isArray(u)&&(h=h.default(u)),o[s]=h}else{if(!c||0===c.length){console.warn("Missing or empty 'options' for enum setting '".concat(s,"'."));continue}h=e.enum(c);o[s]="string"==typeof u?h.default(u):h}else{var h=e.string();d&&(h=h.min(d)),m&&(h=h.max(m)),o[s]="string"==typeof u?h.default(u):h}else{var h=e.boolean();o[s]="boolean"==typeof u?h.default(u):h}else{var h=e.number();p&&(h=(h=h.min(p.min)).max(p.max)),o[s]="number"==typeof u?h.default(u):h}}return e.object(o)}var hn={ZodString:"string",ZodNumber:"number",ZodBoolean:"boolean"};function vn(e){for(var t,i=[],a=new Set,r=0,s=e;r<s.length;r++){void 0!==(c=s[r]).columns&&(c.columns<1||c.columns>4?i.push({code:n.custom,message:"Invalid columns value for setting ".concat(c.key,". Must be between ").concat(1," and ").concat(4,"."),path:["columns"]}):a.add(c.columns))}for(var l=1===a.size?a.values().next().value:2,u=0,p=e;u<p.length;u++){for(var c=p[u],d=0,m=fn;d<m.length;d++){var f=m[d];void 0===c[f]&&i.push({code:n.custom,message:"Missing required field ".concat(f," for setting ").concat(c.key,"."),path:[f]})}var g=Object.values(nn);if(g.includes(c.type)||i.push({code:n.custom,message:"Invalid type for setting ".concat(c.key,". Must be one of ").concat(g.join(", "),"."),path:["type"]}),(c.component===tn.Tags&&c.type!==nn.Array||c.component!==tn.Tags&&c.type===nn.Array)&&i.push({code:n.custom,message:"Tags component for setting ".concat(c.key," must have type array."),path:["type"]}),c.component===tn.Tags&&(void 0!==c.minTags&&c.minTags<0&&i.push({code:n.custom,message:"Invalid minTags value for setting ".concat(c.key,". Must be non-negative."),path:["minTags"]}),void 0!==c.maxTags&&c.maxTags<0&&i.push({code:n.custom,message:"Invalid maxTags value for setting ".concat(c.key,". Must be non-negative."),path:["maxTags"]}),c.default&&!Array.isArray(c.default)&&i.push({code:n.custom,message:"Invalid default value for setting ".concat(c.key,". Must be an array."),path:["default"]}),c.default&&c.maxTags&&c.default.length>c.maxTags&&i.push({code:n.custom,message:"Invalid default value for setting ".concat(c.key,". Must have at most ").concat(c.maxTags," tags."),path:["default"]}),c.default&&c.minTags&&c.default.length<c.minTags&&i.push({code:n.custom,message:"Invalid default value for setting ".concat(c.key,". Must have at least ").concat(c.minTags," tags."),path:["default"]}),c.default||(c.default=[])),c.component!==tn.Input&&c.component!==tn.Textarea||(c.type===nn.Number&&c.component===tn.Textarea&&i.push({code:n.custom,message:"Textarea component for setting ".concat(c.key," must have type string."),path:["type"]}),void 0!==c.minText&&void 0!==c.maxText&&c.minText>c.maxText&&i.push({code:n.custom,message:"For setting ".concat(c.key,", minText cannot be greater than maxText."),path:[c.key,"minText","maxText"]}),c.placeholder||(c.placeholder="")),c.component===tn.Slider&&(c.type!==nn.Number||c.range||i.push({code:n.custom,message:"Slider component for setting ".concat(c.key," must have a range if type is number."),path:["range"]}),c.type===nn.Enum&&(!c.options||c.options.length<2)&&i.push({code:n.custom,message:"Slider component for setting ".concat(c.key," requires at least ").concat(2," options for enum type."),path:["options"]}),c.includeInput=c.type===nn.Number&&(null===(t=c.includeInput)||void 0===t||t)),c.component===tn.Slider&&c.type===nn.Number&&void 0===c.default&&c.range&&(c.default=Math.round((c.range.min+c.range.max)/2)),c.component!==tn.Checkbox&&c.component!==tn.Switch||(c.options&&c.options.length>2&&i.push({code:n.custom,message:"Checkbox/Switch component for setting ".concat(c.key," must have 1-2 options."),path:["options"]}),c.default||c.type!==nn.Boolean||(c.default=!1)),c.component===tn.Dropdown&&((!c.options||c.options.length<2)&&i.push({code:n.custom,message:"Dropdown component for setting ".concat(c.key," requires at least ").concat(2," options."),path:["options"]}),!c.default&&c.options&&c.options.length>0&&(c.default=c.options[0])),c.columnSpan||(c.columnSpan=Math.floor(l/2)),c.label||(c.label=c.key),c.component!==tn.Input&&c.component!==tn.Textarea||(void 0!==c.minText&&c.minText<0&&i.push({code:n.custom,message:"Invalid minText value for setting ".concat(c.key,". Must be non-negative."),path:["minText"]}),void 0!==c.maxText&&c.maxText<0&&i.push({code:n.custom,message:"Invalid maxText value for setting ".concat(c.key,". Must be non-negative."),path:["maxText"]})),c.optionType!==on.Custom){var h=re.shape[c.key];if(h){var v=h._def.typeName;(hn[v]||null)!==c.type&&i.push({code:n.custom,message:"Setting ".concat(c.key,' with optionType "').concat(c.optionType,'" must match the type defined in tConversationSchema.'),path:["optionType"]})}else i.push({code:n.custom,message:"Setting ".concat(c.key,' with optionType "').concat(c.optionType,'" must be defined in tConversationSchema.'),path:["optionType"]})}c.type===nn.Number&&isNaN(c.default)&&i.push({code:n.custom,message:"Invalid default value for setting ".concat(c.key,". Must be a number."),path:["default"]}),c.type===nn.Boolean&&"boolean"!=typeof c.default&&i.push({code:n.custom,message:"Invalid default value for setting ".concat(c.key,". Must be a boolean."),path:["default"]}),c.type!==nn.String&&c.type!==nn.Enum||"string"==typeof c.default||i.push({code:n.custom,message:"Invalid default value for setting ".concat(c.key,". Must be a string."),path:["default"]}),c.type===nn.Enum&&c.options&&!c.options.includes(c.default)&&i.push({code:n.custom,message:"Invalid default value for setting ".concat(c.key,". Must be one of the options: [").concat(c.options.join(", "),"]."),path:["default"]}),c.type===nn.Number&&c.range&&"number"==typeof c.default&&(c.default<c.range.min||c.default>c.range.max)&&i.push({code:n.custom,message:"Invalid default value for setting ".concat(c.key,". Must be within the range [").concat(c.range.min,", ").concat(c.range.max,"]."),path:["default"]})}if(i.length>0)throw new o(i)}var bn,yn,xn=function(e){var t=h(h({},V),e);return re.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,resendFiles:!0,imageDetail:!0,maxContextTokens:!0}).transform((function(e){var n,o,i,a,r,s,l,u,p;return h(h({},e),{model:null!==(n=e.model)&&void 0!==n?n:t.model.default,chatGptLabel:null!==(o=e.chatGptLabel)&&void 0!==o?o:null,promptPrefix:null!==(i=e.promptPrefix)&&void 0!==i?i:null,temperature:null!==(a=e.temperature)&&void 0!==a?a:t.temperature.default,top_p:null!==(r=e.top_p)&&void 0!==r?r:t.top_p.default,presence_penalty:null!==(s=e.presence_penalty)&&void 0!==s?s:t.presence_penalty.default,frequency_penalty:null!==(l=e.frequency_penalty)&&void 0!==l?l:t.frequency_penalty.default,resendFiles:"boolean"==typeof e.resendFiles?e.resendFiles:t.resendFiles.default,imageDetail:null!==(u=e.imageDetail)&&void 0!==u?u:t.imageDetail.default,maxContextTokens:null!==(p=e.maxContextTokens)&&void 0!==p?p:void 0})})).catch((function(){return{model:t.model.default,chatGptLabel:null,promptPrefix:null,temperature:t.temperature.default,top_p:t.top_p.default,presence_penalty:t.presence_penalty.default,frequency_penalty:t.frequency_penalty.default,resendFiles:t.resendFiles.default,imageDetail:t.imageDetail.default,maxContextTokens:void 0}}))},_n=function(e){var t=h(h({},Y),e);return re.pick({model:!0,modelLabel:!0,promptPrefix:!0,examples:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0,maxContextTokens:!0}).transform((function(e){var n,o,i,a,r,s,l,u,p,c,d,m=null===(o=null===(n=null==e?void 0:e.model)||void 0===n?void 0:n.toLowerCase())||void 0===o?void 0:o.includes("gemini"),f=m?t.maxOutputTokens.maxGemini:t.maxOutputTokens.max,g=m?t.maxOutputTokens.defaultGemini:t.maxOutputTokens.default,v=null!==(i=e.maxOutputTokens)&&void 0!==i?i:g;return v=Math.min(v,f),h(h({},e),{model:null!==(a=e.model)&&void 0!==a?a:t.model.default,modelLabel:null!==(r=e.modelLabel)&&void 0!==r?r:null,promptPrefix:null!==(s=e.promptPrefix)&&void 0!==s?s:null,examples:null!==(l=e.examples)&&void 0!==l?l:[{input:{content:""},output:{content:""}}],temperature:null!==(u=e.temperature)&&void 0!==u?u:t.temperature.default,maxOutputTokens:v,topP:null!==(p=e.topP)&&void 0!==p?p:t.topP.default,topK:null!==(c=e.topK)&&void 0!==c?c:t.topK.default,maxContextTokens:null!==(d=e.maxContextTokens)&&void 0!==d?d:void 0})})).catch((function(){return{model:t.model.default,modelLabel:null,promptPrefix:null,examples:[{input:{content:""},output:{content:""}}],temperature:t.temperature.default,maxOutputTokens:t.maxOutputTokens.default,topP:t.topP.default,topK:t.topK.default,maxContextTokens:void 0}}))};function Tn(e){i.defaults.headers.common["Accept-Language"]=e}function En(e){i.defaults.headers.common.Authorization="Bearer "+e}!function(e){e.messages="messages",e.allConversations="allConversations",e.archivedConversations="archivedConversations",e.searchConversations="searchConversations",e.conversation="conversation",e.searchEnabled="searchEnabled",e.user="user",e.name="name",e.models="models",e.balance="balance",e.endpoints="endpoints",e.presets="presets",e.searchResults="searchResults",e.tokenCount="tokenCount",e.availablePlugins="availablePlugins",e.startupConfig="startupConfig",e.assistants="assistants",e.assistant="assistant",e.endpointsConfigOverride="endpointsConfigOverride",e.files="files",e.fileConfig="fileConfig",e.tools="tools",e.actions="actions",e.assistantDocs="assistantDocs",e.fileDownload="fileDownload"}(bn||(bn={})),function(e){e.fileUpload="fileUpload",e.fileDelete="fileDelete",e.updatePreset="updatePreset",e.deletePreset="deletePreset",e.logoutUser="logoutUser",e.avatarUpload="avatarUpload",e.assistantAvatarUpload="assistantAvatarUpload",e.updateAction="updateAction",e.deleteAction="deleteAction"}(yn||(yn={}));var In=function(e,t){return"/api/messages/".concat(e).concat(t?"/".concat(t):"")},On="/api/keys",An="/api/convos",kn=function(e,t){return"".concat(An,"?pageNumber=").concat(e).concat(t?"&isArchived=true":"")},Ln=function(){return"".concat(An,"/update")},Pn=function(){return"".concat(An,"/clear")},Sn=function(e){return"".concat(An,"/import/jobs/").concat(e)},Cn=function(e,t){return"/api/search?q=".concat(e,"&pageNumber=").concat(t)},wn=function(e,t){var n="/api/assistants";if(e&&(n+="/".concat(e)),t&&Object.keys(t).length>0){var o=new URLSearchParams(t).toString();n+="?".concat(o)}return n},Nn=function(){return"".concat("/api/files","/images")};function Rn(e,t){return b(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return[4,i.post(e,JSON.stringify(t),{headers:{"Content-Type":"application/json"}})];case 1:return[2,n.sent().data]}}))}))}var Mn=!1,jn=[],Un=function(e){return Rn(function(e){return"/api/auth/refresh".concat(e?"?retry=true":"")}(e))},Gn=function(e,t){void 0===t&&(t=null),jn.forEach((function(n){e?n.reject(e):n.resolve(t)})),jn=[]};i.interceptors.response.use((function(e){return e}),(function(e){return b(void 0,void 0,void 0,(function(){var t,n,o,a,r;return y(this,(function(s){switch(s.label){case 0:if(t=e.config,401!==e.response.status||t._retry)return[3,13];if(t._retry=!0,!Mn)return[3,5];s.label=1;case 1:return s.trys.push([1,4,,5]),[4,new Promise((function(e,t){jn.push({resolve:e,reject:t})}))];case 2:return o=s.sent(),t.headers.Authorization="Bearer "+o,[4,i(t)];case 3:return[2,s.sent()];case 4:return n=s.sent(),[2,Promise.reject(n)];case 5:Mn=!0,s.label=6;case 6:return s.trys.push([6,11,12,13]),[4,Un(!!(null===(r=t.url)||void 0===r?void 0:r.includes("api/auth/refresh")))];case 7:return(o=s.sent().token)?(t.headers.Authorization="Bearer "+o,En(o),window.dispatchEvent(new CustomEvent("tokenUpdated",{detail:o})),Gn(null,o),[4,i(t)]):[3,9];case 8:return[2,s.sent()];case 9:window.location.href="/login",s.label=10;case 10:return[3,13];case 11:return a=s.sent(),Gn(a,null),[2,Promise.reject(a)];case 12:return Mn=!1,[7];case 13:return[2,Promise.reject(e)]}}))}))}));var Dn={get:function(e,t){return b(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return[4,i.get(e,h({},t))];case 1:return[2,n.sent().data]}}))}))},getResponse:function(e,t){return b(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return[4,i.get(e,h({},t))];case 1:return[2,n.sent()]}}))}))},post:Rn,postMultiPart:function(e,t,n){return b(this,void 0,void 0,(function(){return y(this,(function(o){switch(o.label){case 0:return[4,i.post(e,t,h(h({},n),{headers:{"Content-Type":"multipart/form-data"}}))];case 1:return[2,o.sent().data]}}))}))},put:function(e,t){return b(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return[4,i.put(e,JSON.stringify(t),{headers:{"Content-Type":"application/json"}})];case 1:return[2,n.sent().data]}}))}))},delete:function(e){return b(this,void 0,void 0,(function(){return y(this,(function(t){switch(t.label){case 0:return[4,i.delete(e)];case 1:return[2,t.sent().data]}}))}))},deleteWithOptions:function(e,t){return b(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return[4,i.delete(e,h({},t))];case 1:return[2,n.sent().data]}}))}))},patch:function(e,t){return b(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return[4,i.patch(e,JSON.stringify(t),{headers:{"Content-Type":"application/json"}})];case 1:return[2,n.sent().data]}}))}))},refreshToken:Un};var zn=Object.freeze({__proto__:null,abortRequestWithMessage:function(e,t,n){return Dn.post(function(e){return"/api/ask/".concat(e,"/abort")}(e),{arg:{abortKey:t,message:n}})},archiveConversation:function(e){return Dn.post(Ln(),{arg:e})},clearAllConversations:function(){return Dn.post(Pn(),{arg:{}})},createAssistant:function(e){return Dn.post(wn(),e)},createPreset:function(e){return Dn.post("/api/presets",e)},deleteAction:function(e,t,n){return b(void 0,void 0,void 0,(function(){return y(this,(function(o){return[2,Dn.delete(wn("actions/".concat(e,"/").concat(t,"/").concat(n)))]}))}))},deleteAssistant:function(e,t){return Dn.delete(wn(e,{model:t}))},deleteConversation:function(e){return Dn.post(Pn(),{arg:e})},deleteFiles:function(e,t){return b(void 0,void 0,void 0,(function(){return y(this,(function(n){return[2,Dn.deleteWithOptions("/api/files",{data:{files:e,assistant_id:t}})]}))}))},deletePreset:function(e){return Dn.post("/api/presets/delete",e)},forkConversation:function(e){return Dn.post("".concat(An,"/fork"),e)},genTitle:function(e){return Dn.post("".concat(An,"/gen_title"),e)},getAIEndpoints:function(){return Dn.get("/api/endpoints")},getActions:function(){return Dn.get(wn("actions"))},getAssistantById:function(e){return Dn.get(wn(e))},getAssistantDocs:function(){return Dn.get(wn("documents"))},getAvailablePlugins:function(){return Dn.get("/api/plugins")},getAvailableTools:function(){return Dn.get("".concat(wn(),"/tools"))},getConversationById:function(e){return Dn.get(function(e){return"".concat(An,"/").concat(e)}(e))},getConversations:function(e){return Dn.get(kn(e))},getEndpointsConfigOverride:function(){return Dn.get("/api/endpoints/config/override")},getFileConfig:function(){return Dn.get("".concat("/api/files","/config"))},getFileDownload:function(e,t){return b(void 0,void 0,void 0,(function(){return y(this,(function(n){return[2,Dn.getResponse("".concat("/api/files","/download/").concat(e,"/").concat(t),{responseType:"blob",headers:{Accept:"application/octet-stream"}})]}))}))},getFiles:function(){return Dn.get("/api/files")},getLoginGoogle:function(){return Dn.get("/api/auth/google")},getMessagesByConvoId:function(e){return"new"===e?Promise.resolve([]):Dn.get(In(e))},getModels:function(){return b(void 0,void 0,void 0,(function(){return y(this,(function(e){return[2,Dn.get("/api/models")]}))}))},getPresets:function(){return Dn.get("/api/presets")},getSearchEnabled:function(){return Dn.get("/api/search/enable")},getStartupConfig:function(){return Dn.get("/api/config")},getUser:function(){return Dn.get("/api/user")},getUserBalance:function(){return Dn.get("/api/balance")},importConversationsFile:function(e){return Dn.postMultiPart("".concat(An,"/import"),e)},listAssistants:function(e){return Dn.get(wn(),{params:e})},listConversations:function(e){var t=(null==e?void 0:e.pageNumber)||"1",n=(null==e?void 0:e.isArchived)||!1;return Dn.get(kn(t,n))},listConversationsByQuery:function(e){var t=(null==e?void 0:e.pageNumber)||"1",n=(null==e?void 0:e.searchQuery)||"";return""!==n?Dn.get(Cn(n,t)):Dn.get(kn(t))},login:function(e){return Dn.post("/api/auth/login",e)},logout:function(){return Dn.post("/api/auth/logout")},queryImportConversationJobStatus:function(e){return b(void 0,void 0,void 0,(function(){return y(this,(function(t){return[2,Dn.get(Sn(e))]}))}))},register:function(e){return Dn.post("/api/auth/register",e)},requestPasswordReset:function(e){return Dn.post("/api/auth/requestPasswordReset",e)},resetPassword:function(e){return Dn.post("/api/auth/resetPassword",e)},revokeAllUserKeys:function(){return Dn.delete("".concat(On,"?all=true"))},revokeUserKey:function(e){return Dn.delete(function(e){return"".concat(On,"/").concat(e)}(e))},searchConversations:function(e,t){return b(void 0,void 0,void 0,(function(){return y(this,(function(n){return[2,Dn.get(Cn(e,t))]}))}))},updateAction:function(e){var t=e.assistant_id,n=v(e,["assistant_id"]);return Dn.post(wn("actions/".concat(t)),n)},updateAssistant:function(e,t){return Dn.patch(wn(e),t)},updateConversation:function(e){return Dn.post(Ln(),{arg:e})},updateMessage:function(e){var t=e.conversationId,n=e.messageId,o=e.text;if(!t)throw new Error("conversationId is required");return Dn.put(In(t,n),{text:o})},updatePreset:function(e){return Dn.post("/api/presets",e)},updateTokenCount:function(e){return Dn.post("/api/tokenizer",{arg:e})},updateUserKey:function(e){if(!e.value)throw new Error("value is required");return Dn.put(On,e)},updateUserPlugins:function(e){return Dn.post("/api/user/plugins",e)},uploadAssistantAvatar:function(e){return Dn.postMultiPart(wn("avatar/".concat(e.assistant_id),{model:e.model}),e.formData)},uploadAvatar:function(e){return Dn.postMultiPart("".concat(Nn(),"/avatar"),e)},uploadFile:function(e){return Dn.postMultiPart("/api/files",e)},uploadImage:function(e){return Dn.postMultiPart(Nn(),e)},userKeyQuery:function(e){return Dn.get(function(e){return"".concat(On,"?name=").concat(e)}(e))}}),Fn=function(e,t){if(!(this instanceof Fn))return new Fn(e,t);this.INITIALIZING=-1,this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,this.url=e,t=t||{},this.headers=t.headers||{},this.payload=void 0!==t.payload?t.payload:"",this.method=t.method||this.payload&&"POST"||"GET",this.withCredentials=!!t.withCredentials,this.FIELD_SEPARATOR=":",this.listeners={},this.xhr=null,this.readyState=this.INITIALIZING,this.progress=0,this.chunk="",this.addEventListener=function(e,t){void 0===this.listeners[e]&&(this.listeners[e]=[]),-1===this.listeners[e].indexOf(t)&&this.listeners[e].push(t)},this.removeEventListener=function(e,t){if(void 0!==this.listeners[e]){var n=[];this.listeners[e].forEach((function(e){e!==t&&n.push(e)})),0===n.length?delete this.listeners[e]:this.listeners[e]=n}},this.dispatchEvent=function(e){if(!e)return!0;e.source=this;var t="on"+e.type;return(!this.hasOwnProperty(t)||(this[t].call(this,e),!e.defaultPrevented))&&(!this.listeners[e.type]||this.listeners[e.type].every((function(t){return t(e),!e.defaultPrevented})))},this._setReadyState=function(e){var t=new CustomEvent("readystatechange");t.readyState=e,this.readyState=e,this.dispatchEvent(t)},this._onStreamFailure=function(e){var t=new CustomEvent("error");t.data=e.currentTarget.response,this.dispatchEvent(t),this.close()},this._onStreamAbort=function(e){this.dispatchEvent(new CustomEvent("abort")),this.close()},this._onStreamProgress=async function(e){if(this.xhr){if(401!==this.xhr.status||this._retry){if(200!==this.xhr.status)return void this._onStreamFailure(e)}else{this._retry=!0;try{const e=await Dn.refreshToken();this.headers={"Content-Type":"application/json",Authorization:`Bearer ${e.token}`},En(e.token),window.dispatchEvent(new CustomEvent("tokenUpdated",{detail:e.token})),this.stream()}catch(t){return void this._onStreamFailure(e)}}this.readyState==this.CONNECTING&&(this.dispatchEvent(new CustomEvent("open")),this._setReadyState(this.OPEN));var t=this.xhr.responseText.substring(this.progress);this.progress+=t.length,t.split(/(\r\n|\r|\n){2}/g).forEach(function(e){0===e.trim().length?(this.dispatchEvent(this._parseEventChunk(this.chunk.trim())),this.chunk=""):this.chunk+=e}.bind(this))}},this._onStreamLoaded=function(e){this._onStreamProgress(e),this.dispatchEvent(this._parseEventChunk(this.chunk)),this.chunk=""},this._parseEventChunk=function(e){if(!e||0===e.length)return null;var t={id:null,retry:null,data:"",event:"message"};e.split(/\n|\r\n|\r/).forEach(function(e){var n=(e=e.trimRight()).indexOf(this.FIELD_SEPARATOR);if(!(n<=0)){var o=e.substring(0,n);if(o in t){var i=e.substring(n+1).trimLeft();"data"===o?t[o]+=i:t[o]=i}}}.bind(this));var n=new CustomEvent(t.event);return n.data=t.data,n.id=t.id,n},this._checkStreamClosed=function(){this.xhr&&this.xhr.readyState===XMLHttpRequest.DONE&&this._setReadyState(this.CLOSED)},this.stream=function(){for(var e in this._setReadyState(this.CONNECTING),this.xhr=new XMLHttpRequest,this.xhr.addEventListener("progress",this._onStreamProgress.bind(this)),this.xhr.addEventListener("load",this._onStreamLoaded.bind(this)),this.xhr.addEventListener("readystatechange",this._checkStreamClosed.bind(this)),this.xhr.addEventListener("error",this._onStreamFailure.bind(this)),this.xhr.addEventListener("abort",this._onStreamAbort.bind(this)),this.xhr.open(this.method,this.url),this.headers)this.xhr.setRequestHeader(e,this.headers[e]);this.xhr.withCredentials=this.withCredentials,this.xhr.send(this.payload)},this.close=function(){this.readyState!==this.CLOSED&&(this.xhr.abort(),this.xhr=null,this._setReadyState(this.CLOSED))}};function qn(e){return r.createHash("sha1").update(e).digest("hex")}function Bn(e,t){return new a(t,e).toString()}var Kn=function(){function e(e,t,n){var o,i;this.name=e,this.description=t,(null===(o=n.properties)||void 0===o?void 0:o.requestBody)?this.parameters=null===(i=n.properties)||void 0===i?void 0:i.requestBody:this.parameters=n}return e.prototype.toObjectTool=function(){return{type:l.function,function:{name:this.name,description:this.description,parameters:this.parameters}}},e}(),Hn=function(){function e(e,t,n,o,i,a){this.authHeaders={},this.domain=e,this.path=t,this.method=n,this.operation=o,this.isConsequential=i,this.contentType=a}return e.prototype.setParams=function(e){return b(this,void 0,void 0,(function(){var t,n,o,i,a,r;return y(this,(function(s){for(this.operationHash=qn(JSON.stringify(e)),this.params=e,t=0,n=Object.entries(e);t<n.length;t++)o=n[t],i=o[0],a=o[1],r="{".concat(i,"}"),this.path.includes(r)&&(this.path=this.path.replace(r,encodeURIComponent(a)),delete this.params[i]);return[2]}))}))},e.prototype.setAuth=function(e){return b(this,void 0,void 0,(function(){var t,n,o,a,r,s,l,u,p,c,d,m,f,g,h;return y(this,(function(v){switch(v.label){case 0:return e.auth?(t=e.auth,n=t.type,o=t.authorization_type,a=t.custom_auth_header,r=t.authorization_url,s=t.client_url,l=t.scope,u=t.token_exchange_method,p=e.api_key,c=e.oauth_client_id,d=e.oauth_client_secret,m=p&&n===_.ServiceHttp,f=c&&d&&n===_.OAuth&&r&&s&&l&&u,m&&o===T.Basic?(g=Buffer.from(p).toString("base64"),this.authHeaders.Authorization="Basic ".concat(g),[3,6]):[3,1]):[2];case 1:return m&&o===T.Bearer?(this.authHeaders.Authorization="Bearer ".concat(p),[3,6]):[3,2];case 2:return m&&o===T.Custom&&a?(this.authHeaders[a]=p,[3,6]):[3,3];case 3:return f?this.authToken?[3,5]:[4,i.post(s,{client_id:c,client_secret:d,scope:l,grant_type:"client_credentials"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})]:[3,6];case 4:h=v.sent(),this.authToken=h.data.access_token,v.label=5;case 5:this.authHeaders.Authorization="Bearer ".concat(this.authToken),v.label=6;case 6:return[2]}}))}))},e.prototype.execute=function(){return b(this,void 0,void 0,(function(){var e,t,n;return y(this,(function(o){if(e=Bn(this.domain,this.path),t=h(h({},this.authHeaders),{"Content-Type":this.contentType}),"get"===(n=this.method.toLowerCase()))return[2,i.get(e,{headers:t,params:this.params})];if("post"===n)return[2,i.post(e,this.params,{headers:t})];if("put"===n)return[2,i.put(e,this.params,{headers:t})];if("delete"===n)return[2,i.delete(e,{headers:t,data:this.params})];if("patch"===n)return[2,i.patch(e,this.params,{headers:t})];throw new Error("Unsupported HTTP method: ".concat(this.method))}))}))},e}();function Vn(e,t){var n;if("$ref"in e&&t){var o=e.$ref.replace(/^#\/components\/schemas\//,""),i=null===(n=t.schemas)||void 0===n?void 0:n[o];if(!i)throw new Error("Reference ".concat(e.$ref," not found"));return Vn(i,t)}return e}function Yn(e){for(var t,n,o,i,a=[],r={},s=null!==(o=null===(n=null===(t=e.servers)||void 0===t?void 0:t[0])||void 0===n?void 0:n.url)&&void 0!==o?o:"",l=0,u=Object.entries(e.paths);l<u.length;l++)for(var p=u[l],c=p[0],d=p[1],m=0,f=Object.entries(d);m<f.length;m++){var g=f[m],v=g[0],b=g[1],y=b.operationId||"".concat(v,"_").concat(c),x=b.summary||b.description||"",_={type:"object",properties:{},required:[]};if(b.requestBody){var T=b.requestBody.content,E=Vn(null===(i=T[Object.keys(T)[0]])||void 0===i?void 0:i.schema,e.components);_.properties.requestBody=E}if(b.parameters)for(var I=0,O=b.parameters;I<O.length;I++){var A=O[I];E=Vn(h({},A.schema),e.components);_.properties[A.name]=E,A.required&&_.required.push(A.name),A.description&&!("$$ref"in _.properties[A.name])&&(_.properties[A.name].description=A.description)}var k=new Kn(y,x,_);a.push(k);var L=new Hn(s,c,v,y,!!b["x-openai-isConsequential"],b.requestBody?"application/json":"application/x-www-form-urlencoded");r[y]=L}return{functionSignatures:a,requestBuilders:r}}function $n(e){var t;try{var n=void 0;try{n=JSON.parse(e)}catch(t){n=s(e)}if(!n.servers||!Array.isArray(n.servers)||0===n.servers.length)return{status:!1,message:"Could not find a valid URL in `servers`"};if(!n.servers[0].url)return{status:!1,message:"Could not find a valid URL in `servers`"};var o=n.paths;if(!o||"object"!=typeof o||0===Object.keys(o).length)return{status:!1,message:"No paths found in the OpenAPI spec."};for(var i=(null===(t=n.components)||void 0===t?void 0:t.schemas)||{},a=[],r=0,l=Object.entries(o);r<l.length;r++)for(var u=l[r],p=u[0],c=u[1],d=0,m=Object.entries(c);d<m.length;d++){var f=m[d],g=f[0],h=f[1],v=h.responses;if("object"==typeof h&&v)for(var b=0,y=Object.entries(v);b<y.length;b++){var x=y[b],_=x[0],T=x[1].content;if(T&&T["application/json"]&&T["application/json"].schema){var E=T["application/json"].schema;if("$ref"in E&&"string"==typeof E.$ref){var I=E.$ref.split("/").pop();I&&!i[I]&&a.push("In context=('paths', '".concat(p,"', '").concat(g,"', '").concat(_,"', 'response', 'content', 'application/json', 'schema'), reference to unknown component ").concat(I,"; using empty schema"))}}}}return{status:!0,message:a.join("\n")||"OpenAPI spec is valid.",spec:n}}catch(e){return{status:!1,message:"Error parsing OpenAPI spec."}}}function Zn(e){var t=e.conversation,n=e.message;e.messages;var o=e.endpointOption,i=e.isEdited,a=e.isContinued,r=le.parse(t).conversationId,s=o,l=s.endpoint,u=s.endpointType,p=Pt[null!=u?u:l];return i&&l===j.assistants?p+="/modify":i&&(p=p.replace("/ask/","/edit/")),{server:p,payload:h(h(h({},n),o),{isContinued:!(!i||!a),conversationId:r})}}export{Hn as ActionRequest,u as AnnotationTypes,P as AssistantStreamEvents,Ut as AuthKeys,R as AuthType,_ as AuthTypeEnum,T as AuthorizationTypeEnum,Rt as CacheKeys,ut as Capabilities,Bt as CohereConstants,tn as ComponentTypes,zt as Constants,p as ContentTypes,D as EAgent,ft as EImageOutputType,j as EModelEndpoint,Pt as EndpointURLs,jt as ErrorTypes,xt as FetchTokenConfig,Ze as FileContext,I as FilePurpose,$e as FileSources,qt as ForkOptions,Kn as FunctionSignature,U as ImageDetail,Gt as ImageDetailCost,K as ImageVisionTool,yt as KnownEndpoints,Ft as LocalStorageKeys,f as MessageContentTypes,yn as MutationKeys,on as OptionTypes,bn as QueryKeys,g as RunStatus,Fn as SSE,nn as SettingTypes,Dt as SettingsTabValues,it as SettingsViews,m as StepStatus,c as StepTypes,E as TokenExchangeMethodEnum,d as ToolCallTypes,l as Tools,Mt as ViolationTypes,Et as VisionModes,O as actionDelimiter,A as actionDomainSeparator,te as agentOptionSettings,Ot as alternateName,me as anthropicSchema,Re as applicationMimeTypes,gt as assistantEndpointSchema,ye as assistantSchema,G as authTypeSchema,ct as azureBaseSchema,vt as azureEndpointSchema,mt as azureGroupConfigsSchema,dt as azureGroupSchema,de as bingAISchema,fe as chatGPTBrowserSchema,Ue as codeInterpreterMimeTypes,Pe as codeInterpreterMimeTypesList,Ge as codeTypeMapping,ae as coerceNumber,Ee as compactAnthropicSchema,xe as compactAssistantSchema,Ie as compactChatGPTSchema,Te as compactGoogleSchema,_e as compactOpenAISchema,Oe as compactPluginsSchema,_t as configSchema,pn as conflictingAzureVariables,Ve as convertStringsToRegex,Zn as createPayload,Bn as createURL,zn as dataService,B as defaultAssistantFormValues,It as defaultEndpoints,At as defaultModels,N as defaultOrderQuery,rt as defaultRetrievalModels,at as defaultSocialLogins,un as deprecatedAzureVariables,ne as eAgentOptionsSchema,q as eImageDetailSchema,Q as eModelEndpointSchema,Ke as endpointFileConfigSchema,ht as endpointSchema,$ as endpointSettings,Wt as envVarRegex,Qt as errorsToString,ke as excelFileTypes,we as excelMimeTypes,W as extendedModelEndpointSchema,Xt as extractEnvVariable,qe as fileConfig,He as fileConfigSchema,st as fileSourceSchema,Le as fullMimeTypesList,gn as generateDynamicSchema,_n as generateGoogleSchema,xn as generateOpenAISchema,Tt as getConfigDefaults,$t as getEnabledEndpoints,en as getFirstDefinedValue,rn as getResponseSender,lt as getSchemaDefaults,ce as googleSchema,Y as googleSettings,ge as gptPluginsSchema,k as hostImageIdSuffix,L as hostImageNamePrefix,z as imageDetailNumeric,F as imageDetailValue,Ce as imageExtRegex,Vt as imageGenTools,Me as imageMimeTypes,Lt as initialModelsConfig,H as isImageVisionTool,M as isUUID,mn as mapGroupToAzureConfig,dn as mapModelToAzureConfig,Fe as mbToBytes,ze as megabyte,Ye as mergeFileConfig,pt as modelConfigSchema,St as modularEndpoints,pe as openAISchema,V as openAISettings,Yn as openapiToFunction,Zt as orderEndpointsConfig,ln as parseCompactConvo,an as parseConvo,bt as rateLimitSchema,he as removeNullishValues,Dn as request,Jt as resolveHeaders,Vn as resolveRef,De as retrievalMimeTypes,Se as retrievalMimeTypesList,Tn as setAcceptLanguageHeader,En as setTokenHeader,qn as sha1,ot as specsConfigSchema,je as supportedMimeTypes,Ct as supportsBalanceCheck,Ae as supportsFiles,oe as tAgentOptionsSchema,re as tConversationSchema,le as tConvoUpdateSchema,ee as tExampleSchema,ie as tMessageSchema,nt as tModelSpecSchema,X as tPluginAuthConfigSchema,J as tPluginSchema,se as tPresetSchema,ue as tPresetUpdateSchema,Ne as textMimeTypes,$n as validateAndParseOpenAPISpec,cn as validateAzureGroups,vn as validateSettingDefinitions,Nt as validateVisionModel,wt as visionModels};
|
|
1
|
+
import{z as e,ZodArray as t,ZodIssueCode as n,ZodError as o}from"zod";import i from"axios";import{URL as a}from"url";import r from"crypto";import{load as s}from"js-yaml";var l,u,p,c,d,m,f,g,h=function(){return h=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},h.apply(this,arguments)};function v(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function b(e,t,n,o){return new(n||(n=Promise))((function(i,a){function r(e){try{l(o.next(e))}catch(e){a(e)}}function s(e){try{l(o.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,s)}l((o=o.apply(e,t||[])).next())}))}function y(e,t){var n,o,i,a,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(r=0)),r;)try{if(n=1,o&&(i=2&s[0]?o.return:s[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;switch(o=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return r.label++,{value:s[1],done:!1};case 5:r.label++,o=s[1],s=[0];continue;case 7:s=r.ops.pop(),r.trys.pop();continue;default:if(!(i=r.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){r=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){r.label=s[1];break}if(6===s[0]&&r.label<i[1]){r.label=i[1],i=s;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(s);break}i[2]&&r.ops.pop(),r.trys.pop();continue}s=t.call(e,r)}catch(e){s=[6,e],o=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function x(e,t,n){if(n||2===arguments.length)for(var o,i=0,a=t.length;i<a;i++)!o&&i in t||(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError,function(e){e.code_interpreter="code_interpreter",e.retrieval="retrieval",e.function="function"}(l||(l={})),function(e){e.FILE_CITATION="file_citation",e.FILE_PATH="file_path"}(u||(u={})),function(e){e.TEXT="text",e.TOOL_CALL="tool_call",e.IMAGE_FILE="image_file",e.ERROR="error"}(p||(p={})),function(e){e.TOOL_CALLS="tool_calls",e.MESSAGE_CREATION="message_creation"}(c||(c={})),function(e){e.FUNCTION="function",e.RETRIEVAL="retrieval",e.CODE_INTERPRETER="code_interpreter"}(d||(d={})),function(e){e.IN_PROGRESS="in_progress",e.CANCELLED="cancelled",e.FAILED="failed",e.COMPLETED="completed",e.EXPIRED="expired"}(m||(m={})),function(e){e.TEXT="text",e.IMAGE_FILE="image_file"}(f||(f={})),function(e){e.QUEUED="queued",e.IN_PROGRESS="in_progress",e.REQUIRES_ACTION="requires_action",e.CANCELLING="cancelling",e.CANCELLED="cancelled",e.FAILED="failed",e.COMPLETED="completed",e.EXPIRED="expired"}(g||(g={}));var _,T,E,I,O="_action_",A="---",k="_host_copy",L="host_copy_";!function(e){e.ServiceHttp="service_http",e.OAuth="oauth",e.None="none"}(_||(_={})),function(e){e.Bearer="bearer",e.Basic="basic",e.Custom="custom"}(T||(T={})),function(e){e.DefaultPost="default_post",e.BasicAuthHeader="basic_auth_header"}(E||(E={})),function(e){e.FineTune="fine-tune",e.FineTuneResults="fine-tune-results",e.Assistants="assistants",e.AssistantsOutput="assistants_output"}(I||(I={}));var P,S,C,w,N={order:"desc",limit:100};!function(e){e.ThreadCreated="thread.created",e.ThreadRunCreated="thread.run.created",e.ThreadRunQueued="thread.run.queued",e.ThreadRunInProgress="thread.run.in_progress",e.ThreadRunRequiresAction="thread.run.requires_action",e.ThreadRunCompleted="thread.run.completed",e.ThreadRunFailed="thread.run.failed",e.ThreadRunCancelling="thread.run.cancelling",e.ThreadRunCancelled="thread.run.cancelled",e.ThreadRunExpired="thread.run.expired",e.ThreadRunStepCreated="thread.run.step.created",e.ThreadRunStepInProgress="thread.run.step.in_progress",e.ThreadRunStepCompleted="thread.run.step.completed",e.ThreadRunStepFailed="thread.run.step.failed",e.ThreadRunStepCancelled="thread.run.step.cancelled",e.ThreadRunStepExpired="thread.run.step.expired",e.ThreadRunStepDelta="thread.run.step.delta",e.ThreadMessageCreated="thread.message.created",e.ThreadMessageInProgress="thread.message.in_progress",e.ThreadMessageCompleted="thread.message.completed",e.ThreadMessageIncomplete="thread.message.incomplete",e.ThreadMessageDelta="thread.message.delta",e.ErrorEvent="error"}(P||(P={}));var R,M=e.string().uuid();!function(e){e.OVERRIDE_AUTH="override_auth",e.USER_PROVIDED="user_provided",e.SYSTEM_DEFINED="SYSTEM_DEFINED"}(R||(R={}));var j,U,G=e.nativeEnum(R);!function(e){e.azureOpenAI="azureOpenAI",e.openAI="openAI",e.bingAI="bingAI",e.chatGPTBrowser="chatGPTBrowser",e.google="google",e.gptPlugins="gptPlugins",e.anthropic="anthropic",e.assistants="assistants",e.custom="custom"}(j||(j={})),function(e){e.low="low",e.auto="auto",e.high="high"}(U||(U={}));var D,z=((S={})[U.low]=0,S[U.auto]=1,S[U.high]=2,S),F={0:U.low,1:U.auto,2:U.high},q=e.nativeEnum(U),B={assistant:"",id:"",name:"",description:"",instructions:"",model:"",functions:[],code_interpreter:!1,image_vision:!1,retrieval:!1},K=((C={type:l.function})[l.function]={name:"image_vision",description:"Get detailed text descriptions for all current image attachments.",parameters:{type:"object",properties:{},required:[]}},C),H=function(e){var t,n;return"function"===e.type&&(null===(t=e.function)||void 0===t?void 0:t.name)===(null===(n=null==K?void 0:K.function)||void 0===n?void 0:n.name)},V={model:{default:"gpt-3.5-turbo"},temperature:{min:0,max:1,step:.01,default:1},top_p:{min:0,max:1,step:.01,default:1},presence_penalty:{min:0,max:2,step:.01,default:0},frequency_penalty:{min:0,max:2,step:.01,default:0},resendFiles:{default:!0},maxContextTokens:{default:void 0},max_tokens:{default:void 0},imageDetail:{default:U.auto}},Y={model:{default:"chat-bison"},maxOutputTokens:{min:1,max:2048,step:1,default:1024,maxGemini:8192,defaultGemini:8192},temperature:{min:0,max:1,step:.01,default:.2},topP:{min:0,max:1,step:.01,default:.8},topK:{min:1,max:40,step:.01,default:40}},$=((w={})[j.openAI]=V,w[j.google]=Y,w),Z=$[j.google],Q=e.nativeEnum(j),W=e.union([Q,e.string()]),X=e.object({authField:e.string(),label:e.string(),description:e.string()}),J=e.object({name:e.string(),pluginKey:e.string(),description:e.string(),icon:e.string(),authConfig:e.array(X),authenticated:e.boolean().optional(),isButton:e.boolean().optional()}),ee=e.object({input:e.object({content:e.string()}),output:e.object({content:e.string()})});!function(e){e.functions="functions",e.classic="classic"}(D||(D={}));var te={model:{default:"gpt-4-turbo"},temperature:{min:0,max:1,step:.01,default:0},agent:{default:D.functions,options:[D.functions,D.classic]},skipCompletion:{default:!0}},ne=e.nativeEnum(D),oe=e.object({agent:e.string().default(D.functions),skipCompletion:e.boolean().default(te.skipCompletion.default),model:e.string(),temperature:e.number().default(te.temperature.default)}),ie=e.object({messageId:e.string(),endpoint:e.string().optional(),clientId:e.string().nullable().optional(),conversationId:e.string().nullable(),parentMessageId:e.string().nullable(),responseMessageId:e.string().nullable().optional(),overrideParentMessageId:e.string().nullable().optional(),bg:e.string().nullable().optional(),model:e.string().nullable().optional(),title:e.string().nullable().or(e.literal("New Chat")).default("New Chat"),sender:e.string(),text:e.string(),generation:e.string().nullable().optional(),isEdited:e.boolean().optional(),isCreatedByUser:e.boolean(),error:e.boolean(),createdAt:e.string().optional().default((function(){return(new Date).toISOString()})),updatedAt:e.string().optional().default((function(){return(new Date).toISOString()})),current:e.boolean().optional(),unfinished:e.boolean().optional(),searchResult:e.boolean().optional(),finish_reason:e.string().optional(),thread_id:e.string().optional(),iconURL:e.string().optional()}),ae=e.union([e.number(),e.string()]).transform((function(e){return"string"==typeof e?""===e.trim()?void 0:parseFloat(e):e})),re=e.object({conversationId:e.string().nullable(),title:e.string().nullable().or(e.literal("New Chat")).default("New Chat"),user:e.string().optional(),endpoint:Q.nullable(),endpointType:Q.optional(),suggestions:e.array(e.string()).optional(),messages:e.array(e.string()).optional(),tools:e.union([e.array(J),e.array(e.string())]).optional(),createdAt:e.string(),updatedAt:e.string(),systemMessage:e.string().nullable().optional(),modelLabel:e.string().nullable().optional(),examples:e.array(ee).optional(),chatGptLabel:e.string().nullable().optional(),userLabel:e.string().optional(),model:e.string().nullable().optional(),promptPrefix:e.string().nullable().optional(),temperature:e.number().optional(),topP:e.number().optional(),topK:e.number().optional(),context:e.string().nullable().optional(),top_p:e.number().optional(),frequency_penalty:e.number().optional(),presence_penalty:e.number().optional(),jailbreak:e.boolean().optional(),jailbreakConversationId:e.string().nullable().optional(),conversationSignature:e.string().nullable().optional(),parentMessageId:e.string().optional(),clientId:e.string().nullable().optional(),invocationId:e.number().nullable().optional(),toneStyle:e.string().nullable().optional(),maxOutputTokens:e.number().optional(),agentOptions:oe.nullable().optional(),file_ids:e.array(e.string()).optional(),maxContextTokens:ae.optional(),max_tokens:ae.optional(),resendImages:e.boolean().optional(),resendFiles:e.boolean().optional(),imageDetail:q.optional(),assistant_id:e.string().optional(),instructions:e.string().optional(),presetOverride:e.record(e.unknown()).optional(),stop:e.array(e.string()).optional(),iconURL:e.string().optional(),greeting:e.string().optional(),spec:e.string().optional()}),se=re.omit({conversationId:!0,createdAt:!0,updatedAt:!0,title:!0}).merge(e.object({conversationId:e.string().nullable().optional(),presetId:e.string().nullable().optional(),title:e.string().nullable().optional(),defaultPreset:e.boolean().optional(),order:e.number().optional(),endpoint:W.nullable()})),le=re.merge(e.object({endpoint:W.nullable()})),ue=re.merge(e.object({endpoint:W.nullable()})),pe=re.pick({model:!0,modelLabel:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,resendFiles:!0,imageDetail:!0,stop:!0,iconURL:!0,greeting:!0,spec:!0,maxContextTokens:!0,max_tokens:!0}).transform((function(e){var t,n,o,i,a,r,s,l,u,p,c,d,m,f,g;return h(h({},e),{model:null!==(t=e.model)&&void 0!==t?t:V.model.default,chatGptLabel:null!==(o=null!==(n=e.modelLabel)&&void 0!==n?n:e.chatGptLabel)&&void 0!==o?o:null,promptPrefix:null!==(i=e.promptPrefix)&&void 0!==i?i:null,temperature:null!==(a=e.temperature)&&void 0!==a?a:V.temperature.default,top_p:null!==(r=e.top_p)&&void 0!==r?r:V.top_p.default,presence_penalty:null!==(s=e.presence_penalty)&&void 0!==s?s:V.presence_penalty.default,frequency_penalty:null!==(l=e.frequency_penalty)&&void 0!==l?l:V.frequency_penalty.default,resendFiles:"boolean"==typeof e.resendFiles?e.resendFiles:V.resendFiles.default,imageDetail:null!==(u=e.imageDetail)&&void 0!==u?u:V.imageDetail.default,stop:null!==(p=e.stop)&&void 0!==p?p:void 0,iconURL:null!==(c=e.iconURL)&&void 0!==c?c:void 0,greeting:null!==(d=e.greeting)&&void 0!==d?d:void 0,spec:null!==(m=e.spec)&&void 0!==m?m:void 0,maxContextTokens:null!==(f=e.maxContextTokens)&&void 0!==f?f:void 0,max_tokens:null!==(g=e.max_tokens)&&void 0!==g?g:void 0})})).catch((function(){return{model:V.model.default,chatGptLabel:null,promptPrefix:null,temperature:V.temperature.default,top_p:V.top_p.default,presence_penalty:V.presence_penalty.default,frequency_penalty:V.frequency_penalty.default,resendFiles:V.resendFiles.default,imageDetail:V.imageDetail.default,stop:void 0,iconURL:void 0,greeting:void 0,spec:void 0,maxContextTokens:void 0,max_tokens:void 0}})),ce=re.pick({model:!0,modelLabel:!0,promptPrefix:!0,examples:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0,iconURL:!0,greeting:!0,spec:!0,maxContextTokens:!0}).transform((function(e){var t,n,o,i,a,r,s,l,u,p,c,d,m,f,g=null===(n=null===(t=null==e?void 0:e.model)||void 0===t?void 0:t.toLowerCase())||void 0===n?void 0:n.includes("gemini"),v=g?Z.maxOutputTokens.maxGemini:Z.maxOutputTokens.max,b=g?Z.maxOutputTokens.defaultGemini:Z.maxOutputTokens.default,y=null!==(o=e.maxOutputTokens)&&void 0!==o?o:b;return y=Math.min(y,v),h(h({},e),{model:null!==(i=e.model)&&void 0!==i?i:Z.model.default,modelLabel:null!==(a=e.modelLabel)&&void 0!==a?a:null,promptPrefix:null!==(r=e.promptPrefix)&&void 0!==r?r:null,examples:null!==(s=e.examples)&&void 0!==s?s:[{input:{content:""},output:{content:""}}],temperature:null!==(l=e.temperature)&&void 0!==l?l:Z.temperature.default,maxOutputTokens:y,topP:null!==(u=e.topP)&&void 0!==u?u:Z.topP.default,topK:null!==(p=e.topK)&&void 0!==p?p:Z.topK.default,iconURL:null!==(c=e.iconURL)&&void 0!==c?c:void 0,greeting:null!==(d=e.greeting)&&void 0!==d?d:void 0,spec:null!==(m=e.spec)&&void 0!==m?m:void 0,maxContextTokens:null!==(f=e.maxContextTokens)&&void 0!==f?f:void 0})})).catch((function(){return{model:Z.model.default,modelLabel:null,promptPrefix:null,examples:[{input:{content:""},output:{content:""}}],temperature:Z.temperature.default,maxOutputTokens:Z.maxOutputTokens.default,topP:Z.topP.default,topK:Z.topK.default,iconURL:void 0,greeting:void 0,spec:void 0,maxContextTokens:void 0}})),de=re.pick({jailbreak:!0,systemMessage:!0,context:!0,toneStyle:!0,jailbreakConversationId:!0,conversationSignature:!0,clientId:!0,invocationId:!0}).transform((function(e){var t,n,o,i,a,r,s,l;return h(h({},e),{model:"",jailbreak:null!==(t=e.jailbreak)&&void 0!==t&&t,systemMessage:null!==(n=e.systemMessage)&&void 0!==n?n:null,context:null!==(o=e.context)&&void 0!==o?o:null,toneStyle:null!==(i=e.toneStyle)&&void 0!==i?i:"creative",jailbreakConversationId:null!==(a=e.jailbreakConversationId)&&void 0!==a?a:null,conversationSignature:null!==(r=e.conversationSignature)&&void 0!==r?r:null,clientId:null!==(s=e.clientId)&&void 0!==s?s:null,invocationId:null!==(l=e.invocationId)&&void 0!==l?l:1})})).catch((function(){return{model:"",jailbreak:!1,systemMessage:null,context:null,toneStyle:"creative",jailbreakConversationId:null,conversationSignature:null,clientId:null,invocationId:1}})),me=re.pick({model:!0,modelLabel:!0,promptPrefix:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0,resendFiles:!0,iconURL:!0,greeting:!0,spec:!0,maxContextTokens:!0}).transform((function(e){var t,n,o,i,a,r,s,l,u,p,c;return h(h({},e),{model:null!==(t=e.model)&&void 0!==t?t:"claude-1",modelLabel:null!==(n=e.modelLabel)&&void 0!==n?n:null,promptPrefix:null!==(o=e.promptPrefix)&&void 0!==o?o:null,temperature:null!==(i=e.temperature)&&void 0!==i?i:1,maxOutputTokens:null!==(a=e.maxOutputTokens)&&void 0!==a?a:4e3,topP:null!==(r=e.topP)&&void 0!==r?r:.7,topK:null!==(s=e.topK)&&void 0!==s?s:5,resendFiles:"boolean"!=typeof e.resendFiles||e.resendFiles,iconURL:null!==(l=e.iconURL)&&void 0!==l?l:void 0,greeting:null!==(u=e.greeting)&&void 0!==u?u:void 0,spec:null!==(p=e.spec)&&void 0!==p?p:void 0,maxContextTokens:null!==(c=e.maxContextTokens)&&void 0!==c?c:void 0})})).catch((function(){return{model:"claude-1",modelLabel:null,promptPrefix:null,temperature:1,maxOutputTokens:4e3,topP:.7,topK:5,resendFiles:!0,iconURL:void 0,greeting:void 0,spec:void 0,maxContextTokens:void 0}})),fe=re.pick({model:!0}).transform((function(e){var t;return h(h({},e),{model:null!==(t=e.model)&&void 0!==t?t:"text-davinci-002-render-sha"})})).catch((function(){return{model:"text-davinci-002-render-sha"}})),ge=re.pick({model:!0,modelLabel:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,tools:!0,agentOptions:!0,iconURL:!0,greeting:!0,spec:!0,maxContextTokens:!0}).transform((function(e){var t,n,o,i,a,r,s,l,u,p,c,d,m,f;return h(h({},e),{model:null!==(t=e.model)&&void 0!==t?t:"gpt-3.5-turbo",chatGptLabel:null!==(o=null!==(n=e.modelLabel)&&void 0!==n?n:e.chatGptLabel)&&void 0!==o?o:null,promptPrefix:null!==(i=e.promptPrefix)&&void 0!==i?i:null,temperature:null!==(a=e.temperature)&&void 0!==a?a:.8,top_p:null!==(r=e.top_p)&&void 0!==r?r:1,presence_penalty:null!==(s=e.presence_penalty)&&void 0!==s?s:0,frequency_penalty:null!==(l=e.frequency_penalty)&&void 0!==l?l:0,tools:null!==(u=e.tools)&&void 0!==u?u:[],agentOptions:null!==(p=e.agentOptions)&&void 0!==p?p:{agent:D.functions,skipCompletion:!0,model:"gpt-3.5-turbo",temperature:0},iconURL:null!==(c=e.iconURL)&&void 0!==c?c:void 0,greeting:null!==(d=e.greeting)&&void 0!==d?d:void 0,spec:null!==(m=e.spec)&&void 0!==m?m:void 0,maxContextTokens:null!==(f=e.maxContextTokens)&&void 0!==f?f:void 0})})).catch((function(){return{model:"gpt-3.5-turbo",chatGptLabel:null,promptPrefix:null,temperature:.8,top_p:1,presence_penalty:0,frequency_penalty:0,tools:[],agentOptions:{agent:D.functions,skipCompletion:!0,model:"gpt-3.5-turbo",temperature:0},iconURL:void 0,greeting:void 0,spec:void 0,maxContextTokens:void 0}}));function he(e){var t=h({},e);return Object.keys(t).forEach((function(e){void 0!==t[e]&&null!==t[e]&&""!==t[e]||delete t[e]})),t}var ve,be,ye=re.pick({model:!0,assistant_id:!0,instructions:!0,promptPrefix:!0,iconURL:!0,greeting:!0,spec:!0}).transform((function(e){var t,n,o,i,a,r,s;return h(h({},e),{model:null!==(t=e.model)&&void 0!==t?t:V.model.default,assistant_id:null!==(n=e.assistant_id)&&void 0!==n?n:void 0,instructions:null!==(o=e.instructions)&&void 0!==o?o:void 0,promptPrefix:null!==(i=e.promptPrefix)&&void 0!==i?i:null,iconURL:null!==(a=e.iconURL)&&void 0!==a?a:void 0,greeting:null!==(r=e.greeting)&&void 0!==r?r:void 0,spec:null!==(s=e.spec)&&void 0!==s?s:void 0})})).catch((function(){return{model:V.model.default,assistant_id:void 0,instructions:void 0,promptPrefix:null,iconURL:void 0,greeting:void 0,spec:void 0}})),xe=re.pick({model:!0,assistant_id:!0,instructions:!0,promptPrefix:!0,iconURL:!0,greeting:!0,spec:!0}).transform(he).catch((function(){return{}})),_e=re.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,resendFiles:!0,imageDetail:!0,stop:!0,iconURL:!0,greeting:!0,spec:!0,maxContextTokens:!0,max_tokens:!0}).transform((function(e){var t=h({},e);return 1===t.temperature&&delete t.temperature,1===t.top_p&&delete t.top_p,0===t.presence_penalty&&delete t.presence_penalty,0===t.frequency_penalty&&delete t.frequency_penalty,!0===t.resendFiles&&delete t.resendFiles,t.imageDetail===U.auto&&delete t.imageDetail,he(t)})).catch((function(){return{}})),Te=re.pick({model:!0,modelLabel:!0,promptPrefix:!0,examples:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0,iconURL:!0,greeting:!0,spec:!0,maxContextTokens:!0}).transform((function(e){var t=h({},e);return t.temperature===Z.temperature.default&&delete t.temperature,t.maxOutputTokens===Z.maxOutputTokens.default&&delete t.maxOutputTokens,t.topP===Z.topP.default&&delete t.topP,t.topK===Z.topK.default&&delete t.topK,he(t)})).catch((function(){return{}})),Ee=re.pick({model:!0,modelLabel:!0,promptPrefix:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0,resendFiles:!0,iconURL:!0,greeting:!0,spec:!0,maxContextTokens:!0}).transform((function(e){var t=h({},e);return 1===t.temperature&&delete t.temperature,4e3===t.maxOutputTokens&&delete t.maxOutputTokens,.7===t.topP&&delete t.topP,5===t.topK&&delete t.topK,!0===t.resendFiles&&delete t.resendFiles,he(t)})).catch((function(){return{}})),Ie=re.pick({model:!0}).transform((function(e){return he(h({},e))})).catch((function(){return{}})),Oe=re.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,tools:!0,agentOptions:!0,iconURL:!0,greeting:!0,spec:!0,maxContextTokens:!0}).transform((function(e){var t,n=h({},e);return null===n.chatGptLabel&&delete n.chatGptLabel,null===n.promptPrefix&&delete n.promptPrefix,.8===n.temperature&&delete n.temperature,1===n.top_p&&delete n.top_p,0===n.presence_penalty&&delete n.presence_penalty,0===n.frequency_penalty&&delete n.frequency_penalty,0===(null===(t=n.tools)||void 0===t?void 0:t.length)&&delete n.tools,n.agentOptions&&n.agentOptions.agent===D.functions&&!0===n.agentOptions.skipCompletion&&"gpt-3.5-turbo"===n.agentOptions.model&&0===n.agentOptions.temperature&&delete n.agentOptions,he(n)})).catch((function(){return{}})),Ae=((ve={})[j.openAI]=!0,ve[j.google]=!0,ve[j.assistants]=!0,ve[j.azureOpenAI]=!0,ve[j.anthropic]=!0,ve[j.custom]=!0,ve),ke=["application/vnd.ms-excel","application/msexcel","application/x-msexcel","application/x-ms-excel","application/x-excel","application/x-dos_ms_excel","application/xls","application/x-xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],Le=x(["text/x-c","text/x-c++","application/csv","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/html","text/x-java","application/json","text/markdown","application/pdf","text/x-php","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/x-python","text/x-script.python","text/x-ruby","text/x-tex","text/plain","text/css","image/jpeg","text/javascript","image/gif","image/png","application/x-tar","application/typescript","application/xml","application/zip"],ke,!0),Pe=x(["text/x-c","text/x-c++","application/csv","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/html","text/x-java","application/json","text/markdown","application/pdf","text/x-php","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/x-python","text/x-script.python","text/x-ruby","text/x-tex","text/plain","text/css","image/jpeg","text/javascript","image/gif","image/png","application/x-tar","application/typescript","application/xml","application/zip"],ke,!0),Se=["text/x-c","text/x-c++","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/html","text/x-java","application/json","text/markdown","application/pdf","text/x-php","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/x-python","text/x-script.python","text/x-ruby","text/x-tex","text/plain"],Ce=/\.(jpg|jpeg|png|gif|webp)$/i,we=/^application\/(vnd\.ms-excel|msexcel|x-msexcel|x-ms-excel|x-excel|x-dos_ms_excel|xls|x-xls|vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet)$/,Ne=/^(text\/(x-c|x-c\+\+|x-java|html|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|css|javascript|csv))$/,Re=/^(application\/(epub\+zip|csv|json|pdf|x-tar|typescript|vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation|spreadsheetml\.sheet)|xml|zip))$/,Me=/^image\/(jpeg|gif|png|webp)$/,je=[Ne,we,Re,Me],Ue=[Ne,we,Re,Me],Ge={c:"text/x-c",cs:"text/x-csharp",cpp:"text/x-c++",md:"text/markdown",php:"text/x-php",py:"text/x-python",rb:"text/x-ruby",tex:"text/x-tex",js:"text/javascript",sh:"application/x-sh",ts:"application/typescript",tar:"application/x-tar",zip:"application/zip"},De=[/^(text\/(x-c|x-c\+\+|html|x-java|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|xml))$/,/^(application\/(json|pdf|vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation)))$/],ze=1048576,Fe=function(e){return e*ze},qe={endpoints:(be={},be[j.assistants]={fileLimit:10,fileSizeLimit:Fe(512),totalSizeLimit:Fe(512),supportedMimeTypes:je,disabled:!1},be.default={fileLimit:10,fileSizeLimit:Fe(512),totalSizeLimit:Fe(512),supportedMimeTypes:je,disabled:!1},be),serverFileSizeLimit:Fe(512),avatarSizeLimit:Fe(2),checkType:function(e,t){return void 0===t&&(t=je),t.some((function(t){return t.test(e)}))}},Be=e.array(e.any()).optional().refine((function(e){return!e||e.every((function(e){return e instanceof RegExp||"string"==typeof e}))}),{message:"Each mimeType must be a string or a RegExp object."}),Ke=e.object({disabled:e.boolean().optional(),fileLimit:e.number().min(0).optional(),fileSizeLimit:e.number().min(0).optional(),totalSizeLimit:e.number().min(0).optional(),supportedMimeTypes:Be.optional()}),He=e.object({endpoints:e.record(Ke).optional(),serverFileSizeLimit:e.number().min(0).optional(),avatarSizeLimit:e.number().min(0).optional()}),Ve=function(e){return e.reduce((function(e,t){try{var n=new RegExp(t);e.push(n)}catch(e){console.error('Invalid regex pattern "'.concat(t,'" skipped.'))}return e}),[])};function Ye(e){var t=qe;if(!e)return t;if(void 0!==e.serverFileSizeLimit&&(t.serverFileSizeLimit=Fe(e.serverFileSizeLimit)),void 0!==e.avatarSizeLimit&&(t.avatarSizeLimit=Fe(e.avatarSizeLimit)),!e.endpoints)return t;var n=function(n){var o=e.endpoints[n];t.endpoints[n]||(t.endpoints[n]={});var i=t.endpoints[n];if(!0===o.disabled)return i.disabled=!0,i.fileLimit=0,i.fileSizeLimit=0,i.totalSizeLimit=0,i.supportedMimeTypes=[],"continue";void 0!==o.fileSizeLimit&&(i.fileSizeLimit=Fe(o.fileSizeLimit)),void 0!==o.totalSizeLimit&&(i.totalSizeLimit=Fe(o.totalSizeLimit));["fileLimit"].forEach((function(e){void 0!==o[e]&&(i[e]=o[e])})),o.supportedMimeTypes&&(i.supportedMimeTypes=Ve(o.supportedMimeTypes))};for(var o in e.endpoints)n(o);return t}var $e,Ze,Qe,We,Xe,Je,et,tt,nt=e.object({name:e.string(),label:e.string(),preset:se,order:e.number().optional(),default:e.boolean().optional(),description:e.string().optional(),showIconInMenu:e.boolean().optional(),showIconInHeader:e.boolean().optional(),iconURL:e.union([e.string(),Q]).optional(),authType:G.optional()}),ot=e.object({enforce:e.boolean().default(!1),prioritize:e.boolean().default(!0),list:e.array(nt).optional()});!function(e){e.local="local",e.firebase="firebase",e.openai="openai",e.s3="s3",e.vectordb="vectordb"}($e||($e={})),function(e){e.avatar="avatar",e.unknown="unknown",e.assistants="assistants",e.image_generation="image_generation",e.assistants_output="assistants_output",e.message_attachment="message_attachment",e.filename="filename",e.updatedAt="updatedAt",e.source="source",e.context="context",e.bytes="bytes"}(Ze||(Ze={}));var it,at=["google","facebook","openid","github","discord"],rt=["gpt-4-turbo-preview","gpt-3.5-turbo-0125","gpt-4-0125-preview","gpt-4-1106-preview","gpt-3.5-turbo-1106","gpt-3.5-turbo-0125","gpt-4-turbo","gpt-4-0125","gpt-4-1106"];!function(e){e.default="default",e.advanced="advanced"}(it||(it={}));var st=e.nativeEnum($e);function lt(t){var n=t.shape,o=Object.entries(n).map((function(t){var n=t[0],o=t[1];return o instanceof e.ZodDefault?[n,o._def.defaultValue()]:[n,void 0]}));return Object.fromEntries(o)}var ut,pt=e.object({deploymentName:e.string().optional(),version:e.string().optional(),assistants:e.boolean().optional()}).or(e.boolean()),ct=e.object({apiKey:e.string(),serverless:e.boolean().optional(),instanceName:e.string().optional(),deploymentName:e.string().optional(),assistants:e.boolean().optional(),addParams:e.record(e.any()).optional(),dropParams:e.array(e.string()).optional(),forcePrompt:e.boolean().optional(),version:e.string().optional(),baseURL:e.string().optional(),additionalHeaders:e.record(e.any()).optional()}),dt=e.object({group:e.string(),models:e.record(e.string(),pt)}).required().and(ct),mt=e.array(dt).min(1);!function(e){e.code_interpreter="code_interpreter",e.image_vision="image_vision",e.retrieval="retrieval",e.actions="actions",e.tools="tools"}(ut||(ut={}));var ft,gt=e.object({disableBuilder:e.boolean().optional(),pollIntervalMs:e.number().optional(),timeoutMs:e.number().optional(),supportedIds:e.array(e.string()).min(1).optional(),excludedIds:e.array(e.string()).min(1).optional(),retrievalModels:e.array(e.string()).min(1).optional().default(rt),capabilities:e.array(e.nativeEnum(ut)).optional().default([ut.code_interpreter,ut.image_vision,ut.retrieval,ut.actions,ut.tools]),apiKey:e.string().optional(),baseURL:e.string().optional(),models:e.object({default:e.array(e.string()).min(1),fetch:e.boolean().optional(),userIdQuery:e.boolean().optional()}).optional(),titleConvo:e.boolean().optional(),titleMethod:e.union([e.literal("completion"),e.literal("functions")]).optional(),titleModel:e.string().optional(),headers:e.record(e.any()).optional()}),ht=e.object({name:e.string().refine((function(e){return!Q.safeParse(e).success}),{message:"Value cannot be one of the default endpoint (EModelEndpoint) values: ".concat(Object.values(j).join(", "))}),apiKey:e.string(),baseURL:e.string(),models:e.object({default:e.array(e.string()).min(1),fetch:e.boolean().optional(),userIdQuery:e.boolean().optional()}),titleConvo:e.boolean().optional(),titleMethod:e.union([e.literal("completion"),e.literal("functions")]).optional(),titleModel:e.string().optional(),summarize:e.boolean().optional(),summaryModel:e.string().optional(),forcePrompt:e.boolean().optional(),modelDisplayLabel:e.string().optional(),headers:e.record(e.any()).optional(),addParams:e.record(e.any()).optional(),dropParams:e.array(e.string()).optional(),customOrder:e.number().optional()}),vt=e.object({groups:mt,plugins:e.boolean().optional(),assistants:e.boolean().optional()}).and(ht.pick({titleConvo:!0,titleMethod:!0,titleModel:!0,summarize:!0,summaryModel:!0,customOrder:!0}).partial()),bt=e.object({fileUploads:e.object({ipMax:e.number().optional(),ipWindowInMinutes:e.number().optional(),userMax:e.number().optional(),userWindowInMinutes:e.number().optional()}).optional(),conversationsImport:e.object({ipMax:e.number().optional(),ipWindowInMinutes:e.number().optional(),userMax:e.number().optional(),userWindowInMinutes:e.number().optional()}).optional()});!function(e){e.PNG="png",e.WEBP="webp",e.JPEG="jpeg"}(ft||(ft={}));var yt,xt,_t=e.object({version:e.string(),cache:e.boolean().default(!0),secureImageLinks:e.boolean().optional(),imageOutputType:e.nativeEnum(ft).default(ft.PNG),filteredTools:e.array(e.string()).optional(),interface:e.object({privacyPolicy:e.object({externalUrl:e.string().optional(),openNewTab:e.boolean().optional()}).optional(),termsOfService:e.object({externalUrl:e.string().optional(),openNewTab:e.boolean().optional()}).optional(),endpointsMenu:e.boolean().optional(),modelSelect:e.boolean().optional(),parameters:e.boolean().optional(),sidePanel:e.boolean().optional(),presets:e.boolean().optional()}).default({endpointsMenu:!0,modelSelect:!0,parameters:!0,sidePanel:!0,presets:!0}),fileStrategy:st.default($e.local),registration:e.object({socialLogins:e.array(e.string()).optional(),allowedDomains:e.array(e.string()).optional()}).default({socialLogins:at}),rateLimits:bt.optional(),fileConfig:He.optional(),modelSpecs:ot.optional(),endpoints:e.object((Qe={},Qe[j.azureOpenAI]=vt.optional(),Qe[j.assistants]=gt.optional(),Qe.custom=e.array(ht.partial()).optional(),Qe)).strict().refine((function(e){return Object.keys(e).length>0}),{message:"At least one `endpoints` field must be provided."}).optional()}),Tt=function(){return lt(_t)};!function(e){e.anyscale="anyscale",e.apipie="apipie",e.cohere="cohere",e.fireworks="fireworks",e.groq="groq",e.huggingface="huggingface",e.mistral="mistral",e.mlx="mlx",e.ollama="ollama",e.openrouter="openrouter",e.perplexity="perplexity",e.shuttleai="shuttleai",e["together.ai"]="together.ai"}(yt||(yt={})),function(e){e.openrouter="openrouter"}(xt||(xt={}));var Et,It=[j.openAI,j.assistants,j.azureOpenAI,j.bingAI,j.chatGPTBrowser,j.gptPlugins,j.google,j.anthropic,j.custom],Ot=((We={})[j.openAI]="OpenAI",We[j.assistants]="Assistants",We[j.azureOpenAI]="Azure OpenAI",We[j.bingAI]="Bing",We[j.chatGPTBrowser]="ChatGPT",We[j.gptPlugins]="Plugins",We[j.google]="Google",We[j.anthropic]="Anthropic",We[j.custom]="Custom",We),At=((Xe={})[j.assistants]=["gpt-3.5-turbo","gpt-3.5-turbo-0125","gpt-4-turbo","gpt-4-turbo-2024-04-09","gpt-4-0125-preview","gpt-4-turbo-preview","gpt-4-1106-preview","gpt-3.5-turbo-1106","gpt-3.5-turbo-16k-0613","gpt-3.5-turbo-16k","gpt-4","gpt-4-0314","gpt-4-32k-0314","gpt-4-0613","gpt-3.5-turbo-0613"],Xe[j.google]=["gemini-pro","gemini-pro-vision","chat-bison","chat-bison-32k","codechat-bison","codechat-bison-32k","text-bison","text-bison-32k","text-unicorn","code-gecko","code-bison","code-bison-32k"],Xe[j.anthropic]=["claude-3-opus-20240229","claude-3-sonnet-20240229","claude-3-haiku-20240307","claude-2.1","claude-2","claude-1.2","claude-1","claude-1-100k","claude-instant-1","claude-instant-1-100k"],Xe[j.openAI]=["gpt-3.5-turbo-0125","gpt-4-turbo","gpt-4-turbo-2024-04-09","gpt-3.5-turbo-16k-0613","gpt-3.5-turbo-16k","gpt-4-turbo-preview","gpt-4-0125-preview","gpt-4-1106-preview","gpt-3.5-turbo","gpt-3.5-turbo-1106","gpt-4-vision-preview","gpt-4","gpt-3.5-turbo-instruct-0914","gpt-3.5-turbo-0613","gpt-3.5-turbo-0301","gpt-3.5-turbo-instruct","gpt-4-0613","text-davinci-003","gpt-4-0314"],Xe),kt=At[j.openAI],Lt=((Je={initial:[]})[j.openAI]=kt,Je[j.assistants]=kt.filter((function(e){return/gpt-4|gpt-3\\.5/i.test(e)&&!/vision|instruct/i.test(e)})),Je[j.gptPlugins]=kt,Je[j.azureOpenAI]=kt,Je[j.bingAI]=["BingAI","Sydney"],Je[j.chatGPTBrowser]=["text-davinci-002-render-sha"],Je[j.google]=At[j.google],Je[j.anthropic]=At[j.anthropic],Je),Pt=((et={})[j.openAI]="/api/ask/".concat(j.openAI),et[j.bingAI]="/api/ask/".concat(j.bingAI),et[j.google]="/api/ask/".concat(j.google),et[j.custom]="/api/ask/".concat(j.custom),et[j.anthropic]="/api/ask/".concat(j.anthropic),et[j.gptPlugins]="/api/ask/".concat(j.gptPlugins),et[j.azureOpenAI]="/api/ask/".concat(j.azureOpenAI),et[j.chatGPTBrowser]="/api/ask/".concat(j.chatGPTBrowser),et[j.assistants]="/api/assistants/chat",et),St=new Set([j.gptPlugins,j.anthropic,j.google,j.openAI,j.azureOpenAI,j.custom]),Ct=((tt={})[j.custom]=!0,tt[j.openAI]=!0,tt[j.anthropic]=!0,tt[j.gptPlugins]=!0,tt[j.assistants]=!0,tt[j.azureOpenAI]=!0,tt),wt=["gpt-4-turbo","gpt-4-vision","llava","llava-13b","gemini-pro-vision","claude-3","gemini-1.5"];function Nt(e){var t=e.model,n=e.additionalModels,o=void 0===n?[]:n,i=e.availableModels;return!!t&&("gpt-4-turbo-preview"!==t&&(!(i&&!i.includes(t))&&wt.concat(o).some((function(e){return t.includes(e)}))))}!function(e){e.generative="generative"}(Et||(Et={}));var Rt,Mt,jt,Ut,Gt,Dt,zt,Ft,qt,Bt,Kt,Ht,Vt=new Set(["dalle","dall-e","stable-diffusion"]);!function(e){e.CONFIG_STORE="configStore",e.PLUGINS="plugins",e.GEN_TITLE="genTitle",e.TOOLS="tools",e.MODELS_CONFIG="modelsConfig",e.MODEL_QUERIES="modelQueries",e.ENDPOINT_CONFIG="endpointsConfig",e.TOKEN_CONFIG="tokenConfig",e.CUSTOM_CONFIG="customConfig",e.ABORT_KEYS="abortKeys",e.OVERRIDE_CONFIG="overrideConfig",e.BANS="bans",e.ENCODED_DOMAINS="encoded_domains"}(Rt||(Rt={})),function(e){e.FILE_UPLOAD_LIMIT="file_upload_limit",e.ILLEGAL_MODEL_REQUEST="illegal_model_request",e.TOKEN_BALANCE="token_balance",e.BAN="ban"}(Mt||(Mt={})),function(e){e.NO_USER_KEY="no_user_key",e.EXPIRED_USER_KEY="expired_user_key",e.INVALID_USER_KEY="invalid_user_key",e.NO_BASE_URL="no_base_url",e.MODERATION="moderation"}(jt||(jt={})),function(e){e.GOOGLE_SERVICE_KEY="GOOGLE_SERVICE_KEY",e.GOOGLE_API_KEY="GOOGLE_API_KEY"}(Ut||(Ut={})),function(e){e[e.LOW=85]="LOW",e[e.HIGH=170]="HIGH",e[e.ADDITIONAL=85]="ADDITIONAL"}(Gt||(Gt={})),function(e){e.GENERAL="general",e.MESSAGES="messages",e.BETA="beta",e.DATA="data",e.ACCOUNT="account"}(Dt||(Dt={})),function(e){e.VERSION="v0.7.2",e.CONFIG_VERSION="1.0.9",e.NO_PARENT="00000000-0000-0000-0000-000000000000",e[e.ENCODED_DOMAIN_LENGTH=10]="ENCODED_DOMAIN_LENGTH",e.CURRENT_MODEL="current_model"}(zt||(zt={})),function(e){e.APP_TITLE="appTitle",e.LAST_CONVO_SETUP="lastConversationSetup",e.LAST_BING="lastBingSettings",e.LAST_MODEL="lastSelectedModel",e.LAST_TOOLS="lastSelectedTools",e.LAST_SPEC="lastSelectedSpec",e.FILES_TO_DELETE="filesToDelete",e.ASST_ID_PREFIX="assistant_id__",e.FORK_SETTING="forkSetting",e.REMEMBER_FORK_OPTION="rememberForkOption",e.FORK_SPLIT_AT_TARGET="splitAtTarget"}(Ft||(Ft={})),function(e){e.DIRECT_PATH="directPath",e.INCLUDE_BRANCHES="includeBranches",e.TARGET_LEVEL=""}(qt||(qt={})),function(e){e.API_URL="https://api.cohere.ai/v1",e.ROLE_USER="USER",e.ROLE_SYSTEM="SYSTEM",e.ROLE_CHATBOT="CHATBOT",e.TITLE_MESSAGE="TITLE:"}(Bt||(Bt={}));var Yt=((Kt={})[j.openAI]=pe,Kt[j.azureOpenAI]=pe,Kt[j.custom]=pe,Kt[j.google]=ce,Kt[j.bingAI]=de,Kt[j.anthropic]=me,Kt[j.chatGPTBrowser]=fe,Kt[j.gptPlugins]=ge,Kt[j.assistants]=ye,Kt);function $t(){var e=[j.openAI,j.assistants,j.azureOpenAI,j.google,j.bingAI,j.chatGPTBrowser,j.gptPlugins,j.anthropic],t=process.env.ENDPOINTS||"",n=e;return t&&(n=t.split(",").filter((function(e){return null==e?void 0:e.trim()})).map((function(e){return e.trim()}))),n}function Zt(e){if(!e)return{};var t=$t(),n=Object.keys(e),o=t.indexOf(j.custom);return n.reduce((function(n,i){var a=!(i in j);if(!t.includes(i)&&!a)return n;var r=t.indexOf(i);return a?n[i]=h({order:o>=0?o:9999},e[i]):e[i]&&(n[i]=h(h({},e[i]),{order:r})),n}),{})}function Qt(e){return e.map((function(e){var t=e.path.join("."),n=e.message;return"".concat(t,": ").concat(n)})).join(" ")}var Wt=/^\${(.+)}$/;function Xt(e){var t=e.match(Wt);return t&&process.env[t[1]]||e}function Jt(e){var t=h({},null!=e?e:{});return e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).forEach((function(n){t[n]=Xt(e[n])})),t}function en(e){for(var t,n=0,o=e;n<o.length;n++){var i=o[n];if(i){t=i;break}}return t}var tn,nn,on,an=function(e){var t,n,o=e.endpoint,i=e.endpointType,a=e.conversation,r=e.possibleValues,s=Yt[o];if(!s&&!i)throw new Error("Unknown endpoint: ".concat(o));!s&&i&&(s=Yt[i]);var l=s.parse(a),u=null!=r?r:{},p=u.models,c=u.secondaryModels;return p&&l&&(l.model=null!==(t=en(p))&&void 0!==t?t:l.model),c&&l.agentOptions&&(l.agentOptions.model=null!==(n=en(c))&&void 0!==n?n:l.agentOptions.model),l},rn=function(e){var t,n=e.model,o=e.endpoint,i=e.endpointType,a=e.modelDisplayLabel,r=e.chatGptLabel,s=e.modelLabel,l=e.jailbreak;return[j.openAI,j.azureOpenAI,j.gptPlugins,j.chatGPTBrowser].includes(o)?r||(n&&n.includes("gpt-3")?"GPT-3.5":n&&n.includes("gpt-4")?"GPT-4":n&&n.includes("mistral")?"Mistral":null!==(t=Ot[o])&&void 0!==t?t:"ChatGPT"):o===j.bingAI?l?"Sydney":"BingAI":o===j.anthropic?null!=s?s:"Claude":o===j.google?s||(n&&n.includes("gemini")?"Gemini":n&&n.includes("code")?"Codey":"PaLM2"):o===j.custom||i===j.custom?s||(r||(n&&n.includes("mistral")?"Mistral":n&&n.includes("gpt-3")?"GPT-3.5":n&&n.includes("gpt-4")?"GPT-4":a||"AI")):""},sn=((Ht={})[j.openAI]=_e,Ht[j.azureOpenAI]=_e,Ht[j.custom]=_e,Ht[j.assistants]=xe,Ht[j.google]=Te,Ht[j.bingAI]=de,Ht[j.anthropic]=Ee,Ht[j.chatGPTBrowser]=Ie,Ht[j.gptPlugins]=Oe,Ht),ln=function(e){var t,n=e.endpoint,o=e.endpointType,i=e.conversation,a=e.possibleValues;if(!n)throw new Error("undefined endpoint: ".concat(n));var r=sn[n];if(!r&&!o)throw new Error("Unknown endpoint: ".concat(n));!r&&o&&(r=sn[o]);var s=r.parse(i),l=(null!=a?a:{}).models;return l&&s&&(s.model=null!==(t=en(l))&&void 0!==t?t:s.model),s},un=[{key:"AZURE_OPENAI_DEFAULT_MODEL",description:"setting a default model"},{key:"AZURE_OPENAI_MODELS",description:"setting models"},{key:"AZURE_USE_MODEL_AS_DEPLOYMENT_NAME",description:"using model names as deployment names"},{key:"AZURE_API_KEY",description:"setting a single Azure API key"},{key:"AZURE_OPENAI_API_INSTANCE_NAME",description:"setting a single Azure instance name"},{key:"AZURE_OPENAI_API_DEPLOYMENT_NAME",description:"setting a single Azure deployment name"},{key:"AZURE_OPENAI_API_VERSION",description:"setting a single Azure API version"},{key:"AZURE_OPENAI_API_COMPLETIONS_DEPLOYMENT_NAME",description:"setting a single Azure completions deployment name"},{key:"AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME",description:"setting a single Azure embeddings deployment name"},{key:"PLUGINS_USE_AZURE",description:"using Azure for Plugins"}],pn=[{key:"INSTANCE_NAME"},{key:"DEPLOYMENT_NAME"}];function cn(e){var t=!0,n=[],o={},i={},a=[],r=mt.safeParse(e);if(r.success)for(var s=0,l=r.data;s<l.length;s++){var u=l[s],p=u.group,c=u.apiKey,d=u.instanceName,m=u.deploymentName,f=u.version,g=u.baseURL,b=u.additionalHeaders,y=u.models,x=u.serverless,_=v(u,["group","apiKey","instanceName","deploymentName","version","baseURL","additionalHeaders","models","serverless"]);if(i[p])return a.push('Duplicate group name detected: "'.concat(p,'". Group names must be unique.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:a};if(x&&!g)return a.push('Group "'.concat(p,'" is serverless but missing mandatory "baseURL."')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:a};if(!d&&!x)return a.push('Group "'.concat(p,'" is missing an "instanceName" for non-serverless configuration.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:a};for(var T in i[p]=h({apiKey:c,instanceName:d,deploymentName:m,version:f,baseURL:g,additionalHeaders:b,models:y,serverless:x},_),u.models){n.push(T);var E=u.models[T];if(o[T])return a.push('Duplicate model name detected: "'.concat(T,'". Model names must be unique across groups.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:a};if(x)o[T]={group:p};else if("boolean"==typeof E){if(!u.deploymentName||!u.version)return a.push('Model "'.concat(T,'" in group "').concat(p,'" is missing a deploymentName or version.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:a};o[T]={group:p}}else{if(!E.deploymentName&&!u.deploymentName||!E.version&&!u.version)return a.push('Model "'.concat(T,'" in group "').concat(p,'" is missing a required deploymentName or version.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:a};o[T]={group:p}}}}else t=!1,a.push(Qt(r.error.errors));return{isValid:t,modelNames:n,modelGroupMap:o,groupMap:i,errors:a}}function dn(e){var t=e.modelName,n=e.modelGroupMap,o=e.groupMap,i=n[t];if(!i)throw new Error('Model named "'.concat(t,'" not found in configuration.'));var a=o[i.group];if(!a)throw new Error('Group "'.concat(i.group,'" for model "').concat(t,'" not found in configuration.'));var r=a.instanceName;if(!r&&!a.serverless)throw new Error('Group "'.concat(i.group,'" is missing an instanceName for non-serverless configuration.'));if(a.serverless&&!a.baseURL)throw new Error('Group "'.concat(i.group,'" is missing the required base URL for serverless configuration.'));if(a.serverless){var s={azureOptions:{azureOpenAIApiKey:Xt(a.apiKey)},baseURL:Xt(a.baseURL),serverless:!0},l=s.azureOptions.azureOpenAIApiKey;if("string"==typeof l&&Wt.test(l))throw new Error('Azure configuration environment variable "'.concat(l,'" was not found.'));return a.additionalHeaders&&(s.headers=a.additionalHeaders),s}if(!r)throw new Error('Group "'.concat(i.group,'" is missing an instanceName for non-serverless configuration.'));var u=a.models[t],p="object"==typeof u?{deploymentName:u.deploymentName||a.deploymentName,version:u.version||a.version}:{deploymentName:a.deploymentName,version:a.version},c=p.deploymentName,d=p.version;if(!c||!d)throw new Error('Model "'.concat(t,'" in group "').concat(i.group,'" is missing a deploymentName ("').concat(c,'") or version ("').concat(d,'").'));for(var m={azureOpenAIApiKey:Xt(a.apiKey),azureOpenAIApiInstanceName:Xt(r),azureOpenAIApiDeploymentName:Xt(c),azureOpenAIApiVersion:Xt(d)},f=0,g=Object.values(m);f<g.length;f++){var h=g[f];if("string"==typeof h&&Wt.test(h))throw new Error('Azure configuration environment variable "'.concat(h,'" was not found.'))}var v={azureOptions:m};return a.baseURL&&(v.baseURL=Xt(a.baseURL)),a.additionalHeaders&&(v.headers=a.additionalHeaders),v}function mn(e){var t,n=e.groupName,o=e.groupMap[n];if(!o)throw new Error('Group named "'.concat(n,'" not found in configuration.'));var i=o.instanceName;if(!i&&!o.serverless)throw new Error('Group "'.concat(n,'" is missing an instanceName for non-serverless configuration.'));if(o.serverless&&!o.baseURL)throw new Error('Group "'.concat(n,'" is missing the required base URL for serverless configuration.'));var a=Object.keys(o.models);if(0===a.length)throw new Error('Group "'.concat(n,'" does not have any models configured.'));var r=a[0],s=o.models[r],l={azureOpenAIApiKey:Xt(o.apiKey),azureOpenAIApiInstanceName:Xt(i)};if(o.serverless)return h({azureOptions:l,baseURL:Xt(null!==(t=o.baseURL)&&void 0!==t?t:""),serverless:!0},o.additionalHeaders&&{headers:o.additionalHeaders});var u="object"==typeof s?{deploymentName:s.deploymentName||o.deploymentName,version:s.version||o.version}:{deploymentName:o.deploymentName,version:o.version},p=u.deploymentName,c=u.version;if(!p||!c)throw new Error('Model "'.concat(r,'" in group "').concat(n,'" or the group itself is missing a deploymentName ("').concat(p,'") or version ("').concat(c,'").'));l.azureOpenAIApiDeploymentName=Xt(p),l.azureOpenAIApiVersion=Xt(c);var d={azureOptions:l};return o.baseURL&&(d.baseURL=Xt(o.baseURL)),o.additionalHeaders&&(d.headers=o.additionalHeaders),d}!function(e){e.Input="input",e.Textarea="textarea",e.Slider="slider",e.Checkbox="checkbox",e.Switch="switch",e.Dropdown="dropdown",e.Tags="tags"}(tn||(tn={})),function(e){e.Number="number",e.Boolean="boolean",e.String="string",e.Enum="enum",e.Array="array"}(nn||(nn={})),function(e){e.Conversation="conversation",e.Model="model",e.Custom="custom"}(on||(on={}));var fn=["key","type","component"];function gn(n){for(var o={},i=0,a=n;i<a.length;i++){var r=a[i],s=r.key,l=r.type,u=r.default,p=r.range,c=r.options,d=r.minText,m=r.maxText,f=r.minTags,g=r.maxTags;if(l!==nn.Number)if(l!==nn.Boolean)if(l!==nn.String)if(l!==nn.Enum)if(l!==nn.Array)console.warn("Unsupported setting type: ".concat(l));else{h=e.array(e.string().or(e.number()));f&&h instanceof t&&(h=h.min(f)),g&&h instanceof t&&(h=h.max(g)),u&&Array.isArray(u)&&(h=h.default(u)),o[s]=h}else{if(!c||0===c.length){console.warn("Missing or empty 'options' for enum setting '".concat(s,"'."));continue}h=e.enum(c);o[s]="string"==typeof u?h.default(u):h}else{var h=e.string();d&&(h=h.min(d)),m&&(h=h.max(m)),o[s]="string"==typeof u?h.default(u):h}else{var h=e.boolean();o[s]="boolean"==typeof u?h.default(u):h}else{var h=e.number();p&&(h=(h=h.min(p.min)).max(p.max)),o[s]="number"==typeof u?h.default(u):h}}return e.object(o)}var hn={ZodString:"string",ZodNumber:"number",ZodBoolean:"boolean"};function vn(e){for(var t,i=[],a=new Set,r=0,s=e;r<s.length;r++){void 0!==(c=s[r]).columns&&(c.columns<1||c.columns>4?i.push({code:n.custom,message:"Invalid columns value for setting ".concat(c.key,". Must be between ").concat(1," and ").concat(4,"."),path:["columns"]}):a.add(c.columns))}for(var l=1===a.size?a.values().next().value:2,u=0,p=e;u<p.length;u++){for(var c=p[u],d=0,m=fn;d<m.length;d++){var f=m[d];void 0===c[f]&&i.push({code:n.custom,message:"Missing required field ".concat(f," for setting ").concat(c.key,"."),path:[f]})}var g=Object.values(nn);if(g.includes(c.type)||i.push({code:n.custom,message:"Invalid type for setting ".concat(c.key,". Must be one of ").concat(g.join(", "),"."),path:["type"]}),(c.component===tn.Tags&&c.type!==nn.Array||c.component!==tn.Tags&&c.type===nn.Array)&&i.push({code:n.custom,message:"Tags component for setting ".concat(c.key," must have type array."),path:["type"]}),c.component===tn.Tags&&(void 0!==c.minTags&&c.minTags<0&&i.push({code:n.custom,message:"Invalid minTags value for setting ".concat(c.key,". Must be non-negative."),path:["minTags"]}),void 0!==c.maxTags&&c.maxTags<0&&i.push({code:n.custom,message:"Invalid maxTags value for setting ".concat(c.key,". Must be non-negative."),path:["maxTags"]}),c.default&&!Array.isArray(c.default)&&i.push({code:n.custom,message:"Invalid default value for setting ".concat(c.key,". Must be an array."),path:["default"]}),c.default&&c.maxTags&&c.default.length>c.maxTags&&i.push({code:n.custom,message:"Invalid default value for setting ".concat(c.key,". Must have at most ").concat(c.maxTags," tags."),path:["default"]}),c.default&&c.minTags&&c.default.length<c.minTags&&i.push({code:n.custom,message:"Invalid default value for setting ".concat(c.key,". Must have at least ").concat(c.minTags," tags."),path:["default"]}),c.default||(c.default=[])),c.component!==tn.Input&&c.component!==tn.Textarea||(c.type===nn.Number&&c.component===tn.Textarea&&i.push({code:n.custom,message:"Textarea component for setting ".concat(c.key," must have type string."),path:["type"]}),void 0!==c.minText&&void 0!==c.maxText&&c.minText>c.maxText&&i.push({code:n.custom,message:"For setting ".concat(c.key,", minText cannot be greater than maxText."),path:[c.key,"minText","maxText"]}),c.placeholder||(c.placeholder="")),c.component===tn.Slider&&(c.type!==nn.Number||c.range||i.push({code:n.custom,message:"Slider component for setting ".concat(c.key," must have a range if type is number."),path:["range"]}),c.type===nn.Enum&&(!c.options||c.options.length<2)&&i.push({code:n.custom,message:"Slider component for setting ".concat(c.key," requires at least ").concat(2," options for enum type."),path:["options"]}),c.includeInput=c.type===nn.Number&&(null===(t=c.includeInput)||void 0===t||t)),c.component===tn.Slider&&c.type===nn.Number&&void 0===c.default&&c.range&&(c.default=Math.round((c.range.min+c.range.max)/2)),c.component!==tn.Checkbox&&c.component!==tn.Switch||(c.options&&c.options.length>2&&i.push({code:n.custom,message:"Checkbox/Switch component for setting ".concat(c.key," must have 1-2 options."),path:["options"]}),c.default||c.type!==nn.Boolean||(c.default=!1)),c.component===tn.Dropdown&&((!c.options||c.options.length<2)&&i.push({code:n.custom,message:"Dropdown component for setting ".concat(c.key," requires at least ").concat(2," options."),path:["options"]}),!c.default&&c.options&&c.options.length>0&&(c.default=c.options[0])),c.columnSpan||(c.columnSpan=Math.floor(l/2)),c.label||(c.label=c.key),c.component!==tn.Input&&c.component!==tn.Textarea||(void 0!==c.minText&&c.minText<0&&i.push({code:n.custom,message:"Invalid minText value for setting ".concat(c.key,". Must be non-negative."),path:["minText"]}),void 0!==c.maxText&&c.maxText<0&&i.push({code:n.custom,message:"Invalid maxText value for setting ".concat(c.key,". Must be non-negative."),path:["maxText"]})),c.optionType!==on.Custom){var h=re.shape[c.key];if(h){var v=h._def.typeName;(hn[v]||null)!==c.type&&i.push({code:n.custom,message:"Setting ".concat(c.key,' with optionType "').concat(c.optionType,'" must match the type defined in tConversationSchema.'),path:["optionType"]})}else i.push({code:n.custom,message:"Setting ".concat(c.key,' with optionType "').concat(c.optionType,'" must be defined in tConversationSchema.'),path:["optionType"]})}c.type===nn.Number&&isNaN(c.default)&&i.push({code:n.custom,message:"Invalid default value for setting ".concat(c.key,". Must be a number."),path:["default"]}),c.type===nn.Boolean&&"boolean"!=typeof c.default&&i.push({code:n.custom,message:"Invalid default value for setting ".concat(c.key,". Must be a boolean."),path:["default"]}),c.type!==nn.String&&c.type!==nn.Enum||"string"==typeof c.default||i.push({code:n.custom,message:"Invalid default value for setting ".concat(c.key,". Must be a string."),path:["default"]}),c.type===nn.Enum&&c.options&&!c.options.includes(c.default)&&i.push({code:n.custom,message:"Invalid default value for setting ".concat(c.key,". Must be one of the options: [").concat(c.options.join(", "),"]."),path:["default"]}),c.type===nn.Number&&c.range&&"number"==typeof c.default&&(c.default<c.range.min||c.default>c.range.max)&&i.push({code:n.custom,message:"Invalid default value for setting ".concat(c.key,". Must be within the range [").concat(c.range.min,", ").concat(c.range.max,"]."),path:["default"]})}if(i.length>0)throw new o(i)}var bn,yn,xn=function(e){var t=h(h({},V),e);return re.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,resendFiles:!0,imageDetail:!0,maxContextTokens:!0}).transform((function(e){var n,o,i,a,r,s,l,u,p;return h(h({},e),{model:null!==(n=e.model)&&void 0!==n?n:t.model.default,chatGptLabel:null!==(o=e.chatGptLabel)&&void 0!==o?o:null,promptPrefix:null!==(i=e.promptPrefix)&&void 0!==i?i:null,temperature:null!==(a=e.temperature)&&void 0!==a?a:t.temperature.default,top_p:null!==(r=e.top_p)&&void 0!==r?r:t.top_p.default,presence_penalty:null!==(s=e.presence_penalty)&&void 0!==s?s:t.presence_penalty.default,frequency_penalty:null!==(l=e.frequency_penalty)&&void 0!==l?l:t.frequency_penalty.default,resendFiles:"boolean"==typeof e.resendFiles?e.resendFiles:t.resendFiles.default,imageDetail:null!==(u=e.imageDetail)&&void 0!==u?u:t.imageDetail.default,maxContextTokens:null!==(p=e.maxContextTokens)&&void 0!==p?p:void 0})})).catch((function(){return{model:t.model.default,chatGptLabel:null,promptPrefix:null,temperature:t.temperature.default,top_p:t.top_p.default,presence_penalty:t.presence_penalty.default,frequency_penalty:t.frequency_penalty.default,resendFiles:t.resendFiles.default,imageDetail:t.imageDetail.default,maxContextTokens:void 0}}))},_n=function(e){var t=h(h({},Y),e);return re.pick({model:!0,modelLabel:!0,promptPrefix:!0,examples:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0,maxContextTokens:!0}).transform((function(e){var n,o,i,a,r,s,l,u,p,c,d,m=null===(o=null===(n=null==e?void 0:e.model)||void 0===n?void 0:n.toLowerCase())||void 0===o?void 0:o.includes("gemini"),f=m?t.maxOutputTokens.maxGemini:t.maxOutputTokens.max,g=m?t.maxOutputTokens.defaultGemini:t.maxOutputTokens.default,v=null!==(i=e.maxOutputTokens)&&void 0!==i?i:g;return v=Math.min(v,f),h(h({},e),{model:null!==(a=e.model)&&void 0!==a?a:t.model.default,modelLabel:null!==(r=e.modelLabel)&&void 0!==r?r:null,promptPrefix:null!==(s=e.promptPrefix)&&void 0!==s?s:null,examples:null!==(l=e.examples)&&void 0!==l?l:[{input:{content:""},output:{content:""}}],temperature:null!==(u=e.temperature)&&void 0!==u?u:t.temperature.default,maxOutputTokens:v,topP:null!==(p=e.topP)&&void 0!==p?p:t.topP.default,topK:null!==(c=e.topK)&&void 0!==c?c:t.topK.default,maxContextTokens:null!==(d=e.maxContextTokens)&&void 0!==d?d:void 0})})).catch((function(){return{model:t.model.default,modelLabel:null,promptPrefix:null,examples:[{input:{content:""},output:{content:""}}],temperature:t.temperature.default,maxOutputTokens:t.maxOutputTokens.default,topP:t.topP.default,topK:t.topK.default,maxContextTokens:void 0}}))};function Tn(e){i.defaults.headers.common["Accept-Language"]=e}function En(e){i.defaults.headers.common.Authorization="Bearer "+e}!function(e){e.messages="messages",e.allConversations="allConversations",e.archivedConversations="archivedConversations",e.searchConversations="searchConversations",e.conversation="conversation",e.searchEnabled="searchEnabled",e.user="user",e.name="name",e.models="models",e.balance="balance",e.endpoints="endpoints",e.presets="presets",e.searchResults="searchResults",e.tokenCount="tokenCount",e.availablePlugins="availablePlugins",e.startupConfig="startupConfig",e.assistants="assistants",e.assistant="assistant",e.endpointsConfigOverride="endpointsConfigOverride",e.files="files",e.fileConfig="fileConfig",e.tools="tools",e.actions="actions",e.assistantDocs="assistantDocs",e.fileDownload="fileDownload"}(bn||(bn={})),function(e){e.fileUpload="fileUpload",e.fileDelete="fileDelete",e.updatePreset="updatePreset",e.deletePreset="deletePreset",e.logoutUser="logoutUser",e.avatarUpload="avatarUpload",e.assistantAvatarUpload="assistantAvatarUpload",e.updateAction="updateAction",e.deleteAction="deleteAction"}(yn||(yn={}));var In=function(e,t){return"/api/messages/".concat(e).concat(t?"/".concat(t):"")},On="/api/keys",An="/api/convos",kn=function(e,t){return"".concat(An,"?pageNumber=").concat(e).concat(t?"&isArchived=true":"")},Ln=function(){return"".concat(An,"/update")},Pn=function(){return"".concat(An,"/clear")},Sn=function(e){return"".concat(An,"/import/jobs/").concat(e)},Cn=function(e,t){return"/api/search?q=".concat(e,"&pageNumber=").concat(t)},wn=function(e,t){var n="/api/assistants";if(e&&(n+="/".concat(e)),t&&Object.keys(t).length>0){var o=new URLSearchParams(t).toString();n+="?".concat(o)}return n},Nn=function(){return"".concat("/api/files","/images")};function Rn(e,t){return b(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return[4,i.post(e,JSON.stringify(t),{headers:{"Content-Type":"application/json"}})];case 1:return[2,n.sent().data]}}))}))}var Mn=!1,jn=[],Un=function(e){return Rn(function(e){return"/api/auth/refresh".concat(e?"?retry=true":"")}(e))},Gn=function(e,t){void 0===t&&(t=null),jn.forEach((function(n){e?n.reject(e):n.resolve(t)})),jn=[]};i.interceptors.response.use((function(e){return e}),(function(e){return b(void 0,void 0,void 0,(function(){var t,n,o,a,r;return y(this,(function(s){switch(s.label){case 0:if(t=e.config,401!==e.response.status||t._retry)return[3,13];if(t._retry=!0,!Mn)return[3,5];s.label=1;case 1:return s.trys.push([1,4,,5]),[4,new Promise((function(e,t){jn.push({resolve:e,reject:t})}))];case 2:return o=s.sent(),t.headers.Authorization="Bearer "+o,[4,i(t)];case 3:return[2,s.sent()];case 4:return n=s.sent(),[2,Promise.reject(n)];case 5:Mn=!0,s.label=6;case 6:return s.trys.push([6,11,12,13]),[4,Un(!!(null===(r=t.url)||void 0===r?void 0:r.includes("api/auth/refresh")))];case 7:return(o=s.sent().token)?(t.headers.Authorization="Bearer "+o,En(o),window.dispatchEvent(new CustomEvent("tokenUpdated",{detail:o})),Gn(null,o),[4,i(t)]):[3,9];case 8:return[2,s.sent()];case 9:window.location.href="/login",s.label=10;case 10:return[3,13];case 11:return a=s.sent(),Gn(a,null),[2,Promise.reject(a)];case 12:return Mn=!1,[7];case 13:return[2,Promise.reject(e)]}}))}))}));var Dn={get:function(e,t){return b(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return[4,i.get(e,h({},t))];case 1:return[2,n.sent().data]}}))}))},getResponse:function(e,t){return b(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return[4,i.get(e,h({},t))];case 1:return[2,n.sent()]}}))}))},post:Rn,postMultiPart:function(e,t,n){return b(this,void 0,void 0,(function(){return y(this,(function(o){switch(o.label){case 0:return[4,i.post(e,t,h(h({},n),{headers:{"Content-Type":"multipart/form-data"}}))];case 1:return[2,o.sent().data]}}))}))},put:function(e,t){return b(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return[4,i.put(e,JSON.stringify(t),{headers:{"Content-Type":"application/json"}})];case 1:return[2,n.sent().data]}}))}))},delete:function(e){return b(this,void 0,void 0,(function(){return y(this,(function(t){switch(t.label){case 0:return[4,i.delete(e)];case 1:return[2,t.sent().data]}}))}))},deleteWithOptions:function(e,t){return b(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return[4,i.delete(e,h({},t))];case 1:return[2,n.sent().data]}}))}))},patch:function(e,t){return b(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return[4,i.patch(e,JSON.stringify(t),{headers:{"Content-Type":"application/json"}})];case 1:return[2,n.sent().data]}}))}))},refreshToken:Un};var zn=Object.freeze({__proto__:null,abortRequestWithMessage:function(e,t,n){return Dn.post(function(e){return"/api/ask/".concat(e,"/abort")}(e),{arg:{abortKey:t,message:n}})},archiveConversation:function(e){return Dn.post(Ln(),{arg:e})},clearAllConversations:function(){return Dn.post(Pn(),{arg:{}})},createAssistant:function(e){return Dn.post(wn(),e)},createPreset:function(e){return Dn.post("/api/presets",e)},deleteAction:function(e,t,n){return b(void 0,void 0,void 0,(function(){return y(this,(function(o){return[2,Dn.delete(wn("actions/".concat(e,"/").concat(t,"/").concat(n)))]}))}))},deleteAssistant:function(e,t){return Dn.delete(wn(e,{model:t}))},deleteConversation:function(e){return Dn.post(Pn(),{arg:e})},deleteFiles:function(e,t){return b(void 0,void 0,void 0,(function(){return y(this,(function(n){return[2,Dn.deleteWithOptions("/api/files",{data:{files:e,assistant_id:t}})]}))}))},deletePreset:function(e){return Dn.post("/api/presets/delete",e)},forkConversation:function(e){return Dn.post("".concat(An,"/fork"),e)},genTitle:function(e){return Dn.post("".concat(An,"/gen_title"),e)},getAIEndpoints:function(){return Dn.get("/api/endpoints")},getActions:function(){return Dn.get(wn("actions"))},getAssistantById:function(e){return Dn.get(wn(e))},getAssistantDocs:function(){return Dn.get(wn("documents"))},getAvailablePlugins:function(){return Dn.get("/api/plugins")},getAvailableTools:function(){return Dn.get("".concat(wn(),"/tools"))},getConversationById:function(e){return Dn.get(function(e){return"".concat(An,"/").concat(e)}(e))},getConversations:function(e){return Dn.get(kn(e))},getEndpointsConfigOverride:function(){return Dn.get("/api/endpoints/config/override")},getFileConfig:function(){return Dn.get("".concat("/api/files","/config"))},getFileDownload:function(e,t){return b(void 0,void 0,void 0,(function(){return y(this,(function(n){return[2,Dn.getResponse("".concat("/api/files","/download/").concat(e,"/").concat(t),{responseType:"blob",headers:{Accept:"application/octet-stream"}})]}))}))},getFiles:function(){return Dn.get("/api/files")},getLoginGoogle:function(){return Dn.get("/api/auth/google")},getMessagesByConvoId:function(e){return"new"===e?Promise.resolve([]):Dn.get(In(e))},getModels:function(){return b(void 0,void 0,void 0,(function(){return y(this,(function(e){return[2,Dn.get("/api/models")]}))}))},getPresets:function(){return Dn.get("/api/presets")},getSearchEnabled:function(){return Dn.get("/api/search/enable")},getStartupConfig:function(){return Dn.get("/api/config")},getUser:function(){return Dn.get("/api/user")},getUserBalance:function(){return Dn.get("/api/balance")},importConversationsFile:function(e){return Dn.postMultiPart("".concat(An,"/import"),e)},listAssistants:function(e){return Dn.get(wn(),{params:e})},listConversations:function(e){var t=(null==e?void 0:e.pageNumber)||"1",n=(null==e?void 0:e.isArchived)||!1;return Dn.get(kn(t,n))},listConversationsByQuery:function(e){var t=(null==e?void 0:e.pageNumber)||"1",n=(null==e?void 0:e.searchQuery)||"";return""!==n?Dn.get(Cn(n,t)):Dn.get(kn(t))},login:function(e){return Dn.post("/api/auth/login",e)},logout:function(){return Dn.post("/api/auth/logout")},queryImportConversationJobStatus:function(e){return b(void 0,void 0,void 0,(function(){return y(this,(function(t){return[2,Dn.get(Sn(e))]}))}))},register:function(e){return Dn.post("/api/auth/register",e)},requestPasswordReset:function(e){return Dn.post("/api/auth/requestPasswordReset",e)},resetPassword:function(e){return Dn.post("/api/auth/resetPassword",e)},revokeAllUserKeys:function(){return Dn.delete("".concat(On,"?all=true"))},revokeUserKey:function(e){return Dn.delete(function(e){return"".concat(On,"/").concat(e)}(e))},searchConversations:function(e,t){return b(void 0,void 0,void 0,(function(){return y(this,(function(n){return[2,Dn.get(Cn(e,t))]}))}))},updateAction:function(e){var t=e.assistant_id,n=v(e,["assistant_id"]);return Dn.post(wn("actions/".concat(t)),n)},updateAssistant:function(e,t){return Dn.patch(wn(e),t)},updateConversation:function(e){return Dn.post(Ln(),{arg:e})},updateMessage:function(e){var t=e.conversationId,n=e.messageId,o=e.text;if(!t)throw new Error("conversationId is required");return Dn.put(In(t,n),{text:o})},updatePreset:function(e){return Dn.post("/api/presets",e)},updateTokenCount:function(e){return Dn.post("/api/tokenizer",{arg:e})},updateUserKey:function(e){if(!e.value)throw new Error("value is required");return Dn.put(On,e)},updateUserPlugins:function(e){return Dn.post("/api/user/plugins",e)},uploadAssistantAvatar:function(e){return Dn.postMultiPart(wn("avatar/".concat(e.assistant_id),{model:e.model}),e.formData)},uploadAvatar:function(e){return Dn.postMultiPart("".concat(Nn(),"/avatar"),e)},uploadFile:function(e){return Dn.postMultiPart("/api/files",e)},uploadImage:function(e){return Dn.postMultiPart(Nn(),e)},userKeyQuery:function(e){return Dn.get(function(e){return"".concat(On,"?name=").concat(e)}(e))}}),Fn=function(e,t){if(!(this instanceof Fn))return new Fn(e,t);this.INITIALIZING=-1,this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,this.url=e,t=t||{},this.headers=t.headers||{},this.payload=void 0!==t.payload?t.payload:"",this.method=t.method||this.payload&&"POST"||"GET",this.withCredentials=!!t.withCredentials,this.FIELD_SEPARATOR=":",this.listeners={},this.xhr=null,this.readyState=this.INITIALIZING,this.progress=0,this.chunk="",this.addEventListener=function(e,t){void 0===this.listeners[e]&&(this.listeners[e]=[]),-1===this.listeners[e].indexOf(t)&&this.listeners[e].push(t)},this.removeEventListener=function(e,t){if(void 0!==this.listeners[e]){var n=[];this.listeners[e].forEach((function(e){e!==t&&n.push(e)})),0===n.length?delete this.listeners[e]:this.listeners[e]=n}},this.dispatchEvent=function(e){if(!e)return!0;e.source=this;var t="on"+e.type;return(!this.hasOwnProperty(t)||(this[t].call(this,e),!e.defaultPrevented))&&(!this.listeners[e.type]||this.listeners[e.type].every((function(t){return t(e),!e.defaultPrevented})))},this._setReadyState=function(e){var t=new CustomEvent("readystatechange");t.readyState=e,this.readyState=e,this.dispatchEvent(t)},this._onStreamFailure=function(e){var t=new CustomEvent("error");t.data=e.currentTarget.response,this.dispatchEvent(t),this.close()},this._onStreamAbort=function(e){this.dispatchEvent(new CustomEvent("abort")),this.close()},this._onStreamProgress=async function(e){if(this.xhr){if(401!==this.xhr.status||this._retry){if(200!==this.xhr.status)return void this._onStreamFailure(e)}else{this._retry=!0;try{const e=await Dn.refreshToken();this.headers={"Content-Type":"application/json",Authorization:`Bearer ${e.token}`},En(e.token),window.dispatchEvent(new CustomEvent("tokenUpdated",{detail:e.token})),this.stream()}catch(t){return void this._onStreamFailure(e)}}this.readyState==this.CONNECTING&&(this.dispatchEvent(new CustomEvent("open")),this._setReadyState(this.OPEN));var t=this.xhr.responseText.substring(this.progress);this.progress+=t.length,t.split(/(\r\n|\r|\n){2}/g).forEach(function(e){0===e.trim().length?(this.dispatchEvent(this._parseEventChunk(this.chunk.trim())),this.chunk=""):this.chunk+=e}.bind(this))}},this._onStreamLoaded=function(e){this._onStreamProgress(e),this.dispatchEvent(this._parseEventChunk(this.chunk)),this.chunk=""},this._parseEventChunk=function(e){if(!e||0===e.length)return null;var t={id:null,retry:null,data:"",event:"message"};e.split(/\n|\r\n|\r/).forEach(function(e){var n=(e=e.trimRight()).indexOf(this.FIELD_SEPARATOR);if(!(n<=0)){var o=e.substring(0,n);if(o in t){var i=e.substring(n+1).trimLeft();"data"===o?t[o]+=i:t[o]=i}}}.bind(this));var n=new CustomEvent(t.event);return n.data=t.data,n.id=t.id,n},this._checkStreamClosed=function(){this.xhr&&this.xhr.readyState===XMLHttpRequest.DONE&&this._setReadyState(this.CLOSED)},this.stream=function(){for(var e in this._setReadyState(this.CONNECTING),this.xhr=new XMLHttpRequest,this.xhr.addEventListener("progress",this._onStreamProgress.bind(this)),this.xhr.addEventListener("load",this._onStreamLoaded.bind(this)),this.xhr.addEventListener("readystatechange",this._checkStreamClosed.bind(this)),this.xhr.addEventListener("error",this._onStreamFailure.bind(this)),this.xhr.addEventListener("abort",this._onStreamAbort.bind(this)),this.xhr.open(this.method,this.url),this.headers)this.xhr.setRequestHeader(e,this.headers[e]);this.xhr.withCredentials=this.withCredentials,this.xhr.send(this.payload)},this.close=function(){this.readyState!==this.CLOSED&&(this.xhr.abort(),this.xhr=null,this._setReadyState(this.CLOSED))}};function qn(e){return r.createHash("sha1").update(e).digest("hex")}function Bn(e,t){return new a(t,e).toString()}var Kn=function(){function e(e,t,n){var o,i;this.name=e,this.description=t,(null===(o=n.properties)||void 0===o?void 0:o.requestBody)?this.parameters=null===(i=n.properties)||void 0===i?void 0:i.requestBody:this.parameters=n}return e.prototype.toObjectTool=function(){return{type:l.function,function:{name:this.name,description:this.description,parameters:this.parameters}}},e}(),Hn=function(){function e(e,t,n,o,i,a){this.authHeaders={},this.domain=e,this.path=t,this.method=n,this.operation=o,this.isConsequential=i,this.contentType=a}return e.prototype.setParams=function(e){return b(this,void 0,void 0,(function(){var t,n,o,i,a,r;return y(this,(function(s){for(this.operationHash=qn(JSON.stringify(e)),this.params=e,t=0,n=Object.entries(e);t<n.length;t++)o=n[t],i=o[0],a=o[1],r="{".concat(i,"}"),this.path.includes(r)&&(this.path=this.path.replace(r,encodeURIComponent(a)),delete this.params[i]);return[2]}))}))},e.prototype.setAuth=function(e){return b(this,void 0,void 0,(function(){var t,n,o,a,r,s,l,u,p,c,d,m,f,g,h;return y(this,(function(v){switch(v.label){case 0:return e.auth?(t=e.auth,n=t.type,o=t.authorization_type,a=t.custom_auth_header,r=t.authorization_url,s=t.client_url,l=t.scope,u=t.token_exchange_method,p=e.api_key,c=e.oauth_client_id,d=e.oauth_client_secret,m=p&&n===_.ServiceHttp,f=c&&d&&n===_.OAuth&&r&&s&&l&&u,m&&o===T.Basic?(g=Buffer.from(p).toString("base64"),this.authHeaders.Authorization="Basic ".concat(g),[3,6]):[3,1]):[2];case 1:return m&&o===T.Bearer?(this.authHeaders.Authorization="Bearer ".concat(p),[3,6]):[3,2];case 2:return m&&o===T.Custom&&a?(this.authHeaders[a]=p,[3,6]):[3,3];case 3:return f?this.authToken?[3,5]:[4,i.post(s,{client_id:c,client_secret:d,scope:l,grant_type:"client_credentials"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})]:[3,6];case 4:h=v.sent(),this.authToken=h.data.access_token,v.label=5;case 5:this.authHeaders.Authorization="Bearer ".concat(this.authToken),v.label=6;case 6:return[2]}}))}))},e.prototype.execute=function(){return b(this,void 0,void 0,(function(){var e,t,n;return y(this,(function(o){if(e=Bn(this.domain,this.path),t=h(h({},this.authHeaders),{"Content-Type":this.contentType}),"get"===(n=this.method.toLowerCase()))return[2,i.get(e,{headers:t,params:this.params})];if("post"===n)return[2,i.post(e,this.params,{headers:t})];if("put"===n)return[2,i.put(e,this.params,{headers:t})];if("delete"===n)return[2,i.delete(e,{headers:t,data:this.params})];if("patch"===n)return[2,i.patch(e,this.params,{headers:t})];throw new Error("Unsupported HTTP method: ".concat(this.method))}))}))},e}();function Vn(e,t){var n;if("$ref"in e&&t){var o=e.$ref.replace(/^#\/components\/schemas\//,""),i=null===(n=t.schemas)||void 0===n?void 0:n[o];if(!i)throw new Error("Reference ".concat(e.$ref," not found"));return Vn(i,t)}return e}function Yn(e){for(var t,n,o,i,a=[],r={},s=null!==(o=null===(n=null===(t=e.servers)||void 0===t?void 0:t[0])||void 0===n?void 0:n.url)&&void 0!==o?o:"",l=0,u=Object.entries(e.paths);l<u.length;l++)for(var p=u[l],c=p[0],d=p[1],m=0,f=Object.entries(d);m<f.length;m++){var g=f[m],v=g[0],b=g[1],y=b.operationId||"".concat(v,"_").concat(c),x=b.summary||b.description||"",_={type:"object",properties:{},required:[]};if(b.requestBody){var T=b.requestBody.content,E=Vn(null===(i=T[Object.keys(T)[0]])||void 0===i?void 0:i.schema,e.components);_.properties.requestBody=E}if(b.parameters)for(var I=0,O=b.parameters;I<O.length;I++){var A=O[I];E=Vn(h({},A.schema),e.components);_.properties[A.name]=E,A.required&&_.required.push(A.name),A.description&&!("$$ref"in _.properties[A.name])&&(_.properties[A.name].description=A.description)}var k=new Kn(y,x,_);a.push(k);var L=new Hn(s,c,v,y,!!b["x-openai-isConsequential"],b.requestBody?"application/json":"application/x-www-form-urlencoded");r[y]=L}return{functionSignatures:a,requestBuilders:r}}function $n(e){var t;try{var n=void 0;try{n=JSON.parse(e)}catch(t){n=s(e)}if(!n.servers||!Array.isArray(n.servers)||0===n.servers.length)return{status:!1,message:"Could not find a valid URL in `servers`"};if(!n.servers[0].url)return{status:!1,message:"Could not find a valid URL in `servers`"};var o=n.paths;if(!o||"object"!=typeof o||0===Object.keys(o).length)return{status:!1,message:"No paths found in the OpenAPI spec."};for(var i=(null===(t=n.components)||void 0===t?void 0:t.schemas)||{},a=[],r=0,l=Object.entries(o);r<l.length;r++)for(var u=l[r],p=u[0],c=u[1],d=0,m=Object.entries(c);d<m.length;d++){var f=m[d],g=f[0],h=f[1],v=h.responses;if("object"==typeof h&&v)for(var b=0,y=Object.entries(v);b<y.length;b++){var x=y[b],_=x[0],T=x[1].content;if(T&&T["application/json"]&&T["application/json"].schema){var E=T["application/json"].schema;if("$ref"in E&&"string"==typeof E.$ref){var I=E.$ref.split("/").pop();I&&!i[I]&&a.push("In context=('paths', '".concat(p,"', '").concat(g,"', '").concat(_,"', 'response', 'content', 'application/json', 'schema'), reference to unknown component ").concat(I,"; using empty schema"))}}}}return{status:!0,message:a.join("\n")||"OpenAPI spec is valid.",spec:n}}catch(e){return{status:!1,message:"Error parsing OpenAPI spec."}}}function Zn(e){var t=e.conversation,n=e.message;e.messages;var o=e.endpointOption,i=e.isEdited,a=e.isContinued,r=le.parse(t).conversationId,s=o,l=s.endpoint,u=s.endpointType,p=Pt[null!=u?u:l];return i&&l===j.assistants?p+="/modify":i&&(p=p.replace("/ask/","/edit/")),{server:p,payload:h(h(h({},n),o),{isContinued:!(!i||!a),conversationId:r})}}export{Hn as ActionRequest,u as AnnotationTypes,P as AssistantStreamEvents,Ut as AuthKeys,R as AuthType,_ as AuthTypeEnum,T as AuthorizationTypeEnum,Rt as CacheKeys,ut as Capabilities,Bt as CohereConstants,tn as ComponentTypes,zt as Constants,p as ContentTypes,D as EAgent,ft as EImageOutputType,j as EModelEndpoint,Pt as EndpointURLs,jt as ErrorTypes,xt as FetchTokenConfig,Ze as FileContext,I as FilePurpose,$e as FileSources,qt as ForkOptions,Kn as FunctionSignature,U as ImageDetail,Gt as ImageDetailCost,K as ImageVisionTool,yt as KnownEndpoints,Ft as LocalStorageKeys,f as MessageContentTypes,yn as MutationKeys,on as OptionTypes,bn as QueryKeys,g as RunStatus,Fn as SSE,nn as SettingTypes,Dt as SettingsTabValues,it as SettingsViews,m as StepStatus,c as StepTypes,E as TokenExchangeMethodEnum,d as ToolCallTypes,l as Tools,Mt as ViolationTypes,Et as VisionModes,O as actionDelimiter,A as actionDomainSeparator,te as agentOptionSettings,Ot as alternateName,me as anthropicSchema,Re as applicationMimeTypes,gt as assistantEndpointSchema,ye as assistantSchema,G as authTypeSchema,ct as azureBaseSchema,vt as azureEndpointSchema,mt as azureGroupConfigsSchema,dt as azureGroupSchema,de as bingAISchema,fe as chatGPTBrowserSchema,Ue as codeInterpreterMimeTypes,Pe as codeInterpreterMimeTypesList,Ge as codeTypeMapping,ae as coerceNumber,Ee as compactAnthropicSchema,xe as compactAssistantSchema,Ie as compactChatGPTSchema,Te as compactGoogleSchema,_e as compactOpenAISchema,Oe as compactPluginsSchema,_t as configSchema,pn as conflictingAzureVariables,Ve as convertStringsToRegex,Zn as createPayload,Bn as createURL,zn as dataService,B as defaultAssistantFormValues,It as defaultEndpoints,At as defaultModels,N as defaultOrderQuery,rt as defaultRetrievalModels,at as defaultSocialLogins,un as deprecatedAzureVariables,ne as eAgentOptionsSchema,q as eImageDetailSchema,Q as eModelEndpointSchema,Ke as endpointFileConfigSchema,ht as endpointSchema,$ as endpointSettings,Wt as envVarRegex,Qt as errorsToString,ke as excelFileTypes,we as excelMimeTypes,W as extendedModelEndpointSchema,Xt as extractEnvVariable,qe as fileConfig,He as fileConfigSchema,st as fileSourceSchema,Le as fullMimeTypesList,gn as generateDynamicSchema,_n as generateGoogleSchema,xn as generateOpenAISchema,Tt as getConfigDefaults,$t as getEnabledEndpoints,en as getFirstDefinedValue,rn as getResponseSender,lt as getSchemaDefaults,ce as googleSchema,Y as googleSettings,ge as gptPluginsSchema,k as hostImageIdSuffix,L as hostImageNamePrefix,z as imageDetailNumeric,F as imageDetailValue,Ce as imageExtRegex,Vt as imageGenTools,Me as imageMimeTypes,Lt as initialModelsConfig,H as isImageVisionTool,M as isUUID,mn as mapGroupToAzureConfig,dn as mapModelToAzureConfig,Fe as mbToBytes,ze as megabyte,Ye as mergeFileConfig,pt as modelConfigSchema,St as modularEndpoints,pe as openAISchema,V as openAISettings,Yn as openapiToFunction,Zt as orderEndpointsConfig,ln as parseCompactConvo,an as parseConvo,bt as rateLimitSchema,he as removeNullishValues,Dn as request,Jt as resolveHeaders,Vn as resolveRef,De as retrievalMimeTypes,Se as retrievalMimeTypesList,Tn as setAcceptLanguageHeader,En as setTokenHeader,qn as sha1,ot as specsConfigSchema,je as supportedMimeTypes,Ct as supportsBalanceCheck,Ae as supportsFiles,oe as tAgentOptionsSchema,re as tConversationSchema,le as tConvoUpdateSchema,ee as tExampleSchema,ie as tMessageSchema,nt as tModelSpecSchema,X as tPluginAuthConfigSchema,J as tPluginSchema,se as tPresetSchema,ue as tPresetUpdateSchema,Ne as textMimeTypes,$n as validateAndParseOpenAPISpec,cn as validateAzureGroups,vn as validateSettingDefinitions,Nt as validateVisionModel,wt as visionModels};
|
|
2
2
|
//# sourceMappingURL=index.es.js.map
|