| | import { z } from 'zod'; |
| | import type { ZodError } from 'zod'; |
| | import type { TEndpointsConfig, TModelsConfig, TConfig } from './types'; |
| | import { EModelEndpoint, eModelEndpointSchema } from './schemas'; |
| | import { specsConfigSchema, TSpecsConfig } from './models'; |
| | import { fileConfigSchema } from './file-config'; |
| | import { apiBaseUrl } from './api-endpoints'; |
| | import { FileSources } from './types/files'; |
| | import { MCPServersSchema } from './mcp'; |
| |
|
| | export const defaultSocialLogins = ['google', 'facebook', 'openid', 'github', 'discord', 'saml']; |
| |
|
| | export const defaultRetrievalModels = [ |
| | 'gpt-4o', |
| | 'o1-preview-2024-09-12', |
| | 'o1-preview', |
| | 'o1-mini-2024-09-12', |
| | 'o1-mini', |
| | 'o3-mini', |
| | 'chatgpt-4o-latest', |
| | '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', |
| | ]; |
| |
|
| | export const excludedKeys = new Set([ |
| | 'conversationId', |
| | 'title', |
| | 'iconURL', |
| | 'greeting', |
| | 'endpoint', |
| | 'endpointType', |
| | 'createdAt', |
| | 'updatedAt', |
| | 'expiredAt', |
| | 'messages', |
| | 'isArchived', |
| | 'tags', |
| | 'user', |
| | '__v', |
| | '_id', |
| | 'tools', |
| | 'model', |
| | 'files', |
| | 'spec', |
| | 'disableParams', |
| | ]); |
| |
|
| | export enum SettingsViews { |
| | default = 'default', |
| | advanced = 'advanced', |
| | } |
| |
|
| | export const fileSourceSchema = z.nativeEnum(FileSources); |
| |
|
| | export const fileStrategiesSchema = z |
| | .object({ |
| | default: fileSourceSchema.optional(), |
| | avatar: fileSourceSchema.optional(), |
| | image: fileSourceSchema.optional(), |
| | document: fileSourceSchema.optional(), |
| | }) |
| | .optional(); |
| |
|
| | |
| | type SchemaShape<T> = T extends z.ZodObject<infer U> ? U : never; |
| |
|
| | |
| | type DefaultValue<T> = |
| | T extends z.ZodDefault<z.ZodTypeAny> ? ReturnType<T['_def']['defaultValue']> : undefined; |
| |
|
| | |
| | type ExtractDefaults<T> = { |
| | [P in keyof T]: DefaultValue<T[P]>; |
| | }; |
| |
|
| | export type SchemaDefaults<T> = ExtractDefaults<SchemaShape<T>>; |
| |
|
| | export type TConfigDefaults = SchemaDefaults<typeof configSchema>; |
| |
|
| | export function getSchemaDefaults<Schema extends z.AnyZodObject>( |
| | schema: Schema, |
| | ): ExtractDefaults<SchemaShape<Schema>> { |
| | const shape = schema.shape; |
| | const entries = Object.entries(shape).map(([key, value]) => { |
| | if (value instanceof z.ZodDefault) { |
| | |
| | return [key, value._def.defaultValue()]; |
| | } |
| | return [key, undefined]; |
| | }); |
| |
|
| | |
| | return Object.fromEntries(entries) as ExtractDefaults<SchemaShape<Schema>>; |
| | } |
| |
|
| | export const modelConfigSchema = z |
| | .object({ |
| | deploymentName: z.string().optional(), |
| | version: z.string().optional(), |
| | assistants: z.boolean().optional(), |
| | }) |
| | .or(z.boolean()); |
| |
|
| | export type TAzureModelConfig = z.infer<typeof modelConfigSchema>; |
| |
|
| | export const azureBaseSchema = z.object({ |
| | apiKey: z.string(), |
| | serverless: z.boolean().optional(), |
| | instanceName: z.string().optional(), |
| | deploymentName: z.string().optional(), |
| | assistants: z.boolean().optional(), |
| | addParams: z.record(z.any()).optional(), |
| | dropParams: z.array(z.string()).optional(), |
| | forcePrompt: z.boolean().optional(), |
| | version: z.string().optional(), |
| | baseURL: z.string().optional(), |
| | additionalHeaders: z.record(z.any()).optional(), |
| | }); |
| |
|
| | export type TAzureBaseSchema = z.infer<typeof azureBaseSchema>; |
| |
|
| | export const azureGroupSchema = z |
| | .object({ |
| | group: z.string(), |
| | models: z.record(z.string(), modelConfigSchema), |
| | }) |
| | .required() |
| | .and(azureBaseSchema); |
| |
|
| | export const azureGroupConfigsSchema = z.array(azureGroupSchema).min(1); |
| | export type TAzureGroup = z.infer<typeof azureGroupSchema>; |
| | export type TAzureGroups = z.infer<typeof azureGroupConfigsSchema>; |
| | export type TAzureModelMapSchema = { |
| | |
| | |
| | group: string; |
| | }; |
| |
|
| | export type TAzureModelGroupMap = Record<string, TAzureModelMapSchema | undefined>; |
| | export type TAzureGroupMap = Record< |
| | string, |
| | (TAzureBaseSchema & { models: Record<string, TAzureModelConfig | undefined> }) | undefined |
| | >; |
| |
|
| | export type TValidatedAzureConfig = { |
| | modelNames: string[]; |
| | groupMap: TAzureGroupMap; |
| | assistantModels?: string[]; |
| | assistantGroups?: string[]; |
| | modelGroupMap: TAzureModelGroupMap; |
| | }; |
| |
|
| | export type TAzureConfigValidationResult = TValidatedAzureConfig & { |
| | isValid: boolean; |
| | errors: (ZodError | string)[]; |
| | }; |
| |
|
| | export enum Capabilities { |
| | code_interpreter = 'code_interpreter', |
| | image_vision = 'image_vision', |
| | retrieval = 'retrieval', |
| | actions = 'actions', |
| | tools = 'tools', |
| | } |
| |
|
| | export enum AgentCapabilities { |
| | hide_sequential_outputs = 'hide_sequential_outputs', |
| | end_after_tools = 'end_after_tools', |
| | execute_code = 'execute_code', |
| | file_search = 'file_search', |
| | web_search = 'web_search', |
| | artifacts = 'artifacts', |
| | actions = 'actions', |
| | context = 'context', |
| | tools = 'tools', |
| | chain = 'chain', |
| | ocr = 'ocr', |
| | } |
| |
|
| | export const defaultAssistantsVersion = { |
| | [EModelEndpoint.assistants]: 2, |
| | [EModelEndpoint.azureAssistants]: 1, |
| | }; |
| |
|
| | export const baseEndpointSchema = z.object({ |
| | streamRate: z.number().optional(), |
| | baseURL: z.string().optional(), |
| | titlePrompt: z.string().optional(), |
| | titleModel: z.string().optional(), |
| | titleConvo: z.boolean().optional(), |
| | titleMethod: z |
| | .union([z.literal('completion'), z.literal('functions'), z.literal('structured')]) |
| | .optional(), |
| | titleEndpoint: z.string().optional(), |
| | titlePromptTemplate: z.string().optional(), |
| | }); |
| |
|
| | export type TBaseEndpoint = z.infer<typeof baseEndpointSchema>; |
| |
|
| | export const bedrockEndpointSchema = baseEndpointSchema.merge( |
| | z.object({ |
| | availableRegions: z.array(z.string()).optional(), |
| | }), |
| | ); |
| |
|
| | const modelItemSchema = z.union([ |
| | z.string(), |
| | z.object({ |
| | name: z.string(), |
| | description: z.string().optional(), |
| | }), |
| | ]); |
| |
|
| | export const assistantEndpointSchema = baseEndpointSchema.merge( |
| | z.object({ |
| | |
| | disableBuilder: z.boolean().optional(), |
| | pollIntervalMs: z.number().optional(), |
| | timeoutMs: z.number().optional(), |
| | version: z.union([z.string(), z.number()]).default(2), |
| | supportedIds: z.array(z.string()).min(1).optional(), |
| | excludedIds: z.array(z.string()).min(1).optional(), |
| | privateAssistants: z.boolean().optional(), |
| | retrievalModels: z.array(z.string()).min(1).optional().default(defaultRetrievalModels), |
| | capabilities: z |
| | .array(z.nativeEnum(Capabilities)) |
| | .optional() |
| | .default([ |
| | Capabilities.code_interpreter, |
| | Capabilities.image_vision, |
| | Capabilities.retrieval, |
| | Capabilities.actions, |
| | Capabilities.tools, |
| | ]), |
| | |
| | apiKey: z.string().optional(), |
| | models: z |
| | .object({ |
| | default: z.array(modelItemSchema).min(1), |
| | fetch: z.boolean().optional(), |
| | userIdQuery: z.boolean().optional(), |
| | }) |
| | .optional(), |
| | headers: z.record(z.any()).optional(), |
| | }), |
| | ); |
| |
|
| | export type TAssistantEndpoint = z.infer<typeof assistantEndpointSchema>; |
| |
|
| | export const defaultAgentCapabilities = [ |
| | AgentCapabilities.execute_code, |
| | AgentCapabilities.file_search, |
| | AgentCapabilities.web_search, |
| | AgentCapabilities.artifacts, |
| | AgentCapabilities.actions, |
| | AgentCapabilities.context, |
| | AgentCapabilities.tools, |
| | AgentCapabilities.chain, |
| | AgentCapabilities.ocr, |
| | ]; |
| |
|
| | export const agentsEndpointSchema = baseEndpointSchema |
| | .merge( |
| | z.object({ |
| | |
| | recursionLimit: z.number().optional(), |
| | disableBuilder: z.boolean().optional().default(false), |
| | maxRecursionLimit: z.number().optional(), |
| | maxCitations: z.number().min(1).max(50).optional().default(30), |
| | maxCitationsPerFile: z.number().min(1).max(10).optional().default(7), |
| | minRelevanceScore: z.number().min(0.0).max(1.0).optional().default(0.45), |
| | allowedProviders: z.array(z.union([z.string(), eModelEndpointSchema])).optional(), |
| | capabilities: z |
| | .array(z.nativeEnum(AgentCapabilities)) |
| | .optional() |
| | .default(defaultAgentCapabilities), |
| | }), |
| | ) |
| | .default({ |
| | disableBuilder: false, |
| | capabilities: defaultAgentCapabilities, |
| | maxCitations: 30, |
| | maxCitationsPerFile: 7, |
| | minRelevanceScore: 0.45, |
| | }); |
| |
|
| | export type TAgentsEndpoint = z.infer<typeof agentsEndpointSchema>; |
| |
|
| | export const endpointSchema = baseEndpointSchema.merge( |
| | z.object({ |
| | name: z.string().refine((value) => !eModelEndpointSchema.safeParse(value).success, { |
| | message: `Value cannot be one of the default endpoint (EModelEndpoint) values: ${Object.values( |
| | EModelEndpoint, |
| | ).join(', ')}`, |
| | }), |
| | apiKey: z.string(), |
| | baseURL: z.string(), |
| | models: z.object({ |
| | default: z.array(modelItemSchema).min(1), |
| | fetch: z.boolean().optional(), |
| | userIdQuery: z.boolean().optional(), |
| | }), |
| | summarize: z.boolean().optional(), |
| | summaryModel: z.string().optional(), |
| | iconURL: z.string().optional(), |
| | forcePrompt: z.boolean().optional(), |
| | modelDisplayLabel: z.string().optional(), |
| | headers: z.record(z.any()).optional(), |
| | addParams: z.record(z.any()).optional(), |
| | dropParams: z.array(z.string()).optional(), |
| | customParams: z |
| | .object({ |
| | defaultParamsEndpoint: z.string().default('custom'), |
| | paramDefinitions: z.array(z.record(z.any())).optional(), |
| | }) |
| | .strict(), |
| | customOrder: z.number().optional(), |
| | directEndpoint: z.boolean().optional(), |
| | titleMessageRole: z.string().optional(), |
| | }), |
| | ); |
| |
|
| | export type TEndpoint = z.infer<typeof endpointSchema>; |
| |
|
| | export const azureEndpointSchema = z |
| | .object({ |
| | groups: azureGroupConfigsSchema, |
| | plugins: z.boolean().optional(), |
| | assistants: z.boolean().optional(), |
| | }) |
| | .and( |
| | endpointSchema |
| | .pick({ |
| | streamRate: true, |
| | titleConvo: true, |
| | titleMethod: true, |
| | titleModel: true, |
| | titlePrompt: true, |
| | titlePromptTemplate: true, |
| | summarize: true, |
| | summaryModel: true, |
| | customOrder: true, |
| | }) |
| | .partial(), |
| | ); |
| |
|
| | export type TAzureConfig = Omit<z.infer<typeof azureEndpointSchema>, 'groups'> & |
| | TAzureConfigValidationResult; |
| |
|
| | const ttsOpenaiSchema = z.object({ |
| | url: z.string().optional(), |
| | apiKey: z.string(), |
| | model: z.string(), |
| | voices: z.array(z.string()), |
| | }); |
| |
|
| | const ttsAzureOpenAISchema = z.object({ |
| | instanceName: z.string(), |
| | apiKey: z.string(), |
| | deploymentName: z.string(), |
| | apiVersion: z.string(), |
| | model: z.string(), |
| | voices: z.array(z.string()), |
| | }); |
| |
|
| | const ttsElevenLabsSchema = z.object({ |
| | url: z.string().optional(), |
| | websocketUrl: z.string().optional(), |
| | apiKey: z.string(), |
| | model: z.string(), |
| | voices: z.array(z.string()), |
| | voice_settings: z |
| | .object({ |
| | similarity_boost: z.number().optional(), |
| | stability: z.number().optional(), |
| | style: z.number().optional(), |
| | use_speaker_boost: z.boolean().optional(), |
| | }) |
| | .optional(), |
| | pronunciation_dictionary_locators: z.array(z.string()).optional(), |
| | }); |
| |
|
| | const ttsLocalaiSchema = z.object({ |
| | url: z.string(), |
| | apiKey: z.string().optional(), |
| | voices: z.array(z.string()), |
| | backend: z.string(), |
| | }); |
| |
|
| | const ttsSchema = z.object({ |
| | openai: ttsOpenaiSchema.optional(), |
| | azureOpenAI: ttsAzureOpenAISchema.optional(), |
| | elevenlabs: ttsElevenLabsSchema.optional(), |
| | localai: ttsLocalaiSchema.optional(), |
| | }); |
| |
|
| | const sttOpenaiSchema = z.object({ |
| | url: z.string().optional(), |
| | apiKey: z.string(), |
| | model: z.string(), |
| | }); |
| |
|
| | const sttAzureOpenAISchema = z.object({ |
| | instanceName: z.string(), |
| | apiKey: z.string(), |
| | deploymentName: z.string(), |
| | apiVersion: z.string(), |
| | }); |
| |
|
| | const sttSchema = z.object({ |
| | openai: sttOpenaiSchema.optional(), |
| | azureOpenAI: sttAzureOpenAISchema.optional(), |
| | }); |
| |
|
| | const speechTab = z |
| | .object({ |
| | conversationMode: z.boolean().optional(), |
| | advancedMode: z.boolean().optional(), |
| | speechToText: z |
| | .boolean() |
| | .optional() |
| | .or( |
| | z.object({ |
| | engineSTT: z.string().optional(), |
| | languageSTT: z.string().optional(), |
| | autoTranscribeAudio: z.boolean().optional(), |
| | decibelValue: z.number().optional(), |
| | autoSendText: z.number().optional(), |
| | }), |
| | ) |
| | .optional(), |
| | textToSpeech: z |
| | .boolean() |
| | .optional() |
| | .or( |
| | z.object({ |
| | engineTTS: z.string().optional(), |
| | voice: z.string().optional(), |
| | languageTTS: z.string().optional(), |
| | automaticPlayback: z.boolean().optional(), |
| | playbackRate: z.number().optional(), |
| | cacheTTS: z.boolean().optional(), |
| | }), |
| | ) |
| | .optional(), |
| | }) |
| | .optional(); |
| |
|
| | export enum RateLimitPrefix { |
| | FILE_UPLOAD = 'FILE_UPLOAD', |
| | IMPORT = 'IMPORT', |
| | TTS = 'TTS', |
| | STT = 'STT', |
| | } |
| |
|
| | export const rateLimitSchema = z.object({ |
| | fileUploads: z |
| | .object({ |
| | ipMax: z.number().optional(), |
| | ipWindowInMinutes: z.number().optional(), |
| | userMax: z.number().optional(), |
| | userWindowInMinutes: z.number().optional(), |
| | }) |
| | .optional(), |
| | conversationsImport: z |
| | .object({ |
| | ipMax: z.number().optional(), |
| | ipWindowInMinutes: z.number().optional(), |
| | userMax: z.number().optional(), |
| | userWindowInMinutes: z.number().optional(), |
| | }) |
| | .optional(), |
| | tts: z |
| | .object({ |
| | ipMax: z.number().optional(), |
| | ipWindowInMinutes: z.number().optional(), |
| | userMax: z.number().optional(), |
| | userWindowInMinutes: z.number().optional(), |
| | }) |
| | .optional(), |
| | stt: z |
| | .object({ |
| | ipMax: z.number().optional(), |
| | ipWindowInMinutes: z.number().optional(), |
| | userMax: z.number().optional(), |
| | userWindowInMinutes: z.number().optional(), |
| | }) |
| | .optional(), |
| | }); |
| |
|
| | export enum EImageOutputType { |
| | PNG = 'png', |
| | WEBP = 'webp', |
| | JPEG = 'jpeg', |
| | } |
| |
|
| | const termsOfServiceSchema = z.object({ |
| | externalUrl: z.string().optional(), |
| | openNewTab: z.boolean().optional(), |
| | modalAcceptance: z.boolean().optional(), |
| | modalTitle: z.string().optional(), |
| | modalContent: z.string().or(z.array(z.string())).optional(), |
| | }); |
| |
|
| | export type TTermsOfService = z.infer<typeof termsOfServiceSchema>; |
| |
|
| | const mcpServersSchema = z.object({ |
| | placeholder: z.string().optional(), |
| | }); |
| |
|
| | export type TMcpServersConfig = z.infer<typeof mcpServersSchema>; |
| |
|
| | export const interfaceSchema = z |
| | .object({ |
| | privacyPolicy: z |
| | .object({ |
| | externalUrl: z.string().optional(), |
| | openNewTab: z.boolean().optional(), |
| | }) |
| | .optional(), |
| | termsOfService: termsOfServiceSchema.optional(), |
| | customWelcome: z.string().optional(), |
| | mcpServers: mcpServersSchema.optional(), |
| | endpointsMenu: z.boolean().optional(), |
| | modelSelect: z.boolean().optional(), |
| | parameters: z.boolean().optional(), |
| | sidePanel: z.boolean().optional(), |
| | multiConvo: z.boolean().optional(), |
| | bookmarks: z.boolean().optional(), |
| | memories: z.boolean().optional(), |
| | presets: z.boolean().optional(), |
| | prompts: z.boolean().optional(), |
| | agents: z.boolean().optional(), |
| | temporaryChat: z.boolean().optional(), |
| | temporaryChatRetention: z.number().min(1).max(8760).optional(), |
| | runCode: z.boolean().optional(), |
| | webSearch: z.boolean().optional(), |
| | peoplePicker: z |
| | .object({ |
| | users: z.boolean().optional(), |
| | groups: z.boolean().optional(), |
| | roles: z.boolean().optional(), |
| | }) |
| | .optional(), |
| | marketplace: z |
| | .object({ |
| | use: z.boolean().optional(), |
| | }) |
| | .optional(), |
| | fileSearch: z.boolean().optional(), |
| | fileCitations: z.boolean().optional(), |
| | }) |
| | .default({ |
| | endpointsMenu: true, |
| | modelSelect: true, |
| | parameters: true, |
| | sidePanel: true, |
| | presets: true, |
| | multiConvo: true, |
| | bookmarks: true, |
| | memories: true, |
| | prompts: true, |
| | agents: true, |
| | temporaryChat: true, |
| | runCode: true, |
| | webSearch: true, |
| | peoplePicker: { |
| | users: true, |
| | groups: true, |
| | roles: true, |
| | }, |
| | marketplace: { |
| | use: false, |
| | }, |
| | fileSearch: true, |
| | fileCitations: true, |
| | }); |
| |
|
| | export type TInterfaceConfig = z.infer<typeof interfaceSchema>; |
| | export type TBalanceConfig = z.infer<typeof balanceSchema>; |
| | export type TTransactionsConfig = z.infer<typeof transactionsSchema>; |
| |
|
| | export const turnstileOptionsSchema = z |
| | .object({ |
| | language: z.string().default('auto'), |
| | size: z.enum(['normal', 'compact', 'flexible', 'invisible']).default('normal'), |
| | }) |
| | .default({ |
| | language: 'auto', |
| | size: 'normal', |
| | }); |
| |
|
| | export const turnstileSchema = z.object({ |
| | siteKey: z.string(), |
| | options: turnstileOptionsSchema.optional(), |
| | }); |
| |
|
| | export type TTurnstileConfig = z.infer<typeof turnstileSchema>; |
| |
|
| | export type TStartupConfig = { |
| | appTitle: string; |
| | socialLogins?: string[]; |
| | interface?: TInterfaceConfig; |
| | turnstile?: TTurnstileConfig; |
| | balance?: TBalanceConfig; |
| | transactions?: TTransactionsConfig; |
| | discordLoginEnabled: boolean; |
| | facebookLoginEnabled: boolean; |
| | githubLoginEnabled: boolean; |
| | googleLoginEnabled: boolean; |
| | openidLoginEnabled: boolean; |
| | appleLoginEnabled: boolean; |
| | samlLoginEnabled: boolean; |
| | openidLabel: string; |
| | openidImageUrl: string; |
| | openidAutoRedirect: boolean; |
| | samlLabel: string; |
| | samlImageUrl: string; |
| | /** LDAP Auth Configuration */ |
| | ldap?: { |
| | |
| | enabled: boolean; |
| | |
| | username?: boolean; |
| | }; |
| | serverDomain: string; |
| | emailLoginEnabled: boolean; |
| | registrationEnabled: boolean; |
| | socialLoginEnabled: boolean; |
| | passwordResetEnabled: boolean; |
| | emailEnabled: boolean; |
| | showBirthdayIcon: boolean; |
| | helpAndFaqURL: string; |
| | customFooter?: string; |
| | modelSpecs?: TSpecsConfig; |
| | modelDescriptions?: Record<string, Record<string, string>>; |
| | sharedLinksEnabled: boolean; |
| | publicSharedLinksEnabled: boolean; |
| | analyticsGtmId?: string; |
| | instanceProjectId: string; |
| | bundlerURL?: string; |
| | staticBundlerURL?: string; |
| | sharePointFilePickerEnabled?: boolean; |
| | sharePointBaseUrl?: string; |
| | sharePointPickerGraphScope?: string; |
| | sharePointPickerSharePointScope?: string; |
| | openidReuseTokens?: boolean; |
| | minPasswordLength?: number; |
| | webSearch?: { |
| | searchProvider?: SearchProviders; |
| | scraperProvider?: ScraperProviders; |
| | rerankerType?: RerankerTypes; |
| | }; |
| | mcpServers?: Record< |
| | string, |
| | { |
| | customUserVars: Record< |
| | string, |
| | { |
| | title: string; |
| | description: string; |
| | } |
| | >; |
| | chatMenu?: boolean; |
| | isOAuth?: boolean; |
| | startup?: boolean; |
| | } |
| | >; |
| | mcpPlaceholder?: string; |
| | conversationImportMaxFileSize?: number; |
| | }; |
| |
|
| | export enum OCRStrategy { |
| | MISTRAL_OCR = 'mistral_ocr', |
| | CUSTOM_OCR = 'custom_ocr', |
| | AZURE_MISTRAL_OCR = 'azure_mistral_ocr', |
| | VERTEXAI_MISTRAL_OCR = 'vertexai_mistral_ocr', |
| | } |
| |
|
| | export enum SearchCategories { |
| | PROVIDERS = 'providers', |
| | SCRAPERS = 'scrapers', |
| | RERANKERS = 'rerankers', |
| | } |
| |
|
| | export enum SearchProviders { |
| | SERPER = 'serper', |
| | SEARXNG = 'searxng', |
| | } |
| |
|
| | export enum ScraperProviders { |
| | FIRECRAWL = 'firecrawl', |
| | SERPER = 'serper', |
| | } |
| |
|
| | export enum RerankerTypes { |
| | JINA = 'jina', |
| | COHERE = 'cohere', |
| | } |
| |
|
| | export enum SafeSearchTypes { |
| | OFF = 0, |
| | MODERATE = 1, |
| | STRICT = 2, |
| | } |
| |
|
| | export const webSearchSchema = z.object({ |
| | serperApiKey: z.string().optional().default('${SERPER_API_KEY}'), |
| | searxngInstanceUrl: z.string().optional().default('${SEARXNG_INSTANCE_URL}'), |
| | searxngApiKey: z.string().optional().default('${SEARXNG_API_KEY}'), |
| | firecrawlApiKey: z.string().optional().default('${FIRECRAWL_API_KEY}'), |
| | firecrawlApiUrl: z.string().optional().default('${FIRECRAWL_API_URL}'), |
| | firecrawlVersion: z.string().optional().default('${FIRECRAWL_VERSION}'), |
| | jinaApiKey: z.string().optional().default('${JINA_API_KEY}'), |
| | jinaApiUrl: z.string().optional().default('${JINA_API_URL}'), |
| | cohereApiKey: z.string().optional().default('${COHERE_API_KEY}'), |
| | searchProvider: z.nativeEnum(SearchProviders).optional(), |
| | scraperProvider: z.nativeEnum(ScraperProviders).optional(), |
| | rerankerType: z.nativeEnum(RerankerTypes).optional(), |
| | scraperTimeout: z.number().optional(), |
| | safeSearch: z.nativeEnum(SafeSearchTypes).default(SafeSearchTypes.MODERATE), |
| | firecrawlOptions: z |
| | .object({ |
| | formats: z.array(z.string()).optional(), |
| | includeTags: z.array(z.string()).optional(), |
| | excludeTags: z.array(z.string()).optional(), |
| | headers: z.record(z.string()).optional(), |
| | waitFor: z.number().optional(), |
| | timeout: z.number().optional(), |
| | maxAge: z.number().optional(), |
| | mobile: z.boolean().optional(), |
| | skipTlsVerification: z.boolean().optional(), |
| | blockAds: z.boolean().optional(), |
| | removeBase64Images: z.boolean().optional(), |
| | parsePDF: z.boolean().optional(), |
| | storeInCache: z.boolean().optional(), |
| | zeroDataRetention: z.boolean().optional(), |
| | location: z |
| | .object({ |
| | country: z.string().optional(), |
| | languages: z.array(z.string()).optional(), |
| | }) |
| | .optional(), |
| | onlyMainContent: z.boolean().optional(), |
| | changeTrackingOptions: z |
| | .object({ |
| | modes: z.array(z.string()).optional(), |
| | schema: z.record(z.unknown()).optional(), |
| | prompt: z.string().optional(), |
| | tag: z.string().nullable().optional(), |
| | }) |
| | .optional(), |
| | }) |
| | .optional(), |
| | }); |
| |
|
| | export type TWebSearchConfig = DeepPartial<z.infer<typeof webSearchSchema>>; |
| |
|
| | export const ocrSchema = z.object({ |
| | mistralModel: z.string().optional(), |
| | apiKey: z.string().optional().default('${OCR_API_KEY}'), |
| | baseURL: z.string().optional().default('${OCR_BASEURL}'), |
| | strategy: z.nativeEnum(OCRStrategy).default(OCRStrategy.MISTRAL_OCR), |
| | }); |
| |
|
| | export const balanceSchema = z.object({ |
| | enabled: z.boolean().optional().default(false), |
| | startBalance: z.number().optional().default(20000), |
| | autoRefillEnabled: z.boolean().optional().default(false), |
| | refillIntervalValue: z.number().optional().default(30), |
| | refillIntervalUnit: z |
| | .enum(['seconds', 'minutes', 'hours', 'days', 'weeks', 'months']) |
| | .optional() |
| | .default('days'), |
| | refillAmount: z.number().optional().default(10000), |
| | }); |
| |
|
| | export const transactionsSchema = z.object({ |
| | enabled: z.boolean().optional().default(true), |
| | }); |
| |
|
| | export const memorySchema = z.object({ |
| | disabled: z.boolean().optional(), |
| | validKeys: z.array(z.string()).optional(), |
| | tokenLimit: z.number().optional(), |
| | charLimit: z.number().optional().default(10000), |
| | personalize: z.boolean().default(true), |
| | messageWindowSize: z.number().optional().default(5), |
| | agent: z |
| | .union([ |
| | z.object({ |
| | id: z.string(), |
| | }), |
| | z.object({ |
| | provider: z.string(), |
| | model: z.string(), |
| | instructions: z.string().optional(), |
| | model_parameters: z.record(z.any()).optional(), |
| | }), |
| | ]) |
| | .optional(), |
| | }); |
| |
|
| | export type TMemoryConfig = DeepPartial<z.infer<typeof memorySchema>>; |
| |
|
| | const customEndpointsSchema = z.array(endpointSchema.partial()).optional(); |
| |
|
| | export const configSchema = z.object({ |
| | version: z.string(), |
| | cache: z.boolean().default(true), |
| | ocr: ocrSchema.optional(), |
| | webSearch: webSearchSchema.optional(), |
| | memory: memorySchema.optional(), |
| | secureImageLinks: z.boolean().optional(), |
| | imageOutputType: z.nativeEnum(EImageOutputType).default(EImageOutputType.PNG), |
| | includedTools: z.array(z.string()).optional(), |
| | filteredTools: z.array(z.string()).optional(), |
| | mcpServers: MCPServersSchema.optional(), |
| | interface: interfaceSchema, |
| | turnstile: turnstileSchema.optional(), |
| | fileStrategy: fileSourceSchema.default(FileSources.local), |
| | fileStrategies: fileStrategiesSchema, |
| | actions: z |
| | .object({ |
| | allowedDomains: z.array(z.string()).optional(), |
| | }) |
| | .optional(), |
| | registration: z |
| | .object({ |
| | socialLogins: z.array(z.string()).optional(), |
| | allowedDomains: z.array(z.string()).optional(), |
| | }) |
| | .default({ socialLogins: defaultSocialLogins }), |
| | balance: balanceSchema.optional(), |
| | transactions: transactionsSchema.optional(), |
| | speech: z |
| | .object({ |
| | tts: ttsSchema.optional(), |
| | stt: sttSchema.optional(), |
| | speechTab: speechTab.optional(), |
| | }) |
| | .optional(), |
| | rateLimits: rateLimitSchema.optional(), |
| | fileConfig: fileConfigSchema.optional(), |
| | modelSpecs: specsConfigSchema.optional(), |
| | endpoints: z |
| | .object({ |
| | all: baseEndpointSchema.optional(), |
| | [EModelEndpoint.openAI]: baseEndpointSchema.optional(), |
| | [EModelEndpoint.google]: baseEndpointSchema.optional(), |
| | [EModelEndpoint.anthropic]: baseEndpointSchema.optional(), |
| | [EModelEndpoint.gptPlugins]: baseEndpointSchema.optional(), |
| | [EModelEndpoint.azureOpenAI]: azureEndpointSchema.optional(), |
| | [EModelEndpoint.azureAssistants]: assistantEndpointSchema.optional(), |
| | [EModelEndpoint.assistants]: assistantEndpointSchema.optional(), |
| | [EModelEndpoint.agents]: agentsEndpointSchema.optional(), |
| | [EModelEndpoint.custom]: customEndpointsSchema.optional(), |
| | [EModelEndpoint.bedrock]: baseEndpointSchema.optional(), |
| | }) |
| | .strict() |
| | .refine((data) => Object.keys(data).length > 0, { |
| | message: 'At least one `endpoints` field must be provided.', |
| | }) |
| | .optional(), |
| | }); |
| |
|
| | |
| | |
| | |
| | |
| | export type DeepPartial<T> = T extends (infer U)[] |
| | ? DeepPartial<U>[] |
| | : T extends ReadonlyArray<infer U> |
| | ? ReadonlyArray<DeepPartial<U>> |
| | : |
| | T extends Function |
| | ? T |
| | : T extends Date |
| | ? T |
| | : T extends object |
| | ? { |
| | [P in keyof T]?: DeepPartial<T[P]>; |
| | } |
| | : T; |
| |
|
| | export const getConfigDefaults = () => getSchemaDefaults(configSchema); |
| | export type TCustomConfig = DeepPartial<z.infer<typeof configSchema>>; |
| | export type TCustomEndpoints = z.infer<typeof customEndpointsSchema>; |
| |
|
| | export type TProviderSchema = |
| | | z.infer<typeof ttsOpenaiSchema> |
| | | z.infer<typeof ttsElevenLabsSchema> |
| | | z.infer<typeof ttsLocalaiSchema> |
| | | undefined; |
| |
|
| | export enum KnownEndpoints { |
| | anyscale = 'anyscale', |
| | apipie = 'apipie', |
| | cohere = 'cohere', |
| | fireworks = 'fireworks', |
| | deepseek = 'deepseek', |
| | groq = 'groq', |
| | helicone = 'helicone', |
| | huggingface = 'huggingface', |
| | mistral = 'mistral', |
| | mlx = 'mlx', |
| | ollama = 'ollama', |
| | openrouter = 'openrouter', |
| | perplexity = 'perplexity', |
| | shuttleai = 'shuttleai', |
| | 'together.ai' = 'together.ai', |
| | unify = 'unify', |
| | vercel = 'vercel', |
| | xai = 'xai', |
| | } |
| |
|
| | export enum FetchTokenConfig { |
| | openrouter = KnownEndpoints.openrouter, |
| | helicone = KnownEndpoints.helicone, |
| | } |
| |
|
| | export const defaultEndpoints: EModelEndpoint[] = [ |
| | EModelEndpoint.openAI, |
| | EModelEndpoint.assistants, |
| | EModelEndpoint.azureAssistants, |
| | EModelEndpoint.azureOpenAI, |
| | EModelEndpoint.agents, |
| | EModelEndpoint.chatGPTBrowser, |
| | EModelEndpoint.gptPlugins, |
| | EModelEndpoint.google, |
| | EModelEndpoint.anthropic, |
| | EModelEndpoint.custom, |
| | EModelEndpoint.bedrock, |
| | ]; |
| |
|
| | export const alternateName = { |
| | [EModelEndpoint.openAI]: 'OpenAI', |
| | [EModelEndpoint.assistants]: 'Assistants', |
| | [EModelEndpoint.agents]: 'My Agents', |
| | [EModelEndpoint.azureAssistants]: 'Azure Assistants', |
| | [EModelEndpoint.azureOpenAI]: 'Azure OpenAI', |
| | [EModelEndpoint.chatGPTBrowser]: 'ChatGPT', |
| | [EModelEndpoint.gptPlugins]: 'Plugins', |
| | [EModelEndpoint.google]: 'Google', |
| | [EModelEndpoint.anthropic]: 'Anthropic', |
| | [EModelEndpoint.custom]: 'Custom', |
| | [EModelEndpoint.bedrock]: 'AWS Bedrock', |
| | [KnownEndpoints.ollama]: 'Ollama', |
| | [KnownEndpoints.deepseek]: 'DeepSeek', |
| | [KnownEndpoints.xai]: 'xAI', |
| | [KnownEndpoints.vercel]: 'Vercel', |
| | [KnownEndpoints.helicone]: 'Helicone', |
| | }; |
| |
|
| | const sharedOpenAIModels = [ |
| | 'gpt-5.1', |
| | 'gpt-5.1-chat-latest', |
| | 'gpt-5.1-codex', |
| | 'gpt-5.1-codex-mini', |
| | 'gpt-5', |
| | 'gpt-5-mini', |
| | 'gpt-5-nano', |
| | 'gpt-5-chat-latest', |
| | 'gpt-4.1', |
| | 'gpt-4.1-mini', |
| | 'gpt-4.1-nano', |
| | 'gpt-4o-mini', |
| | 'gpt-4o', |
| | 'gpt-4.5-preview', |
| | 'gpt-4.5-preview-2025-02-27', |
| | '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', |
| | ]; |
| |
|
| | const sharedAnthropicModels = [ |
| | 'claude-sonnet-4-5', |
| | 'claude-sonnet-4-5-20250929', |
| | 'claude-haiku-4-5', |
| | 'claude-haiku-4-5-20251001', |
| | 'claude-opus-4-1', |
| | 'claude-opus-4-1-20250805', |
| | 'claude-opus-4-5', |
| | 'claude-sonnet-4-20250514', |
| | 'claude-sonnet-4-0', |
| | 'claude-opus-4-20250514', |
| | 'claude-opus-4-0', |
| | 'claude-3-7-sonnet-latest', |
| | 'claude-3-7-sonnet-20250219', |
| | 'claude-3-5-haiku-20241022', |
| | 'claude-3-5-sonnet-20241022', |
| | 'claude-3-5-sonnet-20240620', |
| | 'claude-3-5-sonnet-latest', |
| | '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', |
| | ]; |
| |
|
| | export const bedrockModels = [ |
| | 'anthropic.claude-sonnet-4-5-20250929-v1:0', |
| | 'anthropic.claude-haiku-4-5-20251001-v1:0', |
| | 'anthropic.claude-opus-4-1-20250805-v1:0', |
| | 'anthropic.claude-3-5-sonnet-20241022-v2:0', |
| | 'anthropic.claude-3-5-sonnet-20240620-v1:0', |
| | 'anthropic.claude-3-5-haiku-20241022-v1:0', |
| | 'anthropic.claude-3-haiku-20240307-v1:0', |
| | 'anthropic.claude-3-opus-20240229-v1:0', |
| | 'anthropic.claude-3-sonnet-20240229-v1:0', |
| | 'anthropic.claude-v2', |
| | 'anthropic.claude-v2:1', |
| | 'anthropic.claude-instant-v1', |
| | |
| | |
| | 'cohere.command-r-v1:0', |
| | 'cohere.command-r-plus-v1:0', |
| | 'meta.llama2-13b-chat-v1', |
| | 'meta.llama2-70b-chat-v1', |
| | 'meta.llama3-8b-instruct-v1:0', |
| | 'meta.llama3-70b-instruct-v1:0', |
| | 'meta.llama3-1-8b-instruct-v1:0', |
| | 'meta.llama3-1-70b-instruct-v1:0', |
| | 'meta.llama3-1-405b-instruct-v1:0', |
| | 'mistral.mistral-7b-instruct-v0:2', |
| | 'mistral.mixtral-8x7b-instruct-v0:1', |
| | 'mistral.mistral-large-2402-v1:0', |
| | 'mistral.mistral-large-2407-v1:0', |
| | 'mistral.mistral-small-2402-v1:0', |
| | 'ai21.jamba-instruct-v1:0', |
| | |
| | |
| | 'amazon.titan-text-lite-v1', |
| | 'amazon.titan-text-express-v1', |
| | 'amazon.titan-text-premier-v1:0', |
| | ]; |
| |
|
| | export const defaultModels = { |
| | [EModelEndpoint.azureAssistants]: sharedOpenAIModels, |
| | [EModelEndpoint.assistants]: [...sharedOpenAIModels, 'chatgpt-4o-latest'], |
| | [EModelEndpoint.agents]: sharedOpenAIModels, |
| | [EModelEndpoint.google]: [ |
| | |
| | 'gemini-2.5-pro', |
| | 'gemini-2.5-flash', |
| | 'gemini-2.5-flash-lite', |
| | |
| | 'gemini-2.0-flash-001', |
| | 'gemini-2.0-flash-lite', |
| | ], |
| | [EModelEndpoint.anthropic]: sharedAnthropicModels, |
| | [EModelEndpoint.openAI]: [ |
| | ...sharedOpenAIModels, |
| | 'chatgpt-4o-latest', |
| | 'gpt-4-vision-preview', |
| | 'gpt-3.5-turbo-instruct-0914', |
| | 'gpt-3.5-turbo-instruct', |
| | ], |
| | [EModelEndpoint.bedrock]: bedrockModels, |
| | }; |
| |
|
| | const fitlerAssistantModels = (str: string) => { |
| | return /gpt-4|gpt-3\\.5/i.test(str) && !/vision|instruct/i.test(str); |
| | }; |
| |
|
| | const openAIModels = defaultModels[EModelEndpoint.openAI]; |
| |
|
| | export const initialModelsConfig: TModelsConfig = { |
| | initial: [], |
| | [EModelEndpoint.openAI]: openAIModels, |
| | [EModelEndpoint.assistants]: openAIModels.filter(fitlerAssistantModels), |
| | [EModelEndpoint.agents]: openAIModels, |
| | [EModelEndpoint.gptPlugins]: openAIModels, |
| | [EModelEndpoint.azureOpenAI]: openAIModels, |
| | [EModelEndpoint.chatGPTBrowser]: ['text-davinci-002-render-sha'], |
| | [EModelEndpoint.google]: defaultModels[EModelEndpoint.google], |
| | [EModelEndpoint.anthropic]: defaultModels[EModelEndpoint.anthropic], |
| | [EModelEndpoint.bedrock]: defaultModels[EModelEndpoint.bedrock], |
| | }; |
| |
|
| | export const EndpointURLs = { |
| | [EModelEndpoint.assistants]: `${apiBaseUrl()}/api/assistants/v2/chat`, |
| | [EModelEndpoint.azureAssistants]: `${apiBaseUrl()}/api/assistants/v1/chat`, |
| | [EModelEndpoint.agents]: `${apiBaseUrl()}/api/${EModelEndpoint.agents}/chat`, |
| | } as const; |
| |
|
| | export const modularEndpoints = new Set<EModelEndpoint | string>([ |
| | EModelEndpoint.gptPlugins, |
| | EModelEndpoint.anthropic, |
| | EModelEndpoint.google, |
| | EModelEndpoint.openAI, |
| | EModelEndpoint.azureOpenAI, |
| | EModelEndpoint.custom, |
| | EModelEndpoint.agents, |
| | EModelEndpoint.bedrock, |
| | ]); |
| |
|
| | export const supportsBalanceCheck = { |
| | [EModelEndpoint.custom]: true, |
| | [EModelEndpoint.openAI]: true, |
| | [EModelEndpoint.anthropic]: true, |
| | [EModelEndpoint.gptPlugins]: true, |
| | [EModelEndpoint.assistants]: true, |
| | [EModelEndpoint.agents]: true, |
| | [EModelEndpoint.azureAssistants]: true, |
| | [EModelEndpoint.azureOpenAI]: true, |
| | [EModelEndpoint.bedrock]: true, |
| | [EModelEndpoint.google]: true, |
| | }; |
| |
|
| | export const visionModels = [ |
| | 'qwen-vl', |
| | 'grok-vision', |
| | 'grok-2-vision', |
| | 'grok-3', |
| | 'gpt-4o-mini', |
| | 'gpt-4o', |
| | 'gpt-4-turbo', |
| | 'gpt-4-vision', |
| | 'o4-mini', |
| | 'o3', |
| | 'o1', |
| | 'gpt-4.1', |
| | 'gpt-4.5', |
| | 'llava', |
| | 'llava-13b', |
| | 'gemini-pro-vision', |
| | 'claude-3', |
| | 'gemma', |
| | 'gemini-exp', |
| | 'gemini-1.5', |
| | 'gemini-2', |
| | 'gemini-2.5', |
| | 'gemini-3', |
| | 'moondream', |
| | 'llama3.2-vision', |
| | 'llama-3.2-11b-vision', |
| | 'llama-3-2-11b-vision', |
| | 'llama-3.2-90b-vision', |
| | 'llama-3-2-90b-vision', |
| | 'llama-4', |
| | 'claude-opus-4', |
| | 'claude-sonnet-4', |
| | 'claude-haiku-4', |
| | ]; |
| | export enum VisionModes { |
| | generative = 'generative', |
| | agents = 'agents', |
| | } |
| |
|
| | export function validateVisionModel({ |
| | model, |
| | additionalModels = [], |
| | availableModels, |
| | }: { |
| | model: string; |
| | additionalModels?: string[]; |
| | availableModels?: string[]; |
| | }) { |
| | if (!model) { |
| | return false; |
| | } |
| |
|
| | if (model.includes('gpt-4-turbo-preview') || model.includes('o1-mini')) { |
| | return false; |
| | } |
| |
|
| | if (availableModels && !availableModels.includes(model)) { |
| | return false; |
| | } |
| |
|
| | return visionModels.concat(additionalModels).some((visionModel) => model.includes(visionModel)); |
| | } |
| |
|
| | export const imageGenTools = new Set(['dalle', 'dall-e', 'stable-diffusion', 'flux']); |
| |
|
| | |
| | |
| | |
| | export enum InfiniteCollections { |
| | |
| | |
| | |
| | PROMPT_GROUPS = 'promptGroups', |
| | |
| | |
| | |
| | SHARED_LINKS = 'sharedLinks', |
| | } |
| |
|
| | |
| | |
| | |
| | export enum Time { |
| | ONE_DAY = 86400000, |
| | ONE_HOUR = 3600000, |
| | THIRTY_MINUTES = 1800000, |
| | TEN_MINUTES = 600000, |
| | FIVE_MINUTES = 300000, |
| | THREE_MINUTES = 180000, |
| | TWO_MINUTES = 120000, |
| | ONE_MINUTE = 60000, |
| | THIRTY_SECONDS = 30000, |
| | } |
| |
|
| | |
| | |
| | |
| | export enum CacheKeys { |
| | |
| | |
| | |
| | CONFIG_STORE = 'CONFIG_STORE', |
| | |
| | |
| | |
| | ROLES = 'ROLES', |
| | |
| | |
| | |
| | PLUGINS = 'PLUGINS', |
| | |
| | |
| | |
| | GEN_TITLE = 'GEN_TITLE', |
| | |
| | |
| | |
| | TOOLS = 'TOOLS', |
| | |
| | |
| | |
| | MODELS_CONFIG = 'MODELS_CONFIG', |
| | |
| | |
| | |
| | MODEL_QUERIES = 'MODEL_QUERIES', |
| | |
| | |
| | |
| | STARTUP_CONFIG = 'STARTUP_CONFIG', |
| | |
| | |
| | |
| | ENDPOINT_CONFIG = 'ENDPOINT_CONFIG', |
| | |
| | |
| | |
| | TOKEN_CONFIG = 'TOKEN_CONFIG', |
| | |
| | |
| | |
| | APP_CONFIG = 'APP_CONFIG', |
| | |
| | |
| | |
| | ABORT_KEYS = 'ABORT_KEYS', |
| | |
| | |
| | |
| | BANS = 'BANS', |
| | |
| | |
| | |
| | |
| | ENCODED_DOMAINS = 'ENCODED_DOMAINS', |
| | |
| | |
| | |
| | AUDIO_RUNS = 'AUDIO_RUNS', |
| | |
| | |
| | |
| | MESSAGES = 'MESSAGES', |
| | |
| | |
| | |
| | FLOWS = 'FLOWS', |
| | |
| | |
| | |
| | PENDING_REQ = 'PENDING_REQ', |
| | |
| | |
| | |
| | S3_EXPIRY_INTERVAL = 'S3_EXPIRY_INTERVAL', |
| | |
| | |
| | |
| | OPENID_EXCHANGED_TOKENS = 'OPENID_EXCHANGED_TOKENS', |
| | |
| | |
| | |
| | OPENID_SESSION = 'OPENID_SESSION', |
| | |
| | |
| | |
| | SAML_SESSION = 'SAML_SESSION', |
| | } |
| |
|
| | |
| | |
| | |
| | export enum ViolationTypes { |
| | |
| | |
| | |
| | FILE_UPLOAD_LIMIT = 'file_upload_limit', |
| | |
| | |
| | |
| | ILLEGAL_MODEL_REQUEST = 'illegal_model_request', |
| | |
| | |
| | |
| | TOKEN_BALANCE = 'token_balance', |
| | |
| | |
| | |
| | BAN = 'ban', |
| | |
| | |
| | |
| | TTS_LIMIT = 'tts_limit', |
| | |
| | |
| | |
| | STT_LIMIT = 'stt_limit', |
| | |
| | |
| | |
| | RESET_PASSWORD_LIMIT = 'reset_password_limit', |
| | |
| | |
| | |
| | VERIFY_EMAIL_LIMIT = 'verify_email_limit', |
| | |
| | |
| | |
| | CONVO_ACCESS = 'convo_access', |
| | |
| | |
| | |
| | TOOL_CALL_LIMIT = 'tool_call_limit', |
| | |
| | |
| | |
| | GENERAL = 'general', |
| | |
| | |
| | |
| | LOGINS = 'logins', |
| | |
| | |
| | |
| | CONCURRENT = 'concurrent', |
| | |
| | |
| | |
| | NON_BROWSER = 'non_browser', |
| | |
| | |
| | |
| | MESSAGE_LIMIT = 'message_limit', |
| | |
| | |
| | |
| | REGISTRATIONS = 'registrations', |
| | } |
| |
|
| | |
| | |
| | |
| | export enum ErrorTypes { |
| | |
| | |
| | |
| | NO_USER_KEY = 'no_user_key', |
| | |
| | |
| | |
| | EXPIRED_USER_KEY = 'expired_user_key', |
| | |
| | |
| | |
| | INVALID_USER_KEY = 'invalid_user_key', |
| | |
| | |
| | |
| | NO_BASE_URL = 'no_base_url', |
| | |
| | |
| | |
| | MODERATION = 'moderation', |
| | |
| | |
| | |
| | INPUT_LENGTH = 'INPUT_LENGTH', |
| | |
| | |
| | |
| | INVALID_REQUEST = 'invalid_request_error', |
| | |
| | |
| | |
| | INVALID_ACTION = 'invalid_action_error', |
| | |
| | |
| | |
| | NO_SYSTEM_MESSAGES = 'no_system_messages', |
| | |
| | |
| | |
| | GOOGLE_ERROR = 'google_error', |
| | |
| | |
| | |
| | GOOGLE_TOOL_CONFLICT = 'google_tool_conflict', |
| | |
| | |
| | |
| | INVALID_AGENT_PROVIDER = 'invalid_agent_provider', |
| | |
| | |
| | |
| | MISSING_MODEL = 'missing_model', |
| | |
| | |
| | |
| | MODELS_NOT_LOADED = 'models_not_loaded', |
| | |
| | |
| | |
| | ENDPOINT_MODELS_NOT_LOADED = 'endpoint_models_not_loaded', |
| | |
| | |
| | |
| | AUTH_FAILED = 'auth_failed', |
| | |
| | |
| | |
| | REFUSAL = 'refusal', |
| | } |
| |
|
| | |
| | |
| | |
| | export enum AuthKeys { |
| | |
| | |
| | |
| | GOOGLE_SERVICE_KEY = 'GOOGLE_SERVICE_KEY', |
| | |
| | |
| | |
| | |
| | |
| | GOOGLE_API_KEY = 'GOOGLE_API_KEY', |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | export enum ImageDetailCost { |
| | |
| | |
| | |
| | LOW = 85, |
| | |
| | |
| | |
| | HIGH = 170, |
| | |
| | |
| | |
| | |
| | ADDITIONAL = 85, |
| | } |
| |
|
| | |
| | |
| | |
| | export enum SettingsTabValues { |
| | |
| | |
| | |
| | GENERAL = 'general', |
| | |
| | |
| | |
| | CHAT = 'chat', |
| | |
| | |
| | |
| | SPEECH = 'speech', |
| | |
| | |
| | |
| | BETA = 'beta', |
| | |
| | |
| | |
| | DATA = 'data', |
| | |
| | |
| | |
| | BALANCE = 'balance', |
| | |
| | |
| | |
| | ACCOUNT = 'account', |
| | |
| | |
| | |
| | COMMANDS = 'commands', |
| | |
| | |
| | |
| | PERSONALIZATION = 'personalization', |
| | } |
| |
|
| | export enum STTProviders { |
| | |
| | |
| | |
| | OPENAI = 'openai', |
| | |
| | |
| | |
| | AZURE_OPENAI = 'azureOpenAI', |
| | } |
| |
|
| | export enum TTSProviders { |
| | |
| | |
| | |
| | OPENAI = 'openai', |
| | |
| | |
| | |
| | AZURE_OPENAI = 'azureOpenAI', |
| | |
| | |
| | |
| | ELEVENLABS = 'elevenlabs', |
| | |
| | |
| | |
| | LOCALAI = 'localai', |
| | } |
| |
|
| | |
| | export enum Constants { |
| | |
| | VERSION = 'v0.8.1', |
| | |
| | CONFIG_VERSION = '1.3.1', |
| | |
| | NO_PARENT = '00000000-0000-0000-0000-000000000000', |
| | |
| | USE_PRELIM_RESPONSE_MESSAGE_ID = 'USE_PRELIM_RESPONSE_MESSAGE_ID', |
| | |
| | NEW_CONVO = 'new', |
| | |
| | PENDING_CONVO = 'PENDING', |
| | |
| | SEARCH = 'search', |
| | |
| | ENCODED_DOMAIN_LENGTH = 10, |
| | |
| | CURRENT_MODEL = 'current_model', |
| | |
| | COMMON_DIVIDER = '__', |
| | |
| | COMMANDS_MAX_LENGTH = 56, |
| | |
| | DEFAULT_STREAM_RATE = 1, |
| | |
| | SAVED_TAG = 'Saved', |
| | |
| | MAX_CONVO_STARTERS = 4, |
| | |
| | GLOBAL_PROJECT_NAME = 'instance', |
| | |
| | mcp_delimiter = '_mcp_', |
| | |
| | mcp_prefix = 'mcp_', |
| | |
| | mcp_all = 'sys__all__sys', |
| | |
| | mcp_clear = 'sys__clear__sys', |
| | |
| | |
| | |
| | |
| | mcp_server = 'sys__server__sys', |
| | |
| | |
| | |
| | LC_TRANSFER_TO_ = 'lc_transfer_to_', |
| | |
| | EPHEMERAL_AGENT_ID = 'ephemeral', |
| | } |
| |
|
| | export enum LocalStorageKeys { |
| | |
| | APP_TITLE = 'appTitle', |
| | |
| | LAST_CONVO_SETUP = 'lastConversationSetup', |
| | |
| | LAST_MODEL = 'lastSelectedModel', |
| | |
| | LAST_TOOLS = 'lastSelectedTools', |
| | |
| | LAST_SPEC = 'lastSelectedSpec', |
| | |
| | FILES_TO_DELETE = 'filesToDelete', |
| | |
| | ASST_ID_PREFIX = 'assistant_id__', |
| | |
| | AGENT_ID_PREFIX = 'agent_id__', |
| | |
| | FORK_SETTING = 'forkSetting', |
| | |
| | REMEMBER_FORK_OPTION = 'rememberDefaultFork', |
| | |
| | FORK_SPLIT_AT_TARGET = 'splitAtTarget', |
| | |
| | TEXT_DRAFT = 'textDraft_', |
| | |
| | FILES_DRAFT = 'filesDraft_', |
| | |
| | LAST_PROMPT_CATEGORY = 'lastPromptCategory', |
| | |
| | ENABLE_USER_MSG_MARKDOWN = 'enableUserMsgMarkdown', |
| | |
| | SHOW_ANALYSIS_CODE = 'showAnalysisCode', |
| | |
| | LAST_MCP_ = 'LAST_MCP_', |
| | |
| | LAST_CODE_TOGGLE_ = 'LAST_CODE_TOGGLE_', |
| | |
| | LAST_WEB_SEARCH_TOGGLE_ = 'LAST_WEB_SEARCH_TOGGLE_', |
| | |
| | LAST_FILE_SEARCH_TOGGLE_ = 'LAST_FILE_SEARCH_TOGGLE_', |
| | |
| | LAST_ARTIFACTS_TOGGLE_ = 'LAST_ARTIFACTS_TOGGLE_', |
| | |
| | LAST_AGENT_PROVIDER = 'lastAgentProvider', |
| | |
| | LAST_AGENT_MODEL = 'lastAgentModel', |
| | |
| | PIN_MCP_ = 'PIN_MCP_', |
| | |
| | PIN_WEB_SEARCH_ = 'PIN_WEB_SEARCH_', |
| | |
| | PIN_CODE_INTERPRETER_ = 'PIN_CODE_INTERPRETER_', |
| | } |
| |
|
| | export enum ForkOptions { |
| | |
| | DIRECT_PATH = 'directPath', |
| | |
| | INCLUDE_BRANCHES = 'includeBranches', |
| | |
| | TARGET_LEVEL = 'targetLevel', |
| | |
| | DEFAULT = 'default', |
| | } |
| |
|
| | |
| | |
| | |
| | export enum CohereConstants { |
| | |
| | |
| | |
| | API_URL = 'https://api.cohere.ai/v1', |
| | |
| | |
| | |
| | ROLE_USER = 'USER', |
| | |
| | |
| | |
| | ROLE_SYSTEM = 'SYSTEM', |
| | |
| | |
| | |
| | ROLE_CHATBOT = 'CHATBOT', |
| | |
| | |
| | |
| | TITLE_MESSAGE = 'TITLE:', |
| | } |
| |
|
| | export enum SystemCategories { |
| | ALL = 'sys__all__sys', |
| | MY_PROMPTS = 'sys__my__prompts__sys', |
| | NO_CATEGORY = 'sys__no__category__sys', |
| | SHARED_PROMPTS = 'sys__shared__prompts__sys', |
| | } |
| |
|
| | export const providerEndpointMap = { |
| | [EModelEndpoint.openAI]: EModelEndpoint.openAI, |
| | [EModelEndpoint.bedrock]: EModelEndpoint.bedrock, |
| | [EModelEndpoint.anthropic]: EModelEndpoint.anthropic, |
| | [EModelEndpoint.azureOpenAI]: EModelEndpoint.azureOpenAI, |
| | }; |
| |
|
| | export const specialVariables = { |
| | current_date: true, |
| | current_user: true, |
| | iso_datetime: true, |
| | current_datetime: true, |
| | }; |
| |
|
| | export type TSpecialVarLabel = `com_ui_special_var_${keyof typeof specialVariables}`; |
| |
|
| | |
| | |
| | |
| | |
| | export function getEndpointField< |
| | K extends TConfig[keyof TConfig] extends never ? never : keyof TConfig, |
| | >( |
| | endpointsConfig: TEndpointsConfig | undefined | null, |
| | endpoint: EModelEndpoint | string | null | undefined, |
| | property: K, |
| | ): TConfig[K] | undefined { |
| | if (!endpointsConfig || endpoint === null || endpoint === undefined) { |
| | return undefined; |
| | } |
| | const config = endpointsConfig[endpoint]; |
| | if (!config) { |
| | return undefined; |
| | } |
| | return config[property]; |
| | } |
| |
|