librechat-data-provider 0.4.4 → 0.4.6

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 CHANGED
@@ -1,2 +1,2 @@
1
- import{z as e}from"zod";import t from"axios";import{URL as n}from"url";import o from"crypto";import{load as i}from"js-yaml";var r,a,s=function(){return s=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},s.apply(this,arguments)};function l(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{l(o.next(e))}catch(e){r(e)}}function s(e){try{l(o.throw(e))}catch(e){r(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(a,s)}l((o=o.apply(e,t||[])).next())}))}function u(e,t){var n,o,i,r,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;r&&(r=0,s[0]&&(a=0)),a;)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 a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}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 p(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;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;var c,d=e.string().uuid();!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"}(c||(c={}));var m,f={assistant:"",id:"",name:"",description:"",instructions:"",model:"gpt-3.5-turbo-1106",functions:[],code_interpreter:!1,retrieval:!1},g=((r={})[c.google]={model:{default:"chat-bison"},maxOutputTokens:{min:1,max:2048,step:1,default:1024,maxGeminiPro:8192,defaultGeminiPro: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}},r),h=g[c.google],v=e.nativeEnum(c),b=e.union([v,e.string()]);!function(e){e.low="low",e.auto="auto",e.high="high"}(m||(m={}));var y=((a={})[m.low]=0,a[m.auto]=1,a[m.high]=2,a),x={0:m.low,1:m.auto,2:m.high},_=e.nativeEnum(m),E=e.object({authField:e.string(),label:e.string(),description:e.string()}),O=e.object({name:e.string(),pluginKey:e.string(),description:e.string(),icon:e.string(),authConfig:e.array(E),authenticated:e.boolean().optional(),isButton:e.boolean().optional()}),I=e.object({input:e.object({content:e.string()}),output:e.object({content:e.string()})}),A=e.object({agent:e.string(),skipCompletion:e.boolean(),model:e.string(),temperature:e.number()}),P=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()}),L=e.object({conversationId:e.string().nullable(),title:e.string().nullable().or(e.literal("New Chat")).default("New Chat"),user:e.string().optional(),endpoint:v.nullable(),endpointType:v.optional(),suggestions:e.array(e.string()).optional(),messages:e.array(e.string()).optional(),tools:e.array(O).optional(),createdAt:e.string(),updatedAt:e.string(),systemMessage:e.string().nullable().optional(),modelLabel:e.string().nullable().optional(),examples:e.array(I).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:A.nullable().optional(),file_ids:e.array(e.string()).optional(),resendImages:e.boolean().optional(),imageDetail:_.optional(),assistant_id:e.string().optional(),instructions:e.string().optional(),presetOverride:e.record(e.unknown()).optional()}),k=L.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:b.nullable()})),w=L.merge(e.object({endpoint:b.nullable()})),T=L.merge(e.object({endpoint:b.nullable()})),C=L.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,resendImages:!0,imageDetail:!0}).transform((function(e){var t,n,o,i,r,a,l,u,p;return s(s({},e),{model:null!==(t=e.model)&&void 0!==t?t:"gpt-3.5-turbo",chatGptLabel:null!==(n=e.chatGptLabel)&&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,top_p:null!==(r=e.top_p)&&void 0!==r?r:1,presence_penalty:null!==(a=e.presence_penalty)&&void 0!==a?a:0,frequency_penalty:null!==(l=e.frequency_penalty)&&void 0!==l?l:0,resendImages:null!==(u=e.resendImages)&&void 0!==u&&u,imageDetail:null!==(p=e.imageDetail)&&void 0!==p?p:m.auto})})).catch((function(){return{model:"gpt-3.5-turbo",chatGptLabel:null,promptPrefix:null,temperature:1,top_p:1,presence_penalty:0,frequency_penalty:0,resendImages:!1,imageDetail:m.auto}})),S=L.pick({model:!0,modelLabel:!0,promptPrefix:!0,examples:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0}).transform((function(e){var t,n,o,i,r,a,l,u,p,c,d=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-pro"),m=d?h.maxOutputTokens.maxGeminiPro:h.maxOutputTokens.max,f=d?h.maxOutputTokens.defaultGeminiPro:h.maxOutputTokens.default,g=null!==(o=e.maxOutputTokens)&&void 0!==o?o:f;return g=Math.min(g,m),s(s({},e),{model:null!==(i=e.model)&&void 0!==i?i:h.model.default,modelLabel:null!==(r=e.modelLabel)&&void 0!==r?r:null,promptPrefix:null!==(a=e.promptPrefix)&&void 0!==a?a:null,examples:null!==(l=e.examples)&&void 0!==l?l:[{input:{content:""},output:{content:""}}],temperature:null!==(u=e.temperature)&&void 0!==u?u:h.temperature.default,maxOutputTokens:g,topP:null!==(p=e.topP)&&void 0!==p?p:h.topP.default,topK:null!==(c=e.topK)&&void 0!==c?c:h.topK.default})})).catch((function(){return{model:h.model.default,modelLabel:null,promptPrefix:null,examples:[{input:{content:""},output:{content:""}}],temperature:h.temperature.default,maxOutputTokens:h.maxOutputTokens.default,topP:h.topP.default,topK:h.topK.default}})),N=L.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,r,a,l,u;return s(s({},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!==(r=e.jailbreakConversationId)&&void 0!==r?r:null,conversationSignature:null!==(a=e.conversationSignature)&&void 0!==a?a:null,clientId:null!==(l=e.clientId)&&void 0!==l?l:null,invocationId:null!==(u=e.invocationId)&&void 0!==u?u:1})})).catch((function(){return{model:"",jailbreak:!1,systemMessage:null,context:null,toneStyle:"creative",jailbreakConversationId:null,conversationSignature:null,clientId:null,invocationId:1}})),j=L.pick({model:!0,modelLabel:!0,promptPrefix:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0}).transform((function(e){var t,n,o,i,r,a,l;return s(s({},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!==(r=e.maxOutputTokens)&&void 0!==r?r:4e3,topP:null!==(a=e.topP)&&void 0!==a?a:.7,topK:null!==(l=e.topK)&&void 0!==l?l:5})})).catch((function(){return{model:"claude-1",modelLabel:null,promptPrefix:null,temperature:1,maxOutputTokens:4e3,topP:.7,topK:5}})),M=L.pick({model:!0}).transform((function(e){var t;return s(s({},e),{model:null!==(t=e.model)&&void 0!==t?t:"text-davinci-002-render-sha"})})).catch((function(){return{model:"text-davinci-002-render-sha"}})),G=L.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,tools:!0,agentOptions:!0}).transform((function(e){var t,n,o,i,r,a,l,u,p;return s(s({},e),{model:null!==(t=e.model)&&void 0!==t?t:"gpt-3.5-turbo",chatGptLabel:null!==(n=e.chatGptLabel)&&void 0!==n?n:null,promptPrefix:null!==(o=e.promptPrefix)&&void 0!==o?o:null,temperature:null!==(i=e.temperature)&&void 0!==i?i:.8,top_p:null!==(r=e.top_p)&&void 0!==r?r:1,presence_penalty:null!==(a=e.presence_penalty)&&void 0!==a?a: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:"functions",skipCompletion:!0,model:"gpt-3.5-turbo",temperature: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:"functions",skipCompletion:!0,model:"gpt-3.5-turbo",temperature:0}}}));function R(e){var t=s({},e);return Object.keys(t).forEach((function(e){void 0!==t[e]&&null!==t[e]&&""!==t[e]||delete t[e]})),t}var z,D,U,q,B,K,F,H,$,V=L.pick({model:!0,assistant_id:!0,instructions:!0,promptPrefix:!0}).transform(R).catch((function(){return{}})),Z=L.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,resendImages:!0,imageDetail:!0}).transform((function(e){var t=s({},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.resendImages&&delete t.resendImages,t.imageDetail===m.auto&&delete t.imageDetail,R(t)})).catch((function(){return{}})),Y=L.pick({model:!0,modelLabel:!0,promptPrefix:!0,examples:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0}).transform((function(e){var t=s({},e);return t.temperature===h.temperature.default&&delete t.temperature,t.maxOutputTokens===h.maxOutputTokens.default&&delete t.maxOutputTokens,t.topP===h.topP.default&&delete t.topP,t.topK===h.topK.default&&delete t.topK,R(t)})).catch((function(){return{}})),Q=L.pick({model:!0,modelLabel:!0,promptPrefix:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0}).transform((function(e){var t=s({},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,R(t)})).catch((function(){return{}})),W=L.pick({model:!0}).transform((function(e){return R(s({},e))})).catch((function(){return{}})),X=L.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,tools:!0,agentOptions:!0}).transform((function(e){var t,n=s({},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&&"functions"===n.agentOptions.agent&&!0===n.agentOptions.skipCompletion&&"gpt-3.5-turbo"===n.agentOptions.model&&0===n.agentOptions.temperature&&delete n.agentOptions,R(n)})).catch((function(){return{}})),J=((z={})[c.openAI]=!0,z[c.google]=!0,z[c.assistants]=!0,z[c.azureOpenAI]=!0,z[c.custom]=!0,z),ee=["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"],te=p(["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"],ee,!0),ne=p(["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"],ee,!0),oe=["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"],ie=/\.(jpg|jpeg|png|gif|webp)$/i,re=/^application\/(vnd\.ms-excel|msexcel|x-msexcel|x-ms-excel|x-excel|x-dos_ms_excel|xls|x-xls|vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet)$/,ae=/^(text\/(x-c|x-c\+\+|x-java|html|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|css|javascript|csv))$/,se=/^(application\/(csv|json|pdf|x-tar|typescript|vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation|spreadsheetml\.sheet)|xml|zip))$/,le=/^image\/(jpeg|gif|png|webp)$/,ue=[ae,re,se,le],pe=[ae,re,se,le],ce=[/^(text\/(x-c|x-c\+\+|html|x-java|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain))$/,/^(application\/(json|pdf|vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation)))$/],de=1048576,me=function(e){return e*de},fe={endpoints:(D={},D[c.assistants]={fileLimit:10,fileSizeLimit:me(512),totalSizeLimit:me(512),supportedMimeTypes:ue,disabled:!1},D.default={fileLimit:10,fileSizeLimit:me(20),totalSizeLimit:me(25),supportedMimeTypes:[le],disabled:!1},D),serverFileSizeLimit:me(512),avatarSizeLimit:me(2),checkType:function(e,t){return void 0===t&&(t=ue),t.some((function(t){return t.test(e)}))}},ge=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."}),he=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:ge.optional()}),ve=e.object({endpoints:e.record(he).optional(),serverFileSizeLimit:e.number().min(0).optional(),avatarSizeLimit:e.number().min(0).optional()}),be=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=fe;if(!e)return t;if(void 0!==e.serverFileSizeLimit&&(t.serverFileSizeLimit=me(e.serverFileSizeLimit)),void 0!==e.avatarSizeLimit&&(t.avatarSizeLimit=me(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=me(o.fileSizeLimit)),void 0!==o.totalSizeLimit&&(i.totalSizeLimit=me(o.totalSizeLimit));["fileLimit"].forEach((function(e){void 0!==o[e]&&(i[e]=o[e])})),o.supportedMimeTypes&&(i.supportedMimeTypes=be(o.supportedMimeTypes))};for(var o in e.endpoints)n(o);return t}!function(e){e.local="local",e.firebase="firebase",e.openai="openai",e.s3="s3"}(U||(U={})),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"}(q||(q={}));var xe,_e=["google","facebook","openid","github","discord"],Ee=e.nativeEnum(U),Oe=e.object({deploymentName:e.string().optional(),version:e.string().optional()}).or(e.boolean()),Ie=e.object({apiKey:e.string(),instanceName:e.string(),deploymentName:e.string().optional(),version:e.string().optional(),baseURL:e.string().optional(),additionalHeaders:e.record(e.any()).optional()}),Ae=e.object({group:e.string(),models:e.record(e.string(),Oe)}).required().and(Ie),Pe=e.array(Ae).min(1),Le=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(),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()}),ke=e.object({name:e.string().refine((function(e){return!v.safeParse(e).success}),{message:"Value cannot be one of the default endpoint (EModelEndpoint) values: ".concat(Object.values(c).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()}),we=e.object({groups:Pe,plugins:e.boolean().optional()}).and(ke.pick({titleConvo:!0,titleMethod:!0,titleModel:!0,summarize:!0,summaryModel:!0,customOrder:!0}).partial()),Te=e.object({fileUploads:e.object({ipMax:e.number().optional(),ipWindowInMinutes:e.number().optional(),userMax:e.number().optional(),userWindowInMinutes:e.number().optional()}).optional()}),Ce=e.object({version:e.string(),cache:e.boolean(),fileStrategy:Ee.optional(),registration:e.object({socialLogins:e.array(e.string()).optional(),allowedDomains:e.array(e.string()).optional()}).optional(),rateLimits:Te.optional(),fileConfig:ve.optional(),endpoints:e.object((B={},B[c.azureOpenAI]=we.optional(),B[c.assistants]=Le.optional(),B.custom=e.array(ke.partial()).optional(),B)).strict().refine((function(e){return Object.keys(e).length>0}),{message:"At least one `endpoints` field must be provided."}).optional()});!function(e){e.mistral="mistral",e.openrouter="openrouter"}(xe||(xe={}));var Se=[c.openAI,c.assistants,c.azureOpenAI,c.bingAI,c.chatGPTBrowser,c.gptPlugins,c.google,c.anthropic,c.custom],Ne=((K={})[c.openAI]="OpenAI",K[c.assistants]="Assistants",K[c.azureOpenAI]="Azure OpenAI",K[c.bingAI]="Bing",K[c.chatGPTBrowser]="ChatGPT",K[c.gptPlugins]="Plugins",K[c.google]="Google",K[c.anthropic]="Anthropic",K[c.custom]="Custom",K),je=((F={})[c.assistants]=["gpt-3.5-turbo-0125","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-3.5-turbo","gpt-4","gpt-4-0314","gpt-4-32k-0314","gpt-4-0613","gpt-3.5-turbo-0613"],F[c.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"],F[c.anthropic]=["claude-2.1","claude-2","claude-1.2","claude-1","claude-1-100k","claude-instant-1","claude-instant-1-100k"],F[c.openAI]=["gpt-3.5-turbo-0125","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"],F),Me=new Set(["gpt-3.5-turbo-0125","gpt-4-0125-preview","gpt-4-turbo-preview","gpt-4-1106-preview","gpt-3.5-turbo-1106"]),Ge=((H={})[c.openAI]="/api/ask/".concat(c.openAI),H[c.bingAI]="/api/ask/".concat(c.bingAI),H[c.google]="/api/ask/".concat(c.google),H[c.custom]="/api/ask/".concat(c.custom),H[c.anthropic]="/api/ask/".concat(c.anthropic),H[c.gptPlugins]="/api/ask/".concat(c.gptPlugins),H[c.azureOpenAI]="/api/ask/".concat(c.azureOpenAI),H[c.chatGPTBrowser]="/api/ask/".concat(c.chatGPTBrowser),H[c.assistants]="/api/assistants/chat",H),Re=new Set([c.gptPlugins,c.anthropic,c.google,c.openAI,c.azureOpenAI,c.custom]),ze=(($={})[c.openAI]=!0,$[c.azureOpenAI]=!0,$[c.gptPlugins]=!0,$[c.custom]=!0,$),De=["gpt-4-vision","llava-13b","gemini-pro-vision"];function Ue(e,t){return void 0===t&&(t=[]),!!e&&De.concat(t).some((function(t){return e.includes(t)}))}var qe,Be,Ke,Fe,He,$e,Ve=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"}(qe||(qe={})),function(e){e.FILE_UPLOAD_LIMIT="file_upload_limit",e.ILLEGAL_MODEL_REQUEST="illegal_model_request"}(Be||(Be={})),function(e){e.GOOGLE_SERVICE_KEY="GOOGLE_SERVICE_KEY",e.GOOGLE_API_KEY="GOOGLE_API_KEY"}(Ke||(Ke={})),function(e){e[e.LOW=85]="LOW",e[e.HIGH=170]="HIGH",e[e.ADDITIONAL=85]="ADDITIONAL"}(Fe||(Fe={})),function(e){e.GENERAL="general",e.BETA="beta",e.DATA="data",e.ACCOUNT="account"}(He||(He={})),function(e){e.VERSION="v0.6.10",e.CONFIG_VERSION="1.0.4",e.NO_PARENT="00000000-0000-0000-0000-000000000000"}($e||($e={}));var Ze,Ye,Qe={order:"asc"},We=((Ze={})[c.openAI]=C,Ze[c.azureOpenAI]=C,Ze[c.custom]=C,Ze[c.google]=S,Ze[c.bingAI]=N,Ze[c.anthropic]=j,Ze[c.chatGPTBrowser]=M,Ze[c.gptPlugins]=G,Ze[c.assistants]=V,Ze);function Xe(){var e=[c.openAI,c.assistants,c.azureOpenAI,c.google,c.bingAI,c.chatGPTBrowser,c.gptPlugins,c.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 Je(e){if(!e)return{};var t=Xe(),n=Object.keys(e),o=t.indexOf(c.custom);return n.reduce((function(n,i){var r=!(i in c);if(!t.includes(i)&&!r)return n;var a=t.indexOf(i);return r?n[i]=s({order:o>=0?o:9999},e[i]):e[i]&&(n[i]=s(s({},e[i]),{order:a})),n}),{})}function et(e){return e.map((function(e){var t=e.path.join("."),n=e.message;return"".concat(t,": ").concat(n)})).join(" ")}var tt=/^\${(.+)}$/;function nt(e){var t=e.match(tt);return t&&process.env[t[1]]||e}function ot(e){var t=s({},null!=e?e:{});return e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).forEach((function(n){t[n]=nt(e[n])})),t}function it(e){for(var t,n=0,o=e;n<o.length;n++){var i=o[n];if(i){t=i;break}}return t}var rt,at,st,lt,ut,pt,ct,dt=function(e){var t,n,o=e.endpoint,i=e.endpointType,r=e.conversation,a=e.possibleValues,s=We[o];if(!s&&!i)throw new Error("Unknown endpoint: ".concat(o));!s&&i&&(s=We[i]);var l=s.parse(r),u=null!=a?a:{},p=u.models,c=u.secondaryModels;return p&&l&&(l.model=null!==(t=it(p))&&void 0!==t?t:l.model),c&&l.agentOptions&&(l.agentOptions.model=null!==(n=it(c))&&void 0!==n?n:l.agentOptions.model),l},mt=function(e){var t,n=e.model,o=e.endpoint,i=e.endpointType,r=e.modelDisplayLabel,a=e.chatGptLabel,s=e.modelLabel,l=e.jailbreak;return[c.openAI,c.azureOpenAI,c.gptPlugins,c.chatGPTBrowser].includes(o)?a||(n&&n.includes("gpt-3")?"GPT-3.5":n&&n.includes("gpt-4")?"GPT-4":n&&n.includes("mistral")?"Mistral":null!==(t=Ne[o])&&void 0!==t?t:"ChatGPT"):o===c.bingAI?l?"Sydney":"BingAI":o===c.anthropic?null!=s?s:"Claude":o===c.google?s||(n&&n.includes("gemini")?"Gemini":n&&n.includes("code")?"Codey":"PaLM2"):o===c.custom||i===c.custom?s||(a||(n&&n.includes("mistral")?"Mistral":n&&n.includes("gpt-3")?"GPT-3.5":n&&n.includes("gpt-4")?"GPT-4":r||"AI")):""},ft=((Ye={})[c.openAI]=Z,Ye[c.azureOpenAI]=Z,Ye[c.custom]=Z,Ye[c.assistants]=V,Ye[c.google]=Y,Ye[c.bingAI]=N,Ye[c.anthropic]=Q,Ye[c.chatGPTBrowser]=W,Ye[c.gptPlugins]=X,Ye),gt=function(e){var t,n=e.endpoint,o=e.endpointType,i=e.conversation,r=e.possibleValues;if(!n)throw new Error("undefined endpoint: ".concat(n));var a=ft[n];if(!a&&!o)throw new Error("Unknown endpoint: ".concat(n));!a&&o&&(a=ft[o]);var s=a.parse(i),l=(null!=r?r:{}).models;return l&&s&&(s.model=null!==(t=it(l))&&void 0!==t?t:s.model),s},ht=[{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"}],vt=[{key:"INSTANCE_NAME"},{key:"DEPLOYMENT_NAME"}];function bt(e){var t=!0,n=[],o={},i={},r=[],a=Pe.safeParse(e);if(a.success)for(var s=0,l=a.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,h=u.additionalHeaders,v=u.models;if(i[p])return r.push('Duplicate group name detected: "'.concat(p,'". Group names must be unique.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:r};for(var b in i[p]={apiKey:c,instanceName:d,deploymentName:m,version:f,baseURL:g,additionalHeaders:h,models:v},u.models){n.push(b);var y=u.models[b];if(o[b])return r.push('Duplicate model name detected: "'.concat(b,'". Model names must be unique across groups.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:r};if("boolean"==typeof y){if(!u.deploymentName||!u.version)return r.push('Model "'.concat(b,'" in group "').concat(p,'" is missing a deploymentName or version.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:r};o[b]={group:p}}else{if(!y.deploymentName&&!u.deploymentName||!y.version&&!u.version)return r.push('Model "'.concat(b,'" in group "').concat(p,'" is missing a required deploymentName or version.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:r};o[b]={group:p}}}}else t=!1,r.push(et(a.error.errors));return{isValid:t,modelNames:n,modelGroupMap:o,groupMap:i,errors:r}}function yt(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 r=o[i.group];if(!r)throw new Error('Group "'.concat(i.group,'" for model "').concat(t,'" not found in configuration.'));var a=r.models[t],s="object"==typeof a&&a.deploymentName||r.deploymentName,l="object"==typeof a&&a.version||r.version;if(!s||!l)throw new Error('Model "'.concat(t,'" in group "').concat(i.group,'" is missing a deploymentName ("').concat(s,'") or version ("').concat(l,'").'));for(var u={azureOpenAIApiKey:nt(r.apiKey),azureOpenAIApiInstanceName:nt(r.instanceName),azureOpenAIApiDeploymentName:nt(s),azureOpenAIApiVersion:nt(l)},p=0,c=Object.values(u);p<c.length;p++){var d=c[p];if("string"==typeof d&&tt.test(d))throw new Error('Azure configuration environment variable "'.concat(d,'" was not found.'))}var m={azureOptions:u};return r.baseURL&&(m.baseURL=nt(r.baseURL)),r.additionalHeaders&&(m.headers=r.additionalHeaders),m}!function(e){e.code_interpreter="code_interpreter",e.retrieval="retrieval",e.function="function"}(rt||(rt={})),function(e){e.TEXT="text",e.TOOL_CALL="tool_call",e.IMAGE_FILE="image_file"}(at||(at={})),function(e){e.TOOL_CALLS="tool_calls",e.MESSAGE_CREATION="message_creation"}(st||(st={})),function(e){e.FUNCTION="function",e.RETRIEVAL="retrieval",e.CODE_INTERPRETER="code_interpreter"}(lt||(lt={})),function(e){e.IN_PROGRESS="in_progress",e.CANCELLED="cancelled",e.FAILED="failed",e.COMPLETED="completed",e.EXPIRED="expired"}(ut||(ut={})),function(e){e.TEXT="text",e.IMAGE_FILE="image_file"}(pt||(pt={})),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"}(ct||(ct={}));var xt,_t,Et,Ot,It,At,Pt="_action_";function Lt(e){t.defaults.headers.common["Accept-Language"]=e}function kt(e){t.defaults.headers.common.Authorization="Bearer "+e}!function(e){e.ServiceHttp="service_http",e.OAuth="oauth",e.None="none"}(xt||(xt={})),function(e){e.Bearer="bearer",e.Basic="basic",e.Custom="custom"}(_t||(_t={})),function(e){e.DefaultPost="default_post",e.BasicAuthHeader="basic_auth_header"}(Et||(Et={})),function(e){e.FineTune="fine-tune",e.FineTuneResults="fine-tune-results",e.Assistants="assistants",e.AssistantsOutput="assistants_output"}(Ot||(Ot={})),function(e){e.messages="messages",e.allConversations="allConversations",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"}(It||(It={})),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"}(At||(At={}));var wt=function(e,t){return"/api/messages/".concat(e).concat(t?"/".concat(t):"")},Tt="/api/keys",Ct=function(e){return"/api/convos?pageNumber=".concat(e)},St=function(e,t){return"/api/search?q=".concat(e,"&pageNumber=").concat(t)},Nt=function(e){return"/api/assistants".concat(e?"/".concat(e):"")},jt=function(){return"".concat("/api/files","/images")};function Mt(e,n){return l(this,void 0,void 0,(function(){return u(this,(function(o){switch(o.label){case 0:return[4,t.post(e,JSON.stringify(n),{headers:{"Content-Type":"application/json"}})];case 1:return[2,o.sent().data]}}))}))}var Gt=!1,Rt=[],zt=function(e){return Mt(function(e){return"/api/auth/refresh".concat(e?"?retry=true":"")}(e))},Dt=function(e,t){void 0===t&&(t=null),Rt.forEach((function(n){e?n.reject(e):n.resolve(t)})),Rt=[]};t.interceptors.response.use((function(e){return e}),(function(e){return l(void 0,void 0,void 0,(function(){var n,o,i,r,a;return u(this,(function(s){switch(s.label){case 0:if(n=e.config,401!==e.response.status||n._retry)return[3,13];if(n._retry=!0,!Gt)return[3,5];s.label=1;case 1:return s.trys.push([1,4,,5]),[4,new Promise((function(e,t){Rt.push({resolve:e,reject:t})}))];case 2:return i=s.sent(),n.headers.Authorization="Bearer "+i,[4,t(n)];case 3:return[2,s.sent()];case 4:return o=s.sent(),[2,Promise.reject(o)];case 5:Gt=!0,s.label=6;case 6:return s.trys.push([6,11,12,13]),[4,zt(!!(null===(a=n.url)||void 0===a?void 0:a.includes("api/auth/refresh")))];case 7:return(i=s.sent().token)?(n.headers.Authorization="Bearer "+i,kt(i),window.dispatchEvent(new CustomEvent("tokenUpdated",{detail:i})),Dt(null,i),[4,t(n)]):[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 r=s.sent(),Dt(r,null),[2,Promise.reject(r)];case 12:return Gt=!1,[7];case 13:return[2,Promise.reject(e)]}}))}))}));var Ut={get:function(e,n){return l(this,void 0,void 0,(function(){return u(this,(function(o){switch(o.label){case 0:return[4,t.get(e,s({},n))];case 1:return[2,o.sent().data]}}))}))},post:Mt,postMultiPart:function(e,n,o){return l(this,void 0,void 0,(function(){return u(this,(function(i){switch(i.label){case 0:return[4,t.post(e,n,s(s({},o),{headers:{"Content-Type":"multipart/form-data"}}))];case 1:return[2,i.sent().data]}}))}))},put:function(e,n){return l(this,void 0,void 0,(function(){return u(this,(function(o){switch(o.label){case 0:return[4,t.put(e,JSON.stringify(n),{headers:{"Content-Type":"application/json"}})];case 1:return[2,o.sent().data]}}))}))},delete:function(e){return l(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,t.delete(e)];case 1:return[2,n.sent().data]}}))}))},deleteWithOptions:function(e,n){return l(this,void 0,void 0,(function(){return u(this,(function(o){switch(o.label){case 0:return[4,t.delete(e,s({},n))];case 1:return[2,o.sent().data]}}))}))},patch:function(e,n){return l(this,void 0,void 0,(function(){return u(this,(function(o){switch(o.label){case 0:return[4,t.patch(e,JSON.stringify(n),{headers:{"Content-Type":"application/json"}})];case 1:return[2,o.sent().data]}}))}))},refreshToken:zt};var qt=Object.freeze({__proto__:null,abortRequestWithMessage:function(e,t,n){return Ut.post(function(e){return"/api/ask/".concat(e,"/abort")}(e),{arg:{abortKey:t,message:n}})},clearAllConversations:function(){return Ut.post("/api/convos/clear",{arg:{}})},createAssistant:function(e){return Ut.post(Nt(),e)},createPreset:function(e){return Ut.post("/api/presets",e)},deleteAction:function(e,t){return l(void 0,void 0,void 0,(function(){return u(this,(function(n){return[2,Ut.delete(Nt("actions/".concat(e,"/").concat(t)))]}))}))},deleteAssistant:function(e){return Ut.delete(Nt(e))},deleteConversation:function(e){return Ut.post("/api/convos/clear",{arg:e})},deleteFiles:function(e,t){return l(void 0,void 0,void 0,(function(){return u(this,(function(n){return[2,Ut.deleteWithOptions("/api/files",{data:{files:e,assistant_id:t}})]}))}))},deletePreset:function(e){return Ut.post("/api/presets/delete",e)},genTitle:function(e){return Ut.post("/api/convos/gen_title",e)},getAIEndpoints:function(){return Ut.get("/api/endpoints")},getActions:function(){return Ut.get(Nt("actions"))},getAssistantById:function(e){return Ut.get(Nt(e))},getAssistantDocs:function(){return Ut.get(Nt("documents"))},getAvailablePlugins:function(){return Ut.get("/api/plugins")},getAvailableTools:function(){return Ut.get("".concat(Nt(),"/tools"))},getConversationById:function(e){return Ut.get(function(e){return"/api/convos/".concat(e)}(e))},getConversations:function(e){return Ut.get(Ct(e))},getEndpointsConfigOverride:function(){return Ut.get("/api/endpoints/config/override")},getFileConfig:function(){return Ut.get("".concat("/api/files","/config"))},getFiles:function(){return Ut.get("/api/files")},getLoginGoogle:function(){return Ut.get("/api/auth/google")},getMessagesByConvoId:function(e){return"new"===e?Promise.resolve([]):Ut.get(wt(e))},getModels:function(){return l(void 0,void 0,void 0,(function(){return u(this,(function(e){return[2,Ut.get("/api/models")]}))}))},getPresets:function(){return Ut.get("/api/presets")},getSearchEnabled:function(){return Ut.get("/api/search/enable")},getStartupConfig:function(){return Ut.get("/api/config")},getUser:function(){return Ut.get("/api/user")},getUserBalance:function(){return Ut.get("/api/balance")},listAssistants:function(e){return Ut.get(Nt(),{params:e})},listConversations:function(e){var t=(null==e?void 0:e.pageNumber)||"1";return Ut.get(Ct(t))},listConversationsByQuery:function(e){var t=(null==e?void 0:e.pageNumber)||"1",n=(null==e?void 0:e.searchQuery)||"";return""!==n?Ut.get(St(n,t)):Ut.get(Ct(t))},login:function(e){return Ut.post("/api/auth/login",e)},logout:function(){return Ut.post("/api/auth/logout")},register:function(e){return Ut.post("/api/auth/register",e)},requestPasswordReset:function(e){return Ut.post("/api/auth/requestPasswordReset",e)},resetPassword:function(e){return Ut.post("/api/auth/resetPassword",e)},revokeAllUserKeys:function(){return Ut.delete("".concat(Tt,"?all=true"))},revokeUserKey:function(e){return Ut.delete(function(e){return"".concat(Tt,"/").concat(e)}(e))},searchConversations:function(e,t){return l(void 0,void 0,void 0,(function(){return u(this,(function(n){return[2,Ut.get(St(e,t))]}))}))},updateAction:function(e){var t=e.assistant_id,n=function(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}(e,["assistant_id"]);return Ut.post(Nt("actions/".concat(t)),n)},updateAssistant:function(e,t){return Ut.patch(Nt(e),t)},updateConversation:function(e){return Ut.post("/api/convos/update",{arg:e})},updateMessage:function(e){var t=e.conversationId,n=e.messageId,o=e.text;if(!t)throw new Error("conversationId is required");return Ut.put(wt(t,n),{text:o})},updatePreset:function(e){return Ut.post("/api/presets",e)},updateTokenCount:function(e){return Ut.post("/api/tokenizer",{arg:e})},updateUserKey:function(e){if(!e.value)throw new Error("value is required");return Ut.put(Tt,e)},updateUserPlugins:function(e){return Ut.post("/api/user/plugins",e)},uploadAssistantAvatar:function(e){return Ut.postMultiPart(Nt("avatar/".concat(e.assistant_id)),e.formData)},uploadAvatar:function(e){return Ut.postMultiPart("".concat(jt(),"/avatar"),e)},uploadFile:function(e){return Ut.postMultiPart("/api/files",e)},uploadImage:function(e){return Ut.postMultiPart(jt(),e)},userKeyQuery:function(e){return Ut.get(function(e){return"".concat(Tt,"?name=").concat(e)}(e))}}),Bt=function(e,t){if(!(this instanceof Bt))return new Bt(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 Ut.refreshToken();this.headers={"Content-Type":"application/json",Authorization:`Bearer ${e.token}`},kt(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 Kt(e){return o.createHash("sha1").update(e).digest("hex")}function Ft(e,t){return new n(t,e).toString()}var Ht=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:rt.function,function:{name:this.name,description:this.description,parameters:this.parameters}}},e}(),$t=function(){function e(e,t,n,o,i,r){this.authHeaders={},this.domain=e,this.path=t,this.method=n,this.operation=o,this.isConsequential=i,this.contentType=r}return e.prototype.setParams=function(e){return l(this,void 0,void 0,(function(){return u(this,(function(t){return this.operationHash=Kt(JSON.stringify(e)),this.params=e,[2]}))}))},e.prototype.setAuth=function(e){return l(this,void 0,void 0,(function(){var n,o,i,r,a,s,l,p,c,d,m,f,g,h,v;return u(this,(function(u){switch(u.label){case 0:return e.auth?(n=e.auth,o=n.type,i=n.authorization_type,r=n.custom_auth_header,a=n.authorization_url,s=n.client_url,l=n.scope,p=n.token_exchange_method,c=e.api_key,d=e.oauth_client_id,m=e.oauth_client_secret,f=c&&o===xt.ServiceHttp,g=d&&m&&o===xt.OAuth&&a&&s&&l&&p,f&&i===_t.Basic?(h=Buffer.from(c).toString("base64"),this.authHeaders.Authorization="Basic ".concat(h),[3,6]):[3,1]):[2];case 1:return f&&i===_t.Bearer?(this.authHeaders.Authorization="Bearer ".concat(c),[3,6]):[3,2];case 2:return f&&i===_t.Custom&&r?(this.authHeaders[r]=c,[3,6]):[3,3];case 3:return g?this.authToken?[3,5]:[4,t.post(s,{client_id:d,client_secret:m,scope:l,grant_type:"client_credentials"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})]:[3,6];case 4:v=u.sent(),this.authToken=v.data.access_token,u.label=5;case 5:this.authHeaders.Authorization="Bearer ".concat(this.authToken),u.label=6;case 6:return[2]}}))}))},e.prototype.execute=function(){return l(this,void 0,void 0,(function(){var e,n,o;return u(this,(function(i){if(e=Ft(this.domain,this.path),n=s(s({},this.authHeaders),{"Content-Type":this.contentType}),"get"===(o=this.method.toLowerCase()))return[2,t.get(e,{headers:n,params:this.params})];if("post"===o)return[2,t.post(e,this.params,{headers:n})];if("put"===o)return[2,t.put(e,this.params,{headers:n})];if("delete"===o)return[2,t.delete(e,{headers:n,data:this.params})];if("patch"===o)return[2,t.patch(e,this.params,{headers:n})];throw new Error("Unsupported HTTP method: ".concat(this.method))}))}))},e}();function Vt(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 Vt(i,t)}return e}function Zt(e){for(var t,n,o,i,r=[],a={},l=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:"",u=0,p=Object.entries(e.paths);u<p.length;u++)for(var c=p[u],d=c[0],m=c[1],f=0,g=Object.entries(m);f<g.length;f++){var h=g[f],v=h[0],b=h[1],y=b.operationId||"".concat(v,"_").concat(d),x=b.summary||b.description||"",_={type:"object",properties:{},required:[]};if(b.requestBody){var E=b.requestBody.content,O=Vt(null===(i=E[Object.keys(E)[0]])||void 0===i?void 0:i.schema,e.components);_.properties.requestBody=O}if(b.parameters)for(var I=0,A=b.parameters;I<A.length;I++){var P=A[I];O=Vt(s({},P.schema),e.components);_.properties[P.name]=O,P.required&&_.required.push(P.name),P.description&&!("$$ref"in _.properties[P.name])&&(_.properties[P.name].description=P.description)}var L=new Ht(y,x,_);r.push(L);var k=new $t(l,d,v,y,!!b["x-openai-isConsequential"],b.requestBody?"application/json":"application/x-www-form-urlencoded");a[y]=k}return{functionSignatures:r,requestBuilders:a}}function Yt(e){var t;try{var n=void 0;try{n=JSON.parse(e)}catch(t){n=i(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 r=(null===(t=n.components)||void 0===t?void 0:t.schemas)||{},a=[],s=0,l=Object.entries(o);s<l.length;s++)for(var u=l[s],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],E=x[1].content;if(E&&E["application/json"]&&E["application/json"].schema){var O=E["application/json"].schema;if("$ref"in O&&"string"==typeof O.$ref){var I=O.$ref.split("/").pop();I&&!r[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 Qt(e){var t=e.conversation,n=e.message;e.messages;var o=e.endpointOption,i=e.isEdited,r=e.isContinued,a=w.parse(t).conversationId,l=o,u=l.endpoint,p=l.endpointType,d=Ge[null!=p?p:u];return i&&u===c.assistants?d+="/modify":i&&(d=d.replace("/ask/","/edit/")),{server:d,payload:s(s(s({},n),o),{isContinued:!(!i||!r),conversationId:a})}}export{$t as ActionRequest,Ke as AuthKeys,xt as AuthTypeEnum,_t as AuthorizationTypeEnum,qe as CacheKeys,$e as Constants,at as ContentTypes,c as EModelEndpoint,Ge as EndpointURLs,q as FileContext,Ot as FilePurpose,U as FileSources,Ht as FunctionSignature,m as ImageDetail,Fe as ImageDetailCost,xe as KnownEndpoints,pt as MessageContentTypes,At as MutationKeys,It as QueryKeys,ct as RunStatus,Bt as SSE,He as SettingsTabValues,ut as StepStatus,st as StepTypes,Et as TokenExchangeMethodEnum,lt as ToolCallTypes,rt as Tools,Be as ViolationTypes,Pt as actionDelimiter,Ne as alternateName,j as anthropicSchema,se as applicationMimeTypes,Le as assistantEndpointSchema,V as assistantSchema,Ie as azureBaseSchema,we as azureEndpointSchema,Pe as azureGroupConfigsSchema,Ae as azureGroupSchema,N as bingAISchema,M as chatGPTBrowserSchema,pe as codeInterpreterMimeTypes,ne as codeInterpreterMimeTypesList,Q as compactAnthropicSchema,W as compactChatGPTSchema,Y as compactGoogleSchema,Z as compactOpenAISchema,X as compactPluginsSchema,Ce as configSchema,vt as conflictingAzureVariables,be as convertStringsToRegex,Qt as createPayload,Ft as createURL,qt as dataService,f as defaultAssistantFormValues,Se as defaultEndpoints,je as defaultModels,Qe as defaultOrderQuery,_e as defaultSocialLogins,ht as deprecatedAzureVariables,_ as eImageDetailSchema,v as eModelEndpointSchema,he as endpointFileConfigSchema,ke as endpointSchema,g as endpointSettings,tt as envVarRegex,et as errorsToString,ee as excelFileTypes,re as excelMimeTypes,b as extendedModelEndpointSchema,nt as extractEnvVariable,fe as fileConfig,ve as fileConfigSchema,Ee as fileSourceSchema,te as fullMimeTypesList,Xe as getEnabledEndpoints,it as getFirstDefinedValue,mt as getResponseSender,S as googleSchema,G as gptPluginsSchema,y as imageDetailNumeric,x as imageDetailValue,ie as imageExtRegex,Ve as imageGenTools,le as imageMimeTypes,d as isUUID,yt as mapModelToAzureConfig,me as mbToBytes,de as megabyte,ye as mergeFileConfig,Oe as modelConfigSchema,Re as modularEndpoints,C as openAISchema,Zt as openapiToFunction,Je as orderEndpointsConfig,gt as parseCompactConvo,dt as parseConvo,Te as rateLimitSchema,R as removeNullishValues,Ut as request,ot as resolveHeaders,Vt as resolveRef,ce as retrievalMimeTypes,oe as retrievalMimeTypesList,Lt as setAcceptLanguageHeader,kt as setTokenHeader,Kt as sha1,ue as supportedMimeTypes,ze as supportsBalanceCheck,J as supportsFiles,Me as supportsRetrieval,A as tAgentOptionsSchema,L as tConversationSchema,w as tConvoUpdateSchema,I as tExampleSchema,P as tMessageSchema,E as tPluginAuthConfigSchema,O as tPluginSchema,k as tPresetSchema,T as tPresetUpdateSchema,ae as textMimeTypes,Yt as validateAndParseOpenAPISpec,bt as validateAzureGroups,Ue as validateVisionModel,De as visionModels};
1
+ import{z as e}from"zod";import t from"axios";import{URL as n}from"url";import o from"crypto";import{load as i}from"js-yaml";var r,a,s=function(){return s=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},s.apply(this,arguments)};function l(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 u(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{l(o.next(e))}catch(e){r(e)}}function s(e){try{l(o.throw(e))}catch(e){r(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(a,s)}l((o=o.apply(e,t||[])).next())}))}function p(e,t){var n,o,i,r,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;r&&(r=0,s[0]&&(a=0)),a;)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 a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}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 c(e,t,n){if(n||2===arguments.length)for(var o,i=0,r=t.length;i<r;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;var d,m=e.string().uuid();!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"}(d||(d={}));var f,g={assistant:"",id:"",name:"",description:"",instructions:"",model:"gpt-3.5-turbo-1106",functions:[],code_interpreter:!1,retrieval:!1},h=((r={})[d.google]={model:{default:"chat-bison"},maxOutputTokens:{min:1,max:2048,step:1,default:1024,maxGeminiPro:8192,defaultGeminiPro: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}},r),v=h[d.google],b=e.nativeEnum(d),y=e.union([b,e.string()]);!function(e){e.low="low",e.auto="auto",e.high="high"}(f||(f={}));var x=((a={})[f.low]=0,a[f.auto]=1,a[f.high]=2,a),_={0:f.low,1:f.auto,2:f.high},E=e.nativeEnum(f),O=e.object({authField:e.string(),label:e.string(),description:e.string()}),A=e.object({name:e.string(),pluginKey:e.string(),description:e.string(),icon:e.string(),authConfig:e.array(O),authenticated:e.boolean().optional(),isButton:e.boolean().optional()}),I=e.object({input:e.object({content:e.string()}),output:e.object({content:e.string()})}),P=e.object({agent:e.string(),skipCompletion:e.boolean(),model:e.string(),temperature:e.number()}),L=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()}),w=e.object({conversationId:e.string().nullable(),title:e.string().nullable().or(e.literal("New Chat")).default("New Chat"),user:e.string().optional(),endpoint:b.nullable(),endpointType:b.optional(),suggestions:e.array(e.string()).optional(),messages:e.array(e.string()).optional(),tools:e.array(A).optional(),createdAt:e.string(),updatedAt:e.string(),systemMessage:e.string().nullable().optional(),modelLabel:e.string().nullable().optional(),examples:e.array(I).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:P.nullable().optional(),file_ids:e.array(e.string()).optional(),resendImages:e.boolean().optional(),imageDetail:E.optional(),assistant_id:e.string().optional(),instructions:e.string().optional(),presetOverride:e.record(e.unknown()).optional()}),k=w.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:y.nullable()})),T=w.merge(e.object({endpoint:y.nullable()})),C=w.merge(e.object({endpoint:y.nullable()})),S=w.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,resendImages:!0,imageDetail:!0}).transform((function(e){var t,n,o,i,r,a,l,u,p;return s(s({},e),{model:null!==(t=e.model)&&void 0!==t?t:"gpt-3.5-turbo",chatGptLabel:null!==(n=e.chatGptLabel)&&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,top_p:null!==(r=e.top_p)&&void 0!==r?r:1,presence_penalty:null!==(a=e.presence_penalty)&&void 0!==a?a:0,frequency_penalty:null!==(l=e.frequency_penalty)&&void 0!==l?l:0,resendImages:null!==(u=e.resendImages)&&void 0!==u&&u,imageDetail:null!==(p=e.imageDetail)&&void 0!==p?p:f.auto})})).catch((function(){return{model:"gpt-3.5-turbo",chatGptLabel:null,promptPrefix:null,temperature:1,top_p:1,presence_penalty:0,frequency_penalty:0,resendImages:!1,imageDetail:f.auto}})),N=w.pick({model:!0,modelLabel:!0,promptPrefix:!0,examples:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0}).transform((function(e){var t,n,o,i,r,a,l,u,p,c,d=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-pro"),m=d?v.maxOutputTokens.maxGeminiPro:v.maxOutputTokens.max,f=d?v.maxOutputTokens.defaultGeminiPro:v.maxOutputTokens.default,g=null!==(o=e.maxOutputTokens)&&void 0!==o?o:f;return g=Math.min(g,m),s(s({},e),{model:null!==(i=e.model)&&void 0!==i?i:v.model.default,modelLabel:null!==(r=e.modelLabel)&&void 0!==r?r:null,promptPrefix:null!==(a=e.promptPrefix)&&void 0!==a?a:null,examples:null!==(l=e.examples)&&void 0!==l?l:[{input:{content:""},output:{content:""}}],temperature:null!==(u=e.temperature)&&void 0!==u?u:v.temperature.default,maxOutputTokens:g,topP:null!==(p=e.topP)&&void 0!==p?p:v.topP.default,topK:null!==(c=e.topK)&&void 0!==c?c:v.topK.default})})).catch((function(){return{model:v.model.default,modelLabel:null,promptPrefix:null,examples:[{input:{content:""},output:{content:""}}],temperature:v.temperature.default,maxOutputTokens:v.maxOutputTokens.default,topP:v.topP.default,topK:v.topK.default}})),j=w.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,r,a,l,u;return s(s({},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!==(r=e.jailbreakConversationId)&&void 0!==r?r:null,conversationSignature:null!==(a=e.conversationSignature)&&void 0!==a?a:null,clientId:null!==(l=e.clientId)&&void 0!==l?l:null,invocationId:null!==(u=e.invocationId)&&void 0!==u?u:1})})).catch((function(){return{model:"",jailbreak:!1,systemMessage:null,context:null,toneStyle:"creative",jailbreakConversationId:null,conversationSignature:null,clientId:null,invocationId:1}})),M=w.pick({model:!0,modelLabel:!0,promptPrefix:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0}).transform((function(e){var t,n,o,i,r,a,l;return s(s({},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!==(r=e.maxOutputTokens)&&void 0!==r?r:4e3,topP:null!==(a=e.topP)&&void 0!==a?a:.7,topK:null!==(l=e.topK)&&void 0!==l?l:5})})).catch((function(){return{model:"claude-1",modelLabel:null,promptPrefix:null,temperature:1,maxOutputTokens:4e3,topP:.7,topK:5}})),G=w.pick({model:!0}).transform((function(e){var t;return s(s({},e),{model:null!==(t=e.model)&&void 0!==t?t:"text-davinci-002-render-sha"})})).catch((function(){return{model:"text-davinci-002-render-sha"}})),R=w.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,tools:!0,agentOptions:!0}).transform((function(e){var t,n,o,i,r,a,l,u,p;return s(s({},e),{model:null!==(t=e.model)&&void 0!==t?t:"gpt-3.5-turbo",chatGptLabel:null!==(n=e.chatGptLabel)&&void 0!==n?n:null,promptPrefix:null!==(o=e.promptPrefix)&&void 0!==o?o:null,temperature:null!==(i=e.temperature)&&void 0!==i?i:.8,top_p:null!==(r=e.top_p)&&void 0!==r?r:1,presence_penalty:null!==(a=e.presence_penalty)&&void 0!==a?a: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:"functions",skipCompletion:!0,model:"gpt-3.5-turbo",temperature: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:"functions",skipCompletion:!0,model:"gpt-3.5-turbo",temperature:0}}}));function z(e){var t=s({},e);return Object.keys(t).forEach((function(e){void 0!==t[e]&&null!==t[e]&&""!==t[e]||delete t[e]})),t}var D,U,q,K,B,F,H,V,$,Z=w.pick({model:!0,assistant_id:!0,instructions:!0,promptPrefix:!0}).transform(z).catch((function(){return{}})),Y=w.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,resendImages:!0,imageDetail:!0}).transform((function(e){var t=s({},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.resendImages&&delete t.resendImages,t.imageDetail===f.auto&&delete t.imageDetail,z(t)})).catch((function(){return{}})),Q=w.pick({model:!0,modelLabel:!0,promptPrefix:!0,examples:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0}).transform((function(e){var t=s({},e);return t.temperature===v.temperature.default&&delete t.temperature,t.maxOutputTokens===v.maxOutputTokens.default&&delete t.maxOutputTokens,t.topP===v.topP.default&&delete t.topP,t.topK===v.topK.default&&delete t.topK,z(t)})).catch((function(){return{}})),W=w.pick({model:!0,modelLabel:!0,promptPrefix:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0}).transform((function(e){var t=s({},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,z(t)})).catch((function(){return{}})),X=w.pick({model:!0}).transform((function(e){return z(s({},e))})).catch((function(){return{}})),J=w.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,tools:!0,agentOptions:!0}).transform((function(e){var t,n=s({},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&&"functions"===n.agentOptions.agent&&!0===n.agentOptions.skipCompletion&&"gpt-3.5-turbo"===n.agentOptions.model&&0===n.agentOptions.temperature&&delete n.agentOptions,z(n)})).catch((function(){return{}})),ee=((D={})[d.openAI]=!0,D[d.google]=!0,D[d.assistants]=!0,D[d.azureOpenAI]=!0,D[d.custom]=!0,D),te=["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"],ne=c(["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"],te,!0),oe=c(["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"],te,!0),ie=["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"],re=/\.(jpg|jpeg|png|gif|webp)$/i,ae=/^application\/(vnd\.ms-excel|msexcel|x-msexcel|x-ms-excel|x-excel|x-dos_ms_excel|xls|x-xls|vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet)$/,se=/^(text\/(x-c|x-c\+\+|x-java|html|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|css|javascript|csv))$/,le=/^(application\/(csv|json|pdf|x-tar|typescript|vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation|spreadsheetml\.sheet)|xml|zip))$/,ue=/^image\/(jpeg|gif|png|webp)$/,pe=[se,ae,le,ue],ce=[se,ae,le,ue],de=[/^(text\/(x-c|x-c\+\+|html|x-java|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain))$/,/^(application\/(json|pdf|vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation)))$/],me=1048576,fe=function(e){return e*me},ge={endpoints:(U={},U[d.assistants]={fileLimit:10,fileSizeLimit:fe(512),totalSizeLimit:fe(512),supportedMimeTypes:pe,disabled:!1},U.default={fileLimit:10,fileSizeLimit:fe(20),totalSizeLimit:fe(25),supportedMimeTypes:[ue],disabled:!1},U),serverFileSizeLimit:fe(512),avatarSizeLimit:fe(2),checkType:function(e,t){return void 0===t&&(t=pe),t.some((function(t){return t.test(e)}))}},he=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."}),ve=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:he.optional()}),be=e.object({endpoints:e.record(ve).optional(),serverFileSizeLimit:e.number().min(0).optional(),avatarSizeLimit:e.number().min(0).optional()}),ye=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 xe(e){var t=ge;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=ye(o.supportedMimeTypes))};for(var o in e.endpoints)n(o);return t}!function(e){e.local="local",e.firebase="firebase",e.openai="openai",e.s3="s3"}(q||(q={})),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"}(K||(K={}));var _e,Ee,Oe=["google","facebook","openid","github","discord"],Ae=e.nativeEnum(q),Ie=e.object({deploymentName:e.string().optional(),version:e.string().optional()}).or(e.boolean()),Pe=e.object({apiKey:e.string(),serverless:e.boolean().optional(),instanceName:e.string().optional(),deploymentName:e.string().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()}),Le=e.object({group:e.string(),models:e.record(e.string(),Ie)}).required().and(Pe),we=e.array(Le).min(1),ke=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(),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()}),Te=e.object({name:e.string().refine((function(e){return!b.safeParse(e).success}),{message:"Value cannot be one of the default endpoint (EModelEndpoint) values: ".concat(Object.values(d).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()}),Ce=e.object({groups:we,plugins:e.boolean().optional()}).and(Te.pick({titleConvo:!0,titleMethod:!0,titleModel:!0,summarize:!0,summaryModel:!0,customOrder:!0}).partial()),Se=e.object({fileUploads:e.object({ipMax:e.number().optional(),ipWindowInMinutes:e.number().optional(),userMax:e.number().optional(),userWindowInMinutes:e.number().optional()}).optional()}),Ne=e.object({version:e.string(),cache:e.boolean(),fileStrategy:Ae.optional(),registration:e.object({socialLogins:e.array(e.string()).optional(),allowedDomains:e.array(e.string()).optional()}).optional(),rateLimits:Se.optional(),fileConfig:be.optional(),endpoints:e.object((B={},B[d.azureOpenAI]=Ce.optional(),B[d.assistants]=ke.optional(),B.custom=e.array(Te.partial()).optional(),B)).strict().refine((function(e){return Object.keys(e).length>0}),{message:"At least one `endpoints` field must be provided."}).optional()});!function(e){e.mistral="mistral",e.openrouter="openrouter",e.groq="groq",e.anyscale="anyscale",e.fireworks="fireworks",e.ollama="ollama",e.perplexity="perplexity",e["together.ai"]="together.ai"}(_e||(_e={})),function(e){e.openrouter="openrouter"}(Ee||(Ee={}));var je=[d.openAI,d.assistants,d.azureOpenAI,d.bingAI,d.chatGPTBrowser,d.gptPlugins,d.google,d.anthropic,d.custom],Me=((F={})[d.openAI]="OpenAI",F[d.assistants]="Assistants",F[d.azureOpenAI]="Azure OpenAI",F[d.bingAI]="Bing",F[d.chatGPTBrowser]="ChatGPT",F[d.gptPlugins]="Plugins",F[d.google]="Google",F[d.anthropic]="Anthropic",F[d.custom]="Custom",F),Ge=((H={})[d.assistants]=["gpt-3.5-turbo-0125","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-3.5-turbo","gpt-4","gpt-4-0314","gpt-4-32k-0314","gpt-4-0613","gpt-3.5-turbo-0613"],H[d.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"],H[d.anthropic]=["claude-2.1","claude-2","claude-1.2","claude-1","claude-1-100k","claude-instant-1","claude-instant-1-100k"],H[d.openAI]=["gpt-3.5-turbo-0125","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"],H),Re=new Set(["gpt-3.5-turbo-0125","gpt-4-0125-preview","gpt-4-turbo-preview","gpt-4-1106-preview","gpt-3.5-turbo-1106"]),ze=((V={})[d.openAI]="/api/ask/".concat(d.openAI),V[d.bingAI]="/api/ask/".concat(d.bingAI),V[d.google]="/api/ask/".concat(d.google),V[d.custom]="/api/ask/".concat(d.custom),V[d.anthropic]="/api/ask/".concat(d.anthropic),V[d.gptPlugins]="/api/ask/".concat(d.gptPlugins),V[d.azureOpenAI]="/api/ask/".concat(d.azureOpenAI),V[d.chatGPTBrowser]="/api/ask/".concat(d.chatGPTBrowser),V[d.assistants]="/api/assistants/chat",V),De=new Set([d.gptPlugins,d.anthropic,d.google,d.openAI,d.azureOpenAI,d.custom]),Ue=(($={})[d.openAI]=!0,$[d.azureOpenAI]=!0,$[d.gptPlugins]=!0,$[d.custom]=!0,$),qe=["gpt-4-vision","llava-13b","gemini-pro-vision"];function Ke(e,t){return void 0===t&&(t=[]),!!e&&qe.concat(t).some((function(t){return e.includes(t)}))}var Be,Fe,He,Ve,$e,Ze,Ye=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"}(Be||(Be={})),function(e){e.FILE_UPLOAD_LIMIT="file_upload_limit",e.ILLEGAL_MODEL_REQUEST="illegal_model_request"}(Fe||(Fe={})),function(e){e.GOOGLE_SERVICE_KEY="GOOGLE_SERVICE_KEY",e.GOOGLE_API_KEY="GOOGLE_API_KEY"}(He||(He={})),function(e){e[e.LOW=85]="LOW",e[e.HIGH=170]="HIGH",e[e.ADDITIONAL=85]="ADDITIONAL"}(Ve||(Ve={})),function(e){e.GENERAL="general",e.BETA="beta",e.DATA="data",e.ACCOUNT="account"}($e||($e={})),function(e){e.VERSION="v0.6.10",e.CONFIG_VERSION="1.0.4",e.NO_PARENT="00000000-0000-0000-0000-000000000000"}(Ze||(Ze={}));var Qe,We,Xe={order:"asc"},Je=((Qe={})[d.openAI]=S,Qe[d.azureOpenAI]=S,Qe[d.custom]=S,Qe[d.google]=N,Qe[d.bingAI]=j,Qe[d.anthropic]=M,Qe[d.chatGPTBrowser]=G,Qe[d.gptPlugins]=R,Qe[d.assistants]=Z,Qe);function et(){var e=[d.openAI,d.assistants,d.azureOpenAI,d.google,d.bingAI,d.chatGPTBrowser,d.gptPlugins,d.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 tt(e){if(!e)return{};var t=et(),n=Object.keys(e),o=t.indexOf(d.custom);return n.reduce((function(n,i){var r=!(i in d);if(!t.includes(i)&&!r)return n;var a=t.indexOf(i);return r?n[i]=s({order:o>=0?o:9999},e[i]):e[i]&&(n[i]=s(s({},e[i]),{order:a})),n}),{})}function nt(e){return e.map((function(e){var t=e.path.join("."),n=e.message;return"".concat(t,": ").concat(n)})).join(" ")}var ot=/^\${(.+)}$/;function it(e){var t=e.match(ot);return t&&process.env[t[1]]||e}function rt(e){var t=s({},null!=e?e:{});return e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).forEach((function(n){t[n]=it(e[n])})),t}function at(e){for(var t,n=0,o=e;n<o.length;n++){var i=o[n];if(i){t=i;break}}return t}var st,lt,ut,pt,ct,dt,mt,ft=function(e){var t,n,o=e.endpoint,i=e.endpointType,r=e.conversation,a=e.possibleValues,s=Je[o];if(!s&&!i)throw new Error("Unknown endpoint: ".concat(o));!s&&i&&(s=Je[i]);var l=s.parse(r),u=null!=a?a:{},p=u.models,c=u.secondaryModels;return p&&l&&(l.model=null!==(t=at(p))&&void 0!==t?t:l.model),c&&l.agentOptions&&(l.agentOptions.model=null!==(n=at(c))&&void 0!==n?n:l.agentOptions.model),l},gt=function(e){var t,n=e.model,o=e.endpoint,i=e.endpointType,r=e.modelDisplayLabel,a=e.chatGptLabel,s=e.modelLabel,l=e.jailbreak;return[d.openAI,d.azureOpenAI,d.gptPlugins,d.chatGPTBrowser].includes(o)?a||(n&&n.includes("gpt-3")?"GPT-3.5":n&&n.includes("gpt-4")?"GPT-4":n&&n.includes("mistral")?"Mistral":null!==(t=Me[o])&&void 0!==t?t:"ChatGPT"):o===d.bingAI?l?"Sydney":"BingAI":o===d.anthropic?null!=s?s:"Claude":o===d.google?s||(n&&n.includes("gemini")?"Gemini":n&&n.includes("code")?"Codey":"PaLM2"):o===d.custom||i===d.custom?s||(a||(n&&n.includes("mistral")?"Mistral":n&&n.includes("gpt-3")?"GPT-3.5":n&&n.includes("gpt-4")?"GPT-4":r||"AI")):""},ht=((We={})[d.openAI]=Y,We[d.azureOpenAI]=Y,We[d.custom]=Y,We[d.assistants]=Z,We[d.google]=Q,We[d.bingAI]=j,We[d.anthropic]=W,We[d.chatGPTBrowser]=X,We[d.gptPlugins]=J,We),vt=function(e){var t,n=e.endpoint,o=e.endpointType,i=e.conversation,r=e.possibleValues;if(!n)throw new Error("undefined endpoint: ".concat(n));var a=ht[n];if(!a&&!o)throw new Error("Unknown endpoint: ".concat(n));!a&&o&&(a=ht[o]);var s=a.parse(i),l=(null!=r?r:{}).models;return l&&s&&(s.model=null!==(t=at(l))&&void 0!==t?t:s.model),s},bt=[{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"}],yt=[{key:"INSTANCE_NAME"},{key:"DEPLOYMENT_NAME"}];function xt(e){var t=!0,n=[],o={},i={},r=[],a=we.safeParse(e);if(a.success)for(var u=0,p=a.data;u<p.length;u++){var c=p[u],d=c.group,m=c.apiKey,f=c.instanceName,g=c.deploymentName,h=c.version,v=c.baseURL,b=c.additionalHeaders,y=c.models,x=c.serverless,_=l(c,["group","apiKey","instanceName","deploymentName","version","baseURL","additionalHeaders","models","serverless"]);if(i[d])return r.push('Duplicate group name detected: "'.concat(d,'". Group names must be unique.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:r};if(x&&!v)return r.push('Group "'.concat(d,'" is serverless but missing mandatory "baseURL."')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:r};if(!f&&!x)return r.push('Group "'.concat(d,'" is missing an "instanceName" for non-serverless configuration.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:r};for(var E in i[d]=s({apiKey:m,instanceName:f,deploymentName:g,version:h,baseURL:v,additionalHeaders:b,models:y,serverless:x},_),c.models){n.push(E);var O=c.models[E];if(o[E])return r.push('Duplicate model name detected: "'.concat(E,'". Model names must be unique across groups.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:r};if(x)o[E]={group:d};else if("boolean"==typeof O){if(!c.deploymentName||!c.version)return r.push('Model "'.concat(E,'" in group "').concat(d,'" is missing a deploymentName or version.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:r};o[E]={group:d}}else{if(!O.deploymentName&&!c.deploymentName||!O.version&&!c.version)return r.push('Model "'.concat(E,'" in group "').concat(d,'" is missing a required deploymentName or version.')),{isValid:!1,modelNames:n,modelGroupMap:o,groupMap:i,errors:r};o[E]={group:d}}}}else t=!1,r.push(nt(a.error.errors));return{isValid:t,modelNames:n,modelGroupMap:o,groupMap:i,errors:r}}function _t(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 r=o[i.group];if(!r)throw new Error('Group "'.concat(i.group,'" for model "').concat(t,'" not found in configuration.'));var a=r.instanceName;if(!a&&!r.serverless)throw new Error('Group "'.concat(i.group,'" is missing an instanceName for non-serverless configuration.'));if(r.serverless&&!r.baseURL)throw new Error('Group "'.concat(i.group,'" is missing the required base URL for serverless configuration.'));if(r.serverless){var s={azureOptions:{azureOpenAIApiKey:it(r.apiKey)},baseURL:it(r.baseURL),serverless:!0},l=s.azureOptions.azureOpenAIApiKey;if("string"==typeof l&&ot.test(l))throw new Error('Azure configuration environment variable "'.concat(l,'" was not found.'));return r.additionalHeaders&&(s.headers=r.additionalHeaders),s}if(!a)throw new Error('Group "'.concat(i.group,'" is missing an instanceName for non-serverless configuration.'));var u=r.models[t],p="object"==typeof u&&u.deploymentName||r.deploymentName,c="object"==typeof u&&u.version||r.version;if(!p||!c)throw new Error('Model "'.concat(t,'" in group "').concat(i.group,'" is missing a deploymentName ("').concat(p,'") or version ("').concat(c,'").'));for(var d={azureOpenAIApiKey:it(r.apiKey),azureOpenAIApiInstanceName:it(a),azureOpenAIApiDeploymentName:it(p),azureOpenAIApiVersion:it(c)},m=0,f=Object.values(d);m<f.length;m++){var g=f[m];if("string"==typeof g&&ot.test(g))throw new Error('Azure configuration environment variable "'.concat(g,'" was not found.'))}var h={azureOptions:d};return r.baseURL&&(h.baseURL=it(r.baseURL)),r.additionalHeaders&&(h.headers=r.additionalHeaders),h}!function(e){e.code_interpreter="code_interpreter",e.retrieval="retrieval",e.function="function"}(st||(st={})),function(e){e.TEXT="text",e.TOOL_CALL="tool_call",e.IMAGE_FILE="image_file"}(lt||(lt={})),function(e){e.TOOL_CALLS="tool_calls",e.MESSAGE_CREATION="message_creation"}(ut||(ut={})),function(e){e.FUNCTION="function",e.RETRIEVAL="retrieval",e.CODE_INTERPRETER="code_interpreter"}(pt||(pt={})),function(e){e.IN_PROGRESS="in_progress",e.CANCELLED="cancelled",e.FAILED="failed",e.COMPLETED="completed",e.EXPIRED="expired"}(ct||(ct={})),function(e){e.TEXT="text",e.IMAGE_FILE="image_file"}(dt||(dt={})),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"}(mt||(mt={}));var Et,Ot,At,It,Pt,Lt,wt="_action_";function kt(e){t.defaults.headers.common["Accept-Language"]=e}function Tt(e){t.defaults.headers.common.Authorization="Bearer "+e}!function(e){e.ServiceHttp="service_http",e.OAuth="oauth",e.None="none"}(Et||(Et={})),function(e){e.Bearer="bearer",e.Basic="basic",e.Custom="custom"}(Ot||(Ot={})),function(e){e.DefaultPost="default_post",e.BasicAuthHeader="basic_auth_header"}(At||(At={})),function(e){e.FineTune="fine-tune",e.FineTuneResults="fine-tune-results",e.Assistants="assistants",e.AssistantsOutput="assistants_output"}(It||(It={})),function(e){e.messages="messages",e.allConversations="allConversations",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"}(Pt||(Pt={})),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"}(Lt||(Lt={}));var Ct=function(e,t){return"/api/messages/".concat(e).concat(t?"/".concat(t):"")},St="/api/keys",Nt=function(e){return"/api/convos?pageNumber=".concat(e)},jt=function(e,t){return"/api/search?q=".concat(e,"&pageNumber=").concat(t)},Mt=function(e){return"/api/assistants".concat(e?"/".concat(e):"")},Gt=function(){return"".concat("/api/files","/images")};function Rt(e,n){return u(this,void 0,void 0,(function(){return p(this,(function(o){switch(o.label){case 0:return[4,t.post(e,JSON.stringify(n),{headers:{"Content-Type":"application/json"}})];case 1:return[2,o.sent().data]}}))}))}var zt=!1,Dt=[],Ut=function(e){return Rt(function(e){return"/api/auth/refresh".concat(e?"?retry=true":"")}(e))},qt=function(e,t){void 0===t&&(t=null),Dt.forEach((function(n){e?n.reject(e):n.resolve(t)})),Dt=[]};t.interceptors.response.use((function(e){return e}),(function(e){return u(void 0,void 0,void 0,(function(){var n,o,i,r,a;return p(this,(function(s){switch(s.label){case 0:if(n=e.config,401!==e.response.status||n._retry)return[3,13];if(n._retry=!0,!zt)return[3,5];s.label=1;case 1:return s.trys.push([1,4,,5]),[4,new Promise((function(e,t){Dt.push({resolve:e,reject:t})}))];case 2:return i=s.sent(),n.headers.Authorization="Bearer "+i,[4,t(n)];case 3:return[2,s.sent()];case 4:return o=s.sent(),[2,Promise.reject(o)];case 5:zt=!0,s.label=6;case 6:return s.trys.push([6,11,12,13]),[4,Ut(!!(null===(a=n.url)||void 0===a?void 0:a.includes("api/auth/refresh")))];case 7:return(i=s.sent().token)?(n.headers.Authorization="Bearer "+i,Tt(i),window.dispatchEvent(new CustomEvent("tokenUpdated",{detail:i})),qt(null,i),[4,t(n)]):[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 r=s.sent(),qt(r,null),[2,Promise.reject(r)];case 12:return zt=!1,[7];case 13:return[2,Promise.reject(e)]}}))}))}));var Kt={get:function(e,n){return u(this,void 0,void 0,(function(){return p(this,(function(o){switch(o.label){case 0:return[4,t.get(e,s({},n))];case 1:return[2,o.sent().data]}}))}))},post:Rt,postMultiPart:function(e,n,o){return u(this,void 0,void 0,(function(){return p(this,(function(i){switch(i.label){case 0:return[4,t.post(e,n,s(s({},o),{headers:{"Content-Type":"multipart/form-data"}}))];case 1:return[2,i.sent().data]}}))}))},put:function(e,n){return u(this,void 0,void 0,(function(){return p(this,(function(o){switch(o.label){case 0:return[4,t.put(e,JSON.stringify(n),{headers:{"Content-Type":"application/json"}})];case 1:return[2,o.sent().data]}}))}))},delete:function(e){return u(this,void 0,void 0,(function(){return p(this,(function(n){switch(n.label){case 0:return[4,t.delete(e)];case 1:return[2,n.sent().data]}}))}))},deleteWithOptions:function(e,n){return u(this,void 0,void 0,(function(){return p(this,(function(o){switch(o.label){case 0:return[4,t.delete(e,s({},n))];case 1:return[2,o.sent().data]}}))}))},patch:function(e,n){return u(this,void 0,void 0,(function(){return p(this,(function(o){switch(o.label){case 0:return[4,t.patch(e,JSON.stringify(n),{headers:{"Content-Type":"application/json"}})];case 1:return[2,o.sent().data]}}))}))},refreshToken:Ut};var Bt=Object.freeze({__proto__:null,abortRequestWithMessage:function(e,t,n){return Kt.post(function(e){return"/api/ask/".concat(e,"/abort")}(e),{arg:{abortKey:t,message:n}})},clearAllConversations:function(){return Kt.post("/api/convos/clear",{arg:{}})},createAssistant:function(e){return Kt.post(Mt(),e)},createPreset:function(e){return Kt.post("/api/presets",e)},deleteAction:function(e,t){return u(void 0,void 0,void 0,(function(){return p(this,(function(n){return[2,Kt.delete(Mt("actions/".concat(e,"/").concat(t)))]}))}))},deleteAssistant:function(e){return Kt.delete(Mt(e))},deleteConversation:function(e){return Kt.post("/api/convos/clear",{arg:e})},deleteFiles:function(e,t){return u(void 0,void 0,void 0,(function(){return p(this,(function(n){return[2,Kt.deleteWithOptions("/api/files",{data:{files:e,assistant_id:t}})]}))}))},deletePreset:function(e){return Kt.post("/api/presets/delete",e)},genTitle:function(e){return Kt.post("/api/convos/gen_title",e)},getAIEndpoints:function(){return Kt.get("/api/endpoints")},getActions:function(){return Kt.get(Mt("actions"))},getAssistantById:function(e){return Kt.get(Mt(e))},getAssistantDocs:function(){return Kt.get(Mt("documents"))},getAvailablePlugins:function(){return Kt.get("/api/plugins")},getAvailableTools:function(){return Kt.get("".concat(Mt(),"/tools"))},getConversationById:function(e){return Kt.get(function(e){return"/api/convos/".concat(e)}(e))},getConversations:function(e){return Kt.get(Nt(e))},getEndpointsConfigOverride:function(){return Kt.get("/api/endpoints/config/override")},getFileConfig:function(){return Kt.get("".concat("/api/files","/config"))},getFiles:function(){return Kt.get("/api/files")},getLoginGoogle:function(){return Kt.get("/api/auth/google")},getMessagesByConvoId:function(e){return"new"===e?Promise.resolve([]):Kt.get(Ct(e))},getModels:function(){return u(void 0,void 0,void 0,(function(){return p(this,(function(e){return[2,Kt.get("/api/models")]}))}))},getPresets:function(){return Kt.get("/api/presets")},getSearchEnabled:function(){return Kt.get("/api/search/enable")},getStartupConfig:function(){return Kt.get("/api/config")},getUser:function(){return Kt.get("/api/user")},getUserBalance:function(){return Kt.get("/api/balance")},listAssistants:function(e){return Kt.get(Mt(),{params:e})},listConversations:function(e){var t=(null==e?void 0:e.pageNumber)||"1";return Kt.get(Nt(t))},listConversationsByQuery:function(e){var t=(null==e?void 0:e.pageNumber)||"1",n=(null==e?void 0:e.searchQuery)||"";return""!==n?Kt.get(jt(n,t)):Kt.get(Nt(t))},login:function(e){return Kt.post("/api/auth/login",e)},logout:function(){return Kt.post("/api/auth/logout")},register:function(e){return Kt.post("/api/auth/register",e)},requestPasswordReset:function(e){return Kt.post("/api/auth/requestPasswordReset",e)},resetPassword:function(e){return Kt.post("/api/auth/resetPassword",e)},revokeAllUserKeys:function(){return Kt.delete("".concat(St,"?all=true"))},revokeUserKey:function(e){return Kt.delete(function(e){return"".concat(St,"/").concat(e)}(e))},searchConversations:function(e,t){return u(void 0,void 0,void 0,(function(){return p(this,(function(n){return[2,Kt.get(jt(e,t))]}))}))},updateAction:function(e){var t=e.assistant_id,n=l(e,["assistant_id"]);return Kt.post(Mt("actions/".concat(t)),n)},updateAssistant:function(e,t){return Kt.patch(Mt(e),t)},updateConversation:function(e){return Kt.post("/api/convos/update",{arg:e})},updateMessage:function(e){var t=e.conversationId,n=e.messageId,o=e.text;if(!t)throw new Error("conversationId is required");return Kt.put(Ct(t,n),{text:o})},updatePreset:function(e){return Kt.post("/api/presets",e)},updateTokenCount:function(e){return Kt.post("/api/tokenizer",{arg:e})},updateUserKey:function(e){if(!e.value)throw new Error("value is required");return Kt.put(St,e)},updateUserPlugins:function(e){return Kt.post("/api/user/plugins",e)},uploadAssistantAvatar:function(e){return Kt.postMultiPart(Mt("avatar/".concat(e.assistant_id)),e.formData)},uploadAvatar:function(e){return Kt.postMultiPart("".concat(Gt(),"/avatar"),e)},uploadFile:function(e){return Kt.postMultiPart("/api/files",e)},uploadImage:function(e){return Kt.postMultiPart(Gt(),e)},userKeyQuery:function(e){return Kt.get(function(e){return"".concat(St,"?name=").concat(e)}(e))}}),Ft=function(e,t){if(!(this instanceof Ft))return new Ft(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 Kt.refreshToken();this.headers={"Content-Type":"application/json",Authorization:`Bearer ${e.token}`},Tt(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 Ht(e){return o.createHash("sha1").update(e).digest("hex")}function Vt(e,t){return new n(t,e).toString()}var $t=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:st.function,function:{name:this.name,description:this.description,parameters:this.parameters}}},e}(),Zt=function(){function e(e,t,n,o,i,r){this.authHeaders={},this.domain=e,this.path=t,this.method=n,this.operation=o,this.isConsequential=i,this.contentType=r}return e.prototype.setParams=function(e){return u(this,void 0,void 0,(function(){return p(this,(function(t){return this.operationHash=Ht(JSON.stringify(e)),this.params=e,[2]}))}))},e.prototype.setAuth=function(e){return u(this,void 0,void 0,(function(){var n,o,i,r,a,s,l,u,c,d,m,f,g,h,v;return p(this,(function(p){switch(p.label){case 0:return e.auth?(n=e.auth,o=n.type,i=n.authorization_type,r=n.custom_auth_header,a=n.authorization_url,s=n.client_url,l=n.scope,u=n.token_exchange_method,c=e.api_key,d=e.oauth_client_id,m=e.oauth_client_secret,f=c&&o===Et.ServiceHttp,g=d&&m&&o===Et.OAuth&&a&&s&&l&&u,f&&i===Ot.Basic?(h=Buffer.from(c).toString("base64"),this.authHeaders.Authorization="Basic ".concat(h),[3,6]):[3,1]):[2];case 1:return f&&i===Ot.Bearer?(this.authHeaders.Authorization="Bearer ".concat(c),[3,6]):[3,2];case 2:return f&&i===Ot.Custom&&r?(this.authHeaders[r]=c,[3,6]):[3,3];case 3:return g?this.authToken?[3,5]:[4,t.post(s,{client_id:d,client_secret:m,scope:l,grant_type:"client_credentials"},{headers:{"Content-Type":"application/x-www-form-urlencoded"}})]:[3,6];case 4:v=p.sent(),this.authToken=v.data.access_token,p.label=5;case 5:this.authHeaders.Authorization="Bearer ".concat(this.authToken),p.label=6;case 6:return[2]}}))}))},e.prototype.execute=function(){return u(this,void 0,void 0,(function(){var e,n,o;return p(this,(function(i){if(e=Vt(this.domain,this.path),n=s(s({},this.authHeaders),{"Content-Type":this.contentType}),"get"===(o=this.method.toLowerCase()))return[2,t.get(e,{headers:n,params:this.params})];if("post"===o)return[2,t.post(e,this.params,{headers:n})];if("put"===o)return[2,t.put(e,this.params,{headers:n})];if("delete"===o)return[2,t.delete(e,{headers:n,data:this.params})];if("patch"===o)return[2,t.patch(e,this.params,{headers:n})];throw new Error("Unsupported HTTP method: ".concat(this.method))}))}))},e}();function Yt(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 Yt(i,t)}return e}function Qt(e){for(var t,n,o,i,r=[],a={},l=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:"",u=0,p=Object.entries(e.paths);u<p.length;u++)for(var c=p[u],d=c[0],m=c[1],f=0,g=Object.entries(m);f<g.length;f++){var h=g[f],v=h[0],b=h[1],y=b.operationId||"".concat(v,"_").concat(d),x=b.summary||b.description||"",_={type:"object",properties:{},required:[]};if(b.requestBody){var E=b.requestBody.content,O=Yt(null===(i=E[Object.keys(E)[0]])||void 0===i?void 0:i.schema,e.components);_.properties.requestBody=O}if(b.parameters)for(var A=0,I=b.parameters;A<I.length;A++){var P=I[A];O=Yt(s({},P.schema),e.components);_.properties[P.name]=O,P.required&&_.required.push(P.name),P.description&&!("$$ref"in _.properties[P.name])&&(_.properties[P.name].description=P.description)}var L=new $t(y,x,_);r.push(L);var w=new Zt(l,d,v,y,!!b["x-openai-isConsequential"],b.requestBody?"application/json":"application/x-www-form-urlencoded");a[y]=w}return{functionSignatures:r,requestBuilders:a}}function Wt(e){var t;try{var n=void 0;try{n=JSON.parse(e)}catch(t){n=i(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 r=(null===(t=n.components)||void 0===t?void 0:t.schemas)||{},a=[],s=0,l=Object.entries(o);s<l.length;s++)for(var u=l[s],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],E=x[1].content;if(E&&E["application/json"]&&E["application/json"].schema){var O=E["application/json"].schema;if("$ref"in O&&"string"==typeof O.$ref){var A=O.$ref.split("/").pop();A&&!r[A]&&a.push("In context=('paths', '".concat(p,"', '").concat(g,"', '").concat(_,"', 'response', 'content', 'application/json', 'schema'), reference to unknown component ").concat(A,"; 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 Xt(e){var t=e.conversation,n=e.message;e.messages;var o=e.endpointOption,i=e.isEdited,r=e.isContinued,a=T.parse(t).conversationId,l=o,u=l.endpoint,p=l.endpointType,c=ze[null!=p?p:u];return i&&u===d.assistants?c+="/modify":i&&(c=c.replace("/ask/","/edit/")),{server:c,payload:s(s(s({},n),o),{isContinued:!(!i||!r),conversationId:a})}}export{Zt as ActionRequest,He as AuthKeys,Et as AuthTypeEnum,Ot as AuthorizationTypeEnum,Be as CacheKeys,Ze as Constants,lt as ContentTypes,d as EModelEndpoint,ze as EndpointURLs,Ee as FetchTokenConfig,K as FileContext,It as FilePurpose,q as FileSources,$t as FunctionSignature,f as ImageDetail,Ve as ImageDetailCost,_e as KnownEndpoints,dt as MessageContentTypes,Lt as MutationKeys,Pt as QueryKeys,mt as RunStatus,Ft as SSE,$e as SettingsTabValues,ct as StepStatus,ut as StepTypes,At as TokenExchangeMethodEnum,pt as ToolCallTypes,st as Tools,Fe as ViolationTypes,wt as actionDelimiter,Me as alternateName,M as anthropicSchema,le as applicationMimeTypes,ke as assistantEndpointSchema,Z as assistantSchema,Pe as azureBaseSchema,Ce as azureEndpointSchema,we as azureGroupConfigsSchema,Le as azureGroupSchema,j as bingAISchema,G as chatGPTBrowserSchema,ce as codeInterpreterMimeTypes,oe as codeInterpreterMimeTypesList,W as compactAnthropicSchema,X as compactChatGPTSchema,Q as compactGoogleSchema,Y as compactOpenAISchema,J as compactPluginsSchema,Ne as configSchema,yt as conflictingAzureVariables,ye as convertStringsToRegex,Xt as createPayload,Vt as createURL,Bt as dataService,g as defaultAssistantFormValues,je as defaultEndpoints,Ge as defaultModels,Xe as defaultOrderQuery,Oe as defaultSocialLogins,bt as deprecatedAzureVariables,E as eImageDetailSchema,b as eModelEndpointSchema,ve as endpointFileConfigSchema,Te as endpointSchema,h as endpointSettings,ot as envVarRegex,nt as errorsToString,te as excelFileTypes,ae as excelMimeTypes,y as extendedModelEndpointSchema,it as extractEnvVariable,ge as fileConfig,be as fileConfigSchema,Ae as fileSourceSchema,ne as fullMimeTypesList,et as getEnabledEndpoints,at as getFirstDefinedValue,gt as getResponseSender,N as googleSchema,R as gptPluginsSchema,x as imageDetailNumeric,_ as imageDetailValue,re as imageExtRegex,Ye as imageGenTools,ue as imageMimeTypes,m as isUUID,_t as mapModelToAzureConfig,fe as mbToBytes,me as megabyte,xe as mergeFileConfig,Ie as modelConfigSchema,De as modularEndpoints,S as openAISchema,Qt as openapiToFunction,tt as orderEndpointsConfig,vt as parseCompactConvo,ft as parseConvo,Se as rateLimitSchema,z as removeNullishValues,Kt as request,rt as resolveHeaders,Yt as resolveRef,de as retrievalMimeTypes,ie as retrievalMimeTypesList,kt as setAcceptLanguageHeader,Tt as setTokenHeader,Ht as sha1,pe as supportedMimeTypes,Ue as supportsBalanceCheck,ee as supportsFiles,Re as supportsRetrieval,P as tAgentOptionsSchema,w as tConversationSchema,T as tConvoUpdateSchema,I as tExampleSchema,L as tMessageSchema,O as tPluginAuthConfigSchema,A as tPluginSchema,k as tPresetSchema,C as tPresetUpdateSchema,se as textMimeTypes,Wt as validateAndParseOpenAPISpec,xt as validateAzureGroups,Ke as validateVisionModel,qe as visionModels};
2
2
  //# sourceMappingURL=index.es.js.map