librechat-data-provider 0.7.4 → 0.7.41
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/api-endpoints.ts +16 -2
- package/src/config.ts +14 -2
- package/src/data-service.ts +37 -1
- package/src/keys.ts +2 -0
- package/src/schemas.ts +12 -0
- package/src/types/mutations.ts +6 -0
- package/src/types/queries.ts +5 -1
- package/src/types.ts +26 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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,S,_,A;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,P=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 O,L=function(e){return!!e&&e.toLowerCase().endsWith(exports.EModelEndpoint.assistants)};exports.ImageDetail=void 0,(O=exports.ImageDetail||(exports.ImageDetail={})).low="low",O.auto="auto",O.high="high";var k,R=((S={})[exports.ImageDetail.low]=0,S[exports.ImageDetail.auto]=1,S[exports.ImageDetail.high]=2,S),N={0:exports.ImageDetail.low,1:exports.ImageDetail.auto,2:exports.ImageDetail.high},w=l.z.nativeEnum(exports.ImageDetail),D=((_={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:[]}},_),U={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}},j={model:{default:"gemini-1.5-flash-latest"},maxOutputTokens:{min:1,max:8192,step:1,default:8192},temperature:{min:0,max:2,step:.01,default:1},topP:{min:0,max:1,step:.01,default:.95},topK:{min:1,max:40,step:.01,default:40}},G=8192,F=4096,K={model:{default:"claude-3-5-sonnet-20240620"},temperature:{min:0,max:1,step:.01,default:1},maxOutputTokens:{min:1,max:G,step:1,default:G,reset:function(e){return e.includes("claude-3-5-sonnet")?G:4096},set:function(e,t){return!t.includes("claude-3-5-sonnet")&&e>F?F:e}},topP:{min:0,max:1,step:.01,default:.7},topK:{min:1,max:40,step:1,default:5},resendFiles:{default:!0},maxContextTokens:{default:void 0},legacy:{maxOutputTokens:{min:1,max:F,step:1,default:F}}},B=((A={})[exports.EModelEndpoint.openAI]=U,A[exports.EModelEndpoint.google]=j,A[exports.EModelEndpoint.anthropic]=K,A),q=B[exports.EModelEndpoint.google],H=l.z.nativeEnum(exports.EModelEndpoint),V=l.z.union([H,l.z.string()]),Z=l.z.object({authField:l.z.string(),label:l.z.string(),description:l.z.string()}),Y=l.z.object({name:l.z.string(),pluginKey:l.z.string(),description:l.z.string(),icon:l.z.string(),authConfig:l.z.array(Z),authenticated:l.z.boolean().optional(),isButton:l.z.boolean().optional()}),W=l.z.object({input:l.z.object({content:l.z.string()}),output:l.z.object({content:l.z.string()})});exports.EAgent=void 0,(k=exports.EAgent||(exports.EAgent={})).functions="functions",k.classic="classic";var $={model:{default:"gpt-4o-mini"},temperature:{min:0,max:1,step:.01,default:0},agent:{default:exports.EAgent.functions,options:[exports.EAgent.functions,exports.EAgent.classic]},skipCompletion:{default:!0}},Q=l.z.nativeEnum(exports.EAgent),X=l.z.object({agent:l.z.string().default(exports.EAgent.functions),skipCompletion:l.z.boolean().default($.skipCompletion.default),model:l.z.string(),temperature:l.z.number().default($.temperature.default)}),J=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()}),ee=l.z.union([l.z.number(),l.z.string()]).transform((function(e){return"string"==typeof e?""===e.trim()?void 0:parseFloat(e):e})),te=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:H.nullable(),endpointType:H.optional(),suggestions:l.z.array(l.z.string()).optional(),messages:l.z.array(l.z.string()).optional(),tools:l.z.union([l.z.array(Y),l.z.array(l.z.string())]).optional(),createdAt:l.z.string(),updatedAt:l.z.string(),modelLabel:l.z.string().nullable().optional(),examples:l.z.array(W).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(),parentMessageId:l.z.string().optional(),maxOutputTokens:l.z.number().optional(),agentOptions:X.nullable().optional(),file_ids:l.z.array(l.z.string()).optional(),maxContextTokens:ee.optional(),max_tokens:ee.optional(),resendFiles:l.z.boolean().optional(),imageDetail:w.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(),systemMessage:l.z.string().nullable().optional(),jailbreak:l.z.boolean().optional(),jailbreakConversationId:l.z.string().nullable().optional(),conversationSignature:l.z.string().nullable().optional(),clientId:l.z.string().nullable().optional(),invocationId:l.z.number().nullable().optional(),toneStyle:l.z.string().nullable().optional(),resendImages:l.z.boolean().optional()}),oe=te.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:V.nullable()})),ne=te.merge(l.z.object({endpoint:V.nullable()})),re=te.merge(l.z.object({endpoint:V.nullable()})),ie=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()}),se=te.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:U.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:U.temperature.default,top_p:null!==(s=e.top_p)&&void 0!==s?s:U.top_p.default,presence_penalty:null!==(a=e.presence_penalty)&&void 0!==a?a:U.presence_penalty.default,frequency_penalty:null!==(p=e.frequency_penalty)&&void 0!==p?p:U.frequency_penalty.default,resendFiles:"boolean"==typeof e.resendFiles?e.resendFiles:U.resendFiles.default,imageDetail:null!==(l=e.imageDetail)&&void 0!==l?l:U.imageDetail.default,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:U.model.default,chatGptLabel:null,promptPrefix:null,temperature:U.temperature.default,top_p:U.top_p.default,presence_penalty:U.presence_penalty.default,frequency_penalty:U.frequency_penalty.default,resendFiles:U.resendFiles.default,imageDetail:U.imageDetail.default,stop:void 0,iconURL:void 0,greeting:void 0,spec:void 0,maxContextTokens:void 0,max_tokens:void 0}})),ae=te.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;return g(g({},e),{model:null!==(t=e.model)&&void 0!==t?t:q.model.default,modelLabel:null!==(o=e.modelLabel)&&void 0!==o?o:null,promptPrefix:null!==(n=e.promptPrefix)&&void 0!==n?n:null,examples:null!==(r=e.examples)&&void 0!==r?r:[{input:{content:""},output:{content:""}}],temperature:null!==(i=e.temperature)&&void 0!==i?i:q.temperature.default,maxOutputTokens:null!==(s=e.maxOutputTokens)&&void 0!==s?s:q.maxOutputTokens.default,topP:null!==(a=e.topP)&&void 0!==a?a:q.topP.default,topK:null!==(p=e.topK)&&void 0!==p?p:q.topK.default,iconURL:null!==(l=e.iconURL)&&void 0!==l?l:void 0,greeting:null!==(u=e.greeting)&&void 0!==u?u:void 0,spec:null!==(d=e.spec)&&void 0!==d?d:void 0,maxContextTokens:null!==(c=e.maxContextTokens)&&void 0!==c?c:void 0})})).catch((function(){return{model:q.model.default,modelLabel:null,promptPrefix:null,examples:[{input:{content:""},output:{content:""}}],temperature:q.temperature.default,maxOutputTokens:q.maxOutputTokens.default,topP:q.topP.default,topK:q.topK.default,iconURL:void 0,greeting:void 0,spec:void 0,maxContextTokens:void 0}})),pe=te.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}})),le=te.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,c=null!==(t=e.model)&&void 0!==t?t:K.model.default;return g(g({},e),{model:c,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:K.temperature.default,maxOutputTokens:null!==(i=e.maxOutputTokens)&&void 0!==i?i:K.maxOutputTokens.reset(c),topP:null!==(s=e.topP)&&void 0!==s?s:K.topP.default,topK:null!==(a=e.topK)&&void 0!==a?a:K.topK.default,resendFiles:"boolean"==typeof e.resendFiles?e.resendFiles:K.resendFiles.default,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:K.maxContextTokens.default})})).catch((function(){return{model:K.model.default,modelLabel:null,promptPrefix:null,temperature:K.temperature.default,maxOutputTokens:K.maxOutputTokens.default,topP:K.topP.default,topK:K.topK.default,resendFiles:K.resendFiles.default,iconURL:void 0,greeting:void 0,spec:void 0,maxContextTokens:K.maxContextTokens.default}})),ue=te.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"}})),de=te.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 ce(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 me,ge,fe=te.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:U.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:U.model.default,assistant_id:void 0,instructions:void 0,promptPrefix:null,iconURL:void 0,greeting:void 0,spec:void 0}})),xe=te.pick({model:!0,assistant_id:!0,instructions:!0,promptPrefix:!0,iconURL:!0,greeting:!0,spec:!0}).transform(ce).catch((function(){return{}})),he=te.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,ce(t)})).catch((function(){return{}})),ve=te.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===q.temperature.default&&delete t.temperature,t.maxOutputTokens===q.maxOutputTokens.default&&delete t.maxOutputTokens,t.topP===q.topP.default&&delete t.topP,t.topK===q.topK.default&&delete t.topK,ce(t)})).catch((function(){return{}})),Ee=te.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 t.temperature===K.temperature.default&&delete t.temperature,t.maxOutputTokens===K.legacy.maxOutputTokens.default&&delete t.maxOutputTokens,t.topP===K.topP.default&&delete t.topP,t.topK===K.topK.default&&delete t.topK,t.resendFiles===K.resendFiles.default&&delete t.resendFiles,ce(t)})).catch((function(){return{}})),ye=te.pick({model:!0}).transform((function(e){return ce(g({},e))})).catch((function(){return{}})),be=te.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,ce(o)})).catch((function(){return{}})),Te=((me={})[exports.EModelEndpoint.openAI]=!0,me[exports.EModelEndpoint.google]=!0,me[exports.EModelEndpoint.assistants]=!0,me[exports.EModelEndpoint.azureAssistants]=!0,me[exports.EModelEndpoint.azureOpenAI]=!0,me[exports.EModelEndpoint.anthropic]=!0,me[exports.EModelEndpoint.custom]=!0,me),ze=["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"],Se=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"],ze,!0),_e=v(["text/x-c","text/x-c++","application/csv","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/html","text/x-java","application/json","text/markdown","application/pdf","text/x-php","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/x-python","text/x-script.python","text/x-ruby","text/x-tex","text/plain","text/css","image/jpeg","text/javascript","image/gif","image/png","application/x-tar","application/typescript","application/xml","application/zip"],ze,!0),Ae=/^application\/(vnd\.ms-excel|msexcel|x-msexcel|x-ms-excel|x-excel|x-dos_ms_excel|xls|x-xls|vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet)$/,Ie=/^(text\/(x-c|x-c\+\+|x-java|html|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|css|javascript|csv))$/,Me=/^(application\/(epub\+zip|csv|json|pdf|x-tar|typescript|vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation|spreadsheetml\.sheet)|xml|zip))$/,Ce=/^image\/(jpeg|gif|png|webp)$/,Pe=[Ie,Ae,Me,Ce],Oe=[Ie,Ae,Me,Ce],Le=1048576,ke=function(e){return e*Le},Re=ke(512),Ne={fileLimit:10,fileSizeLimit:Re,totalSizeLimit:Re,supportedMimeTypes:Pe,disabled:!1},we={endpoints:(ge={},ge[exports.EModelEndpoint.assistants]=Ne,ge[exports.EModelEndpoint.azureAssistants]=Ne,ge.default={fileLimit:10,fileSizeLimit:Re,totalSizeLimit:Re,supportedMimeTypes:Pe,disabled:!1},ge),serverFileSizeLimit:Re,avatarSizeLimit:ke(2),checkType:function(e,t){return void 0===t&&(t=Pe),t.some((function(t){return t.test(e)}))}},De=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."}),Ue=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:De.optional()}),je=l.z.object({endpoints:l.z.record(Ue).optional(),serverFileSizeLimit:l.z.number().min(0).optional(),avatarSizeLimit:l.z.number().min(0).optional()}),Ge=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 Fe,Ke=l.z.object({name:l.z.string(),label:l.z.string(),preset:oe,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(),H]).optional(),authType:P.optional()}),Be=l.z.object({enforce:l.z.boolean().default(!1),prioritize:l.z.boolean().default(!0),list:l.z.array(Ke).optional()});exports.FileSources=void 0,(Fe=exports.FileSources||(exports.FileSources={})).local="local",Fe.firebase="firebase",Fe.azure="azure",Fe.openai="openai",Fe.s3="s3",Fe.vectordb="vectordb";var qe,He,Ve,Ze,Ye,We,$e,Qe;exports.FileContext=void 0,(qe=exports.FileContext||(exports.FileContext={})).avatar="avatar",qe.unknown="unknown",qe.assistants="assistants",qe.image_generation="image_generation",qe.assistants_output="assistants_output",qe.message_attachment="message_attachment",qe.filename="filename",qe.updatedAt="updatedAt",qe.source="source",qe.context="context",qe.bytes="bytes";var Xe,Je=["google","facebook","openid","github","discord"],et=["gpt-4o","gpt-4o-2024-05-13","gpt-4o-mini","gpt-4o-mini-2024-07-18","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,(Xe=exports.SettingsViews||(exports.SettingsViews={})).default="default",Xe.advanced="advanced";var tt=l.z.nativeEnum(exports.FileSources);function ot(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 nt,rt=l.z.object({deploymentName:l.z.string().optional(),version:l.z.string().optional(),assistants:l.z.boolean().optional()}).or(l.z.boolean()),it=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()}),st=l.z.object({group:l.z.string(),models:l.z.record(l.z.string(),rt)}).required().and(it),at=l.z.array(st).min(1);exports.Capabilities=void 0,(nt=exports.Capabilities||(exports.Capabilities={})).code_interpreter="code_interpreter",nt.image_vision="image_vision",nt.retrieval="retrieval",nt.actions="actions",nt.tools="tools";var pt,lt=((He={})[exports.EModelEndpoint.assistants]=2,He[exports.EModelEndpoint.azureAssistants]=1,He),ut=l.z.object({streamRate:l.z.number().optional()}),dt=ut.merge(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(),privateAssistants:l.z.boolean().optional(),retrievalModels:l.z.array(l.z.string()).min(1).optional().default(et),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()})),ct=ut.merge(l.z.object({name:l.z.string().refine((function(e){return!H.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(),directEndpoint:l.z.boolean().optional(),titleMessageRole:l.z.string().optional()})),mt=l.z.object({groups:at,plugins:l.z.boolean().optional(),assistants:l.z.boolean().optional()}).and(ct.pick({streamRate:!0,titleConvo:!0,titleMethod:!0,titleModel:!0,summarize:!0,summaryModel:!0,customOrder:!0}).partial()),gt=l.z.object({url:l.z.string().optional(),apiKey:l.z.string(),model:l.z.string(),voices:l.z.array(l.z.string())}),ft=l.z.object({instanceName:l.z.string(),apiKey:l.z.string(),deploymentName:l.z.string(),apiVersion:l.z.string(),model:l.z.string(),voices:l.z.array(l.z.string())}),xt=l.z.object({url:l.z.string().optional(),websocketUrl:l.z.string().optional(),apiKey:l.z.string(),model:l.z.string(),voices:l.z.array(l.z.string()),voice_settings:l.z.object({similarity_boost:l.z.number().optional(),stability:l.z.number().optional(),style:l.z.number().optional(),use_speaker_boost:l.z.boolean().optional()}).optional(),pronunciation_dictionary_locators:l.z.array(l.z.string()).optional()}),ht=l.z.object({url:l.z.string(),apiKey:l.z.string().optional(),voices:l.z.array(l.z.string()),backend:l.z.string()}),vt=l.z.object({openai:gt.optional(),azureOpenAI:ft.optional(),elevenLabs:xt.optional(),localai:ht.optional()}),Et=l.z.object({url:l.z.string().optional(),apiKey:l.z.string(),model:l.z.string()}),yt=l.z.object({instanceName:l.z.string(),apiKey:l.z.string(),deploymentName:l.z.string(),apiVersion:l.z.string()}),bt=l.z.object({openai:Et.optional(),azureOpenAI:yt.optional()}),Tt=l.z.object({conversationMode:l.z.boolean().optional(),advancedMode:l.z.boolean().optional(),speechToText:l.z.boolean().optional().or(l.z.object({engineSTT:l.z.string().optional(),languageSTT:l.z.string().optional(),autoTranscribeAudio:l.z.boolean().optional(),decibelValue:l.z.number().optional(),autoSendText:l.z.number().optional()})).optional(),textToSpeech:l.z.boolean().optional().or(l.z.object({engineTTS:l.z.string().optional(),voice:l.z.string().optional(),languageTTS:l.z.string().optional(),automaticPlayback:l.z.boolean().optional(),playbackRate:l.z.number().optional(),cacheTTS:l.z.boolean().optional()})).optional()}).optional();exports.RateLimitPrefix=void 0,(pt=exports.RateLimitPrefix||(exports.RateLimitPrefix={})).FILE_UPLOAD="FILE_UPLOAD",pt.IMPORT="IMPORT",pt.TTS="TTS",pt.STT="STT";var zt,St=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(),tts:l.z.object({ipMax:l.z.number().optional(),ipWindowInMinutes:l.z.number().optional(),userMax:l.z.number().optional(),userWindowInMinutes:l.z.number().optional()}).optional(),stt: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,(zt=exports.EImageOutputType||(exports.EImageOutputType={})).PNG="png",zt.WEBP="webp",zt.JPEG="jpeg";var _t,At=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:tt.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:Je}),speech:l.z.object({tts:vt.optional(),stt:bt.optional(),speechTab:Tt.optional()}).optional(),rateLimits:St.optional(),fileConfig:je.optional(),modelSpecs:Be.optional(),endpoints:l.z.object((Ve={all:ut.optional()},Ve[exports.EModelEndpoint.openAI]=ut.optional(),Ve[exports.EModelEndpoint.google]=ut.optional(),Ve[exports.EModelEndpoint.anthropic]=ut.optional(),Ve[exports.EModelEndpoint.gptPlugins]=ut.optional(),Ve[exports.EModelEndpoint.azureOpenAI]=mt.optional(),Ve[exports.EModelEndpoint.azureAssistants]=dt.optional(),Ve[exports.EModelEndpoint.assistants]=dt.optional(),Ve[exports.EModelEndpoint.custom]=l.z.array(ct.partial()).optional(),Ve)).strict().refine((function(e){return Object.keys(e).length>0}),{message:"At least one `endpoints` field must be provided."}).optional()});exports.KnownEndpoints=void 0,(_t=exports.KnownEndpoints||(exports.KnownEndpoints={})).anyscale="anyscale",_t.apipie="apipie",_t.cohere="cohere",_t.fireworks="fireworks",_t.groq="groq",_t.huggingface="huggingface",_t.mistral="mistral",_t.mlx="mlx",_t.ollama="ollama",_t.openrouter="openrouter",_t.perplexity="perplexity",_t.shuttleai="shuttleai",_t["together.ai"]="together.ai",exports.FetchTokenConfig=void 0,(exports.FetchTokenConfig||(exports.FetchTokenConfig={})).openrouter="openrouter";var It=[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],Mt=((Ze={})[exports.EModelEndpoint.openAI]="OpenAI",Ze[exports.EModelEndpoint.assistants]="Assistants",Ze[exports.EModelEndpoint.azureAssistants]="Azure Assistants",Ze[exports.EModelEndpoint.azureOpenAI]="Azure OpenAI",Ze[exports.EModelEndpoint.bingAI]="Bing",Ze[exports.EModelEndpoint.chatGPTBrowser]="ChatGPT",Ze[exports.EModelEndpoint.gptPlugins]="Plugins",Ze[exports.EModelEndpoint.google]="Google",Ze[exports.EModelEndpoint.anthropic]="Anthropic",Ze[exports.EModelEndpoint.custom]="Custom",Ze),Ct=["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"],Pt=((Ye={})[exports.EModelEndpoint.azureAssistants]=Ct,Ye[exports.EModelEndpoint.assistants]=v(["gpt-4o-mini","gpt-4o"],Ct,!0),Ye[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"],Ye[exports.EModelEndpoint.anthropic]=["claude-3-5-sonnet-20240620","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"],Ye[exports.EModelEndpoint.openAI]=v(v(["gpt-4o-mini","gpt-4o"],Ct,!0),["gpt-4-vision-preview","gpt-3.5-turbo-instruct-0914","gpt-3.5-turbo-instruct"],!1),Ye),Ot=Pt[exports.EModelEndpoint.openAI],Lt=((We={initial:[]})[exports.EModelEndpoint.openAI]=Ot,We[exports.EModelEndpoint.assistants]=Ot.filter((function(e){return/gpt-4|gpt-3\\.5/i.test(e)&&!/vision|instruct/i.test(e)})),We[exports.EModelEndpoint.gptPlugins]=Ot,We[exports.EModelEndpoint.azureOpenAI]=Ot,We[exports.EModelEndpoint.bingAI]=["BingAI","Sydney"],We[exports.EModelEndpoint.chatGPTBrowser]=["text-davinci-002-render-sha"],We[exports.EModelEndpoint.google]=Pt[exports.EModelEndpoint.google],We[exports.EModelEndpoint.anthropic]=Pt[exports.EModelEndpoint.anthropic],We),kt=(($e={})[exports.EModelEndpoint.openAI]="/api/ask/".concat(exports.EModelEndpoint.openAI),$e[exports.EModelEndpoint.bingAI]="/api/ask/".concat(exports.EModelEndpoint.bingAI),$e[exports.EModelEndpoint.google]="/api/ask/".concat(exports.EModelEndpoint.google),$e[exports.EModelEndpoint.custom]="/api/ask/".concat(exports.EModelEndpoint.custom),$e[exports.EModelEndpoint.anthropic]="/api/ask/".concat(exports.EModelEndpoint.anthropic),$e[exports.EModelEndpoint.gptPlugins]="/api/ask/".concat(exports.EModelEndpoint.gptPlugins),$e[exports.EModelEndpoint.azureOpenAI]="/api/ask/".concat(exports.EModelEndpoint.azureOpenAI),$e[exports.EModelEndpoint.chatGPTBrowser]="/api/ask/".concat(exports.EModelEndpoint.chatGPTBrowser),$e[exports.EModelEndpoint.azureAssistants]="/api/assistants/v1/chat",$e[exports.EModelEndpoint.assistants]="/api/assistants/v2/chat",$e),Rt=new Set([exports.EModelEndpoint.gptPlugins,exports.EModelEndpoint.anthropic,exports.EModelEndpoint.google,exports.EModelEndpoint.openAI,exports.EModelEndpoint.azureOpenAI,exports.EModelEndpoint.custom]),Nt=((Qe={})[exports.EModelEndpoint.custom]=!0,Qe[exports.EModelEndpoint.openAI]=!0,Qe[exports.EModelEndpoint.anthropic]=!0,Qe[exports.EModelEndpoint.gptPlugins]=!0,Qe[exports.EModelEndpoint.assistants]=!0,Qe[exports.EModelEndpoint.azureAssistants]=!0,Qe[exports.EModelEndpoint.azureOpenAI]=!0,Qe),wt=["gpt-4o","gpt-4o-mini","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 Dt,Ut,jt,Gt,Ft,Kt,Bt,qt,Ht,Vt,Zt,Yt,Wt,$t,Qt,Xt,Jt,eo=new Set(["dalle","dall-e","stable-diffusion"]);exports.InfiniteCollections=void 0,(Dt=exports.InfiniteCollections||(exports.InfiniteCollections={})).PROMPT_GROUPS="promptGroups",Dt.SHARED_LINKS="sharedLinks",exports.Time=void 0,(Ut=exports.Time||(exports.Time={}))[Ut.THIRTY_MINUTES=18e5]="THIRTY_MINUTES",Ut[Ut.TEN_MINUTES=6e5]="TEN_MINUTES",Ut[Ut.FIVE_MINUTES=3e5]="FIVE_MINUTES",Ut[Ut.TWO_MINUTES=12e4]="TWO_MINUTES",Ut[Ut.ONE_MINUTE=6e4]="ONE_MINUTE",Ut[Ut.THIRTY_SECONDS=3e4]="THIRTY_SECONDS",exports.CacheKeys=void 0,(jt=exports.CacheKeys||(exports.CacheKeys={})).CONFIG_STORE="configStore",jt.ROLES="roles",jt.PLUGINS="plugins",jt.GEN_TITLE="genTitle",jt.TOOLS="tools",jt.MODELS_CONFIG="modelsConfig",jt.MODEL_QUERIES="modelQueries",jt.STARTUP_CONFIG="startupConfig",jt.ENDPOINT_CONFIG="endpointsConfig",jt.TOKEN_CONFIG="tokenConfig",jt.CUSTOM_CONFIG="customConfig",jt.ABORT_KEYS="abortKeys",jt.OVERRIDE_CONFIG="overrideConfig",jt.BANS="bans",jt.ENCODED_DOMAINS="encoded_domains",jt.AUDIO_RUNS="audioRuns",jt.MESSAGES="messages",exports.ViolationTypes=void 0,(Gt=exports.ViolationTypes||(exports.ViolationTypes={})).FILE_UPLOAD_LIMIT="file_upload_limit",Gt.ILLEGAL_MODEL_REQUEST="illegal_model_request",Gt.TOKEN_BALANCE="token_balance",Gt.BAN="ban",Gt.TTS_LIMIT="tts_limit",Gt.STT_LIMIT="stt_limit",Gt.RESET_PASSWORD_LIMIT="reset_password_limit",Gt.VERIFY_EMAIL_LIMIT="verify_email_limit",exports.ErrorTypes=void 0,(Ft=exports.ErrorTypes||(exports.ErrorTypes={})).NO_USER_KEY="no_user_key",Ft.EXPIRED_USER_KEY="expired_user_key",Ft.INVALID_USER_KEY="invalid_user_key",Ft.NO_BASE_URL="no_base_url",Ft.MODERATION="moderation",exports.AuthKeys=void 0,(Kt=exports.AuthKeys||(exports.AuthKeys={})).GOOGLE_SERVICE_KEY="GOOGLE_SERVICE_KEY",Kt.GOOGLE_API_KEY="GOOGLE_API_KEY",exports.ImageDetailCost=void 0,(Bt=exports.ImageDetailCost||(exports.ImageDetailCost={}))[Bt.LOW=85]="LOW",Bt[Bt.HIGH=170]="HIGH",Bt[Bt.ADDITIONAL=85]="ADDITIONAL",exports.SettingsTabValues=void 0,(qt=exports.SettingsTabValues||(exports.SettingsTabValues={})).GENERAL="general",qt.CHAT="chat",qt.SPEECH="speech",qt.BETA="beta",qt.DATA="data",qt.ACCOUNT="account",exports.STTProviders=void 0,(Ht=exports.STTProviders||(exports.STTProviders={})).OPENAI="openai",Ht.AZURE_OPENAI="azureOpenAI",exports.TTSProviders=void 0,(Vt=exports.TTSProviders||(exports.TTSProviders={})).OPENAI="openai",Vt.AZURE_OPENAI="azureOpenAI",Vt.ELEVENLABS="elevenlabs",Vt.LOCALAI="localai",exports.Constants=void 0,(Zt=exports.Constants||(exports.Constants={})).VERSION="v0.7.4-rc1",Zt.CONFIG_VERSION="1.1.5",Zt.NO_PARENT="00000000-0000-0000-0000-000000000000",Zt.NEW_CONVO="new",Zt[Zt.ENCODED_DOMAIN_LENGTH=10]="ENCODED_DOMAIN_LENGTH",Zt.CURRENT_MODEL="current_model",Zt.COMMON_DIVIDER="__",Zt[Zt.COMMANDS_MAX_LENGTH=56]="COMMANDS_MAX_LENGTH",Zt[Zt.DEFAULT_STREAM_RATE=1]="DEFAULT_STREAM_RATE",exports.LocalStorageKeys=void 0,(Yt=exports.LocalStorageKeys||(exports.LocalStorageKeys={})).APP_TITLE="appTitle",Yt.LAST_CONVO_SETUP="lastConversationSetup",Yt.LAST_BING="lastBingSettings",Yt.LAST_MODEL="lastSelectedModel",Yt.LAST_TOOLS="lastSelectedTools",Yt.LAST_SPEC="lastSelectedSpec",Yt.FILES_TO_DELETE="filesToDelete",Yt.ASST_ID_PREFIX="assistant_id__",Yt.FORK_SETTING="forkSetting",Yt.REMEMBER_FORK_OPTION="rememberForkOption",Yt.FORK_SPLIT_AT_TARGET="splitAtTarget",Yt.TEXT_DRAFT="textDraft_",Yt.FILES_DRAFT="filesDraft_",Yt.LAST_PROMPT_CATEGORY="lastPromptCategory",exports.ForkOptions=void 0,(Wt=exports.ForkOptions||(exports.ForkOptions={})).DIRECT_PATH="directPath",Wt.INCLUDE_BRANCHES="includeBranches",Wt.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:",exports.SystemCategories=void 0,(Qt=exports.SystemCategories||(exports.SystemCategories={})).ALL="sys__all__sys",Qt.MY_PROMPTS="sys__my__prompts__sys",Qt.NO_CATEGORY="sys__no__category__sys",Qt.SHARED_PROMPTS="sys__shared__prompts__sys";var to=((Xt={})[exports.EModelEndpoint.openAI]=se,Xt[exports.EModelEndpoint.azureOpenAI]=se,Xt[exports.EModelEndpoint.custom]=se,Xt[exports.EModelEndpoint.google]=ae,Xt[exports.EModelEndpoint.bingAI]=pe,Xt[exports.EModelEndpoint.anthropic]=le,Xt[exports.EModelEndpoint.chatGPTBrowser]=ue,Xt[exports.EModelEndpoint.gptPlugins]=de,Xt[exports.EModelEndpoint.assistants]=fe,Xt[exports.EModelEndpoint.azureAssistants]=fe,Xt);function oo(){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 no(e){return e.map((function(e){var t=e.path.join("."),o=e.message;return"".concat(t,": ").concat(o)})).join(" ")}var ro=/^\${(.+)}$/;function io(e){var t=e.match(ro);return t&&process.env[t[1]]||e}function so(e){for(var t,o=0,n=e;o<n.length;o++){var r=n[o];if(r){t=r;break}}return t}var ao=((Jt={})[exports.EModelEndpoint.openAI]=he,Jt[exports.EModelEndpoint.azureOpenAI]=he,Jt[exports.EModelEndpoint.custom]=he,Jt[exports.EModelEndpoint.assistants]=xe,Jt[exports.EModelEndpoint.azureAssistants]=xe,Jt[exports.EModelEndpoint.google]=ve,Jt[exports.EModelEndpoint.bingAI]=pe,Jt[exports.EModelEndpoint.anthropic]=Ee,Jt[exports.EModelEndpoint.chatGPTBrowser]=ye,Jt[exports.EModelEndpoint.gptPlugins]=be,Jt);var po,lo,uo;exports.ComponentTypes=void 0,(po=exports.ComponentTypes||(exports.ComponentTypes={})).Input="input",po.Textarea="textarea",po.Slider="slider",po.Checkbox="checkbox",po.Switch="switch",po.Dropdown="dropdown",po.Tags="tags",exports.SettingTypes=void 0,(lo=exports.SettingTypes||(exports.SettingTypes={})).Number="number",lo.Boolean="boolean",lo.String="string",lo.Enum="enum",lo.Array="array",exports.OptionTypes=void 0,(uo=exports.OptionTypes||(exports.OptionTypes={})).Conversation="conversation",uo.Model="model",uo.Custom="custom";var co=["key","type","component"];var mo={ZodString:"string",ZodNumber:"number",ZodBoolean:"boolean"};var go,fo,xo,ho,vo,Eo,yo,bo,To,zo,So;exports.SystemRoles=void 0,(zo=exports.SystemRoles||(exports.SystemRoles={})).ADMIN="ADMIN",zo.USER="USER",exports.PermissionTypes=void 0,(exports.PermissionTypes||(exports.PermissionTypes={})).PROMPTS="PROMPTS",exports.Permissions=void 0,(So=exports.Permissions||(exports.Permissions={})).SHARED_GLOBAL="SHARED_GLOBAL",So.USE="USE",So.CREATE="CREATE",So.SHARE="SHARE";var _o,Ao,Io=l.z.object(((go={})[exports.Permissions.SHARED_GLOBAL]=l.z.boolean().default(!1),go[exports.Permissions.USE]=l.z.boolean().default(!0),go[exports.Permissions.CREATE]=l.z.boolean().default(!0),go[exports.Permissions.SHARE]=l.z.boolean().default(!1),go)),Mo=l.z.object(((fo={name:l.z.string()})[exports.PermissionTypes.PROMPTS]=Io,fo)),Co=l.z.object(((xo={})[exports.SystemRoles.ADMIN]=Mo.extend(((ho={name:l.z.literal(exports.SystemRoles.ADMIN)})[exports.PermissionTypes.PROMPTS]=Io.extend(((vo={})[exports.Permissions.SHARED_GLOBAL]=l.z.boolean().default(!0),vo[exports.Permissions.USE]=l.z.boolean().default(!0),vo[exports.Permissions.CREATE]=l.z.boolean().default(!0),vo[exports.Permissions.SHARE]=l.z.boolean().default(!0),vo)),ho)),xo[exports.SystemRoles.USER]=Mo.extend(((Eo={name:l.z.literal(exports.SystemRoles.USER)})[exports.PermissionTypes.PROMPTS]=Io,Eo)),xo)).parse(((yo={})[exports.SystemRoles.ADMIN]=((bo={name:exports.SystemRoles.ADMIN})[exports.PermissionTypes.PROMPTS]={},bo),yo[exports.SystemRoles.USER]=((To={name:exports.SystemRoles.USER})[exports.PermissionTypes.PROMPTS]={},To),yo));function Po(e){u.defaults.headers.common.Authorization="Bearer "+e}exports.QueryKeys=void 0,(_o=exports.QueryKeys||(exports.QueryKeys={})).messages="messages",_o.sharedMessages="sharedMessages",_o.sharedLinks="sharedLinks",_o.allConversations="allConversations",_o.archivedConversations="archivedConversations",_o.searchConversations="searchConversations",_o.conversation="conversation",_o.searchEnabled="searchEnabled",_o.user="user",_o.name="name",_o.models="models",_o.balance="balance",_o.endpoints="endpoints",_o.presets="presets",_o.searchResults="searchResults",_o.tokenCount="tokenCount",_o.availablePlugins="availablePlugins",_o.startupConfig="startupConfig",_o.assistants="assistants",_o.assistant="assistant",_o.endpointsConfigOverride="endpointsConfigOverride",_o.files="files",_o.fileConfig="fileConfig",_o.tools="tools",_o.actions="actions",_o.assistantDocs="assistantDocs",_o.fileDownload="fileDownload",_o.voices="voices",_o.customConfigSpeech="customConfigSpeech",_o.prompts="prompts",_o.prompt="prompt",_o.promptGroups="promptGroups",_o.allPromptGroups="allPromptGroups",_o.promptGroup="promptGroup",_o.categories="categories",_o.randomPrompts="randomPrompts",_o.roles="roles",exports.MutationKeys=void 0,(Ao=exports.MutationKeys||(exports.MutationKeys={})).fileUpload="fileUpload",Ao.fileDelete="fileDelete",Ao.updatePreset="updatePreset",Ao.deletePreset="deletePreset",Ao.logoutUser="logoutUser",Ao.avatarUpload="avatarUpload",Ao.speechToText="speechToText",Ao.textToSpeech="textToSpeech",Ao.assistantAvatarUpload="assistantAvatarUpload",Ao.updateAction="updateAction",Ao.deleteAction="deleteAction",Ao.deleteUser="deleteUser",Ao.updateRole="updateRole";var Oo=function(e,t){return"/api/messages/".concat(e).concat(t?"/".concat(t):"")},Lo="/api/share",ko=function(e){return"".concat(Lo,"/").concat(e)},Ro=Lo,No=Lo,wo="/api/keys",Do="/api/convos",Uo=function(e,t){return"".concat(Do,"?pageNumber=").concat(e).concat(t?"&isArchived=true":"")},jo=function(){return"".concat(Do,"/update")},Go=function(){return"".concat(Do,"/clear")},Fo=function(e,t){return"/api/search?q=".concat(e,"&pageNumber=").concat(t)},Ko=function(){return"/api/prompts"},Bo=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},qo=function(){return"".concat("/api/files","/images")},Ho=function(){return"".concat("/api/files","/speech")},Vo=function(){return"".concat(Ho(),"/tts")},Zo=function(e){return"".concat("/api/prompts","/groups/").concat(e)},Yo=function(e){return"".concat("/api/prompts","/").concat(e)},Wo=Ko,$o=Zo,Qo=Zo;function Xo(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 Jo=!1,en=[],tn=function(e){return Xo(function(e){return"/api/auth/refresh".concat(e?"?retry=true":"")}(e))},on=function(e,t){void 0===t&&(t=null),en.forEach((function(o){e?o.reject(e):o.resolve(t)})),en=[]};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,!Jo)return[3,5];s.label=1;case 1:return s.trys.push([1,4,,5]),[4,new Promise((function(e,t){en.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:Jo=!0,s.label=6;case 6:return s.trys.push([6,11,12,13]),[4,tn(!!(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,Po(n),window.dispatchEvent(new CustomEvent("tokenUpdated",{detail:n})),on(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(),on(r,null),[2,Promise.reject(r)];case 12:return Jo=!1,[7];case 13:return[2,Promise.reject(e)]}}))}))}));var nn={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:Xo,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]}}))}))},postTTS: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"},responseType:"arraybuffer"}))];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:tn};var rn=Object.freeze({__proto__:null,abortRequestWithMessage:function(e,t,o){return nn.post(function(e){return"/api/ask/".concat(e,"/abort")}(e),{arg:{abortKey:t,message:o}})},archiveConversation:function(e){return nn.post(jo(),{arg:e})},clearAllConversations:function(){return nn.post(Go(),{arg:{}})},createAssistant:function(e){var t=e.version,o=f(e,["version"]);return nn.post(Bo({version:t}),o)},createPreset:function(e){return nn.post("/api/presets",e)},createPrompt:function(e){return nn.post(Wo(),e)},createSharedLink:function(e){return nn.post(Ro,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,nn.delete(Bo({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 nn.delete(Bo({path:t,options:{model:o,endpoint:n},version:r}))},deleteConversation:function(e){return nn.post(Go(),{arg:e})},deleteFiles:function(e,t,o){return x(void 0,void 0,void 0,(function(){return h(this,(function(n){return[2,nn.deleteWithOptions("/api/files",{data:{files:e,assistant_id:t,tool_resource:o}})]}))}))},deletePreset:function(e){return nn.post("/api/presets/delete",e)},deletePrompt:function(e){return nn.delete(function(e){var t=e._id,o=e.groupId;return"".concat("/api/prompts","/").concat(t,"?groupId=").concat(o)}(e))},deletePromptGroup:function(e){return nn.delete(Qo(e))},deleteSharedLink:function(e){return nn.delete(ko(e))},deleteUser:function(){return nn.delete("/api/user/delete")},forkConversation:function(e){return nn.post("".concat(Do,"/fork"),e)},genTitle:function(e){return nn.post("".concat(Do,"/gen_title"),e)},getAIEndpoints:function(){return nn.get("/api/endpoints")},getActions:function(e){var t=e.endpoint,o=e.version;return nn.get(Bo({path:"actions",version:o,endpoint:t}))},getAllPromptGroups:function(){return nn.get("".concat("/api/prompts","/all"))},getAssistantById:function(e){var t=e.endpoint,o=e.assistant_id,n=e.version;return nn.get(Bo({path:o,endpoint:t,version:n}))},getAssistantDocs:function(e){var t=e.endpoint,o=e.version;return nn.get(Bo({path:"documents",version:o,endpoint:t}))},getAvailablePlugins:function(){return nn.get("/api/plugins")},getAvailableTools:function(e,t){return nn.get(Bo({path:"tools",endpoint:t,version:e}))},getCategories:function(){return nn.get("/api/categories")},getConversationById:function(e){return nn.get(function(e){return"".concat(Do,"/").concat(e)}(e))},getConversations:function(e){return nn.get(Uo(e))},getCustomConfigSpeech:function(){return nn.get("".concat(Ho(),"/config/get"))},getEndpointsConfigOverride:function(){return nn.get("/api/endpoints/config/override")},getFileConfig:function(){return nn.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,nn.getResponse("".concat("/api/files","/download/").concat(e,"/").concat(t),{responseType:"blob",headers:{Accept:"application/octet-stream"}})]}))}))},getFiles:function(){return nn.get("/api/files")},getLoginGoogle:function(){return nn.get("/api/auth/google")},getMessagesByConvoId:function(e){return"new"===e?Promise.resolve([]):nn.get(Oo(e))},getModels:function(){return x(void 0,void 0,void 0,(function(){return h(this,(function(e){return[2,nn.get("/api/models")]}))}))},getPresets:function(){return nn.get("/api/presets")},getPrompt:function(e){return nn.get(Yo(e))},getPromptGroup:function(e){return nn.get(Zo(e))},getPromptGroups:function(e){return nn.get(function(e){var t="".concat("/api/prompts","/groups");if(Object.keys(e).length>0){var o=new URLSearchParams(e).toString();t+="?".concat(o)}return t}(e))},getPrompts:function(e){return nn.get(function(e){var t="/api/prompts";if(Object.keys(e).length>0){var o=new URLSearchParams(e).toString();t+="?".concat(o)}return t}(e))},getRandomPrompts:function(e){return nn.get((t=e.limit,o=e.skip,"".concat("/api/prompts","/random?limit=").concat(t,"&skip=").concat(o)));var t,o},getRole:function(e){return nn.get(function(e){return"".concat("/api/roles","/").concat(e.toLowerCase())}(e))},getSearchEnabled:function(){return nn.get("/api/search/enable")},getSharedLink:function(e){return nn.get(ko(e))},getSharedMessages:function(e){return nn.get(ko(e))},getStartupConfig:function(){return nn.get("/api/config")},getUser:function(){return nn.get("/api/user")},getUserBalance:function(){return nn.get("/api/balance")},getVoices:function(){return nn.get("".concat(Vo(),"/voices"))},importConversationsFile:function(e){return nn.postMultiPart("".concat(Do,"/import"),e)},listAssistants:function(e,t){return nn.get(Bo({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 nn.get(Uo(t,o))},listConversationsByQuery:function(e){var t=(null==e?void 0:e.pageNumber)||"1",o=(null==e?void 0:e.searchQuery)||"";return""!==o?nn.get(Fo(o,t)):nn.get(Uo(t))},listSharedLinks:function(e){var t=(null==e?void 0:e.pageNumber)||"1",o=(null==e?void 0:e.isPublic)||!0;return nn.get(function(e,t){return"".concat(Lo,"?pageNumber=").concat(e,"&isPublic=").concat(t)}(t,o))},login:function(e){return nn.post("/api/auth/login",e)},logout:function(){return nn.post("/api/auth/logout")},makePromptProduction:function(e){return nn.patch("".concat(Yo(e),"/tags/production"))},register:function(e){return nn.post("/api/auth/register",e)},requestPasswordReset:function(e){return nn.post("/api/auth/requestPasswordReset",e)},resendVerificationEmail:function(e){return nn.post("/api/user/verify/resend",e)},resetPassword:function(e){return nn.post("/api/auth/resetPassword",e)},revokeAllUserKeys:function(){return nn.delete("".concat(wo,"?all=true"))},revokeUserKey:function(e){return nn.delete(function(e){return"".concat(wo,"/").concat(e)}(e))},searchConversations:function(e,t){return x(void 0,void 0,void 0,(function(){return h(this,(function(o){return[2,nn.get(Fo(e,t))]}))}))},speechToText:function(e){return nn.postMultiPart("".concat(Ho(),"/stt"),e)},textToSpeech:function(e){return nn.postTTS("".concat(Vo(),"/manual"),e)},updateAction:function(e){var t=e.assistant_id,o=e.version,n=f(e,["assistant_id","version"]);return nn.post(Bo({path:"actions/".concat(t),version:o}),n)},updateAssistant:function(e){var t=e.assistant_id,o=e.data,n=e.version;return nn.patch(Bo({path:t,version:n}),o)},updateConversation:function(e){return nn.post(jo(),{arg:e})},updateMessage:function(e){var t=e.conversationId,o=e.messageId,n=e.text;if(!t)throw new Error("conversationId is required");return nn.put(Oo(t,o),{text:n})},updatePreset:function(e){return nn.post("/api/presets",e)},updatePromptGroup:function(e){return nn.patch($o(e.id),e.payload)},updatePromptLabels:function(e){return nn.patch((t=e.id,"".concat(Yo(t),"/labels")),e.payload);var t},updatePromptPermissions:function(e){return nn.put((t=e.roleName,"".concat("/api/roles","/").concat(t.toLowerCase(),"/prompts")),e.updates);var t},updateSharedLink:function(e){return nn.patch(No,e)},updateTokenCount:function(e){return nn.post("/api/tokenizer",{arg:e})},updateUserKey:function(e){if(!e.value)throw new Error("value is required");return nn.put(wo,e)},updateUserPlugins:function(e){return nn.post("/api/user/plugins",e)},uploadAssistantAvatar:function(e){return nn.postMultiPart(Bo({path:"avatar/".concat(e.assistant_id),options:{model:e.model,endpoint:e.endpoint},version:e.version}),e.formData)},uploadAvatar:function(e){return nn.postMultiPart("".concat(qo(),"/avatar"),e)},uploadFile:function(e){return nn.postMultiPart("/api/files",e)},uploadImage:function(e){return nn.postMultiPart(qo(),e)},userKeyQuery:function(e){return nn.get(function(e){return"".concat(wo,"?name=").concat(e)}(e))},verifyEmail:function(e){return nn.post("/api/user/verify",e)}}),sn=function(e,t){if(!(this instanceof sn))return new sn(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 nn.refreshToken();this.headers={"Content-Type":"application/json",Authorization:`Bearer ${e.token}`},Po(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 an(e){return c.createHash("sha1").update(e).digest("hex")}function pn(e,t){var o=e.replace(/\/$/,""),n=t.replace(/^\//,""),r="".concat(o,"/").concat(n);return new d.URL(r).toString()}var ln=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}(),un=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){this.operationHash=an(JSON.stringify(e)),this.params=e;for(var t=0,o=Object.entries(e);t<o.length;t++){var 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])}},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=pn(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 dn(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 dn(r,t)}return e}exports.ActionRequest=un,exports.EndpointURLs=kt,exports.FunctionSignature=ln,exports.ImageVisionTool=D,exports.SSE=sn,exports.actionDelimiter="_action_",exports.actionDomainSeparator="---",exports.agentOptionSettings=$,exports.alternateName=Mt,exports.anthropicSchema=le,exports.anthropicSettings=K,exports.applicationMimeTypes=Me,exports.assistantEndpointSchema=dt,exports.assistantSchema=fe,exports.authTypeSchema=P,exports.azureBaseSchema=it,exports.azureEndpointSchema=mt,exports.azureGroupConfigsSchema=at,exports.azureGroupSchema=st,exports.baseEndpointSchema=ut,exports.bingAISchema=pe,exports.chatGPTBrowserSchema=ue,exports.checkOpenAIStorage=function(e){return e===exports.FileSources.openai||e===exports.FileSources.azure},exports.codeInterpreterMimeTypes=Oe,exports.codeInterpreterMimeTypesList=_e,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=ee,exports.compactAnthropicSchema=Ee,exports.compactAssistantSchema=xe,exports.compactChatGPTSchema=ye,exports.compactGoogleSchema=ve,exports.compactOpenAISchema=he,exports.compactPluginsSchema=be,exports.configSchema=At,exports.conflictingAzureVariables=[{key:"INSTANCE_NAME"},{key:"DEPLOYMENT_NAME"}],exports.convertStringsToRegex=Ge,exports.createPayload=function(e){var t=e.conversation,o=e.userMessage,n=e.endpointOption,r=e.isEdited,i=e.isContinued,s=ne.parse(t).conversationId,a=n,p=a.endpoint,l=a.endpointType,u=kt[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=pn,exports.dataService=rn,exports.defaultAssistantFormValues={assistant:"",id:"",name:"",description:"",instructions:"",model:"",functions:[],code_interpreter:!1,image_vision:!1,retrieval:!1},exports.defaultAssistantsVersion=lt,exports.defaultEndpoints=It,exports.defaultModels=Pt,exports.defaultOrderQuery={order:"desc",limit:100},exports.defaultRetrievalModels=et,exports.defaultSocialLogins=Je,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=Q,exports.eImageDetailSchema=w,exports.eModelEndpointSchema=H,exports.endpointFileConfigSchema=Ue,exports.endpointSchema=ct,exports.endpointSettings=B,exports.envVarRegex=ro,exports.errorsToString=no,exports.excelFileTypes=ze,exports.excelMimeTypes=Ae,exports.extendedModelEndpointSchema=V,exports.extractEnvVariable=io,exports.fileConfig=we,exports.fileConfigSchema=je,exports.fileSourceSchema=tt,exports.fullMimeTypesList=Se,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({},j),e);return te.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;return g(g({},e),{model:null!==(o=e.model)&&void 0!==o?o:t.model.default,modelLabel:null!==(n=e.modelLabel)&&void 0!==n?n:null,promptPrefix:null!==(r=e.promptPrefix)&&void 0!==r?r:null,examples:null!==(i=e.examples)&&void 0!==i?i:[{input:{content:""},output:{content:""}}],temperature:null!==(s=e.temperature)&&void 0!==s?s:t.temperature.default,maxOutputTokens:null!==(a=e.maxOutputTokens)&&void 0!==a?a:t.maxOutputTokens.default,topP:null!==(p=e.topP)&&void 0!==p?p:t.topP.default,topK:null!==(l=e.topK)&&void 0!==l?l:t.topK.default,maxContextTokens:null!==(u=e.maxContextTokens)&&void 0!==u?u: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({},U),e);return te.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 ot(At)},exports.getEnabledEndpoints=oo,exports.getFirstDefinedValue=so,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=Mt[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=ot,exports.googleSchema=ae,exports.googleSettings=j,exports.gptPluginsSchema=de,exports.hostImageIdSuffix="_host_copy",exports.hostImageNamePrefix="host_copy_",exports.imageDetailNumeric=R,exports.imageDetailValue=N,exports.imageExtRegex=/\.(jpg|jpeg|png|gif|webp)$/i,exports.imageGenTools=eo,exports.imageMimeTypes=Ce,exports.initialModelsConfig=Lt,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:io(n.apiKey),azureOpenAIApiInstanceName:io(r)};if(n.serverless)return g({azureOptions:p,baseURL:io(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=io(u),p.azureOpenAIApiVersion=io(d);var c={azureOptions:p};return n.baseURL&&(c.baseURL=io(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:io(i.apiKey)},baseURL:io(i.baseURL),serverless:!0},p=a.azureOptions.azureOpenAIApiKey;if("string"==typeof p&&ro.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:io(i.apiKey),azureOpenAIApiInstanceName:io(s),azureOpenAIApiDeploymentName:io(d),azureOpenAIApiVersion:io(c)},g=0,f=Object.values(m);g<f.length;g++){var x=f[g];if("string"==typeof x&&ro.test(x))throw new Error('Azure configuration environment variable "'.concat(x,'" was not found.'))}var h={azureOptions:m};return i.baseURL&&(h.baseURL=io(i.baseURL)),i.additionalHeaders&&(h.headers=i.additionalHeaders),h},exports.mbToBytes=ke,exports.megabyte=Le,exports.mergeFileConfig=function(e){var t=we;if(!e)return t;if(void 0!==e.serverFileSizeLimit&&(t.serverFileSizeLimit=ke(e.serverFileSizeLimit)),void 0!==e.avatarSizeLimit&&(t.avatarSizeLimit=ke(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=ke(n.fileSizeLimit)),void 0!==n.totalSizeLimit&&(r.totalSizeLimit=ke(n.totalSizeLimit));["fileLimit"].forEach((function(e){void 0!==n[e]&&(r[e]=n[e])})),n.supportedMimeTypes&&(r.supportedMimeTypes=Ge(n.supportedMimeTypes))};for(var n in e.endpoints)o(n);return t},exports.modelConfigSchema=rt,exports.modularEndpoints=Rt,exports.openAISchema=se,exports.openAISettings=U,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,S=dn(null===(r=z[Object.keys(z)[0]])||void 0===r?void 0:r.schema,e.components);T.properties.requestBody=S}if(v.parameters)for(var _=0,A=v.parameters;_<A.length;_++){var I=A[_];S=dn(g({},I.schema),e.components);T.properties[I.name]=S,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 ln(y,b,T);i.push(M);var C=new un(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=oo(),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=ao[o];if(!s&&!n)throw new Error("Unknown endpoint: ".concat(o));!s&&n&&(s=ao[n]);var a=s.parse(r),p=(null!=i?i:{}).models;return p&&a&&(a.model=null!==(t=so(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=to[n];if(!a&&!r)throw new Error("Unknown endpoint: ".concat(n));!a&&r&&(a=to[r]);var p=a.parse(i),l=null!=s?s:{},u=l.models,d=l.secondaryModels;return u&&p&&(p.model=null!==(t=so(u))&&void 0!==t?t:p.model),d&&p.agentOptions&&(p.agentOptions.model=null!==(o=so(d))&&void 0!==o?o:p.agentOptions.model),p},exports.parseTextParts=function(e){for(var t="",o=0,n=e;o<n.length;o++){var r=n[o];if(r.type===exports.ContentTypes.TEXT){var i=r.text.value;t.length>0&&i.length>0&&" "!==t[t.length-1]&&" "!==i[0]&&(t+=" "),t+=i}}return t},exports.promptPermissionsSchema=Io,exports.rateLimitSchema=St,exports.removeNullishValues=ce,exports.request=nn,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]=io(e[o])})),t},exports.resolveRef=dn,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.roleDefaults=Co,exports.roleSchema=Mo,exports.setAcceptLanguageHeader=function(e){u.defaults.headers.common["Accept-Language"]=e},exports.setTokenHeader=Po,exports.sha1=an,exports.specsConfigSchema=Be,exports.supportedMimeTypes=Pe,exports.supportsBalanceCheck=Nt,exports.supportsFiles=Te,exports.tAgentOptionsSchema=X,exports.tConversationSchema=te,exports.tConvoUpdateSchema=ne,exports.tExampleSchema=W,exports.tMessageSchema=J,exports.tModelSpecSchema=Ke,exports.tPluginAuthConfigSchema=Z,exports.tPluginSchema=Y,exports.tPresetSchema=oe,exports.tPresetUpdateSchema=re,exports.tSharedLinkSchema=ie,exports.textMimeTypes=Ie,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 S=z.$ref.split("/").pop();S&&!r[S]&&i.push("In context=('paths', '".concat(l,"', '").concat(f,"', '").concat(b,"', 'response', 'content', 'application/json', 'schema'), reference to unknown component ").concat(S,"; 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=at.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(no(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=co;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=te.shape[u.key];if(f){var x=f._def.typeName;(mo[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))&&wt.concat(n).some((function(e){return t.includes(e)}))))},exports.visionModels=wt;
|
|
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,T,b;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,(T=exports.TokenExchangeMethodEnum||(exports.TokenExchangeMethodEnum={})).DefaultPost="default_post",T.BasicAuthHeader="basic_auth_header",exports.FilePurpose=void 0,(b=exports.FilePurpose||(exports.FilePurpose={})).Vision="vision",b.FineTune="fine-tune",b.FineTuneResults="fine-tune-results",b.Assistants="assistants",b.AssistantsOutput="assistants_output";var z,S,_,A;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 P,L=function(e){return!!e&&e.toLowerCase().endsWith(exports.EModelEndpoint.assistants)};exports.ImageDetail=void 0,(P=exports.ImageDetail||(exports.ImageDetail={})).low="low",P.auto="auto",P.high="high";var k,R=((S={})[exports.ImageDetail.low]=0,S[exports.ImageDetail.auto]=1,S[exports.ImageDetail.high]=2,S),N={0:exports.ImageDetail.low,1:exports.ImageDetail.auto,2:exports.ImageDetail.high},w=l.z.nativeEnum(exports.ImageDetail),D=((_={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:[]}},_),U={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}},j={model:{default:"gemini-1.5-flash-latest"},maxOutputTokens:{min:1,max:8192,step:1,default:8192},temperature:{min:0,max:2,step:.01,default:1},topP:{min:0,max:1,step:.01,default:.95},topK:{min:1,max:40,step:.01,default:40}},G=8192,F=4096,K={model:{default:"claude-3-5-sonnet-20240620"},temperature:{min:0,max:1,step:.01,default:1},maxOutputTokens:{min:1,max:G,step:1,default:G,reset:function(e){return e.includes("claude-3-5-sonnet")?G:4096},set:function(e,t){return!t.includes("claude-3-5-sonnet")&&e>F?F:e}},topP:{min:0,max:1,step:.01,default:.7},topK:{min:1,max:40,step:1,default:5},resendFiles:{default:!0},maxContextTokens:{default:void 0},legacy:{maxOutputTokens:{min:1,max:F,step:1,default:F}}},B=((A={})[exports.EModelEndpoint.openAI]=U,A[exports.EModelEndpoint.google]=j,A[exports.EModelEndpoint.anthropic]=K,A),q=B[exports.EModelEndpoint.google],H=l.z.nativeEnum(exports.EModelEndpoint),V=l.z.union([H,l.z.string()]),Z=l.z.object({authField:l.z.string(),label:l.z.string(),description:l.z.string()}),Y=l.z.object({name:l.z.string(),pluginKey:l.z.string(),description:l.z.string(),icon:l.z.string(),authConfig:l.z.array(Z),authenticated:l.z.boolean().optional(),isButton:l.z.boolean().optional()}),W=l.z.object({input:l.z.object({content:l.z.string()}),output:l.z.object({content:l.z.string()})});exports.EAgent=void 0,(k=exports.EAgent||(exports.EAgent={})).functions="functions",k.classic="classic";var $={model:{default:"gpt-4o-mini"},temperature:{min:0,max:1,step:.01,default:0},agent:{default:exports.EAgent.functions,options:[exports.EAgent.functions,exports.EAgent.classic]},skipCompletion:{default:!0}},Q=l.z.nativeEnum(exports.EAgent),X=l.z.object({agent:l.z.string().default(exports.EAgent.functions),skipCompletion:l.z.boolean().default($.skipCompletion.default),model:l.z.string(),temperature:l.z.number().default($.temperature.default)}),J=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()}),ee=l.z.union([l.z.number(),l.z.string()]).transform((function(e){return"string"==typeof e?""===e.trim()?void 0:parseFloat(e):e})),te=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:H.nullable(),endpointType:H.optional(),suggestions:l.z.array(l.z.string()).optional(),messages:l.z.array(l.z.string()).optional(),tools:l.z.union([l.z.array(Y),l.z.array(l.z.string())]).optional(),createdAt:l.z.string(),updatedAt:l.z.string(),modelLabel:l.z.string().nullable().optional(),examples:l.z.array(W).optional(),tags:l.z.array(l.z.string()).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(),parentMessageId:l.z.string().optional(),maxOutputTokens:l.z.number().optional(),agentOptions:X.nullable().optional(),file_ids:l.z.array(l.z.string()).optional(),maxContextTokens:ee.optional(),max_tokens:ee.optional(),resendFiles:l.z.boolean().optional(),imageDetail:w.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(),systemMessage:l.z.string().nullable().optional(),jailbreak:l.z.boolean().optional(),jailbreakConversationId:l.z.string().nullable().optional(),conversationSignature:l.z.string().nullable().optional(),clientId:l.z.string().nullable().optional(),invocationId:l.z.number().nullable().optional(),toneStyle:l.z.string().nullable().optional(),resendImages:l.z.boolean().optional()}),oe=te.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:V.nullable()})),ne=te.merge(l.z.object({endpoint:V.nullable()})),re=te.merge(l.z.object({endpoint:V.nullable()})),ie=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()}),se=l.z.object({user:l.z.string(),tag:l.z.string(),description:l.z.string().optional(),createdAt:l.z.string(),updatedAt:l.z.string(),count:l.z.number(),position:l.z.number()}),ae=te.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:U.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:U.temperature.default,top_p:null!==(s=e.top_p)&&void 0!==s?s:U.top_p.default,presence_penalty:null!==(a=e.presence_penalty)&&void 0!==a?a:U.presence_penalty.default,frequency_penalty:null!==(p=e.frequency_penalty)&&void 0!==p?p:U.frequency_penalty.default,resendFiles:"boolean"==typeof e.resendFiles?e.resendFiles:U.resendFiles.default,imageDetail:null!==(l=e.imageDetail)&&void 0!==l?l:U.imageDetail.default,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:U.model.default,chatGptLabel:null,promptPrefix:null,temperature:U.temperature.default,top_p:U.top_p.default,presence_penalty:U.presence_penalty.default,frequency_penalty:U.frequency_penalty.default,resendFiles:U.resendFiles.default,imageDetail:U.imageDetail.default,stop:void 0,iconURL:void 0,greeting:void 0,spec:void 0,maxContextTokens:void 0,max_tokens:void 0}})),pe=te.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;return g(g({},e),{model:null!==(t=e.model)&&void 0!==t?t:q.model.default,modelLabel:null!==(o=e.modelLabel)&&void 0!==o?o:null,promptPrefix:null!==(n=e.promptPrefix)&&void 0!==n?n:null,examples:null!==(r=e.examples)&&void 0!==r?r:[{input:{content:""},output:{content:""}}],temperature:null!==(i=e.temperature)&&void 0!==i?i:q.temperature.default,maxOutputTokens:null!==(s=e.maxOutputTokens)&&void 0!==s?s:q.maxOutputTokens.default,topP:null!==(a=e.topP)&&void 0!==a?a:q.topP.default,topK:null!==(p=e.topK)&&void 0!==p?p:q.topK.default,iconURL:null!==(l=e.iconURL)&&void 0!==l?l:void 0,greeting:null!==(u=e.greeting)&&void 0!==u?u:void 0,spec:null!==(d=e.spec)&&void 0!==d?d:void 0,maxContextTokens:null!==(c=e.maxContextTokens)&&void 0!==c?c:void 0})})).catch((function(){return{model:q.model.default,modelLabel:null,promptPrefix:null,examples:[{input:{content:""},output:{content:""}}],temperature:q.temperature.default,maxOutputTokens:q.maxOutputTokens.default,topP:q.topP.default,topK:q.topK.default,iconURL:void 0,greeting:void 0,spec:void 0,maxContextTokens:void 0}})),le=te.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}})),ue=te.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,c=null!==(t=e.model)&&void 0!==t?t:K.model.default;return g(g({},e),{model:c,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:K.temperature.default,maxOutputTokens:null!==(i=e.maxOutputTokens)&&void 0!==i?i:K.maxOutputTokens.reset(c),topP:null!==(s=e.topP)&&void 0!==s?s:K.topP.default,topK:null!==(a=e.topK)&&void 0!==a?a:K.topK.default,resendFiles:"boolean"==typeof e.resendFiles?e.resendFiles:K.resendFiles.default,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:K.maxContextTokens.default})})).catch((function(){return{model:K.model.default,modelLabel:null,promptPrefix:null,temperature:K.temperature.default,maxOutputTokens:K.maxOutputTokens.default,topP:K.topP.default,topK:K.topK.default,resendFiles:K.resendFiles.default,iconURL:void 0,greeting:void 0,spec:void 0,maxContextTokens:K.maxContextTokens.default}})),de=te.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"}})),ce=te.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 me(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 ge,fe,xe=te.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:U.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:U.model.default,assistant_id:void 0,instructions:void 0,promptPrefix:null,iconURL:void 0,greeting:void 0,spec:void 0}})),he=te.pick({model:!0,assistant_id:!0,instructions:!0,promptPrefix:!0,iconURL:!0,greeting:!0,spec:!0}).transform(me).catch((function(){return{}})),ve=te.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,me(t)})).catch((function(){return{}})),Ee=te.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===q.temperature.default&&delete t.temperature,t.maxOutputTokens===q.maxOutputTokens.default&&delete t.maxOutputTokens,t.topP===q.topP.default&&delete t.topP,t.topK===q.topK.default&&delete t.topK,me(t)})).catch((function(){return{}})),ye=te.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 t.temperature===K.temperature.default&&delete t.temperature,t.maxOutputTokens===K.legacy.maxOutputTokens.default&&delete t.maxOutputTokens,t.topP===K.topP.default&&delete t.topP,t.topK===K.topK.default&&delete t.topK,t.resendFiles===K.resendFiles.default&&delete t.resendFiles,me(t)})).catch((function(){return{}})),Te=te.pick({model:!0}).transform((function(e){return me(g({},e))})).catch((function(){return{}})),be=te.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,me(o)})).catch((function(){return{}})),ze=((ge={})[exports.EModelEndpoint.openAI]=!0,ge[exports.EModelEndpoint.google]=!0,ge[exports.EModelEndpoint.assistants]=!0,ge[exports.EModelEndpoint.azureAssistants]=!0,ge[exports.EModelEndpoint.azureOpenAI]=!0,ge[exports.EModelEndpoint.anthropic]=!0,ge[exports.EModelEndpoint.custom]=!0,ge),Se=["application/vnd.ms-excel","application/msexcel","application/x-msexcel","application/x-ms-excel","application/x-excel","application/x-dos_ms_excel","application/xls","application/x-xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],_e=v(["text/x-c","text/x-c++","application/csv","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/html","text/x-java","application/json","text/markdown","application/pdf","text/x-php","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/x-python","text/x-script.python","text/x-ruby","text/x-tex","text/plain","text/css","image/jpeg","text/javascript","image/gif","image/png","application/x-tar","application/typescript","application/xml","application/zip"],Se,!0),Ae=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"],Se,!0),Ie=/^application\/(vnd\.ms-excel|msexcel|x-msexcel|x-ms-excel|x-excel|x-dos_ms_excel|xls|x-xls|vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet)$/,Me=/^(text\/(x-c|x-c\+\+|x-java|html|markdown|x-php|x-python|x-script\.python|x-ruby|x-tex|plain|css|javascript|csv))$/,Ce=/^(application\/(epub\+zip|csv|json|pdf|x-tar|typescript|vnd\.openxmlformats-officedocument\.(wordprocessingml\.document|presentationml\.presentation|spreadsheetml\.sheet)|xml|zip))$/,Oe=/^image\/(jpeg|gif|png|webp)$/,Pe=[Me,Ie,Ce,Oe],Le=[Me,Ie,Ce,Oe],ke=1048576,Re=function(e){return e*ke},Ne=Re(512),we={fileLimit:10,fileSizeLimit:Ne,totalSizeLimit:Ne,supportedMimeTypes:Pe,disabled:!1},De={endpoints:(fe={},fe[exports.EModelEndpoint.assistants]=we,fe[exports.EModelEndpoint.azureAssistants]=we,fe.default={fileLimit:10,fileSizeLimit:Ne,totalSizeLimit:Ne,supportedMimeTypes:Pe,disabled:!1},fe),serverFileSizeLimit:Ne,avatarSizeLimit:Re(2),checkType:function(e,t){return void 0===t&&(t=Pe),t.some((function(t){return t.test(e)}))}},Ue=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."}),je=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:Ue.optional()}),Ge=l.z.object({endpoints:l.z.record(je).optional(),serverFileSizeLimit:l.z.number().min(0).optional(),avatarSizeLimit:l.z.number().min(0).optional()}),Fe=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 Ke,Be=l.z.object({name:l.z.string(),label:l.z.string(),preset:oe,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(),H]).optional(),authType:O.optional()}),qe=l.z.object({enforce:l.z.boolean().default(!1),prioritize:l.z.boolean().default(!0),list:l.z.array(Be).optional()});exports.FileSources=void 0,(Ke=exports.FileSources||(exports.FileSources={})).local="local",Ke.firebase="firebase",Ke.azure="azure",Ke.openai="openai",Ke.s3="s3",Ke.vectordb="vectordb";var He,Ve,Ze,Ye,We,$e,Qe,Xe;exports.FileContext=void 0,(He=exports.FileContext||(exports.FileContext={})).avatar="avatar",He.unknown="unknown",He.assistants="assistants",He.image_generation="image_generation",He.assistants_output="assistants_output",He.message_attachment="message_attachment",He.filename="filename",He.updatedAt="updatedAt",He.source="source",He.context="context",He.bytes="bytes";var Je,et=["google","facebook","openid","github","discord"],tt=["gpt-4o","gpt-4o-2024-05-13","gpt-4o-2024-08-06","gpt-4o-mini","gpt-4o-mini-2024-07-18","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,(Je=exports.SettingsViews||(exports.SettingsViews={})).default="default",Je.advanced="advanced";var ot=l.z.nativeEnum(exports.FileSources);function nt(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 rt,it=l.z.object({deploymentName:l.z.string().optional(),version:l.z.string().optional(),assistants:l.z.boolean().optional()}).or(l.z.boolean()),st=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()}),at=l.z.object({group:l.z.string(),models:l.z.record(l.z.string(),it)}).required().and(st),pt=l.z.array(at).min(1);exports.Capabilities=void 0,(rt=exports.Capabilities||(exports.Capabilities={})).code_interpreter="code_interpreter",rt.image_vision="image_vision",rt.retrieval="retrieval",rt.actions="actions",rt.tools="tools";var lt,ut=((Ve={})[exports.EModelEndpoint.assistants]=2,Ve[exports.EModelEndpoint.azureAssistants]=1,Ve),dt=l.z.object({streamRate:l.z.number().optional()}),ct=dt.merge(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(),privateAssistants:l.z.boolean().optional(),retrievalModels:l.z.array(l.z.string()).min(1).optional().default(tt),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()})),mt=dt.merge(l.z.object({name:l.z.string().refine((function(e){return!H.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(),directEndpoint:l.z.boolean().optional(),titleMessageRole:l.z.string().optional()})),gt=l.z.object({groups:pt,plugins:l.z.boolean().optional(),assistants:l.z.boolean().optional()}).and(mt.pick({streamRate:!0,titleConvo:!0,titleMethod:!0,titleModel:!0,summarize:!0,summaryModel:!0,customOrder:!0}).partial()),ft=l.z.object({url:l.z.string().optional(),apiKey:l.z.string(),model:l.z.string(),voices:l.z.array(l.z.string())}),xt=l.z.object({instanceName:l.z.string(),apiKey:l.z.string(),deploymentName:l.z.string(),apiVersion:l.z.string(),model:l.z.string(),voices:l.z.array(l.z.string())}),ht=l.z.object({url:l.z.string().optional(),websocketUrl:l.z.string().optional(),apiKey:l.z.string(),model:l.z.string(),voices:l.z.array(l.z.string()),voice_settings:l.z.object({similarity_boost:l.z.number().optional(),stability:l.z.number().optional(),style:l.z.number().optional(),use_speaker_boost:l.z.boolean().optional()}).optional(),pronunciation_dictionary_locators:l.z.array(l.z.string()).optional()}),vt=l.z.object({url:l.z.string(),apiKey:l.z.string().optional(),voices:l.z.array(l.z.string()),backend:l.z.string()}),Et=l.z.object({openai:ft.optional(),azureOpenAI:xt.optional(),elevenlabs:ht.optional(),localai:vt.optional()}),yt=l.z.object({url:l.z.string().optional(),apiKey:l.z.string(),model:l.z.string()}),Tt=l.z.object({instanceName:l.z.string(),apiKey:l.z.string(),deploymentName:l.z.string(),apiVersion:l.z.string()}),bt=l.z.object({openai:yt.optional(),azureOpenAI:Tt.optional()}),zt=l.z.object({conversationMode:l.z.boolean().optional(),advancedMode:l.z.boolean().optional(),speechToText:l.z.boolean().optional().or(l.z.object({engineSTT:l.z.string().optional(),languageSTT:l.z.string().optional(),autoTranscribeAudio:l.z.boolean().optional(),decibelValue:l.z.number().optional(),autoSendText:l.z.number().optional()})).optional(),textToSpeech:l.z.boolean().optional().or(l.z.object({engineTTS:l.z.string().optional(),voice:l.z.string().optional(),languageTTS:l.z.string().optional(),automaticPlayback:l.z.boolean().optional(),playbackRate:l.z.number().optional(),cacheTTS:l.z.boolean().optional()})).optional()}).optional();exports.RateLimitPrefix=void 0,(lt=exports.RateLimitPrefix||(exports.RateLimitPrefix={})).FILE_UPLOAD="FILE_UPLOAD",lt.IMPORT="IMPORT",lt.TTS="TTS",lt.STT="STT";var St,_t=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(),tts:l.z.object({ipMax:l.z.number().optional(),ipWindowInMinutes:l.z.number().optional(),userMax:l.z.number().optional(),userWindowInMinutes:l.z.number().optional()}).optional(),stt: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,(St=exports.EImageOutputType||(exports.EImageOutputType={})).PNG="png",St.WEBP="webp",St.JPEG="jpeg";var At,It=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:ot.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:et}),speech:l.z.object({tts:Et.optional(),stt:bt.optional(),speechTab:zt.optional()}).optional(),rateLimits:_t.optional(),fileConfig:Ge.optional(),modelSpecs:qe.optional(),endpoints:l.z.object((Ze={all:dt.optional()},Ze[exports.EModelEndpoint.openAI]=dt.optional(),Ze[exports.EModelEndpoint.google]=dt.optional(),Ze[exports.EModelEndpoint.anthropic]=dt.optional(),Ze[exports.EModelEndpoint.gptPlugins]=dt.optional(),Ze[exports.EModelEndpoint.azureOpenAI]=gt.optional(),Ze[exports.EModelEndpoint.azureAssistants]=ct.optional(),Ze[exports.EModelEndpoint.assistants]=ct.optional(),Ze[exports.EModelEndpoint.custom]=l.z.array(mt.partial()).optional(),Ze)).strict().refine((function(e){return Object.keys(e).length>0}),{message:"At least one `endpoints` field must be provided."}).optional()});exports.KnownEndpoints=void 0,(At=exports.KnownEndpoints||(exports.KnownEndpoints={})).anyscale="anyscale",At.apipie="apipie",At.cohere="cohere",At.fireworks="fireworks",At.groq="groq",At.huggingface="huggingface",At.mistral="mistral",At.mlx="mlx",At.ollama="ollama",At.openrouter="openrouter",At.perplexity="perplexity",At.shuttleai="shuttleai",At["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],Ct=((Ye={})[exports.EModelEndpoint.openAI]="OpenAI",Ye[exports.EModelEndpoint.assistants]="Assistants",Ye[exports.EModelEndpoint.azureAssistants]="Azure Assistants",Ye[exports.EModelEndpoint.azureOpenAI]="Azure OpenAI",Ye[exports.EModelEndpoint.bingAI]="Bing",Ye[exports.EModelEndpoint.chatGPTBrowser]="ChatGPT",Ye[exports.EModelEndpoint.gptPlugins]="Plugins",Ye[exports.EModelEndpoint.google]="Google",Ye[exports.EModelEndpoint.anthropic]="Anthropic",Ye[exports.EModelEndpoint.custom]="Custom",Ye),Ot=["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"],Pt=((We={})[exports.EModelEndpoint.azureAssistants]=Ot,We[exports.EModelEndpoint.assistants]=v(["gpt-4o-mini","gpt-4o"],Ot,!0),We[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"],We[exports.EModelEndpoint.anthropic]=["claude-3-5-sonnet-20240620","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"],We[exports.EModelEndpoint.openAI]=v(v(["gpt-4o-mini","gpt-4o"],Ot,!0),["gpt-4-vision-preview","gpt-3.5-turbo-instruct-0914","gpt-3.5-turbo-instruct"],!1),We),Lt=Pt[exports.EModelEndpoint.openAI],kt=(($e={initial:[]})[exports.EModelEndpoint.openAI]=Lt,$e[exports.EModelEndpoint.assistants]=Lt.filter((function(e){return/gpt-4|gpt-3\\.5/i.test(e)&&!/vision|instruct/i.test(e)})),$e[exports.EModelEndpoint.gptPlugins]=Lt,$e[exports.EModelEndpoint.azureOpenAI]=Lt,$e[exports.EModelEndpoint.bingAI]=["BingAI","Sydney"],$e[exports.EModelEndpoint.chatGPTBrowser]=["text-davinci-002-render-sha"],$e[exports.EModelEndpoint.google]=Pt[exports.EModelEndpoint.google],$e[exports.EModelEndpoint.anthropic]=Pt[exports.EModelEndpoint.anthropic],$e),Rt=((Qe={})[exports.EModelEndpoint.openAI]="/api/ask/".concat(exports.EModelEndpoint.openAI),Qe[exports.EModelEndpoint.bingAI]="/api/ask/".concat(exports.EModelEndpoint.bingAI),Qe[exports.EModelEndpoint.google]="/api/ask/".concat(exports.EModelEndpoint.google),Qe[exports.EModelEndpoint.custom]="/api/ask/".concat(exports.EModelEndpoint.custom),Qe[exports.EModelEndpoint.anthropic]="/api/ask/".concat(exports.EModelEndpoint.anthropic),Qe[exports.EModelEndpoint.gptPlugins]="/api/ask/".concat(exports.EModelEndpoint.gptPlugins),Qe[exports.EModelEndpoint.azureOpenAI]="/api/ask/".concat(exports.EModelEndpoint.azureOpenAI),Qe[exports.EModelEndpoint.chatGPTBrowser]="/api/ask/".concat(exports.EModelEndpoint.chatGPTBrowser),Qe[exports.EModelEndpoint.azureAssistants]="/api/assistants/v1/chat",Qe[exports.EModelEndpoint.assistants]="/api/assistants/v2/chat",Qe),Nt=new Set([exports.EModelEndpoint.gptPlugins,exports.EModelEndpoint.anthropic,exports.EModelEndpoint.google,exports.EModelEndpoint.openAI,exports.EModelEndpoint.azureOpenAI,exports.EModelEndpoint.custom]),wt=((Xe={})[exports.EModelEndpoint.custom]=!0,Xe[exports.EModelEndpoint.openAI]=!0,Xe[exports.EModelEndpoint.anthropic]=!0,Xe[exports.EModelEndpoint.gptPlugins]=!0,Xe[exports.EModelEndpoint.assistants]=!0,Xe[exports.EModelEndpoint.azureAssistants]=!0,Xe[exports.EModelEndpoint.azureOpenAI]=!0,Xe),Dt=["gpt-4o","gpt-4o-mini","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 Ut,jt,Gt,Ft,Kt,Bt,qt,Ht,Vt,Zt,Yt,Wt,$t,Qt,Xt,Jt,eo,to=new Set(["dalle","dall-e","stable-diffusion"]);exports.InfiniteCollections=void 0,(Ut=exports.InfiniteCollections||(exports.InfiniteCollections={})).PROMPT_GROUPS="promptGroups",Ut.SHARED_LINKS="sharedLinks",exports.Time=void 0,(jt=exports.Time||(exports.Time={}))[jt.ONE_HOUR=36e5]="ONE_HOUR",jt[jt.THIRTY_MINUTES=18e5]="THIRTY_MINUTES",jt[jt.TEN_MINUTES=6e5]="TEN_MINUTES",jt[jt.FIVE_MINUTES=3e5]="FIVE_MINUTES",jt[jt.TWO_MINUTES=12e4]="TWO_MINUTES",jt[jt.ONE_MINUTE=6e4]="ONE_MINUTE",jt[jt.THIRTY_SECONDS=3e4]="THIRTY_SECONDS",exports.CacheKeys=void 0,(Gt=exports.CacheKeys||(exports.CacheKeys={})).CONFIG_STORE="configStore",Gt.ROLES="roles",Gt.PLUGINS="plugins",Gt.GEN_TITLE="genTitle",Gt.TOOLS="tools",Gt.MODELS_CONFIG="modelsConfig",Gt.MODEL_QUERIES="modelQueries",Gt.STARTUP_CONFIG="startupConfig",Gt.ENDPOINT_CONFIG="endpointsConfig",Gt.TOKEN_CONFIG="tokenConfig",Gt.CUSTOM_CONFIG="customConfig",Gt.ABORT_KEYS="abortKeys",Gt.OVERRIDE_CONFIG="overrideConfig",Gt.BANS="bans",Gt.ENCODED_DOMAINS="encoded_domains",Gt.AUDIO_RUNS="audioRuns",Gt.MESSAGES="messages",exports.ViolationTypes=void 0,(Ft=exports.ViolationTypes||(exports.ViolationTypes={})).FILE_UPLOAD_LIMIT="file_upload_limit",Ft.ILLEGAL_MODEL_REQUEST="illegal_model_request",Ft.TOKEN_BALANCE="token_balance",Ft.BAN="ban",Ft.TTS_LIMIT="tts_limit",Ft.STT_LIMIT="stt_limit",Ft.RESET_PASSWORD_LIMIT="reset_password_limit",Ft.VERIFY_EMAIL_LIMIT="verify_email_limit",Ft.CONVO_ACCESS="convo_access",exports.ErrorTypes=void 0,(Kt=exports.ErrorTypes||(exports.ErrorTypes={})).NO_USER_KEY="no_user_key",Kt.EXPIRED_USER_KEY="expired_user_key",Kt.INVALID_USER_KEY="invalid_user_key",Kt.NO_BASE_URL="no_base_url",Kt.MODERATION="moderation",exports.AuthKeys=void 0,(Bt=exports.AuthKeys||(exports.AuthKeys={})).GOOGLE_SERVICE_KEY="GOOGLE_SERVICE_KEY",Bt.GOOGLE_API_KEY="GOOGLE_API_KEY",exports.ImageDetailCost=void 0,(qt=exports.ImageDetailCost||(exports.ImageDetailCost={}))[qt.LOW=85]="LOW",qt[qt.HIGH=170]="HIGH",qt[qt.ADDITIONAL=85]="ADDITIONAL",exports.SettingsTabValues=void 0,(Ht=exports.SettingsTabValues||(exports.SettingsTabValues={})).GENERAL="general",Ht.CHAT="chat",Ht.SPEECH="speech",Ht.BETA="beta",Ht.DATA="data",Ht.ACCOUNT="account",Ht.COMMANDS="commands",exports.STTProviders=void 0,(Vt=exports.STTProviders||(exports.STTProviders={})).OPENAI="openai",Vt.AZURE_OPENAI="azureOpenAI",exports.TTSProviders=void 0,(Zt=exports.TTSProviders||(exports.TTSProviders={})).OPENAI="openai",Zt.AZURE_OPENAI="azureOpenAI",Zt.ELEVENLABS="elevenlabs",Zt.LOCALAI="localai",exports.Constants=void 0,(Yt=exports.Constants||(exports.Constants={})).VERSION="v0.7.4",Yt.CONFIG_VERSION="1.1.5",Yt.NO_PARENT="00000000-0000-0000-0000-000000000000",Yt.NEW_CONVO="new",Yt[Yt.ENCODED_DOMAIN_LENGTH=10]="ENCODED_DOMAIN_LENGTH",Yt.CURRENT_MODEL="current_model",Yt.COMMON_DIVIDER="__",Yt[Yt.COMMANDS_MAX_LENGTH=56]="COMMANDS_MAX_LENGTH",Yt[Yt.DEFAULT_STREAM_RATE=1]="DEFAULT_STREAM_RATE",Yt.SAVED_TAG="Saved",exports.LocalStorageKeys=void 0,(Wt=exports.LocalStorageKeys||(exports.LocalStorageKeys={})).APP_TITLE="appTitle",Wt.LAST_CONVO_SETUP="lastConversationSetup",Wt.LAST_BING="lastBingSettings",Wt.LAST_MODEL="lastSelectedModel",Wt.LAST_TOOLS="lastSelectedTools",Wt.LAST_SPEC="lastSelectedSpec",Wt.FILES_TO_DELETE="filesToDelete",Wt.ASST_ID_PREFIX="assistant_id__",Wt.FORK_SETTING="forkSetting",Wt.REMEMBER_FORK_OPTION="rememberForkOption",Wt.FORK_SPLIT_AT_TARGET="splitAtTarget",Wt.TEXT_DRAFT="textDraft_",Wt.FILES_DRAFT="filesDraft_",Wt.LAST_PROMPT_CATEGORY="lastPromptCategory",exports.ForkOptions=void 0,($t=exports.ForkOptions||(exports.ForkOptions={})).DIRECT_PATH="directPath",$t.INCLUDE_BRANCHES="includeBranches",$t.TARGET_LEVEL="",exports.CohereConstants=void 0,(Qt=exports.CohereConstants||(exports.CohereConstants={})).API_URL="https://api.cohere.ai/v1",Qt.ROLE_USER="USER",Qt.ROLE_SYSTEM="SYSTEM",Qt.ROLE_CHATBOT="CHATBOT",Qt.TITLE_MESSAGE="TITLE:",exports.SystemCategories=void 0,(Xt=exports.SystemCategories||(exports.SystemCategories={})).ALL="sys__all__sys",Xt.MY_PROMPTS="sys__my__prompts__sys",Xt.NO_CATEGORY="sys__no__category__sys",Xt.SHARED_PROMPTS="sys__shared__prompts__sys";var oo=((Jt={})[exports.EModelEndpoint.openAI]=ae,Jt[exports.EModelEndpoint.azureOpenAI]=ae,Jt[exports.EModelEndpoint.custom]=ae,Jt[exports.EModelEndpoint.google]=pe,Jt[exports.EModelEndpoint.bingAI]=le,Jt[exports.EModelEndpoint.anthropic]=ue,Jt[exports.EModelEndpoint.chatGPTBrowser]=de,Jt[exports.EModelEndpoint.gptPlugins]=ce,Jt[exports.EModelEndpoint.assistants]=xe,Jt[exports.EModelEndpoint.azureAssistants]=xe,Jt);function no(){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 ro(e){return e.map((function(e){var t=e.path.join("."),o=e.message;return"".concat(t,": ").concat(o)})).join(" ")}var io=/^\${(.+)}$/;function so(e){var t=e.match(io);return t&&process.env[t[1]]||e}function ao(e){for(var t,o=0,n=e;o<n.length;o++){var r=n[o];if(r){t=r;break}}return t}var po=((eo={})[exports.EModelEndpoint.openAI]=ve,eo[exports.EModelEndpoint.azureOpenAI]=ve,eo[exports.EModelEndpoint.custom]=ve,eo[exports.EModelEndpoint.assistants]=he,eo[exports.EModelEndpoint.azureAssistants]=he,eo[exports.EModelEndpoint.google]=Ee,eo[exports.EModelEndpoint.bingAI]=le,eo[exports.EModelEndpoint.anthropic]=ye,eo[exports.EModelEndpoint.chatGPTBrowser]=Te,eo[exports.EModelEndpoint.gptPlugins]=be,eo);var lo,uo,co;exports.ComponentTypes=void 0,(lo=exports.ComponentTypes||(exports.ComponentTypes={})).Input="input",lo.Textarea="textarea",lo.Slider="slider",lo.Checkbox="checkbox",lo.Switch="switch",lo.Dropdown="dropdown",lo.Tags="tags",exports.SettingTypes=void 0,(uo=exports.SettingTypes||(exports.SettingTypes={})).Number="number",uo.Boolean="boolean",uo.String="string",uo.Enum="enum",uo.Array="array",exports.OptionTypes=void 0,(co=exports.OptionTypes||(exports.OptionTypes={})).Conversation="conversation",co.Model="model",co.Custom="custom";var mo=["key","type","component"];var go={ZodString:"string",ZodNumber:"number",ZodBoolean:"boolean"};var fo,xo,ho,vo,Eo,yo,To,bo,zo,So,_o;exports.SystemRoles=void 0,(So=exports.SystemRoles||(exports.SystemRoles={})).ADMIN="ADMIN",So.USER="USER",exports.PermissionTypes=void 0,(exports.PermissionTypes||(exports.PermissionTypes={})).PROMPTS="PROMPTS",exports.Permissions=void 0,(_o=exports.Permissions||(exports.Permissions={})).SHARED_GLOBAL="SHARED_GLOBAL",_o.USE="USE",_o.CREATE="CREATE",_o.SHARE="SHARE";var Ao,Io,Mo=l.z.object(((fo={})[exports.Permissions.SHARED_GLOBAL]=l.z.boolean().default(!1),fo[exports.Permissions.USE]=l.z.boolean().default(!0),fo[exports.Permissions.CREATE]=l.z.boolean().default(!0),fo[exports.Permissions.SHARE]=l.z.boolean().default(!1),fo)),Co=l.z.object(((xo={name:l.z.string()})[exports.PermissionTypes.PROMPTS]=Mo,xo)),Oo=l.z.object(((ho={})[exports.SystemRoles.ADMIN]=Co.extend(((vo={name:l.z.literal(exports.SystemRoles.ADMIN)})[exports.PermissionTypes.PROMPTS]=Mo.extend(((Eo={})[exports.Permissions.SHARED_GLOBAL]=l.z.boolean().default(!0),Eo[exports.Permissions.USE]=l.z.boolean().default(!0),Eo[exports.Permissions.CREATE]=l.z.boolean().default(!0),Eo[exports.Permissions.SHARE]=l.z.boolean().default(!0),Eo)),vo)),ho[exports.SystemRoles.USER]=Co.extend(((yo={name:l.z.literal(exports.SystemRoles.USER)})[exports.PermissionTypes.PROMPTS]=Mo,yo)),ho)).parse(((To={})[exports.SystemRoles.ADMIN]=((bo={name:exports.SystemRoles.ADMIN})[exports.PermissionTypes.PROMPTS]={},bo),To[exports.SystemRoles.USER]=((zo={name:exports.SystemRoles.USER})[exports.PermissionTypes.PROMPTS]={},zo),To));function Po(e){u.defaults.headers.common.Authorization="Bearer "+e}exports.QueryKeys=void 0,(Ao=exports.QueryKeys||(exports.QueryKeys={})).messages="messages",Ao.sharedMessages="sharedMessages",Ao.sharedLinks="sharedLinks",Ao.allConversations="allConversations",Ao.archivedConversations="archivedConversations",Ao.searchConversations="searchConversations",Ao.conversation="conversation",Ao.searchEnabled="searchEnabled",Ao.user="user",Ao.name="name",Ao.models="models",Ao.balance="balance",Ao.endpoints="endpoints",Ao.presets="presets",Ao.searchResults="searchResults",Ao.tokenCount="tokenCount",Ao.availablePlugins="availablePlugins",Ao.startupConfig="startupConfig",Ao.assistants="assistants",Ao.assistant="assistant",Ao.endpointsConfigOverride="endpointsConfigOverride",Ao.files="files",Ao.fileConfig="fileConfig",Ao.tools="tools",Ao.actions="actions",Ao.assistantDocs="assistantDocs",Ao.fileDownload="fileDownload",Ao.voices="voices",Ao.customConfigSpeech="customConfigSpeech",Ao.prompts="prompts",Ao.prompt="prompt",Ao.promptGroups="promptGroups",Ao.allPromptGroups="allPromptGroups",Ao.promptGroup="promptGroup",Ao.categories="categories",Ao.randomPrompts="randomPrompts",Ao.roles="roles",Ao.conversationTags="conversationTags",Ao.health="health",exports.MutationKeys=void 0,(Io=exports.MutationKeys||(exports.MutationKeys={})).fileUpload="fileUpload",Io.fileDelete="fileDelete",Io.updatePreset="updatePreset",Io.deletePreset="deletePreset",Io.logoutUser="logoutUser",Io.avatarUpload="avatarUpload",Io.speechToText="speechToText",Io.textToSpeech="textToSpeech",Io.assistantAvatarUpload="assistantAvatarUpload",Io.updateAction="updateAction",Io.deleteAction="deleteAction",Io.deleteUser="deleteUser",Io.updateRole="updateRole";var Lo=function(e,t){return"/api/messages/".concat(e).concat(t?"/".concat(t):"")},ko="/api/share",Ro=function(e){return"".concat(ko,"/").concat(e)},No=ko,wo=ko,Do="/api/keys",Uo="/api/convos",jo=function(e,t,o){return"".concat(Uo,"?pageNumber=").concat(e).concat(t?"&isArchived=true":"").concat(null==o?void 0:o.map((function(e){return"&tags=".concat(e)})).join(""))},Go=function(){return"".concat(Uo,"/update")},Fo=function(){return"".concat(Uo,"/clear")},Ko=function(e,t){return"/api/search?q=".concat(e,"&pageNumber=").concat(t)},Bo=function(){return"/api/prompts"},qo=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},Ho=function(){return"".concat("/api/files","/images")},Vo=function(){return"".concat("/api/files","/speech")},Zo=function(){return"".concat(Vo(),"/tts")},Yo=function(e){return"".concat("/api/prompts","/groups/").concat(e)},Wo=function(e){return"".concat("/api/prompts","/").concat(e)},$o=Bo,Qo=Yo,Xo=Yo,Jo=function(e){return"/api/tags".concat(e?"/".concat(e):"")};function en(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 tn=!1,on=[],nn=function(e){return en(function(e){return"/api/auth/refresh".concat(e?"?retry=true":"")}(e))},rn=function(e,t){void 0===t&&(t=null),on.forEach((function(o){e?o.reject(e):o.resolve(t)})),on=[]};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,!tn)return[3,5];s.label=1;case 1:return s.trys.push([1,4,,5]),[4,new Promise((function(e,t){on.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:tn=!0,s.label=6;case 6:return s.trys.push([6,11,12,13]),[4,nn(!!(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,Po(n),window.dispatchEvent(new CustomEvent("tokenUpdated",{detail:n})),rn(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(),rn(r,null),[2,Promise.reject(r)];case 12:return tn=!1,[7];case 13:return[2,Promise.reject(e)]}}))}))}));var sn={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:en,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]}}))}))},postTTS: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"},responseType:"arraybuffer"}))];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:nn};var an=Object.freeze({__proto__:null,abortRequestWithMessage:function(e,t,o){return sn.post(function(e){return"/api/ask/".concat(e,"/abort")}(e),{arg:{abortKey:t,message:o}})},addTagToConversation:function(e,t){return sn.put(function(e){return"".concat(Uo,"/tags/").concat(e)}(e),t)},archiveConversation:function(e){return sn.post(Go(),{arg:e})},clearAllConversations:function(){return sn.post(Fo(),{arg:{}})},createAssistant:function(e){var t=e.version,o=f(e,["version"]);return sn.post(qo({version:t}),o)},createConversationTag:function(e){return sn.post(Jo(),e)},createPreset:function(e){return sn.post("/api/presets",e)},createPrompt:function(e){return sn.post($o(),e)},createSharedLink:function(e){return sn.post(No,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,sn.delete(qo({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 sn.delete(qo({path:t,options:{model:o,endpoint:n},version:r}))},deleteConversation:function(e){return sn.post(Fo(),{arg:e})},deleteConversationTag:function(e){return sn.delete(Jo(e))},deleteFiles:function(e,t,o){return x(void 0,void 0,void 0,(function(){return h(this,(function(n){return[2,sn.deleteWithOptions("/api/files",{data:{files:e,assistant_id:t,tool_resource:o}})]}))}))},deletePreset:function(e){return sn.post("/api/presets/delete",e)},deletePrompt:function(e){return sn.delete(function(e){var t=e._id,o=e.groupId;return"".concat("/api/prompts","/").concat(t,"?groupId=").concat(o)}(e))},deletePromptGroup:function(e){return sn.delete(Xo(e))},deleteSharedLink:function(e){return sn.delete(Ro(e))},deleteUser:function(){return sn.delete("/api/user/delete")},forkConversation:function(e){return sn.post("".concat(Uo,"/fork"),e)},genTitle:function(e){return sn.post("".concat(Uo,"/gen_title"),e)},getAIEndpoints:function(){return sn.get("/api/endpoints")},getActions:function(e){var t=e.endpoint,o=e.version;return sn.get(qo({path:"actions",version:o,endpoint:t}))},getAllPromptGroups:function(){return sn.get("".concat("/api/prompts","/all"))},getAssistantById:function(e){var t=e.endpoint,o=e.assistant_id,n=e.version;return sn.get(qo({path:o,endpoint:t,version:n}))},getAssistantDocs:function(e){var t=e.endpoint,o=e.version;return sn.get(qo({path:"documents",version:o,endpoint:t}))},getAvailablePlugins:function(){return sn.get("/api/plugins")},getAvailableTools:function(e,t){return sn.get(qo({path:"tools",endpoint:t,version:e}))},getCategories:function(){return sn.get("/api/categories")},getConversationById:function(e){return sn.get(function(e){return"".concat(Uo,"/").concat(e)}(e))},getConversationTags:function(){return sn.get(Jo())},getConversations:function(e){return sn.get(jo(e))},getCustomConfigSpeech:function(){return sn.get("".concat(Vo(),"/config/get"))},getEndpointsConfigOverride:function(){return sn.get("/api/endpoints/config/override")},getFileConfig:function(){return sn.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,sn.getResponse("".concat("/api/files","/download/").concat(e,"/").concat(t),{responseType:"blob",headers:{Accept:"application/octet-stream"}})]}))}))},getFiles:function(){return sn.get("/api/files")},getLoginGoogle:function(){return sn.get("/api/auth/google")},getMessagesByConvoId:function(e){return"new"===e?Promise.resolve([]):sn.get(Lo(e))},getModels:function(){return x(void 0,void 0,void 0,(function(){return h(this,(function(e){return[2,sn.get("/api/models")]}))}))},getPresets:function(){return sn.get("/api/presets")},getPrompt:function(e){return sn.get(Wo(e))},getPromptGroup:function(e){return sn.get(Yo(e))},getPromptGroups:function(e){return sn.get(function(e){var t="".concat("/api/prompts","/groups");if(Object.keys(e).length>0){var o=new URLSearchParams(e).toString();t+="?".concat(o)}return t}(e))},getPrompts:function(e){return sn.get(function(e){var t="/api/prompts";if(Object.keys(e).length>0){var o=new URLSearchParams(e).toString();t+="?".concat(o)}return t}(e))},getRandomPrompts:function(e){return sn.get((t=e.limit,o=e.skip,"".concat("/api/prompts","/random?limit=").concat(t,"&skip=").concat(o)));var t,o},getRole:function(e){return sn.get(function(e){return"".concat("/api/roles","/").concat(e.toLowerCase())}(e))},getSearchEnabled:function(){return sn.get("/api/search/enable")},getSharedLink:function(e){return sn.get(Ro(e))},getSharedMessages:function(e){return sn.get(Ro(e))},getStartupConfig:function(){return sn.get("/api/config")},getUser:function(){return sn.get("/api/user")},getUserBalance:function(){return sn.get("/api/balance")},getVoices:function(){return sn.get("".concat(Zo(),"/voices"))},healthCheck:function(){return sn.get("/health")},importConversationsFile:function(e){return sn.postMultiPart("".concat(Uo,"/import"),e)},listAssistants:function(e,t){return sn.get(qo({version:t,options:e}))},listConversations:function(e){var t=(null==e?void 0:e.pageNumber)||"1",o=(null==e?void 0:e.isArchived)||!1,n=(null==e?void 0:e.tags)||[];return sn.get(jo(t,o,n))},listConversationsByQuery:function(e){var t=(null==e?void 0:e.pageNumber)||"1",o=(null==e?void 0:e.searchQuery)||"";return""!==o?sn.get(Ko(o,t)):sn.get(jo(t))},listSharedLinks:function(e){var t=(null==e?void 0:e.pageNumber)||"1",o=(null==e?void 0:e.isPublic)||!0;return sn.get(function(e,t){return"".concat(ko,"?pageNumber=").concat(e,"&isPublic=").concat(t)}(t,o))},login:function(e){return sn.post("/api/auth/login",e)},logout:function(){return sn.post("/api/auth/logout")},makePromptProduction:function(e){return sn.patch("".concat(Wo(e),"/tags/production"))},rebuildConversationTags:function(){return sn.post(Jo("rebuild"))},register:function(e){return sn.post("/api/auth/register",e)},requestPasswordReset:function(e){return sn.post("/api/auth/requestPasswordReset",e)},resendVerificationEmail:function(e){return sn.post("/api/user/verify/resend",e)},resetPassword:function(e){return sn.post("/api/auth/resetPassword",e)},revokeAllUserKeys:function(){return sn.delete("".concat(Do,"?all=true"))},revokeUserKey:function(e){return sn.delete(function(e){return"".concat(Do,"/").concat(e)}(e))},searchConversations:function(e,t){return x(void 0,void 0,void 0,(function(){return h(this,(function(o){return[2,sn.get(Ko(e,t))]}))}))},speechToText:function(e){return sn.postMultiPart("".concat(Vo(),"/stt"),e)},textToSpeech:function(e){return sn.postTTS("".concat(Zo(),"/manual"),e)},updateAction:function(e){var t=e.assistant_id,o=e.version,n=f(e,["assistant_id","version"]);return sn.post(qo({path:"actions/".concat(t),version:o}),n)},updateAssistant:function(e){var t=e.assistant_id,o=e.data,n=e.version;return sn.patch(qo({path:t,version:n}),o)},updateConversation:function(e){return sn.post(Go(),{arg:e})},updateConversationTag:function(e,t){return sn.put(Jo(e),t)},updateMessage:function(e){var t=e.conversationId,o=e.messageId,n=e.text;if(!t)throw new Error("conversationId is required");return sn.put(Lo(t,o),{text:n})},updatePreset:function(e){return sn.post("/api/presets",e)},updatePromptGroup:function(e){return sn.patch(Qo(e.id),e.payload)},updatePromptLabels:function(e){return sn.patch((t=e.id,"".concat(Wo(t),"/labels")),e.payload);var t},updatePromptPermissions:function(e){return sn.put((t=e.roleName,"".concat("/api/roles","/").concat(t.toLowerCase(),"/prompts")),e.updates);var t},updateSharedLink:function(e){return sn.patch(wo,e)},updateTokenCount:function(e){return sn.post("/api/tokenizer",{arg:e})},updateUserKey:function(e){if(!e.value)throw new Error("value is required");return sn.put(Do,e)},updateUserPlugins:function(e){return sn.post("/api/user/plugins",e)},uploadAssistantAvatar:function(e){return sn.postMultiPart(qo({path:"avatar/".concat(e.assistant_id),options:{model:e.model,endpoint:e.endpoint},version:e.version}),e.formData)},uploadAvatar:function(e){return sn.postMultiPart("".concat(Ho(),"/avatar"),e)},uploadFile:function(e){return sn.postMultiPart("/api/files",e)},uploadImage:function(e){return sn.postMultiPart(Ho(),e)},userKeyQuery:function(e){return sn.get(function(e){return"".concat(Do,"?name=").concat(e)}(e))},verifyEmail:function(e){return sn.post("/api/user/verify",e)}}),pn=function(e,t){if(!(this instanceof pn))return new pn(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 sn.refreshToken();this.headers={"Content-Type":"application/json",Authorization:`Bearer ${e.token}`},Po(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 ln(e){return c.createHash("sha1").update(e).digest("hex")}function un(e,t){var o=e.replace(/\/$/,""),n=t.replace(/^\//,""),r="".concat(o,"/").concat(n);return new d.URL(r).toString()}var dn=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}(),cn=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){this.operationHash=ln(JSON.stringify(e)),this.params=e;for(var t=0,o=Object.entries(e);t<o.length;t++){var 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])}},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=un(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 mn(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 mn(r,t)}return e}exports.ActionRequest=cn,exports.EndpointURLs=Rt,exports.FunctionSignature=dn,exports.ImageVisionTool=D,exports.SSE=pn,exports.actionDelimiter="_action_",exports.actionDomainSeparator="---",exports.agentOptionSettings=$,exports.alternateName=Ct,exports.anthropicSchema=ue,exports.anthropicSettings=K,exports.applicationMimeTypes=Ce,exports.assistantEndpointSchema=ct,exports.assistantSchema=xe,exports.authTypeSchema=O,exports.azureBaseSchema=st,exports.azureEndpointSchema=gt,exports.azureGroupConfigsSchema=pt,exports.azureGroupSchema=at,exports.baseEndpointSchema=dt,exports.bingAISchema=le,exports.chatGPTBrowserSchema=de,exports.checkOpenAIStorage=function(e){return e===exports.FileSources.openai||e===exports.FileSources.azure},exports.codeInterpreterMimeTypes=Le,exports.codeInterpreterMimeTypesList=Ae,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=ee,exports.compactAnthropicSchema=ye,exports.compactAssistantSchema=he,exports.compactChatGPTSchema=Te,exports.compactGoogleSchema=Ee,exports.compactOpenAISchema=ve,exports.compactPluginsSchema=be,exports.configSchema=It,exports.conflictingAzureVariables=[{key:"INSTANCE_NAME"},{key:"DEPLOYMENT_NAME"}],exports.convertStringsToRegex=Fe,exports.createPayload=function(e){var t=e.conversation,o=e.userMessage,n=e.endpointOption,r=e.isEdited,i=e.isContinued,s=ne.parse(t).conversationId,a=n,p=a.endpoint,l=a.endpointType,u=Rt[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=un,exports.dataService=an,exports.defaultAssistantFormValues={assistant:"",id:"",name:"",description:"",instructions:"",model:"",functions:[],code_interpreter:!1,image_vision:!1,retrieval:!1},exports.defaultAssistantsVersion=ut,exports.defaultEndpoints=Mt,exports.defaultModels=Pt,exports.defaultOrderQuery={order:"desc",limit:100},exports.defaultRetrievalModels=tt,exports.defaultSocialLogins=et,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=Q,exports.eImageDetailSchema=w,exports.eModelEndpointSchema=H,exports.endpointFileConfigSchema=je,exports.endpointSchema=mt,exports.endpointSettings=B,exports.envVarRegex=io,exports.errorsToString=ro,exports.excelFileTypes=Se,exports.excelMimeTypes=Ie,exports.extendedModelEndpointSchema=V,exports.extractEnvVariable=so,exports.fileConfig=De,exports.fileConfigSchema=Ge,exports.fileSourceSchema=ot,exports.fullMimeTypesList=_e,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({},j),e);return te.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;return g(g({},e),{model:null!==(o=e.model)&&void 0!==o?o:t.model.default,modelLabel:null!==(n=e.modelLabel)&&void 0!==n?n:null,promptPrefix:null!==(r=e.promptPrefix)&&void 0!==r?r:null,examples:null!==(i=e.examples)&&void 0!==i?i:[{input:{content:""},output:{content:""}}],temperature:null!==(s=e.temperature)&&void 0!==s?s:t.temperature.default,maxOutputTokens:null!==(a=e.maxOutputTokens)&&void 0!==a?a:t.maxOutputTokens.default,topP:null!==(p=e.topP)&&void 0!==p?p:t.topP.default,topK:null!==(l=e.topK)&&void 0!==l?l:t.topK.default,maxContextTokens:null!==(u=e.maxContextTokens)&&void 0!==u?u: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({},U),e);return te.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 nt(It)},exports.getEnabledEndpoints=no,exports.getFirstDefinedValue=ao,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=Ct[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=nt,exports.googleSchema=pe,exports.googleSettings=j,exports.gptPluginsSchema=ce,exports.hostImageIdSuffix="_host_copy",exports.hostImageNamePrefix="host_copy_",exports.imageDetailNumeric=R,exports.imageDetailValue=N,exports.imageExtRegex=/\.(jpg|jpeg|png|gif|webp)$/i,exports.imageGenTools=to,exports.imageMimeTypes=Oe,exports.initialModelsConfig=kt,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:so(n.apiKey),azureOpenAIApiInstanceName:so(r)};if(n.serverless)return g({azureOptions:p,baseURL:so(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=so(u),p.azureOpenAIApiVersion=so(d);var c={azureOptions:p};return n.baseURL&&(c.baseURL=so(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:so(i.apiKey)},baseURL:so(i.baseURL),serverless:!0},p=a.azureOptions.azureOpenAIApiKey;if("string"==typeof p&&io.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:so(i.apiKey),azureOpenAIApiInstanceName:so(s),azureOpenAIApiDeploymentName:so(d),azureOpenAIApiVersion:so(c)},g=0,f=Object.values(m);g<f.length;g++){var x=f[g];if("string"==typeof x&&io.test(x))throw new Error('Azure configuration environment variable "'.concat(x,'" was not found.'))}var h={azureOptions:m};return i.baseURL&&(h.baseURL=so(i.baseURL)),i.additionalHeaders&&(h.headers=i.additionalHeaders),h},exports.mbToBytes=Re,exports.megabyte=ke,exports.mergeFileConfig=function(e){var t=De;if(!e)return t;if(void 0!==e.serverFileSizeLimit&&(t.serverFileSizeLimit=Re(e.serverFileSizeLimit)),void 0!==e.avatarSizeLimit&&(t.avatarSizeLimit=Re(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=Re(n.fileSizeLimit)),void 0!==n.totalSizeLimit&&(r.totalSizeLimit=Re(n.totalSizeLimit));["fileLimit"].forEach((function(e){void 0!==n[e]&&(r[e]=n[e])})),n.supportedMimeTypes&&(r.supportedMimeTypes=Fe(n.supportedMimeTypes))};for(var n in e.endpoints)o(n);return t},exports.modelConfigSchema=it,exports.modularEndpoints=Nt,exports.openAISchema=ae,exports.openAISettings=U,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,""),T=v.summary||v.description||"",b={type:"object",properties:{},required:[]};if(v.requestBody){var z=v.requestBody.content,S=mn(null===(r=z[Object.keys(z)[0]])||void 0===r?void 0:r.schema,e.components);b.properties.requestBody=S}if(v.parameters)for(var _=0,A=v.parameters;_<A.length;_++){var I=A[_];S=mn(g({},I.schema),e.components);b.properties[I.name]=S,I.required&&b.required.push(I.name),I.description&&!("$$ref"in b.properties[I.name])&&(b.properties[I.name].description=I.description)}var M=new dn(y,T,b);i.push(M);var C=new cn(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=no(),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=po[o];if(!s&&!n)throw new Error("Unknown endpoint: ".concat(o));!s&&n&&(s=po[n]);var a=s.parse(r),p=(null!=i?i:{}).models;return p&&a&&(a.model=null!==(t=ao(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=oo[n];if(!a&&!r)throw new Error("Unknown endpoint: ".concat(n));!a&&r&&(a=oo[r]);var p=a.parse(i),l=null!=s?s:{},u=l.models,d=l.secondaryModels;return u&&p&&(p.model=null!==(t=ao(u))&&void 0!==t?t:p.model),d&&p.agentOptions&&(p.agentOptions.model=null!==(o=ao(d))&&void 0!==o?o:p.agentOptions.model),p},exports.parseTextParts=function(e){for(var t="",o=0,n=e;o<n.length;o++){var r=n[o];if(r.type===exports.ContentTypes.TEXT){var i=r.text.value;t.length>0&&i.length>0&&" "!==t[t.length-1]&&" "!==i[0]&&(t+=" "),t+=i}}return t},exports.promptPermissionsSchema=Mo,exports.rateLimitSchema=_t,exports.removeNullishValues=me,exports.request=sn,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]=so(e[o])})),t},exports.resolveRef=mn,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.roleDefaults=Oo,exports.roleSchema=Co,exports.setAcceptLanguageHeader=function(e){u.defaults.headers.common["Accept-Language"]=e},exports.setTokenHeader=Po,exports.sha1=ln,exports.specsConfigSchema=qe,exports.supportedMimeTypes=Pe,exports.supportsBalanceCheck=wt,exports.supportsFiles=ze,exports.tAgentOptionsSchema=X,exports.tConversationSchema=te,exports.tConversationTagSchema=se,exports.tConvoUpdateSchema=ne,exports.tExampleSchema=W,exports.tMessageSchema=J,exports.tModelSpecSchema=Be,exports.tPluginAuthConfigSchema=Z,exports.tPluginSchema=Y,exports.tPresetSchema=oe,exports.tPresetUpdateSchema=re,exports.tSharedLinkSchema=ie,exports.textMimeTypes=Me,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],T=y[0],b=y[1].content;if(b&&b["application/json"]&&b["application/json"].schema){var z=b["application/json"].schema;if("$ref"in z&&"string"==typeof z.$ref){var S=z.$ref.split("/").pop();S&&!r[S]&&i.push("In context=('paths', '".concat(l,"', '").concat(f,"', '").concat(T,"', 'response', 'content', 'application/json', 'schema'), reference to unknown component ").concat(S,"; 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=pt.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,T=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 b in r[u]=g({apiKey:d,instanceName:c,deploymentName:m,version:x,baseURL:h,additionalHeaders:v,models:E,serverless:y},T),l.models){o.push(b);var z=l.models[b];if(n[b])return i.push('Duplicate model name detected: "'.concat(b,'". Model names must be unique across groups.')),{isValid:!1,modelNames:o,modelGroupMap:n,groupMap:r,errors:i};if(y)n[b]={group:u};else if("boolean"==typeof z){if(!l.deploymentName||!l.version)return i.push('Model "'.concat(b,'" in group "').concat(u,'" is missing a deploymentName or version.')),{isValid:!1,modelNames:o,modelGroupMap:n,groupMap:r,errors:i};n[b]={group:u}}else{if(!z.deploymentName&&!l.deploymentName||!z.version&&!l.version)return i.push('Model "'.concat(b,'" in group "').concat(u,'" is missing a required deploymentName or version.')),{isValid:!1,modelNames:o,modelGroupMap:n,groupMap:r,errors:i};n[b]={group:u}}}}else t=!1,i.push(ro(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=mo;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=te.shape[u.key];if(f){var x=f._def.typeName;(go[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))&&Dt.concat(n).some((function(e){return t.includes(e)}))))},exports.visionModels=Dt;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|