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