Merge branch 'main' into feat/multi-lang-Terms-of-service

This commit is contained in:
Ruben Talstra 2025-03-19 13:30:26 +01:00 committed by GitHub
commit b170a57482
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
107 changed files with 3274 additions and 765 deletions

View file

@ -168,6 +168,8 @@ export enum AgentCapabilities {
artifacts = 'artifacts',
actions = 'actions',
tools = 'tools',
chain = 'chain',
ocr = 'ocr',
}
export const defaultAssistantsVersion = {
@ -233,6 +235,7 @@ export const agentsEndpointSChema = baseEndpointSchema.merge(
/* agents specific */
recursionLimit: z.number().optional(),
disableBuilder: z.boolean().optional(),
maxRecursionLimit: z.number().optional(),
capabilities: z
.array(z.nativeEnum(AgentCapabilities))
.optional()
@ -242,6 +245,8 @@ export const agentsEndpointSChema = baseEndpointSchema.merge(
AgentCapabilities.artifacts,
AgentCapabilities.actions,
AgentCapabilities.tools,
AgentCapabilities.ocr,
AgentCapabilities.chain,
]),
}),
);
@ -533,9 +538,22 @@ export type TStartupConfig = {
bundlerURL?: string;
};
export enum OCRStrategy {
MISTRAL_OCR = 'mistral_ocr',
CUSTOM_OCR = 'custom_ocr',
}
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 configSchema = z.object({
version: z.string(),
cache: z.boolean().default(true),
ocr: ocrSchema.optional(),
secureImageLinks: z.boolean().optional(),
imageOutputType: z.nativeEnum(EImageOutputType).default(EImageOutputType.PNG),
includedTools: z.array(z.string()).optional(),
@ -811,28 +829,29 @@ export const supportsBalanceCheck = {
};
export const visionModels = [
'grok-3',
'grok-2-vision',
'qwen-vl',
'grok-vision',
'gpt-4.5',
'gpt-4o',
'grok-2-vision',
'grok-3',
'gpt-4o-mini',
'o1',
'gpt-4o',
'gpt-4-turbo',
'gpt-4-vision',
'o1',
'gpt-4.5',
'llava',
'llava-13b',
'gemini-pro-vision',
'claude-3',
'gemini-2.0',
'gemini-1.5',
'gemini-exp',
'gemini-1.5',
'gemini-2.0',
'moondream',
'llama3.2-vision',
'llama-3.2-90b-vision',
'llama-3.2-11b-vision',
'llama-3-2-90b-vision',
'llama-3-2-11b-vision',
'llama-3.2-90b-vision',
'llama-3-2-90b-vision',
];
export enum VisionModes {
generative = 'generative',
@ -1174,7 +1193,7 @@ export enum Constants {
/** Key for the app's version. */
VERSION = 'v0.7.7',
/** Key for the Custom Config's version (librechat.yaml). */
CONFIG_VERSION = '1.2.1',
CONFIG_VERSION = '1.2.3',
/** Standard value for the first message's `parentMessageId` value, to indicate no parent exists. */
NO_PARENT = '00000000-0000-0000-0000-000000000000',
/** Standard value for the initial conversationId before a request is sent */

View file

@ -7,6 +7,7 @@ export * from './file-config';
export * from './artifacts';
/* schema helpers */
export * from './parsers';
export * from './ocr';
export * from './zod';
/* custom/dynamic configurations */
export * from './generate';

View file

@ -4,6 +4,7 @@ import { extractEnvVariable } from './utils';
const BaseOptionsSchema = z.object({
iconPath: z.string().optional(),
timeout: z.number().optional(),
initTimeout: z.number().optional(),
});
export const StdioOptionsSchema = BaseOptionsSchema.extend({
@ -85,3 +86,26 @@ export const MCPOptionsSchema = z.union([
]);
export const MCPServersSchema = z.record(z.string(), MCPOptionsSchema);
export type MCPOptions = z.infer<typeof MCPOptionsSchema>;
/**
* Recursively processes an object to replace environment variables in string values
* @param {MCPOptions} obj - The object to process
* @returns {MCPOptions} - The processed object with environment variables replaced
*/
export function processMCPEnv(obj: MCPOptions): MCPOptions {
if (obj === null || obj === undefined) {
return obj;
}
if ('env' in obj && obj.env) {
const processedEnv: Record<string, string> = {};
for (const [key, value] of Object.entries(obj.env)) {
processedEnv[key] = extractEnvVariable(value);
}
obj.env = processedEnv;
}
return obj;
}

View file

@ -0,0 +1,14 @@
import type { TCustomConfig } from '../src/config';
import { OCRStrategy } from '../src/config';
export function loadOCRConfig(config: TCustomConfig['ocr']): TCustomConfig['ocr'] {
const baseURL = config?.baseURL ?? '';
const apiKey = config?.apiKey ?? '';
const mistralModel = config?.mistralModel ?? '';
return {
apiKey,
baseURL,
mistralModel,
strategy: config?.strategy ?? OCRStrategy.MISTRAL_OCR,
};
}

View file

@ -47,6 +47,7 @@ export enum BedrockProviders {
Meta = 'meta',
MistralAI = 'mistral',
StabilityAI = 'stability',
DeepSeek = 'deepseek',
}
export const getModelKey = (endpoint: EModelEndpoint | string, model: string) => {
@ -157,6 +158,7 @@ export const defaultAgentFormValues = {
projectIds: [],
artifacts: '',
isCollaborative: false,
recursion_limit: undefined,
[Tools.execute_code]: false,
[Tools.file_search]: false,
};
@ -1152,7 +1154,6 @@ export const compactAgentsSchema = tConversationSchema
iconURL: true,
greeting: true,
agent_id: true,
resendFiles: true,
instructions: true,
additional_instructions: true,
})

View file

@ -19,6 +19,15 @@ export namespace Agents {
tool_call_ids?: string[];
};
export type AgentUpdate = {
type: ContentTypes.AGENT_UPDATE;
agent_update: {
index: number;
runId: string;
agentId: string;
};
};
export type MessageContentImageUrl = {
type: ContentTypes.IMAGE_URL;
image_url: string | { url: string; detail?: ImageDetail };
@ -26,6 +35,7 @@ export namespace Agents {
export type MessageContentComplex =
| ReasoningContentText
| AgentUpdate
| MessageContentText
| MessageContentImageUrl
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@ -159,12 +169,7 @@ export namespace Agents {
index: number; // #new
stepIndex?: number; // #new
stepDetails: StepDetails;
usage: null | {
// Define usage structure if it's ever non-null
// prompt_tokens: number; // #new
// completion_tokens: number; // #new
// total_tokens: number; // #new
};
usage: null | object;
};
/**
* Represents a run step delta i.e. any changed fields on a run step during

View file

@ -27,6 +27,7 @@ export enum EToolResources {
code_interpreter = 'code_interpreter',
execute_code = 'execute_code',
file_search = 'file_search',
ocr = 'ocr',
}
export type Tool = {
@ -163,7 +164,8 @@ export type AgentModelParameters = {
export interface AgentToolResources {
execute_code?: ExecuteCodeResource;
file_search?: AgentFileSearchResource;
file_search?: AgentFileResource;
ocr?: Omit<AgentFileResource, 'vector_store_ids'>;
}
export interface ExecuteCodeResource {
/**
@ -177,7 +179,7 @@ export interface ExecuteCodeResource {
files?: Array<TFile>;
}
export interface AgentFileSearchResource {
export interface AgentFileResource {
/**
* The ID of the vector store attached to this agent. There
* can be a maximum of 1 vector store attached to the agent.
@ -220,6 +222,7 @@ export type Agent = {
end_after_tools?: boolean;
hide_sequential_outputs?: boolean;
artifacts?: ArtifactModes;
recursion_limit?: number;
};
export type TAgentsMap = Record<string, Agent | undefined>;
@ -234,7 +237,10 @@ export type AgentCreateParams = {
provider: AgentProvider;
model: string | null;
model_parameters: AgentModelParameters;
} & Pick<Agent, 'agent_ids' | 'end_after_tools' | 'hide_sequential_outputs' | 'artifacts'>;
} & Pick<
Agent,
'agent_ids' | 'end_after_tools' | 'hide_sequential_outputs' | 'artifacts' | 'recursion_limit'
>;
export type AgentUpdateParams = {
name?: string | null;
@ -250,7 +256,10 @@ export type AgentUpdateParams = {
projectIds?: string[];
removeProjectIds?: string[];
isCollaborative?: boolean;
} & Pick<Agent, 'agent_ids' | 'end_after_tools' | 'hide_sequential_outputs' | 'artifacts'>;
} & Pick<
Agent,
'agent_ids' | 'end_after_tools' | 'hide_sequential_outputs' | 'artifacts' | 'recursion_limit'
>;
export type AgentListParams = {
limit?: number;
@ -453,6 +462,7 @@ export type TMessageContentParts =
PartMetadata;
}
| { type: ContentTypes.IMAGE_FILE; image_file: ImageFile & PartMetadata }
| Agents.AgentUpdate
| Agents.MessageContentImageUrl;
export type StreamContentData = TMessageContentParts & {

View file

@ -8,6 +8,8 @@ export enum FileSources {
s3 = 's3',
vectordb = 'vectordb',
execute_code = 'execute_code',
mistral_ocr = 'mistral_ocr',
text = 'text',
}
export const checkOpenAIStorage = (source: string) =>

View file

@ -5,6 +5,7 @@ export enum ContentTypes {
TOOL_CALL = 'tool_call',
IMAGE_FILE = 'image_file',
IMAGE_URL = 'image_url',
AGENT_UPDATE = 'agent_update',
ERROR = 'error',
}