librechat-data-provider 0.5.2 → 0.5.3

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