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