librechat-data-provider 0.3.8 → 0.3.9
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 +2 -0
- package/src/config.ts +19 -0
- package/src/data-service.ts +28 -0
- package/src/index.ts +1 -0
- package/src/keys.ts +1 -0
- package/src/react-query/react-query-service.ts +1 -75
- package/src/types/mutations.ts +8 -0
- package/src/types/queries.ts +34 -0
- package/src/types.ts +7 -6
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e,t,n,o=require("zod"),r=require("axios"),i=function(){return i=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},i.apply(this,arguments)};function a(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((o=o.apply(e,t||[])).next())}))}function s(e,t){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}"function"==typeof SuppressedError&&SuppressedError,exports.EModelEndpoint=void 0,(n=exports.EModelEndpoint||(exports.EModelEndpoint={})).azureOpenAI="azureOpenAI",n.openAI="openAI",n.bingAI="bingAI",n.chatGPTBrowser="chatGPTBrowser",n.google="google",n.gptPlugins="gptPlugins",n.anthropic="anthropic",n.assistant="assistant",n.custom="custom";var l,p=((e={})[exports.EModelEndpoint.google]={model:{default:"chat-bison"},maxOutputTokens:{min:1,max:2048,step:1,default:1024,maxGeminiPro:8192,defaultGeminiPro:8192},temperature:{min:0,max:1,step:.01,default:.2},topP:{min:0,max:1,step:.01,default:.8},topK:{min:1,max:40,step:.01,default:40}},e),u=p[exports.EModelEndpoint.google],d=o.z.nativeEnum(exports.EModelEndpoint),c=o.z.union([d,o.z.string()]);exports.ImageDetail=void 0,(l=exports.ImageDetail||(exports.ImageDetail={})).low="low",l.auto="auto",l.high="high";var h=((t={})[exports.ImageDetail.low]=0,t[exports.ImageDetail.auto]=1,t[exports.ImageDetail.high]=2,t),m={0:exports.ImageDetail.low,1:exports.ImageDetail.auto,2:exports.ImageDetail.high},g=o.z.nativeEnum(exports.ImageDetail),f=o.z.object({authField:o.z.string(),label:o.z.string(),description:o.z.string()}),v=o.z.object({name:o.z.string(),pluginKey:o.z.string(),description:o.z.string(),icon:o.z.string(),authConfig:o.z.array(f),authenticated:o.z.boolean().optional(),isButton:o.z.boolean().optional()}),x=o.z.object({input:o.z.object({content:o.z.string()}),output:o.z.object({content:o.z.string()})}),E=o.z.object({agent:o.z.string(),skipCompletion:o.z.boolean(),model:o.z.string(),temperature:o.z.number()}),b=o.z.object({messageId:o.z.string(),endpoint:o.z.string().optional(),clientId:o.z.string().nullable().optional(),conversationId:o.z.string().nullable(),parentMessageId:o.z.string().nullable(),responseMessageId:o.z.string().nullable().optional(),overrideParentMessageId:o.z.string().nullable().optional(),bg:o.z.string().nullable().optional(),model:o.z.string().nullable().optional(),title:o.z.string().nullable().or(o.z.literal("New Chat")).default("New Chat"),sender:o.z.string(),text:o.z.string(),generation:o.z.string().nullable().optional(),isEdited:o.z.boolean().optional(),isCreatedByUser:o.z.boolean(),error:o.z.boolean(),createdAt:o.z.string().optional().default((function(){return(new Date).toISOString()})),updatedAt:o.z.string().optional().default((function(){return(new Date).toISOString()})),current:o.z.boolean().optional(),unfinished:o.z.boolean().optional(),searchResult:o.z.boolean().optional(),finish_reason:o.z.string().optional()}),y=o.z.object({conversationId:o.z.string().nullable(),title:o.z.string().nullable().or(o.z.literal("New Chat")).default("New Chat"),user:o.z.string().optional(),endpoint:d.nullable(),endpointType:d.optional(),suggestions:o.z.array(o.z.string()).optional(),messages:o.z.array(o.z.string()).optional(),tools:o.z.array(v).optional(),createdAt:o.z.string(),updatedAt:o.z.string(),systemMessage:o.z.string().nullable().optional(),modelLabel:o.z.string().nullable().optional(),examples:o.z.array(x).optional(),chatGptLabel:o.z.string().nullable().optional(),userLabel:o.z.string().optional(),model:o.z.string().nullable().optional(),promptPrefix:o.z.string().nullable().optional(),temperature:o.z.number().optional(),topP:o.z.number().optional(),topK:o.z.number().optional(),context:o.z.string().nullable().optional(),top_p:o.z.number().optional(),frequency_penalty:o.z.number().optional(),presence_penalty:o.z.number().optional(),jailbreak:o.z.boolean().optional(),jailbreakConversationId:o.z.string().nullable().optional(),conversationSignature:o.z.string().nullable().optional(),parentMessageId:o.z.string().optional(),clientId:o.z.string().nullable().optional(),invocationId:o.z.number().nullable().optional(),toneStyle:o.z.string().nullable().optional(),maxOutputTokens:o.z.number().optional(),agentOptions:E.nullable().optional(),resendImages:o.z.boolean().optional(),imageDetail:g.optional(),assistant_id:o.z.string().optional(),thread_id:o.z.string().optional()}),z=y.omit({conversationId:!0,createdAt:!0,updatedAt:!0,title:!0}).merge(o.z.object({conversationId:o.z.string().nullable().optional(),presetId:o.z.string().nullable().optional(),title:o.z.string().nullable().optional(),defaultPreset:o.z.boolean().optional(),order:o.z.number().optional(),endpoint:c.nullable()})),I=y.merge(o.z.object({endpoint:c.nullable()})),P=y.merge(o.z.object({endpoint:c.nullable()})),M=y.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,resendImages:!0,imageDetail:!0}).transform((function(e){var t,n,o,r,a,s,l,p,u;return i(i({},e),{model:null!==(t=e.model)&&void 0!==t?t:"gpt-3.5-turbo",chatGptLabel:null!==(n=e.chatGptLabel)&&void 0!==n?n:null,promptPrefix:null!==(o=e.promptPrefix)&&void 0!==o?o:null,temperature:null!==(r=e.temperature)&&void 0!==r?r:1,top_p:null!==(a=e.top_p)&&void 0!==a?a:1,presence_penalty:null!==(s=e.presence_penalty)&&void 0!==s?s:0,frequency_penalty:null!==(l=e.frequency_penalty)&&void 0!==l?l:0,resendImages:null!==(p=e.resendImages)&&void 0!==p&&p,imageDetail:null!==(u=e.imageDetail)&&void 0!==u?u:exports.ImageDetail.auto})})).catch((function(){return{model:"gpt-3.5-turbo",chatGptLabel:null,promptPrefix:null,temperature:1,top_p:1,presence_penalty:0,frequency_penalty:0,resendImages:!1,imageDetail:exports.ImageDetail.auto}})),O=y.pick({model:!0,modelLabel:!0,promptPrefix:!0,examples:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0}).transform((function(e){var t,n,o,r,a,s,l,p,d,c,h=null===(n=null===(t=null==e?void 0:e.model)||void 0===t?void 0:t.toLowerCase())||void 0===n?void 0:n.includes("gemini-pro"),m=h?u.maxOutputTokens.maxGeminiPro:u.maxOutputTokens.max,g=h?u.maxOutputTokens.defaultGeminiPro:u.maxOutputTokens.default,f=null!==(o=e.maxOutputTokens)&&void 0!==o?o:g;return f=Math.min(f,m),i(i({},e),{model:null!==(r=e.model)&&void 0!==r?r:u.model.default,modelLabel:null!==(a=e.modelLabel)&&void 0!==a?a:null,promptPrefix:null!==(s=e.promptPrefix)&&void 0!==s?s:null,examples:null!==(l=e.examples)&&void 0!==l?l:[{input:{content:""},output:{content:""}}],temperature:null!==(p=e.temperature)&&void 0!==p?p:u.temperature.default,maxOutputTokens:f,topP:null!==(d=e.topP)&&void 0!==d?d:u.topP.default,topK:null!==(c=e.topK)&&void 0!==c?c:u.topK.default})})).catch((function(){return{model:u.model.default,modelLabel:null,promptPrefix:null,examples:[{input:{content:""},output:{content:""}}],temperature:u.temperature.default,maxOutputTokens:u.maxOutputTokens.default,topP:u.topP.default,topK:u.topK.default}})),k=y.pick({jailbreak:!0,systemMessage:!0,context:!0,toneStyle:!0,jailbreakConversationId:!0,conversationSignature:!0,clientId:!0,invocationId:!0}).transform((function(e){var t,n,o,r,a,s,l,p;return i(i({},e),{model:"",jailbreak:null!==(t=e.jailbreak)&&void 0!==t&&t,systemMessage:null!==(n=e.systemMessage)&&void 0!==n?n:null,context:null!==(o=e.context)&&void 0!==o?o:null,toneStyle:null!==(r=e.toneStyle)&&void 0!==r?r:"creative",jailbreakConversationId:null!==(a=e.jailbreakConversationId)&&void 0!==a?a:null,conversationSignature:null!==(s=e.conversationSignature)&&void 0!==s?s:null,clientId:null!==(l=e.clientId)&&void 0!==l?l: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}})),S=y.pick({model:!0,modelLabel:!0,promptPrefix:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0}).transform((function(e){var t,n,o,r,a,s,l;return i(i({},e),{model:null!==(t=e.model)&&void 0!==t?t:"claude-1",modelLabel:null!==(n=e.modelLabel)&&void 0!==n?n:null,promptPrefix:null!==(o=e.promptPrefix)&&void 0!==o?o:null,temperature:null!==(r=e.temperature)&&void 0!==r?r:1,maxOutputTokens:null!==(a=e.maxOutputTokens)&&void 0!==a?a:4e3,topP:null!==(s=e.topP)&&void 0!==s?s:.7,topK:null!==(l=e.topK)&&void 0!==l?l:5})})).catch((function(){return{model:"claude-1",modelLabel:null,promptPrefix:null,temperature:1,maxOutputTokens:4e3,topP:.7,topK:5}})),C=y.pick({model:!0}).transform((function(e){var t;return i(i({},e),{model:null!==(t=e.model)&&void 0!==t?t:"text-davinci-002-render-sha"})})).catch((function(){return{model:"text-davinci-002-render-sha"}})),_=y.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,tools:!0,agentOptions:!0}).transform((function(e){var t,n,o,r,a,s,l,p,u;return i(i({},e),{model:null!==(t=e.model)&&void 0!==t?t:"gpt-3.5-turbo",chatGptLabel:null!==(n=e.chatGptLabel)&&void 0!==n?n:null,promptPrefix:null!==(o=e.promptPrefix)&&void 0!==o?o:null,temperature:null!==(r=e.temperature)&&void 0!==r?r:.8,top_p:null!==(a=e.top_p)&&void 0!==a?a:1,presence_penalty:null!==(s=e.presence_penalty)&&void 0!==s?s:0,frequency_penalty:null!==(l=e.frequency_penalty)&&void 0!==l?l:0,tools:null!==(p=e.tools)&&void 0!==p?p:[],agentOptions:null!==(u=e.agentOptions)&&void 0!==u?u:{agent:"functions",skipCompletion:!0,model:"gpt-3.5-turbo",temperature:0}})})).catch((function(){return{model:"gpt-3.5-turbo",chatGptLabel:null,promptPrefix:null,temperature:.8,top_p:1,presence_penalty:0,frequency_penalty:0,tools:[],agentOptions:{agent:"functions",skipCompletion:!0,model:"gpt-3.5-turbo",temperature:0}}}));function A(e){var t=i({},e);return Object.keys(t).forEach((function(e){void 0!==t[e]&&null!==t[e]&&""!==t[e]||delete t[e]})),t}var w,T,L,G,D,K,j=y.pick({model:!0,assistant_id:!0,thread_id:!0}).transform(A).catch((function(){return{}})),N=y.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,resendImages:!0,imageDetail:!0}).transform((function(e){var t=i({},e);return"gpt-3.5-turbo"===t.model&&delete t.model,1===t.temperature&&delete t.temperature,1===t.top_p&&delete t.top_p,0===t.presence_penalty&&delete t.presence_penalty,0===t.frequency_penalty&&delete t.frequency_penalty,!0!==t.resendImages&&delete t.resendImages,t.imageDetail===exports.ImageDetail.auto&&delete t.imageDetail,A(t)})).catch((function(){return{}})),R=y.pick({model:!0,modelLabel:!0,promptPrefix:!0,examples:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0}).transform((function(e){var t=i({},e);return t.model===u.model.default&&delete t.model,t.temperature===u.temperature.default&&delete t.temperature,t.maxOutputTokens===u.maxOutputTokens.default&&delete t.maxOutputTokens,t.topP===u.topP.default&&delete t.topP,t.topK===u.topK.default&&delete t.topK,A(t)})).catch((function(){return{}})),q=y.pick({model:!0,modelLabel:!0,promptPrefix:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0}).transform((function(e){var t=i({},e);return"claude-1"===t.model&&delete t.model,1===t.temperature&&delete t.temperature,4e3===t.maxOutputTokens&&delete t.maxOutputTokens,.7===t.topP&&delete t.topP,5===t.topK&&delete t.topK,A(t)})).catch((function(){return{}})),B=y.pick({model:!0}).transform((function(e){var t=i({},e);return"text-davinci-002-render-sha"===t.model&&delete t.model,A(t)})).catch((function(){return{}})),U=y.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,tools:!0,agentOptions:!0}).transform((function(e){var t,n=i({},e);return"gpt-3.5-turbo"===n.model&&delete n.model,null===n.chatGptLabel&&delete n.chatGptLabel,null===n.promptPrefix&&delete n.promptPrefix,.8===n.temperature&&delete n.temperature,1===n.top_p&&delete n.top_p,0===n.presence_penalty&&delete n.presence_penalty,0===n.frequency_penalty&&delete n.frequency_penalty,0===(null===(t=n.tools)||void 0===t?void 0:t.length)&&delete n.tools,n.agentOptions&&"functions"===n.agentOptions.agent&&!0===n.agentOptions.skipCompletion&&"gpt-3.5-turbo"===n.agentOptions.model&&0===n.agentOptions.temperature&&delete n.agentOptions,A(n)})).catch((function(){return{}}));exports.FileSources=void 0,(w=exports.FileSources||(exports.FileSources={})).local="local",w.firebase="firebase",w.openai="openai",w.s3="s3";var F,V=o.z.nativeEnum(exports.FileSources),H=o.z.object({name:o.z.string().refine((function(e){return!d.safeParse(e).success}),{message:"Value cannot be one of the default endpoint (EModelEndpoint) values: ".concat(Object.values(exports.EModelEndpoint).join(", "))}),apiKey:o.z.string(),baseURL:o.z.string(),models:o.z.object({default:o.z.array(o.z.string()).min(1),fetch:o.z.boolean().optional()}),titleConvo:o.z.boolean().optional(),titleMethod:o.z.union([o.z.literal("completion"),o.z.literal("functions")]).optional(),titleModel:o.z.string().optional(),summarize:o.z.boolean().optional(),summaryModel:o.z.string().optional(),forcePrompt:o.z.boolean().optional(),modelDisplayLabel:o.z.string().optional(),headers:o.z.record(o.z.any()).optional()}),W=o.z.object({version:o.z.string(),cache:o.z.boolean(),fileStrategy:V.optional(),endpoints:o.z.object({custom:o.z.array(H.partial())}).strict()});exports.KnownEndpoints=void 0,(F=exports.KnownEndpoints||(exports.KnownEndpoints={})).mistral="mistral",F.openrouter="openrouter";var Q,Y,J,X,Z,$=[exports.EModelEndpoint.openAI,exports.EModelEndpoint.assistant,exports.EModelEndpoint.azureOpenAI,exports.EModelEndpoint.bingAI,exports.EModelEndpoint.chatGPTBrowser,exports.EModelEndpoint.gptPlugins,exports.EModelEndpoint.google,exports.EModelEndpoint.anthropic,exports.EModelEndpoint.custom],ee=((T={})[exports.EModelEndpoint.openAI]="OpenAI",T[exports.EModelEndpoint.assistant]="Assistants",T[exports.EModelEndpoint.azureOpenAI]="Azure OpenAI",T[exports.EModelEndpoint.bingAI]="Bing",T[exports.EModelEndpoint.chatGPTBrowser]="ChatGPT",T[exports.EModelEndpoint.gptPlugins]="Plugins",T[exports.EModelEndpoint.google]="Google",T[exports.EModelEndpoint.anthropic]="Anthropic",T[exports.EModelEndpoint.custom]="Custom",T),te=((L={})[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"],L[exports.EModelEndpoint.anthropic]=["claude-2.1","claude-2","claude-1.2","claude-1","claude-1-100k","claude-instant-1","claude-instant-1-100k"],L[exports.EModelEndpoint.openAI]=["gpt-3.5-turbo-16k-0613","gpt-3.5-turbo-16k","gpt-4-1106-preview","gpt-3.5-turbo","gpt-3.5-turbo-1106","gpt-4-vision-preview","gpt-4","gpt-3.5-turbo-instruct-0914","gpt-3.5-turbo-0613","gpt-3.5-turbo-0301","gpt-3.5-turbo-instruct","gpt-4-0613","text-davinci-003","gpt-4-0314"],L),ne=((G={})[exports.EModelEndpoint.openAI]="/api/ask/".concat(exports.EModelEndpoint.openAI),G[exports.EModelEndpoint.bingAI]="/api/ask/".concat(exports.EModelEndpoint.bingAI),G[exports.EModelEndpoint.google]="/api/ask/".concat(exports.EModelEndpoint.google),G[exports.EModelEndpoint.custom]="/api/ask/".concat(exports.EModelEndpoint.custom),G[exports.EModelEndpoint.anthropic]="/api/ask/".concat(exports.EModelEndpoint.anthropic),G[exports.EModelEndpoint.gptPlugins]="/api/ask/".concat(exports.EModelEndpoint.gptPlugins),G[exports.EModelEndpoint.azureOpenAI]="/api/ask/".concat(exports.EModelEndpoint.azureOpenAI),G[exports.EModelEndpoint.chatGPTBrowser]="/api/ask/".concat(exports.EModelEndpoint.chatGPTBrowser),G[exports.EModelEndpoint.assistant]="/api/assistants/chat",G),oe=new Set([exports.EModelEndpoint.gptPlugins,exports.EModelEndpoint.anthropic,exports.EModelEndpoint.google,exports.EModelEndpoint.openAI,exports.EModelEndpoint.azureOpenAI,exports.EModelEndpoint.custom]),re=((D={})[exports.EModelEndpoint.openAI]=!0,D[exports.EModelEndpoint.google]=!0,D[exports.EModelEndpoint.assistant]=!0,D[exports.EModelEndpoint.azureOpenAI]=!0,D[exports.EModelEndpoint.custom]=!0,D),ie=((K={})[exports.EModelEndpoint.openAI]=!0,K[exports.EModelEndpoint.azureOpenAI]=!0,K[exports.EModelEndpoint.gptPlugins]=!0,K[exports.EModelEndpoint.custom]=!0,K);exports.CacheKeys=void 0,(Q=exports.CacheKeys||(exports.CacheKeys={})).CONFIG_STORE="configStore",Q.PLUGINS="plugins",Q.MODELS_CONFIG="modelsConfig",Q.ENDPOINT_CONFIG="endpointsConfig",Q.CUSTOM_CONFIG="customConfig",Q.OVERRIDE_CONFIG="overrideConfig",exports.AuthKeys=void 0,(Y=exports.AuthKeys||(exports.AuthKeys={})).GOOGLE_SERVICE_KEY="GOOGLE_SERVICE_KEY",Y.GOOGLE_API_KEY="GOOGLE_API_KEY",exports.ImageDetailCost=void 0,(J=exports.ImageDetailCost||(exports.ImageDetailCost={}))[J.LOW=85]="LOW",J[J.HIGH=170]="HIGH",J[J.ADDITIONAL=85]="ADDITIONAL",exports.SettingsTabValues=void 0,(X=exports.SettingsTabValues||(exports.SettingsTabValues={})).GENERAL="general",X.BETA="beta",X.DATA="data",X.ACCOUNT="account";var ae=((Z={})[exports.EModelEndpoint.openAI]=M,Z[exports.EModelEndpoint.azureOpenAI]=M,Z[exports.EModelEndpoint.custom]=M,Z[exports.EModelEndpoint.google]=O,Z[exports.EModelEndpoint.bingAI]=k,Z[exports.EModelEndpoint.anthropic]=S,Z[exports.EModelEndpoint.chatGPTBrowser]=C,Z[exports.EModelEndpoint.gptPlugins]=_,Z[exports.EModelEndpoint.assistant]=j,Z);function se(e){for(var t,n=0,o=e;n<o.length;n++){var r=o[n];if(r){t=r;break}}return t}var le,pe,ue,de={openAI:N,azureOpenAI:N,custom:N,assistant:j,google:R,bingAI:k,anthropic:q,chatGPTBrowser:B,gptPlugins:U};function ce(e){r.defaults.headers.common.Authorization="Bearer "+e}exports.Tools=void 0,(le=exports.Tools||(exports.Tools={})).code_interpreter="code_interpreter",le.retrieval="retrieval",le.function="function",exports.QueryKeys=void 0,(pe=exports.QueryKeys||(exports.QueryKeys={})).messages="messages",pe.allConversations="allConversations",pe.conversation="conversation",pe.searchEnabled="searchEnabled",pe.user="user",pe.name="name",pe.models="models",pe.balance="balance",pe.endpoints="endpoints",pe.presets="presets",pe.searchResults="searchResults",pe.tokenCount="tokenCount",pe.availablePlugins="availablePlugins",pe.startupConfig="startupConfig",pe.assistants="assistants",pe.assistant="assistant",pe.endpointsConfigOverride="endpointsConfigOverride",pe.files="files",exports.MutationKeys=void 0,(ue=exports.MutationKeys||(exports.MutationKeys={})).imageUpload="imageUpload",ue.fileDelete="fileDelete",ue.updatePreset="updatePreset",ue.deletePreset="deletePreset",ue.logoutUser="logoutUser",ue.avatarUpload="avatarUpload";var he=function(e,t){return"/api/messages/".concat(e).concat(t?"/".concat(t):"")},me="/api/keys",ge=function(e,t){return"/api/search?q=".concat(e,"&pageNumber=").concat(t)},fe=function(e){return"/api/assistants".concat(e?"/".concat(e):"")},ve=function(){return"".concat("/api/files","/images")};function xe(e,t){return a(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,r.post(e,JSON.stringify(t),{headers:{"Content-Type":"application/json"}})];case 1:return[2,n.sent().data]}}))}))}var Ee=!1,be=[],ye=function(e){return xe(function(e){return"/api/auth/refresh".concat(e?"?retry=true":"")}(e))},ze=function(e,t){void 0===t&&(t=null),be.forEach((function(n){e?n.reject(e):n.resolve(t)})),be=[]};r.interceptors.response.use((function(e){return e}),(function(e){return a(void 0,void 0,void 0,(function(){var t,n,o,i,a;return s(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,!Ee)return[3,5];s.label=1;case 1:return s.trys.push([1,4,,5]),[4,new Promise((function(e,t){be.push({resolve:e,reject:t})}))];case 2:return o=s.sent(),t.headers.Authorization="Bearer "+o,[4,r(t)];case 3:return[2,s.sent()];case 4:return n=s.sent(),[2,Promise.reject(n)];case 5:Ee=!0,s.label=6;case 6:return s.trys.push([6,11,12,13]),[4,ye(!!(null===(a=t.url)||void 0===a?void 0:a.includes("api/auth/refresh")))];case 7:return(o=s.sent().token)?(t.headers.Authorization="Bearer "+o,ce(o),window.dispatchEvent(new CustomEvent("tokenUpdated",{detail:o})),ze(null,o),[4,r(t)]):[3,9];case 8:return[2,s.sent()];case 9:window.location.href="/login",s.label=10;case 10:return[3,13];case 11:return i=s.sent(),ze(i,null),[2,Promise.reject(i)];case 12:return Ee=!1,[7];case 13:return[2,Promise.reject(e)]}}))}))}));var Ie={get:function(e,t){return a(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,r.get(e,i({},t))];case 1:return[2,n.sent().data]}}))}))},post:xe,postMultiPart:function(e,t,n){return a(this,void 0,void 0,(function(){return s(this,(function(o){switch(o.label){case 0:return[4,r.post(e,t,i(i({},n),{headers:{"Content-Type":"multipart/form-data"}}))];case 1:return[2,o.sent().data]}}))}))},put:function(e,t){return a(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,r.put(e,JSON.stringify(t),{headers:{"Content-Type":"application/json"}})];case 1:return[2,n.sent().data]}}))}))},delete:function(e){return a(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,r.delete(e)];case 1:return[2,t.sent().data]}}))}))},deleteWithOptions:function(e,t){return a(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,r.delete(e,i({},t))];case 1:return[2,n.sent().data]}}))}))},patch:function(e,t){return a(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,r.patch(e,JSON.stringify(t),{headers:{"Content-Type":"application/json"}})];case 1:return[2,n.sent().data]}}))}))},refreshToken:ye};var Pe=Object.freeze({__proto__:null,abortRequestWithMessage:function(e,t,n){return Ie.post(function(e){return"/api/ask/".concat(e,"/abort")}(e),{arg:{abortKey:t,message:n}})},clearAllConversations:function(){return Ie.post("/api/convos/clear",{arg:{}})},createAssistant:function(e){return Ie.post(fe(),e)},createPreset:function(e){return Ie.post("/api/presets",e)},deleteAssistant:function(e){return Ie.delete(fe(e))},deleteConversation:function(e){return Ie.post("/api/convos/clear",{arg:e})},deleteFiles:function(e){return a(void 0,void 0,void 0,(function(){return s(this,(function(t){return[2,Ie.deleteWithOptions("/api/files",{data:{files:e}})]}))}))},deletePreset:function(e){return Ie.post("/api/presets/delete",e)},getAIEndpoints:function(){return Ie.get("/api/endpoints")},getAssistantById:function(e){return Ie.get(fe(e))},getAvailablePlugins:function(){return Ie.get("/api/plugins")},getConversationById:function(e){return Ie.get(function(e){return"/api/convos/".concat(e)}(e))},getConversations:function(e){return Ie.get(function(e){return"/api/convos?pageNumber=".concat(e)}(e))},getEndpointsConfigOverride:function(){return Ie.get("/api/endpoints/config/override")},getFiles:function(){return Ie.get("/api/files")},getLoginGoogle:function(){return Ie.get("/api/auth/google")},getMessagesByConvoId:function(e){return"new"===e?Promise.resolve([]):Ie.get(he(e))},getModels:function(){return a(void 0,void 0,void 0,(function(){return s(this,(function(e){return[2,Ie.get("/api/models")]}))}))},getPresets:function(){return Ie.get("/api/presets")},getSearchEnabled:function(){return Ie.get("/api/search/enable")},getStartupConfig:function(){return Ie.get("/api/config")},getUser:function(){return Ie.get("/api/user")},getUserBalance:function(){return Ie.get("/api/balance")},listAssistants:function(e){return Ie.get(fe(),{params:e})},login:function(e){return Ie.post("/api/auth/login",e)},logout:function(){return Ie.post("/api/auth/logout")},register:function(e){return Ie.post("/api/auth/register",e)},requestPasswordReset:function(e){return Ie.post("/api/auth/requestPasswordReset",e)},resetPassword:function(e){return Ie.post("/api/auth/resetPassword",e)},revokeAllUserKeys:function(){return Ie.delete("".concat(me,"?all=true"))},revokeUserKey:function(e){return Ie.delete(function(e){return"".concat(me,"/").concat(e)}(e))},searchConversations:function(e,t){return a(void 0,void 0,void 0,(function(){return s(this,(function(n){return[2,Ie.get(ge(e,t))]}))}))},updateAssistant:function(e,t){return Ie.patch(fe(e),t)},updateConversation:function(e){return Ie.post("/api/convos/update",{arg:e})},updateMessage:function(e){var t=e.conversationId,n=e.messageId,o=e.text;if(!t)throw new Error("conversationId is required");return Ie.put(he(t,n),{text:o})},updatePreset:function(e){return Ie.post("/api/presets",e)},updateTokenCount:function(e){return Ie.post("/api/tokenizer",{arg:e})},updateUserKey:function(e){if(!e.value)throw new Error("value is required");return Ie.put(me,e)},updateUserPlugins:function(e){return Ie.post("/api/user/plugins",e)},uploadAvatar:function(e){return Ie.postMultiPart("".concat(ve(),"/avatar"),e)},uploadImage:function(e){return Ie.postMultiPart(ve(),e)},userKeyQuery:function(e){return Ie.get(function(e){return"".concat(me,"?name=").concat(e)}(e))}}),Me=function(e,t){if(!(this instanceof Me))return new Me(e,t);this.INITIALIZING=-1,this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,this.url=e,t=t||{},this.headers=t.headers||{},this.payload=void 0!==t.payload?t.payload:"",this.method=t.method||this.payload&&"POST"||"GET",this.withCredentials=!!t.withCredentials,this.FIELD_SEPARATOR=":",this.listeners={},this.xhr=null,this.readyState=this.INITIALIZING,this.progress=0,this.chunk="",this.addEventListener=function(e,t){void 0===this.listeners[e]&&(this.listeners[e]=[]),-1===this.listeners[e].indexOf(t)&&this.listeners[e].push(t)},this.removeEventListener=function(e,t){if(void 0!==this.listeners[e]){var n=[];this.listeners[e].forEach((function(e){e!==t&&n.push(e)})),0===n.length?delete this.listeners[e]:this.listeners[e]=n}},this.dispatchEvent=function(e){if(!e)return!0;e.source=this;var t="on"+e.type;return(!this.hasOwnProperty(t)||(this[t].call(this,e),!e.defaultPrevented))&&(!this.listeners[e.type]||this.listeners[e.type].every((function(t){return t(e),!e.defaultPrevented})))},this._setReadyState=function(e){var t=new CustomEvent("readystatechange");t.readyState=e,this.readyState=e,this.dispatchEvent(t)},this._onStreamFailure=function(e){var t=new CustomEvent("error");t.data=e.currentTarget.response,this.dispatchEvent(t),this.close()},this._onStreamAbort=function(e){this.dispatchEvent(new CustomEvent("abort")),this.close()},this._onStreamProgress=async function(e){if(this.xhr){if(401!==this.xhr.status||this._retry){if(200!==this.xhr.status)return void this._onStreamFailure(e)}else{this._retry=!0;try{const e=await Ie.refreshToken();this.headers={"Content-Type":"application/json",Authorization:`Bearer ${e.token}`},ce(e.token),window.dispatchEvent(new CustomEvent("tokenUpdated",{detail:e.token})),this.stream()}catch(t){return void this._onStreamFailure(e)}}this.readyState==this.CONNECTING&&(this.dispatchEvent(new CustomEvent("open")),this._setReadyState(this.OPEN));var t=this.xhr.responseText.substring(this.progress);this.progress+=t.length,t.split(/(\r\n|\r|\n){2}/g).forEach(function(e){0===e.trim().length?(this.dispatchEvent(this._parseEventChunk(this.chunk.trim())),this.chunk=""):this.chunk+=e}.bind(this))}},this._onStreamLoaded=function(e){this._onStreamProgress(e),this.dispatchEvent(this._parseEventChunk(this.chunk)),this.chunk=""},this._parseEventChunk=function(e){if(!e||0===e.length)return null;var t={id:null,retry:null,data:"",event:"message"};e.split(/\n|\r\n|\r/).forEach(function(e){var n=(e=e.trimRight()).indexOf(this.FIELD_SEPARATOR);if(!(n<=0)){var o=e.substring(0,n);if(o in t){var r=e.substring(n+1).trimLeft();"data"===o?t[o]+=r:t[o]=r}}}.bind(this));var n=new CustomEvent(t.event);return n.data=t.data,n.id=t.id,n},this._checkStreamClosed=function(){this.xhr&&this.xhr.readyState===XMLHttpRequest.DONE&&this._setReadyState(this.CLOSED)},this.stream=function(){for(var e in this._setReadyState(this.CONNECTING),this.xhr=new XMLHttpRequest,this.xhr.addEventListener("progress",this._onStreamProgress.bind(this)),this.xhr.addEventListener("load",this._onStreamLoaded.bind(this)),this.xhr.addEventListener("readystatechange",this._checkStreamClosed.bind(this)),this.xhr.addEventListener("error",this._onStreamFailure.bind(this)),this.xhr.addEventListener("abort",this._onStreamAbort.bind(this)),this.xhr.open(this.method,this.url),this.headers)this.xhr.setRequestHeader(e,this.headers[e]);this.xhr.withCredentials=this.withCredentials,this.xhr.send(this.payload)},this.close=function(){this.readyState!==this.CLOSED&&(this.xhr.abort(),this.xhr=null,this._setReadyState(this.CLOSED))}};exports.EndpointURLs=ne,exports.SSE=Me,exports.alternateName=ee,exports.anthropicSchema=S,exports.assistantSchema=j,exports.bingAISchema=k,exports.chatGPTBrowserSchema=C,exports.compactAnthropicSchema=q,exports.compactChatGPTSchema=B,exports.compactGoogleSchema=R,exports.compactOpenAISchema=N,exports.compactPluginsSchema=U,exports.configSchema=W,exports.createPayload=function(e){var t=e.conversation,n=e.message,o=e.messages,r=e.endpointOption,a=e.isEdited,s=e.isContinued,l=I.parse(t).conversationId,p=r,u=p.endpoint,d=p.endpointType,c=ne[null!=d?d:u];a&&u===exports.EModelEndpoint.assistant?c+="/modify":a&&(c=c.replace("/ask/","/edit/"));var h=i(i(i({},n),r),{isContinued:!(!a||!s),conversationId:l});return u===exports.EModelEndpoint.assistant&&(h.messages=o),{server:c,payload:h}},exports.dataService=Pe,exports.defaultEndpoints=$,exports.defaultModels=te,exports.eImageDetailSchema=g,exports.eModelEndpointSchema=d,exports.endpointSchema=H,exports.endpointSettings=p,exports.extendedModelEndpointSchema=c,exports.fileSourceSchema=V,exports.getFirstDefinedValue=se,exports.getResponseSender=function(e){var t,n=e.model,o=e.endpoint,r=e.endpointType,i=e.modelDisplayLabel,a=e.chatGptLabel,s=e.modelLabel,l=e.jailbreak;return[exports.EModelEndpoint.openAI,exports.EModelEndpoint.azureOpenAI,exports.EModelEndpoint.gptPlugins,exports.EModelEndpoint.chatGPTBrowser].includes(o)?a||(n&&n.includes("gpt-3")?"GPT-3.5":n&&n.includes("gpt-4")?"GPT-4":n&&n.includes("mistral")?"Mistral":null!==(t=ee[o])&&void 0!==t?t:"ChatGPT"):o===exports.EModelEndpoint.bingAI?l?"Sydney":"BingAI":o===exports.EModelEndpoint.anthropic?null!=s?s:"Claude":o===exports.EModelEndpoint.google?s||(n&&n.includes("gemini")?"Gemini":n&&n.includes("code")?"Codey":"PaLM2"):o===exports.EModelEndpoint.custom||r===exports.EModelEndpoint.custom?s||(a||(n&&n.includes("mistral")?"Mistral":n&&n.includes("gpt-3")?"GPT-3.5":n&&n.includes("gpt-4")?"GPT-4":i||"AI")):""},exports.googleSchema=O,exports.gptPluginsSchema=_,exports.imageDetailNumeric=h,exports.imageDetailValue=m,exports.modularEndpoints=oe,exports.openAISchema=M,exports.parseCompactConvo=function(e){var t,n=e.endpoint,o=e.endpointType,r=e.conversation,i=e.possibleValues;if(!n)throw new Error("undefined endpoint: ".concat(n));var a=de[n];if(!a&&!o)throw new Error("Unknown endpoint: ".concat(n));!a&&o&&(a=de[o]);var s=a.parse(r),l=(null!=i?i:{}).models;return l&&s&&(s.model=null!==(t=se(l))&&void 0!==t?t:s.model),s},exports.parseConvo=function(e){var t,n,o=e.endpoint,r=e.endpointType,i=e.conversation,a=e.possibleValues,s=ae[o];if(!s&&!r)throw new Error("Unknown endpoint: ".concat(o));!s&&r&&(s=ae[r]);var l=s.parse(i),p=null!=a?a:{},u=p.models,d=p.secondaryModels;return u&&l&&(l.model=null!==(t=se(u))&&void 0!==t?t:l.model),d&&l.agentOptions&&(l.agentOptions.model=null!==(n=se(d))&&void 0!==n?n:l.agentOptions.model),l},exports.removeNullishValues=A,exports.request=Ie,exports.setAcceptLanguageHeader=function(e){r.defaults.headers.common["Accept-Language"]=e},exports.setTokenHeader=ce,exports.supportsBalanceCheck=ie,exports.supportsFiles=re,exports.tAgentOptionsSchema=E,exports.tConversationSchema=y,exports.tConvoUpdateSchema=I,exports.tExampleSchema=x,exports.tMessageSchema=b,exports.tPluginAuthConfigSchema=f,exports.tPluginSchema=v,exports.tPresetSchema=z,exports.tPresetUpdateSchema=P,exports.visionModels=["gpt-4-vision","llava-13b","gemini-pro-vision"];
|
|
1
|
+
"use strict";var e,t,n,o=require("zod"),r=require("axios"),i=function(){return i=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},i.apply(this,arguments)};function a(e,t,n,o){return new(n||(n=Promise))((function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((o=o.apply(e,t||[])).next())}))}function s(e,t){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}"function"==typeof SuppressedError&&SuppressedError,exports.EModelEndpoint=void 0,(n=exports.EModelEndpoint||(exports.EModelEndpoint={})).azureOpenAI="azureOpenAI",n.openAI="openAI",n.bingAI="bingAI",n.chatGPTBrowser="chatGPTBrowser",n.google="google",n.gptPlugins="gptPlugins",n.anthropic="anthropic",n.assistant="assistant",n.custom="custom";var l,p=((e={})[exports.EModelEndpoint.google]={model:{default:"chat-bison"},maxOutputTokens:{min:1,max:2048,step:1,default:1024,maxGeminiPro:8192,defaultGeminiPro:8192},temperature:{min:0,max:1,step:.01,default:.2},topP:{min:0,max:1,step:.01,default:.8},topK:{min:1,max:40,step:.01,default:40}},e),u=p[exports.EModelEndpoint.google],d=o.z.nativeEnum(exports.EModelEndpoint),c=o.z.union([d,o.z.string()]);exports.ImageDetail=void 0,(l=exports.ImageDetail||(exports.ImageDetail={})).low="low",l.auto="auto",l.high="high";var h=((t={})[exports.ImageDetail.low]=0,t[exports.ImageDetail.auto]=1,t[exports.ImageDetail.high]=2,t),g={0:exports.ImageDetail.low,1:exports.ImageDetail.auto,2:exports.ImageDetail.high},m=o.z.nativeEnum(exports.ImageDetail),f=o.z.object({authField:o.z.string(),label:o.z.string(),description:o.z.string()}),v=o.z.object({name:o.z.string(),pluginKey:o.z.string(),description:o.z.string(),icon:o.z.string(),authConfig:o.z.array(f),authenticated:o.z.boolean().optional(),isButton:o.z.boolean().optional()}),x=o.z.object({input:o.z.object({content:o.z.string()}),output:o.z.object({content:o.z.string()})}),E=o.z.object({agent:o.z.string(),skipCompletion:o.z.boolean(),model:o.z.string(),temperature:o.z.number()}),b=o.z.object({messageId:o.z.string(),endpoint:o.z.string().optional(),clientId:o.z.string().nullable().optional(),conversationId:o.z.string().nullable(),parentMessageId:o.z.string().nullable(),responseMessageId:o.z.string().nullable().optional(),overrideParentMessageId:o.z.string().nullable().optional(),bg:o.z.string().nullable().optional(),model:o.z.string().nullable().optional(),title:o.z.string().nullable().or(o.z.literal("New Chat")).default("New Chat"),sender:o.z.string(),text:o.z.string(),generation:o.z.string().nullable().optional(),isEdited:o.z.boolean().optional(),isCreatedByUser:o.z.boolean(),error:o.z.boolean(),createdAt:o.z.string().optional().default((function(){return(new Date).toISOString()})),updatedAt:o.z.string().optional().default((function(){return(new Date).toISOString()})),current:o.z.boolean().optional(),unfinished:o.z.boolean().optional(),searchResult:o.z.boolean().optional(),finish_reason:o.z.string().optional()}),y=o.z.object({conversationId:o.z.string().nullable(),title:o.z.string().nullable().or(o.z.literal("New Chat")).default("New Chat"),user:o.z.string().optional(),endpoint:d.nullable(),endpointType:d.optional(),suggestions:o.z.array(o.z.string()).optional(),messages:o.z.array(o.z.string()).optional(),tools:o.z.array(v).optional(),createdAt:o.z.string(),updatedAt:o.z.string(),systemMessage:o.z.string().nullable().optional(),modelLabel:o.z.string().nullable().optional(),examples:o.z.array(x).optional(),chatGptLabel:o.z.string().nullable().optional(),userLabel:o.z.string().optional(),model:o.z.string().nullable().optional(),promptPrefix:o.z.string().nullable().optional(),temperature:o.z.number().optional(),topP:o.z.number().optional(),topK:o.z.number().optional(),context:o.z.string().nullable().optional(),top_p:o.z.number().optional(),frequency_penalty:o.z.number().optional(),presence_penalty:o.z.number().optional(),jailbreak:o.z.boolean().optional(),jailbreakConversationId:o.z.string().nullable().optional(),conversationSignature:o.z.string().nullable().optional(),parentMessageId:o.z.string().optional(),clientId:o.z.string().nullable().optional(),invocationId:o.z.number().nullable().optional(),toneStyle:o.z.string().nullable().optional(),maxOutputTokens:o.z.number().optional(),agentOptions:E.nullable().optional(),resendImages:o.z.boolean().optional(),imageDetail:m.optional(),assistant_id:o.z.string().optional(),thread_id:o.z.string().optional()}),z=y.omit({conversationId:!0,createdAt:!0,updatedAt:!0,title:!0}).merge(o.z.object({conversationId:o.z.string().nullable().optional(),presetId:o.z.string().nullable().optional(),title:o.z.string().nullable().optional(),defaultPreset:o.z.boolean().optional(),order:o.z.number().optional(),endpoint:c.nullable()})),I=y.merge(o.z.object({endpoint:c.nullable()})),P=y.merge(o.z.object({endpoint:c.nullable()})),M=y.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,resendImages:!0,imageDetail:!0}).transform((function(e){var t,n,o,r,a,s,l,p,u;return i(i({},e),{model:null!==(t=e.model)&&void 0!==t?t:"gpt-3.5-turbo",chatGptLabel:null!==(n=e.chatGptLabel)&&void 0!==n?n:null,promptPrefix:null!==(o=e.promptPrefix)&&void 0!==o?o:null,temperature:null!==(r=e.temperature)&&void 0!==r?r:1,top_p:null!==(a=e.top_p)&&void 0!==a?a:1,presence_penalty:null!==(s=e.presence_penalty)&&void 0!==s?s:0,frequency_penalty:null!==(l=e.frequency_penalty)&&void 0!==l?l:0,resendImages:null!==(p=e.resendImages)&&void 0!==p&&p,imageDetail:null!==(u=e.imageDetail)&&void 0!==u?u:exports.ImageDetail.auto})})).catch((function(){return{model:"gpt-3.5-turbo",chatGptLabel:null,promptPrefix:null,temperature:1,top_p:1,presence_penalty:0,frequency_penalty:0,resendImages:!1,imageDetail:exports.ImageDetail.auto}})),O=y.pick({model:!0,modelLabel:!0,promptPrefix:!0,examples:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0}).transform((function(e){var t,n,o,r,a,s,l,p,d,c,h=null===(n=null===(t=null==e?void 0:e.model)||void 0===t?void 0:t.toLowerCase())||void 0===n?void 0:n.includes("gemini-pro"),g=h?u.maxOutputTokens.maxGeminiPro:u.maxOutputTokens.max,m=h?u.maxOutputTokens.defaultGeminiPro:u.maxOutputTokens.default,f=null!==(o=e.maxOutputTokens)&&void 0!==o?o:m;return f=Math.min(f,g),i(i({},e),{model:null!==(r=e.model)&&void 0!==r?r:u.model.default,modelLabel:null!==(a=e.modelLabel)&&void 0!==a?a:null,promptPrefix:null!==(s=e.promptPrefix)&&void 0!==s?s:null,examples:null!==(l=e.examples)&&void 0!==l?l:[{input:{content:""},output:{content:""}}],temperature:null!==(p=e.temperature)&&void 0!==p?p:u.temperature.default,maxOutputTokens:f,topP:null!==(d=e.topP)&&void 0!==d?d:u.topP.default,topK:null!==(c=e.topK)&&void 0!==c?c:u.topK.default})})).catch((function(){return{model:u.model.default,modelLabel:null,promptPrefix:null,examples:[{input:{content:""},output:{content:""}}],temperature:u.temperature.default,maxOutputTokens:u.maxOutputTokens.default,topP:u.topP.default,topK:u.topK.default}})),C=y.pick({jailbreak:!0,systemMessage:!0,context:!0,toneStyle:!0,jailbreakConversationId:!0,conversationSignature:!0,clientId:!0,invocationId:!0}).transform((function(e){var t,n,o,r,a,s,l,p;return i(i({},e),{model:"",jailbreak:null!==(t=e.jailbreak)&&void 0!==t&&t,systemMessage:null!==(n=e.systemMessage)&&void 0!==n?n:null,context:null!==(o=e.context)&&void 0!==o?o:null,toneStyle:null!==(r=e.toneStyle)&&void 0!==r?r:"creative",jailbreakConversationId:null!==(a=e.jailbreakConversationId)&&void 0!==a?a:null,conversationSignature:null!==(s=e.conversationSignature)&&void 0!==s?s:null,clientId:null!==(l=e.clientId)&&void 0!==l?l: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}})),k=y.pick({model:!0,modelLabel:!0,promptPrefix:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0}).transform((function(e){var t,n,o,r,a,s,l;return i(i({},e),{model:null!==(t=e.model)&&void 0!==t?t:"claude-1",modelLabel:null!==(n=e.modelLabel)&&void 0!==n?n:null,promptPrefix:null!==(o=e.promptPrefix)&&void 0!==o?o:null,temperature:null!==(r=e.temperature)&&void 0!==r?r:1,maxOutputTokens:null!==(a=e.maxOutputTokens)&&void 0!==a?a:4e3,topP:null!==(s=e.topP)&&void 0!==s?s:.7,topK:null!==(l=e.topK)&&void 0!==l?l:5})})).catch((function(){return{model:"claude-1",modelLabel:null,promptPrefix:null,temperature:1,maxOutputTokens:4e3,topP:.7,topK:5}})),S=y.pick({model:!0}).transform((function(e){var t;return i(i({},e),{model:null!==(t=e.model)&&void 0!==t?t:"text-davinci-002-render-sha"})})).catch((function(){return{model:"text-davinci-002-render-sha"}})),_=y.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,tools:!0,agentOptions:!0}).transform((function(e){var t,n,o,r,a,s,l,p,u;return i(i({},e),{model:null!==(t=e.model)&&void 0!==t?t:"gpt-3.5-turbo",chatGptLabel:null!==(n=e.chatGptLabel)&&void 0!==n?n:null,promptPrefix:null!==(o=e.promptPrefix)&&void 0!==o?o:null,temperature:null!==(r=e.temperature)&&void 0!==r?r:.8,top_p:null!==(a=e.top_p)&&void 0!==a?a:1,presence_penalty:null!==(s=e.presence_penalty)&&void 0!==s?s:0,frequency_penalty:null!==(l=e.frequency_penalty)&&void 0!==l?l:0,tools:null!==(p=e.tools)&&void 0!==p?p:[],agentOptions:null!==(u=e.agentOptions)&&void 0!==u?u:{agent:"functions",skipCompletion:!0,model:"gpt-3.5-turbo",temperature:0}})})).catch((function(){return{model:"gpt-3.5-turbo",chatGptLabel:null,promptPrefix:null,temperature:.8,top_p:1,presence_penalty:0,frequency_penalty:0,tools:[],agentOptions:{agent:"functions",skipCompletion:!0,model:"gpt-3.5-turbo",temperature:0}}}));function A(e){var t=i({},e);return Object.keys(t).forEach((function(e){void 0!==t[e]&&null!==t[e]&&""!==t[e]||delete t[e]})),t}var w,T,L,G,D,K,N=y.pick({model:!0,assistant_id:!0,thread_id:!0}).transform(A).catch((function(){return{}})),j=y.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,resendImages:!0,imageDetail:!0}).transform((function(e){var t=i({},e);return"gpt-3.5-turbo"===t.model&&delete t.model,1===t.temperature&&delete t.temperature,1===t.top_p&&delete t.top_p,0===t.presence_penalty&&delete t.presence_penalty,0===t.frequency_penalty&&delete t.frequency_penalty,!0!==t.resendImages&&delete t.resendImages,t.imageDetail===exports.ImageDetail.auto&&delete t.imageDetail,A(t)})).catch((function(){return{}})),R=y.pick({model:!0,modelLabel:!0,promptPrefix:!0,examples:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0}).transform((function(e){var t=i({},e);return t.model===u.model.default&&delete t.model,t.temperature===u.temperature.default&&delete t.temperature,t.maxOutputTokens===u.maxOutputTokens.default&&delete t.maxOutputTokens,t.topP===u.topP.default&&delete t.topP,t.topK===u.topK.default&&delete t.topK,A(t)})).catch((function(){return{}})),q=y.pick({model:!0,modelLabel:!0,promptPrefix:!0,temperature:!0,maxOutputTokens:!0,topP:!0,topK:!0}).transform((function(e){var t=i({},e);return"claude-1"===t.model&&delete t.model,1===t.temperature&&delete t.temperature,4e3===t.maxOutputTokens&&delete t.maxOutputTokens,.7===t.topP&&delete t.topP,5===t.topK&&delete t.topK,A(t)})).catch((function(){return{}})),B=y.pick({model:!0}).transform((function(e){var t=i({},e);return"text-davinci-002-render-sha"===t.model&&delete t.model,A(t)})).catch((function(){return{}})),U=y.pick({model:!0,chatGptLabel:!0,promptPrefix:!0,temperature:!0,top_p:!0,presence_penalty:!0,frequency_penalty:!0,tools:!0,agentOptions:!0}).transform((function(e){var t,n=i({},e);return"gpt-3.5-turbo"===n.model&&delete n.model,null===n.chatGptLabel&&delete n.chatGptLabel,null===n.promptPrefix&&delete n.promptPrefix,.8===n.temperature&&delete n.temperature,1===n.top_p&&delete n.top_p,0===n.presence_penalty&&delete n.presence_penalty,0===n.frequency_penalty&&delete n.frequency_penalty,0===(null===(t=n.tools)||void 0===t?void 0:t.length)&&delete n.tools,n.agentOptions&&"functions"===n.agentOptions.agent&&!0===n.agentOptions.skipCompletion&&"gpt-3.5-turbo"===n.agentOptions.model&&0===n.agentOptions.temperature&&delete n.agentOptions,A(n)})).catch((function(){return{}}));exports.FileSources=void 0,(w=exports.FileSources||(exports.FileSources={})).local="local",w.firebase="firebase",w.openai="openai",w.s3="s3";var F,V=o.z.nativeEnum(exports.FileSources),H=o.z.object({name:o.z.string().refine((function(e){return!d.safeParse(e).success}),{message:"Value cannot be one of the default endpoint (EModelEndpoint) values: ".concat(Object.values(exports.EModelEndpoint).join(", "))}),apiKey:o.z.string(),baseURL:o.z.string(),models:o.z.object({default:o.z.array(o.z.string()).min(1),fetch:o.z.boolean().optional()}),titleConvo:o.z.boolean().optional(),titleMethod:o.z.union([o.z.literal("completion"),o.z.literal("functions")]).optional(),titleModel:o.z.string().optional(),summarize:o.z.boolean().optional(),summaryModel:o.z.string().optional(),forcePrompt:o.z.boolean().optional(),modelDisplayLabel:o.z.string().optional(),headers:o.z.record(o.z.any()).optional()}),Q=o.z.object({version:o.z.string(),cache:o.z.boolean(),fileStrategy:V.optional(),registration:o.z.object({socialLogins:o.z.array(o.z.string()).optional(),allowedDomains:o.z.array(o.z.string()).optional()}).optional(),endpoints:o.z.object({custom:o.z.array(H.partial())}).strict()});exports.KnownEndpoints=void 0,(F=exports.KnownEndpoints||(exports.KnownEndpoints={})).mistral="mistral",F.openrouter="openrouter";var W,Y,J,X,Z,$=[exports.EModelEndpoint.openAI,exports.EModelEndpoint.assistant,exports.EModelEndpoint.azureOpenAI,exports.EModelEndpoint.bingAI,exports.EModelEndpoint.chatGPTBrowser,exports.EModelEndpoint.gptPlugins,exports.EModelEndpoint.google,exports.EModelEndpoint.anthropic,exports.EModelEndpoint.custom],ee=((T={})[exports.EModelEndpoint.openAI]="OpenAI",T[exports.EModelEndpoint.assistant]="Assistants",T[exports.EModelEndpoint.azureOpenAI]="Azure OpenAI",T[exports.EModelEndpoint.bingAI]="Bing",T[exports.EModelEndpoint.chatGPTBrowser]="ChatGPT",T[exports.EModelEndpoint.gptPlugins]="Plugins",T[exports.EModelEndpoint.google]="Google",T[exports.EModelEndpoint.anthropic]="Anthropic",T[exports.EModelEndpoint.custom]="Custom",T),te=((L={})[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"],L[exports.EModelEndpoint.anthropic]=["claude-2.1","claude-2","claude-1.2","claude-1","claude-1-100k","claude-instant-1","claude-instant-1-100k"],L[exports.EModelEndpoint.openAI]=["gpt-3.5-turbo-0125","gpt-3.5-turbo-16k-0613","gpt-3.5-turbo-16k","gpt-4-turbo-preview","gpt-4-0125-preview","gpt-4-1106-preview","gpt-3.5-turbo","gpt-3.5-turbo-1106","gpt-4-vision-preview","gpt-4","gpt-3.5-turbo-instruct-0914","gpt-3.5-turbo-0613","gpt-3.5-turbo-0301","gpt-3.5-turbo-instruct","gpt-4-0613","text-davinci-003","gpt-4-0314"],L),ne=((G={})[exports.EModelEndpoint.openAI]="/api/ask/".concat(exports.EModelEndpoint.openAI),G[exports.EModelEndpoint.bingAI]="/api/ask/".concat(exports.EModelEndpoint.bingAI),G[exports.EModelEndpoint.google]="/api/ask/".concat(exports.EModelEndpoint.google),G[exports.EModelEndpoint.custom]="/api/ask/".concat(exports.EModelEndpoint.custom),G[exports.EModelEndpoint.anthropic]="/api/ask/".concat(exports.EModelEndpoint.anthropic),G[exports.EModelEndpoint.gptPlugins]="/api/ask/".concat(exports.EModelEndpoint.gptPlugins),G[exports.EModelEndpoint.azureOpenAI]="/api/ask/".concat(exports.EModelEndpoint.azureOpenAI),G[exports.EModelEndpoint.chatGPTBrowser]="/api/ask/".concat(exports.EModelEndpoint.chatGPTBrowser),G[exports.EModelEndpoint.assistant]="/api/assistants/chat",G),oe=new Set([exports.EModelEndpoint.gptPlugins,exports.EModelEndpoint.anthropic,exports.EModelEndpoint.google,exports.EModelEndpoint.openAI,exports.EModelEndpoint.azureOpenAI,exports.EModelEndpoint.custom]),re=((D={})[exports.EModelEndpoint.openAI]=!0,D[exports.EModelEndpoint.google]=!0,D[exports.EModelEndpoint.assistant]=!0,D[exports.EModelEndpoint.azureOpenAI]=!0,D[exports.EModelEndpoint.custom]=!0,D),ie=((K={})[exports.EModelEndpoint.openAI]=!0,K[exports.EModelEndpoint.azureOpenAI]=!0,K[exports.EModelEndpoint.gptPlugins]=!0,K[exports.EModelEndpoint.custom]=!0,K);exports.CacheKeys=void 0,(W=exports.CacheKeys||(exports.CacheKeys={})).CONFIG_STORE="configStore",W.PLUGINS="plugins",W.GEN_TITLE="genTitle",W.MODELS_CONFIG="modelsConfig",W.ENDPOINT_CONFIG="endpointsConfig",W.TOKEN_CONFIG="tokenConfig",W.CUSTOM_CONFIG="customConfig",W.OVERRIDE_CONFIG="overrideConfig",exports.AuthKeys=void 0,(Y=exports.AuthKeys||(exports.AuthKeys={})).GOOGLE_SERVICE_KEY="GOOGLE_SERVICE_KEY",Y.GOOGLE_API_KEY="GOOGLE_API_KEY",exports.ImageDetailCost=void 0,(J=exports.ImageDetailCost||(exports.ImageDetailCost={}))[J.LOW=85]="LOW",J[J.HIGH=170]="HIGH",J[J.ADDITIONAL=85]="ADDITIONAL",exports.SettingsTabValues=void 0,(X=exports.SettingsTabValues||(exports.SettingsTabValues={})).GENERAL="general",X.BETA="beta",X.DATA="data",X.ACCOUNT="account";var ae=((Z={})[exports.EModelEndpoint.openAI]=M,Z[exports.EModelEndpoint.azureOpenAI]=M,Z[exports.EModelEndpoint.custom]=M,Z[exports.EModelEndpoint.google]=O,Z[exports.EModelEndpoint.bingAI]=C,Z[exports.EModelEndpoint.anthropic]=k,Z[exports.EModelEndpoint.chatGPTBrowser]=S,Z[exports.EModelEndpoint.gptPlugins]=_,Z[exports.EModelEndpoint.assistant]=N,Z);function se(e){for(var t,n=0,o=e;n<o.length;n++){var r=o[n];if(r){t=r;break}}return t}var le,pe,ue,de={openAI:j,azureOpenAI:j,custom:j,assistant:N,google:R,bingAI:C,anthropic:q,chatGPTBrowser:B,gptPlugins:U};function ce(e){r.defaults.headers.common.Authorization="Bearer "+e}exports.Tools=void 0,(le=exports.Tools||(exports.Tools={})).code_interpreter="code_interpreter",le.retrieval="retrieval",le.function="function",exports.QueryKeys=void 0,(pe=exports.QueryKeys||(exports.QueryKeys={})).messages="messages",pe.allConversations="allConversations",pe.searchConversations="searchConversations",pe.conversation="conversation",pe.searchEnabled="searchEnabled",pe.user="user",pe.name="name",pe.models="models",pe.balance="balance",pe.endpoints="endpoints",pe.presets="presets",pe.searchResults="searchResults",pe.tokenCount="tokenCount",pe.availablePlugins="availablePlugins",pe.startupConfig="startupConfig",pe.assistants="assistants",pe.assistant="assistant",pe.endpointsConfigOverride="endpointsConfigOverride",pe.files="files",exports.MutationKeys=void 0,(ue=exports.MutationKeys||(exports.MutationKeys={})).imageUpload="imageUpload",ue.fileDelete="fileDelete",ue.updatePreset="updatePreset",ue.deletePreset="deletePreset",ue.logoutUser="logoutUser",ue.avatarUpload="avatarUpload";var he=function(e,t){return"/api/messages/".concat(e).concat(t?"/".concat(t):"")},ge="/api/keys",me=function(e){return"/api/convos?pageNumber=".concat(e)},fe=function(e,t){return"/api/search?q=".concat(e,"&pageNumber=").concat(t)},ve=function(e){return"/api/assistants".concat(e?"/".concat(e):"")},xe=function(){return"".concat("/api/files","/images")};function Ee(e,t){return a(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,r.post(e,JSON.stringify(t),{headers:{"Content-Type":"application/json"}})];case 1:return[2,n.sent().data]}}))}))}var be=!1,ye=[],ze=function(e){return Ee(function(e){return"/api/auth/refresh".concat(e?"?retry=true":"")}(e))},Ie=function(e,t){void 0===t&&(t=null),ye.forEach((function(n){e?n.reject(e):n.resolve(t)})),ye=[]};r.interceptors.response.use((function(e){return e}),(function(e){return a(void 0,void 0,void 0,(function(){var t,n,o,i,a;return s(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,!be)return[3,5];s.label=1;case 1:return s.trys.push([1,4,,5]),[4,new Promise((function(e,t){ye.push({resolve:e,reject:t})}))];case 2:return o=s.sent(),t.headers.Authorization="Bearer "+o,[4,r(t)];case 3:return[2,s.sent()];case 4:return n=s.sent(),[2,Promise.reject(n)];case 5:be=!0,s.label=6;case 6:return s.trys.push([6,11,12,13]),[4,ze(!!(null===(a=t.url)||void 0===a?void 0:a.includes("api/auth/refresh")))];case 7:return(o=s.sent().token)?(t.headers.Authorization="Bearer "+o,ce(o),window.dispatchEvent(new CustomEvent("tokenUpdated",{detail:o})),Ie(null,o),[4,r(t)]):[3,9];case 8:return[2,s.sent()];case 9:window.location.href="/login",s.label=10;case 10:return[3,13];case 11:return i=s.sent(),Ie(i,null),[2,Promise.reject(i)];case 12:return be=!1,[7];case 13:return[2,Promise.reject(e)]}}))}))}));var Pe={get:function(e,t){return a(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,r.get(e,i({},t))];case 1:return[2,n.sent().data]}}))}))},post:Ee,postMultiPart:function(e,t,n){return a(this,void 0,void 0,(function(){return s(this,(function(o){switch(o.label){case 0:return[4,r.post(e,t,i(i({},n),{headers:{"Content-Type":"multipart/form-data"}}))];case 1:return[2,o.sent().data]}}))}))},put:function(e,t){return a(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,r.put(e,JSON.stringify(t),{headers:{"Content-Type":"application/json"}})];case 1:return[2,n.sent().data]}}))}))},delete:function(e){return a(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,r.delete(e)];case 1:return[2,t.sent().data]}}))}))},deleteWithOptions:function(e,t){return a(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,r.delete(e,i({},t))];case 1:return[2,n.sent().data]}}))}))},patch:function(e,t){return a(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,r.patch(e,JSON.stringify(t),{headers:{"Content-Type":"application/json"}})];case 1:return[2,n.sent().data]}}))}))},refreshToken:ze};var Me=Object.freeze({__proto__:null,abortRequestWithMessage:function(e,t,n){return Pe.post(function(e){return"/api/ask/".concat(e,"/abort")}(e),{arg:{abortKey:t,message:n}})},clearAllConversations:function(){return Pe.post("/api/convos/clear",{arg:{}})},createAssistant:function(e){return Pe.post(ve(),e)},createPreset:function(e){return Pe.post("/api/presets",e)},deleteAssistant:function(e){return Pe.delete(ve(e))},deleteConversation:function(e){return Pe.post("/api/convos/clear",{arg:e})},deleteFiles:function(e){return a(void 0,void 0,void 0,(function(){return s(this,(function(t){return[2,Pe.deleteWithOptions("/api/files",{data:{files:e}})]}))}))},deletePreset:function(e){return Pe.post("/api/presets/delete",e)},genTitle:function(e){return Pe.post("/api/convos/gen_title",e)},getAIEndpoints:function(){return Pe.get("/api/endpoints")},getAssistantById:function(e){return Pe.get(ve(e))},getAvailablePlugins:function(){return Pe.get("/api/plugins")},getConversationById:function(e){return Pe.get(function(e){return"/api/convos/".concat(e)}(e))},getConversations:function(e){return Pe.get(me(e))},getEndpointsConfigOverride:function(){return Pe.get("/api/endpoints/config/override")},getFiles:function(){return Pe.get("/api/files")},getLoginGoogle:function(){return Pe.get("/api/auth/google")},getMessagesByConvoId:function(e){return"new"===e?Promise.resolve([]):Pe.get(he(e))},getModels:function(){return a(void 0,void 0,void 0,(function(){return s(this,(function(e){return[2,Pe.get("/api/models")]}))}))},getPresets:function(){return Pe.get("/api/presets")},getSearchEnabled:function(){return Pe.get("/api/search/enable")},getStartupConfig:function(){return Pe.get("/api/config")},getUser:function(){return Pe.get("/api/user")},getUserBalance:function(){return Pe.get("/api/balance")},listAssistants:function(e){return Pe.get(ve(),{params:e})},listConversations:function(e){var t=(null==e?void 0:e.pageNumber)||"1";return Pe.get(me(t))},listConversationsByQuery:function(e){var t=(null==e?void 0:e.pageNumber)||"1",n=(null==e?void 0:e.searchQuery)||"";return""!==n?Pe.get(fe(n,t)):Pe.get(me(t))},login:function(e){return Pe.post("/api/auth/login",e)},logout:function(){return Pe.post("/api/auth/logout")},register:function(e){return Pe.post("/api/auth/register",e)},requestPasswordReset:function(e){return Pe.post("/api/auth/requestPasswordReset",e)},resetPassword:function(e){return Pe.post("/api/auth/resetPassword",e)},revokeAllUserKeys:function(){return Pe.delete("".concat(ge,"?all=true"))},revokeUserKey:function(e){return Pe.delete(function(e){return"".concat(ge,"/").concat(e)}(e))},searchConversations:function(e,t){return a(void 0,void 0,void 0,(function(){return s(this,(function(n){return[2,Pe.get(fe(e,t))]}))}))},updateAssistant:function(e,t){return Pe.patch(ve(e),t)},updateConversation:function(e){return Pe.post("/api/convos/update",{arg:e})},updateMessage:function(e){var t=e.conversationId,n=e.messageId,o=e.text;if(!t)throw new Error("conversationId is required");return Pe.put(he(t,n),{text:o})},updatePreset:function(e){return Pe.post("/api/presets",e)},updateTokenCount:function(e){return Pe.post("/api/tokenizer",{arg:e})},updateUserKey:function(e){if(!e.value)throw new Error("value is required");return Pe.put(ge,e)},updateUserPlugins:function(e){return Pe.post("/api/user/plugins",e)},uploadAvatar:function(e){return Pe.postMultiPart("".concat(xe(),"/avatar"),e)},uploadImage:function(e){return Pe.postMultiPart(xe(),e)},userKeyQuery:function(e){return Pe.get(function(e){return"".concat(ge,"?name=").concat(e)}(e))}}),Oe=function(e,t){if(!(this instanceof Oe))return new Oe(e,t);this.INITIALIZING=-1,this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,this.url=e,t=t||{},this.headers=t.headers||{},this.payload=void 0!==t.payload?t.payload:"",this.method=t.method||this.payload&&"POST"||"GET",this.withCredentials=!!t.withCredentials,this.FIELD_SEPARATOR=":",this.listeners={},this.xhr=null,this.readyState=this.INITIALIZING,this.progress=0,this.chunk="",this.addEventListener=function(e,t){void 0===this.listeners[e]&&(this.listeners[e]=[]),-1===this.listeners[e].indexOf(t)&&this.listeners[e].push(t)},this.removeEventListener=function(e,t){if(void 0!==this.listeners[e]){var n=[];this.listeners[e].forEach((function(e){e!==t&&n.push(e)})),0===n.length?delete this.listeners[e]:this.listeners[e]=n}},this.dispatchEvent=function(e){if(!e)return!0;e.source=this;var t="on"+e.type;return(!this.hasOwnProperty(t)||(this[t].call(this,e),!e.defaultPrevented))&&(!this.listeners[e.type]||this.listeners[e.type].every((function(t){return t(e),!e.defaultPrevented})))},this._setReadyState=function(e){var t=new CustomEvent("readystatechange");t.readyState=e,this.readyState=e,this.dispatchEvent(t)},this._onStreamFailure=function(e){var t=new CustomEvent("error");t.data=e.currentTarget.response,this.dispatchEvent(t),this.close()},this._onStreamAbort=function(e){this.dispatchEvent(new CustomEvent("abort")),this.close()},this._onStreamProgress=async function(e){if(this.xhr){if(401!==this.xhr.status||this._retry){if(200!==this.xhr.status)return void this._onStreamFailure(e)}else{this._retry=!0;try{const e=await Pe.refreshToken();this.headers={"Content-Type":"application/json",Authorization:`Bearer ${e.token}`},ce(e.token),window.dispatchEvent(new CustomEvent("tokenUpdated",{detail:e.token})),this.stream()}catch(t){return void this._onStreamFailure(e)}}this.readyState==this.CONNECTING&&(this.dispatchEvent(new CustomEvent("open")),this._setReadyState(this.OPEN));var t=this.xhr.responseText.substring(this.progress);this.progress+=t.length,t.split(/(\r\n|\r|\n){2}/g).forEach(function(e){0===e.trim().length?(this.dispatchEvent(this._parseEventChunk(this.chunk.trim())),this.chunk=""):this.chunk+=e}.bind(this))}},this._onStreamLoaded=function(e){this._onStreamProgress(e),this.dispatchEvent(this._parseEventChunk(this.chunk)),this.chunk=""},this._parseEventChunk=function(e){if(!e||0===e.length)return null;var t={id:null,retry:null,data:"",event:"message"};e.split(/\n|\r\n|\r/).forEach(function(e){var n=(e=e.trimRight()).indexOf(this.FIELD_SEPARATOR);if(!(n<=0)){var o=e.substring(0,n);if(o in t){var r=e.substring(n+1).trimLeft();"data"===o?t[o]+=r:t[o]=r}}}.bind(this));var n=new CustomEvent(t.event);return n.data=t.data,n.id=t.id,n},this._checkStreamClosed=function(){this.xhr&&this.xhr.readyState===XMLHttpRequest.DONE&&this._setReadyState(this.CLOSED)},this.stream=function(){for(var e in this._setReadyState(this.CONNECTING),this.xhr=new XMLHttpRequest,this.xhr.addEventListener("progress",this._onStreamProgress.bind(this)),this.xhr.addEventListener("load",this._onStreamLoaded.bind(this)),this.xhr.addEventListener("readystatechange",this._checkStreamClosed.bind(this)),this.xhr.addEventListener("error",this._onStreamFailure.bind(this)),this.xhr.addEventListener("abort",this._onStreamAbort.bind(this)),this.xhr.open(this.method,this.url),this.headers)this.xhr.setRequestHeader(e,this.headers[e]);this.xhr.withCredentials=this.withCredentials,this.xhr.send(this.payload)},this.close=function(){this.readyState!==this.CLOSED&&(this.xhr.abort(),this.xhr=null,this._setReadyState(this.CLOSED))}};exports.EndpointURLs=ne,exports.SSE=Oe,exports.alternateName=ee,exports.anthropicSchema=k,exports.assistantSchema=N,exports.bingAISchema=C,exports.chatGPTBrowserSchema=S,exports.compactAnthropicSchema=q,exports.compactChatGPTSchema=B,exports.compactGoogleSchema=R,exports.compactOpenAISchema=j,exports.compactPluginsSchema=U,exports.configSchema=Q,exports.createPayload=function(e){var t=e.conversation,n=e.message,o=e.messages,r=e.endpointOption,a=e.isEdited,s=e.isContinued,l=I.parse(t).conversationId,p=r,u=p.endpoint,d=p.endpointType,c=ne[null!=d?d:u];a&&u===exports.EModelEndpoint.assistant?c+="/modify":a&&(c=c.replace("/ask/","/edit/"));var h=i(i(i({},n),r),{isContinued:!(!a||!s),conversationId:l});return u===exports.EModelEndpoint.assistant&&(h.messages=o),{server:c,payload:h}},exports.dataService=Me,exports.defaultEndpoints=$,exports.defaultModels=te,exports.eImageDetailSchema=m,exports.eModelEndpointSchema=d,exports.endpointSchema=H,exports.endpointSettings=p,exports.extendedModelEndpointSchema=c,exports.fileSourceSchema=V,exports.getFirstDefinedValue=se,exports.getResponseSender=function(e){var t,n=e.model,o=e.endpoint,r=e.endpointType,i=e.modelDisplayLabel,a=e.chatGptLabel,s=e.modelLabel,l=e.jailbreak;return[exports.EModelEndpoint.openAI,exports.EModelEndpoint.azureOpenAI,exports.EModelEndpoint.gptPlugins,exports.EModelEndpoint.chatGPTBrowser].includes(o)?a||(n&&n.includes("gpt-3")?"GPT-3.5":n&&n.includes("gpt-4")?"GPT-4":n&&n.includes("mistral")?"Mistral":null!==(t=ee[o])&&void 0!==t?t:"ChatGPT"):o===exports.EModelEndpoint.bingAI?l?"Sydney":"BingAI":o===exports.EModelEndpoint.anthropic?null!=s?s:"Claude":o===exports.EModelEndpoint.google?s||(n&&n.includes("gemini")?"Gemini":n&&n.includes("code")?"Codey":"PaLM2"):o===exports.EModelEndpoint.custom||r===exports.EModelEndpoint.custom?s||(a||(n&&n.includes("mistral")?"Mistral":n&&n.includes("gpt-3")?"GPT-3.5":n&&n.includes("gpt-4")?"GPT-4":i||"AI")):""},exports.googleSchema=O,exports.gptPluginsSchema=_,exports.imageDetailNumeric=h,exports.imageDetailValue=g,exports.modularEndpoints=oe,exports.openAISchema=M,exports.parseCompactConvo=function(e){var t,n=e.endpoint,o=e.endpointType,r=e.conversation,i=e.possibleValues;if(!n)throw new Error("undefined endpoint: ".concat(n));var a=de[n];if(!a&&!o)throw new Error("Unknown endpoint: ".concat(n));!a&&o&&(a=de[o]);var s=a.parse(r),l=(null!=i?i:{}).models;return l&&s&&(s.model=null!==(t=se(l))&&void 0!==t?t:s.model),s},exports.parseConvo=function(e){var t,n,o=e.endpoint,r=e.endpointType,i=e.conversation,a=e.possibleValues,s=ae[o];if(!s&&!r)throw new Error("Unknown endpoint: ".concat(o));!s&&r&&(s=ae[r]);var l=s.parse(i),p=null!=a?a:{},u=p.models,d=p.secondaryModels;return u&&l&&(l.model=null!==(t=se(u))&&void 0!==t?t:l.model),d&&l.agentOptions&&(l.agentOptions.model=null!==(n=se(d))&&void 0!==n?n:l.agentOptions.model),l},exports.removeNullishValues=A,exports.request=Pe,exports.setAcceptLanguageHeader=function(e){r.defaults.headers.common["Accept-Language"]=e},exports.setTokenHeader=ce,exports.supportsBalanceCheck=ie,exports.supportsFiles=re,exports.tAgentOptionsSchema=E,exports.tConversationSchema=y,exports.tConvoUpdateSchema=I,exports.tExampleSchema=x,exports.tMessageSchema=b,exports.tPluginAuthConfigSchema=f,exports.tPluginSchema=v,exports.tPresetSchema=z,exports.tPresetUpdateSchema=P,exports.visionModels=["gpt-4-vision","llava-13b","gemini-pro-vision"];
|
|
2
2
|
//# sourceMappingURL=index.js.map
|