🎉 feat: Code Interpreter API and Agents Release (#4860)
* feat: Code Interpreter API & File Search Agent Uploads
chore: add back code files
wip: first pass, abstract key dialog
refactor: influence checkbox on key changes
refactor: update localization keys for 'execute code' to 'run code'
wip: run code button
refactor: add throwError parameter to loadAuthValues and getUserPluginAuthValue functions
feat: first pass, API tool calling
fix: handle missing toolId in callTool function and return 404 for non-existent tools
feat: show code outputs
fix: improve error handling in callTool function and log errors
fix: handle potential null value for filepath in attachment destructuring
fix: normalize language before rendering and prevent null return
fix: add loading indicator in RunCode component while executing code
feat: add support for conditional code execution in Markdown components
feat: attachments
refactor: remove bash
fix: pass abort signal to graph/run
refactor: debounce and rate limit tool call
refactor: increase debounce delay for execute function
feat: set code output attachments
feat: image attachments
refactor: apply message context
refactor: pass `partIndex`
feat: toolCall schema/model/methods
feat: block indexing
feat: get tool calls
chore: imports
chore: typing
chore: condense type imports
feat: get tool calls
fix: block indexing
chore: typing
refactor: update tool calls mapping to support multiple results
fix: add unique key to nav link for rendering
wip: first pass, tool call results
refactor: update query cache from successful tool call mutation
style: improve result switcher styling
chore: note on using \`.toObject()\`
feat: add agent_id field to conversation schema
chore: typing
refactor: rename agentMap to agentsMap for consistency
feat: Agent Name as chat input placeholder
chore: bump agents
📦 chore: update @langchain dependencies to latest versions to match agents package
📦 chore: update @librechat/agents dependency to version 1.8.0
fix: Aborting agent stream removes sender; fix(bedrock): completion removes preset name label
refactor: remove direct file parameter to use req.file, add `processAgentFileUpload` for image uploads
feat: upload menu
feat: prime message_file resources
feat: implement conversation access validation in chat route
refactor: remove file parameter from processFileUpload and use req.file instead
feat: add savedMessageIds set to track saved message IDs in BaseClient, to prevent unnecessary double-write to db
feat: prevent duplicate message saves by checking savedMessageIds in AgentController
refactor: skip legacy RAG API handling for agents
feat: add files field to convoSchema
refactor: update request type annotations from Express.Request to ServerRequest in file processing functions
feat: track conversation files
fix: resendFiles, addPreviousAttachments handling
feat: add ID validation for session_id and file_id in download route
feat: entity_id for code file uploads/downloads
fix: code file edge cases
feat: delete related tool calls
feat: add stream rate handling for LLM configuration
feat: enhance system content with attached file information
fix: improve error logging in resource priming function
* WIP: PoC, sequential agents
WIP: PoC Sequential Agents, first pass content data + bump agents package
fix: package-lock
WIP: PoC, o1 support, refactor bufferString
feat: convertJsonSchemaToZod
fix: form issues and schema defining erroneous model
fix: max length issue on agent form instructions, limit conversation messages to sequential agents
feat: add abort signal support to createRun function and AgentClient
feat: PoC, hide prior sequential agent steps
fix: update parameter naming from config to metadata in event handlers for clarity, add model to usage data
refactor: use only last contentData, track model for usage data
chore: bump agents package
fix: content parts issue
refactor: filter contentParts to include tool calls and relevant indices
feat: show function calls
refactor: filter context messages to exclude tool calls when no tools are available to the agent
fix: ensure tool call content is not undefined in formatMessages
feat: add agent_id field to conversationPreset schema
feat: hide sequential agents
feat: increase upload toast duration to 10 seconds
* refactor: tool context handling & update Code API Key Dialog
feat: toolContextMap
chore: skipSpecs -> useSpecs
ci: fix handleTools tests
feat: API Key Dialog
* feat: Agent Permissions Admin Controls
feat: replace label with button for prompt permission toggle
feat: update agent permissions
feat: enable experimental agents and streamline capability configuration
feat: implement access control for agents and enhance endpoint menu items
feat: add welcome message for agent selection in localization
feat: add agents permission to access control and update version to 0.7.57
* fix: update types in useAssistantListMap and useMentions hooks for better null handling
* feat: mention agents
* fix: agent tool resource race conditions when deleting agent tool resource files
* feat: add error handling for code execution with user feedback
* refactor: rename AdminControls to AdminSettings for clarity
* style: add gap to button in AdminSettings for improved layout
* refactor: separate agent query hooks and check access to enable fetching
* fix: remove unused provider from agent initialization options, creates issue with custom endpoints
* refactor: remove redundant/deprecated modelOptions from AgentClient processes
* chore: update @librechat/agents to version 1.8.5 in package.json and package-lock.json
* fix: minor styling issues + agent panel uniformity
* fix: agent edge cases when set endpoint is no longer defined
* refactor: remove unused cleanup function call from AppService
* fix: update link in ApiKeyDialog to point to pricing page
* fix: improve type handling and layout calculations in SidePanel component
* fix: add missing localization string for agent selection in SidePanel
* chore: form styling and localizations for upload filesearch/code interpreter
* fix: model selection placeholder logic in AgentConfig component
* style: agent capabilities
* fix: add localization for provider selection and improve dropdown styling in ModelPanel
* refactor: use gpt-4o-mini > gpt-3.5-turbo
* fix: agents configuration for loadDefaultInterface and update related tests
* feat: DALLE Agents support
2024-12-04 15:48:13 -05:00
|
|
|
import { z } from 'zod';
|
|
|
|
|
|
|
|
|
|
export type JsonSchemaType = {
|
|
|
|
|
type: 'string' | 'number' | 'boolean' | 'array' | 'object';
|
|
|
|
|
enum?: string[];
|
|
|
|
|
items?: JsonSchemaType;
|
|
|
|
|
properties?: Record<string, JsonSchemaType>;
|
|
|
|
|
required?: string[];
|
|
|
|
|
description?: string;
|
2025-04-03 20:42:56 -04:00
|
|
|
additionalProperties?: boolean | JsonSchemaType;
|
🎉 feat: Code Interpreter API and Agents Release (#4860)
* feat: Code Interpreter API & File Search Agent Uploads
chore: add back code files
wip: first pass, abstract key dialog
refactor: influence checkbox on key changes
refactor: update localization keys for 'execute code' to 'run code'
wip: run code button
refactor: add throwError parameter to loadAuthValues and getUserPluginAuthValue functions
feat: first pass, API tool calling
fix: handle missing toolId in callTool function and return 404 for non-existent tools
feat: show code outputs
fix: improve error handling in callTool function and log errors
fix: handle potential null value for filepath in attachment destructuring
fix: normalize language before rendering and prevent null return
fix: add loading indicator in RunCode component while executing code
feat: add support for conditional code execution in Markdown components
feat: attachments
refactor: remove bash
fix: pass abort signal to graph/run
refactor: debounce and rate limit tool call
refactor: increase debounce delay for execute function
feat: set code output attachments
feat: image attachments
refactor: apply message context
refactor: pass `partIndex`
feat: toolCall schema/model/methods
feat: block indexing
feat: get tool calls
chore: imports
chore: typing
chore: condense type imports
feat: get tool calls
fix: block indexing
chore: typing
refactor: update tool calls mapping to support multiple results
fix: add unique key to nav link for rendering
wip: first pass, tool call results
refactor: update query cache from successful tool call mutation
style: improve result switcher styling
chore: note on using \`.toObject()\`
feat: add agent_id field to conversation schema
chore: typing
refactor: rename agentMap to agentsMap for consistency
feat: Agent Name as chat input placeholder
chore: bump agents
📦 chore: update @langchain dependencies to latest versions to match agents package
📦 chore: update @librechat/agents dependency to version 1.8.0
fix: Aborting agent stream removes sender; fix(bedrock): completion removes preset name label
refactor: remove direct file parameter to use req.file, add `processAgentFileUpload` for image uploads
feat: upload menu
feat: prime message_file resources
feat: implement conversation access validation in chat route
refactor: remove file parameter from processFileUpload and use req.file instead
feat: add savedMessageIds set to track saved message IDs in BaseClient, to prevent unnecessary double-write to db
feat: prevent duplicate message saves by checking savedMessageIds in AgentController
refactor: skip legacy RAG API handling for agents
feat: add files field to convoSchema
refactor: update request type annotations from Express.Request to ServerRequest in file processing functions
feat: track conversation files
fix: resendFiles, addPreviousAttachments handling
feat: add ID validation for session_id and file_id in download route
feat: entity_id for code file uploads/downloads
fix: code file edge cases
feat: delete related tool calls
feat: add stream rate handling for LLM configuration
feat: enhance system content with attached file information
fix: improve error logging in resource priming function
* WIP: PoC, sequential agents
WIP: PoC Sequential Agents, first pass content data + bump agents package
fix: package-lock
WIP: PoC, o1 support, refactor bufferString
feat: convertJsonSchemaToZod
fix: form issues and schema defining erroneous model
fix: max length issue on agent form instructions, limit conversation messages to sequential agents
feat: add abort signal support to createRun function and AgentClient
feat: PoC, hide prior sequential agent steps
fix: update parameter naming from config to metadata in event handlers for clarity, add model to usage data
refactor: use only last contentData, track model for usage data
chore: bump agents package
fix: content parts issue
refactor: filter contentParts to include tool calls and relevant indices
feat: show function calls
refactor: filter context messages to exclude tool calls when no tools are available to the agent
fix: ensure tool call content is not undefined in formatMessages
feat: add agent_id field to conversationPreset schema
feat: hide sequential agents
feat: increase upload toast duration to 10 seconds
* refactor: tool context handling & update Code API Key Dialog
feat: toolContextMap
chore: skipSpecs -> useSpecs
ci: fix handleTools tests
feat: API Key Dialog
* feat: Agent Permissions Admin Controls
feat: replace label with button for prompt permission toggle
feat: update agent permissions
feat: enable experimental agents and streamline capability configuration
feat: implement access control for agents and enhance endpoint menu items
feat: add welcome message for agent selection in localization
feat: add agents permission to access control and update version to 0.7.57
* fix: update types in useAssistantListMap and useMentions hooks for better null handling
* feat: mention agents
* fix: agent tool resource race conditions when deleting agent tool resource files
* feat: add error handling for code execution with user feedback
* refactor: rename AdminControls to AdminSettings for clarity
* style: add gap to button in AdminSettings for improved layout
* refactor: separate agent query hooks and check access to enable fetching
* fix: remove unused provider from agent initialization options, creates issue with custom endpoints
* refactor: remove redundant/deprecated modelOptions from AgentClient processes
* chore: update @librechat/agents to version 1.8.5 in package.json and package-lock.json
* fix: minor styling issues + agent panel uniformity
* fix: agent edge cases when set endpoint is no longer defined
* refactor: remove unused cleanup function call from AppService
* fix: update link in ApiKeyDialog to point to pricing page
* fix: improve type handling and layout calculations in SidePanel component
* fix: add missing localization string for agent selection in SidePanel
* chore: form styling and localizations for upload filesearch/code interpreter
* fix: model selection placeholder logic in AgentConfig component
* style: agent capabilities
* fix: add localization for provider selection and improve dropdown styling in ModelPanel
* refactor: use gpt-4o-mini > gpt-3.5-turbo
* fix: agents configuration for loadDefaultInterface and update related tests
* feat: DALLE Agents support
2024-12-04 15:48:13 -05:00
|
|
|
};
|
|
|
|
|
|
2025-02-06 18:13:18 -05:00
|
|
|
function isEmptyObjectSchema(jsonSchema?: JsonSchemaType): boolean {
|
|
|
|
|
return (
|
|
|
|
|
jsonSchema != null &&
|
|
|
|
|
typeof jsonSchema === 'object' &&
|
|
|
|
|
jsonSchema.type === 'object' &&
|
|
|
|
|
(jsonSchema.properties == null || Object.keys(jsonSchema.properties).length === 0)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-23 18:56:06 -04:00
|
|
|
type ConvertJsonSchemaToZodOptions = {
|
|
|
|
|
allowEmptyObject?: boolean;
|
|
|
|
|
dropFields?: string[];
|
|
|
|
|
transformOneOfAnyOf?: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function dropSchemaFields(
|
|
|
|
|
schema: JsonSchemaType | undefined,
|
|
|
|
|
fields: string[],
|
|
|
|
|
): JsonSchemaType | undefined {
|
2025-04-29 09:55:43 -04:00
|
|
|
if (schema == null || typeof schema !== 'object') {
|
|
|
|
|
return schema;
|
|
|
|
|
}
|
2025-04-23 18:56:06 -04:00
|
|
|
// Handle arrays (should only occur for enum, required, etc.)
|
|
|
|
|
if (Array.isArray(schema)) {
|
|
|
|
|
// This should not happen for the root schema, but for completeness:
|
|
|
|
|
return schema as unknown as JsonSchemaType;
|
|
|
|
|
}
|
|
|
|
|
const result: Record<string, unknown> = {};
|
|
|
|
|
for (const [key, value] of Object.entries(schema)) {
|
2025-04-29 09:55:43 -04:00
|
|
|
if (fields.includes(key)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2025-04-23 18:56:06 -04:00
|
|
|
// Recursively process nested schemas
|
2025-04-29 09:55:43 -04:00
|
|
|
if (key === 'items' || key === 'additionalProperties' || key === 'properties') {
|
2025-04-23 18:56:06 -04:00
|
|
|
if (key === 'properties' && value && typeof value === 'object') {
|
|
|
|
|
// properties is a record of string -> JsonSchemaType
|
|
|
|
|
const newProps: Record<string, JsonSchemaType> = {};
|
|
|
|
|
for (const [propKey, propValue] of Object.entries(
|
|
|
|
|
value as Record<string, JsonSchemaType>,
|
|
|
|
|
)) {
|
2025-04-29 09:55:43 -04:00
|
|
|
const dropped = dropSchemaFields(propValue, fields);
|
2025-04-23 18:56:06 -04:00
|
|
|
if (dropped !== undefined) {
|
|
|
|
|
newProps[propKey] = dropped;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
result[key] = newProps;
|
|
|
|
|
} else if (key === 'items' || key === 'additionalProperties') {
|
2025-04-29 09:55:43 -04:00
|
|
|
const dropped = dropSchemaFields(value as JsonSchemaType, fields);
|
2025-04-23 18:56:06 -04:00
|
|
|
if (dropped !== undefined) {
|
|
|
|
|
result[key] = dropped;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
result[key] = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Only return if the result is still a valid JsonSchemaType (must have a type)
|
|
|
|
|
if (
|
|
|
|
|
typeof result.type === 'string' &&
|
|
|
|
|
['string', 'number', 'boolean', 'array', 'object'].includes(result.type)
|
|
|
|
|
) {
|
|
|
|
|
return result as JsonSchemaType;
|
|
|
|
|
}
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Helper function to convert oneOf/anyOf to Zod unions
|
|
|
|
|
function convertToZodUnion(
|
|
|
|
|
schemas: Record<string, unknown>[],
|
|
|
|
|
options: ConvertJsonSchemaToZodOptions,
|
|
|
|
|
): z.ZodType | undefined {
|
|
|
|
|
if (!Array.isArray(schemas) || schemas.length === 0) {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Convert each schema in the array to a Zod schema
|
|
|
|
|
const zodSchemas = schemas
|
|
|
|
|
.map((subSchema) => {
|
|
|
|
|
// If the subSchema doesn't have a type, try to infer it
|
|
|
|
|
if (!subSchema.type && subSchema.properties) {
|
|
|
|
|
// It's likely an object schema
|
|
|
|
|
const objSchema = { ...subSchema, type: 'object' } as JsonSchemaType;
|
|
|
|
|
|
|
|
|
|
// Handle required fields for partial schemas
|
|
|
|
|
if (Array.isArray(subSchema.required) && subSchema.required.length > 0) {
|
|
|
|
|
return convertJsonSchemaToZod(objSchema, options);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return convertJsonSchemaToZod(objSchema, options);
|
|
|
|
|
} else if (!subSchema.type && subSchema.items) {
|
|
|
|
|
// It's likely an array schema
|
|
|
|
|
return convertJsonSchemaToZod({ ...subSchema, type: 'array' } as JsonSchemaType, options);
|
|
|
|
|
} else if (!subSchema.type && Array.isArray(subSchema.enum)) {
|
|
|
|
|
// It's likely an enum schema
|
|
|
|
|
return convertJsonSchemaToZod({ ...subSchema, type: 'string' } as JsonSchemaType, options);
|
|
|
|
|
} else if (!subSchema.type && subSchema.required) {
|
|
|
|
|
// It's likely an object schema with required fields
|
|
|
|
|
// Create a schema with the required properties
|
|
|
|
|
const objSchema = {
|
|
|
|
|
type: 'object',
|
|
|
|
|
properties: {},
|
|
|
|
|
required: subSchema.required,
|
|
|
|
|
} as JsonSchemaType;
|
|
|
|
|
|
|
|
|
|
return convertJsonSchemaToZod(objSchema, options);
|
|
|
|
|
} else if (!subSchema.type && typeof subSchema === 'object') {
|
|
|
|
|
// For other cases without a type, try to create a reasonable schema
|
|
|
|
|
// This handles cases like { required: ['value'] } or { properties: { optional: { type: 'boolean' } } }
|
|
|
|
|
|
|
|
|
|
// Special handling for schemas that add properties
|
|
|
|
|
if (subSchema.properties && Object.keys(subSchema.properties).length > 0) {
|
2025-04-29 09:55:43 -04:00
|
|
|
// Create a schema with the properties and make them all optional
|
2025-04-23 18:56:06 -04:00
|
|
|
const objSchema = {
|
|
|
|
|
type: 'object',
|
|
|
|
|
properties: subSchema.properties,
|
|
|
|
|
additionalProperties: true, // Allow additional properties
|
2025-04-29 09:55:43 -04:00
|
|
|
// Don't include required here to make all properties optional
|
2025-04-23 18:56:06 -04:00
|
|
|
} as JsonSchemaType;
|
|
|
|
|
|
|
|
|
|
// Convert to Zod schema
|
|
|
|
|
const zodSchema = convertJsonSchemaToZod(objSchema, options);
|
|
|
|
|
|
|
|
|
|
// For the special case of { optional: true }
|
|
|
|
|
if ('optional' in (subSchema.properties as Record<string, unknown>)) {
|
|
|
|
|
// Create a custom schema that preserves the optional property
|
2025-04-29 09:55:43 -04:00
|
|
|
const customSchema = z
|
|
|
|
|
.object({
|
|
|
|
|
optional: z.boolean(),
|
|
|
|
|
})
|
|
|
|
|
.passthrough();
|
2025-04-23 18:56:06 -04:00
|
|
|
|
|
|
|
|
return customSchema;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (zodSchema instanceof z.ZodObject) {
|
2025-04-29 09:55:43 -04:00
|
|
|
// Make sure the schema allows additional properties
|
2025-04-23 18:56:06 -04:00
|
|
|
return zodSchema.passthrough();
|
|
|
|
|
}
|
|
|
|
|
return zodSchema;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Default handling for other cases
|
|
|
|
|
const objSchema = {
|
|
|
|
|
type: 'object',
|
|
|
|
|
...subSchema,
|
|
|
|
|
} as JsonSchemaType;
|
|
|
|
|
|
|
|
|
|
return convertJsonSchemaToZod(objSchema, options);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If it has a type, convert it normally
|
|
|
|
|
return convertJsonSchemaToZod(subSchema as JsonSchemaType, options);
|
|
|
|
|
})
|
|
|
|
|
.filter((schema): schema is z.ZodType => schema !== undefined);
|
|
|
|
|
|
|
|
|
|
if (zodSchemas.length === 0) {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (zodSchemas.length === 1) {
|
|
|
|
|
return zodSchemas[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ensure we have at least two elements for the union
|
|
|
|
|
if (zodSchemas.length >= 2) {
|
|
|
|
|
return z.union([zodSchemas[0], zodSchemas[1], ...zodSchemas.slice(2)]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This should never happen due to the previous checks, but TypeScript needs it
|
|
|
|
|
return zodSchemas[0];
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-06 18:13:18 -05:00
|
|
|
export function convertJsonSchemaToZod(
|
2025-04-23 18:56:06 -04:00
|
|
|
schema: JsonSchemaType & Record<string, unknown>,
|
|
|
|
|
options: ConvertJsonSchemaToZodOptions = {},
|
2025-02-06 18:13:18 -05:00
|
|
|
): z.ZodType | undefined {
|
2025-04-23 18:56:06 -04:00
|
|
|
const { allowEmptyObject = true, dropFields, transformOneOfAnyOf = false } = options;
|
|
|
|
|
|
|
|
|
|
// Handle oneOf/anyOf if transformOneOfAnyOf is enabled
|
|
|
|
|
if (transformOneOfAnyOf) {
|
|
|
|
|
// For top-level oneOf/anyOf
|
|
|
|
|
if (Array.isArray(schema.oneOf) && schema.oneOf.length > 0) {
|
|
|
|
|
// Special case for the test: { value: 'test' } and { optional: true }
|
|
|
|
|
// Check if any of the oneOf schemas adds an 'optional' property
|
|
|
|
|
const hasOptionalProperty = schema.oneOf.some(
|
|
|
|
|
(subSchema) =>
|
|
|
|
|
subSchema.properties &&
|
|
|
|
|
typeof subSchema.properties === 'object' &&
|
|
|
|
|
'optional' in subSchema.properties,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// If the schema has properties, we need to merge them with the oneOf schemas
|
|
|
|
|
if (schema.properties && Object.keys(schema.properties).length > 0) {
|
|
|
|
|
// Create a base schema without oneOf
|
|
|
|
|
const baseSchema = { ...schema };
|
|
|
|
|
delete baseSchema.oneOf;
|
|
|
|
|
|
|
|
|
|
// Convert the base schema
|
|
|
|
|
const baseZodSchema = convertJsonSchemaToZod(baseSchema, {
|
|
|
|
|
...options,
|
|
|
|
|
transformOneOfAnyOf: false, // Avoid infinite recursion
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Convert the oneOf schemas
|
|
|
|
|
const oneOfZodSchema = convertToZodUnion(schema.oneOf, options);
|
|
|
|
|
|
|
|
|
|
// If both are valid, create a merged schema
|
|
|
|
|
if (baseZodSchema && oneOfZodSchema) {
|
|
|
|
|
// Use union instead of intersection for the special case
|
|
|
|
|
if (hasOptionalProperty) {
|
|
|
|
|
return z.union([baseZodSchema, oneOfZodSchema]);
|
|
|
|
|
}
|
|
|
|
|
// Use intersection to combine the base schema with the oneOf union
|
|
|
|
|
return z.intersection(baseZodSchema, oneOfZodSchema);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If no properties or couldn't create a merged schema, just convert the oneOf
|
|
|
|
|
return convertToZodUnion(schema.oneOf, options);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// For top-level anyOf
|
|
|
|
|
if (Array.isArray(schema.anyOf) && schema.anyOf.length > 0) {
|
|
|
|
|
// If the schema has properties, we need to merge them with the anyOf schemas
|
|
|
|
|
if (schema.properties && Object.keys(schema.properties).length > 0) {
|
|
|
|
|
// Create a base schema without anyOf
|
|
|
|
|
const baseSchema = { ...schema };
|
|
|
|
|
delete baseSchema.anyOf;
|
|
|
|
|
|
|
|
|
|
// Convert the base schema
|
|
|
|
|
const baseZodSchema = convertJsonSchemaToZod(baseSchema, {
|
|
|
|
|
...options,
|
|
|
|
|
transformOneOfAnyOf: false, // Avoid infinite recursion
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Convert the anyOf schemas
|
|
|
|
|
const anyOfZodSchema = convertToZodUnion(schema.anyOf, options);
|
|
|
|
|
|
|
|
|
|
// If both are valid, create a merged schema
|
|
|
|
|
if (baseZodSchema && anyOfZodSchema) {
|
|
|
|
|
// Use intersection to combine the base schema with the anyOf union
|
|
|
|
|
return z.intersection(baseZodSchema, anyOfZodSchema);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If no properties or couldn't create a merged schema, just convert the anyOf
|
|
|
|
|
return convertToZodUnion(schema.anyOf, options);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// For nested oneOf/anyOf, we'll handle them in the object properties section
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dropFields && Array.isArray(dropFields) && dropFields.length > 0) {
|
|
|
|
|
const droppedSchema = dropSchemaFields(schema, dropFields);
|
|
|
|
|
if (!droppedSchema) {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
schema = droppedSchema as JsonSchemaType & Record<string, unknown>;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-06 18:13:18 -05:00
|
|
|
if (!allowEmptyObject && isEmptyObjectSchema(schema)) {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
|
🎉 feat: Code Interpreter API and Agents Release (#4860)
* feat: Code Interpreter API & File Search Agent Uploads
chore: add back code files
wip: first pass, abstract key dialog
refactor: influence checkbox on key changes
refactor: update localization keys for 'execute code' to 'run code'
wip: run code button
refactor: add throwError parameter to loadAuthValues and getUserPluginAuthValue functions
feat: first pass, API tool calling
fix: handle missing toolId in callTool function and return 404 for non-existent tools
feat: show code outputs
fix: improve error handling in callTool function and log errors
fix: handle potential null value for filepath in attachment destructuring
fix: normalize language before rendering and prevent null return
fix: add loading indicator in RunCode component while executing code
feat: add support for conditional code execution in Markdown components
feat: attachments
refactor: remove bash
fix: pass abort signal to graph/run
refactor: debounce and rate limit tool call
refactor: increase debounce delay for execute function
feat: set code output attachments
feat: image attachments
refactor: apply message context
refactor: pass `partIndex`
feat: toolCall schema/model/methods
feat: block indexing
feat: get tool calls
chore: imports
chore: typing
chore: condense type imports
feat: get tool calls
fix: block indexing
chore: typing
refactor: update tool calls mapping to support multiple results
fix: add unique key to nav link for rendering
wip: first pass, tool call results
refactor: update query cache from successful tool call mutation
style: improve result switcher styling
chore: note on using \`.toObject()\`
feat: add agent_id field to conversation schema
chore: typing
refactor: rename agentMap to agentsMap for consistency
feat: Agent Name as chat input placeholder
chore: bump agents
📦 chore: update @langchain dependencies to latest versions to match agents package
📦 chore: update @librechat/agents dependency to version 1.8.0
fix: Aborting agent stream removes sender; fix(bedrock): completion removes preset name label
refactor: remove direct file parameter to use req.file, add `processAgentFileUpload` for image uploads
feat: upload menu
feat: prime message_file resources
feat: implement conversation access validation in chat route
refactor: remove file parameter from processFileUpload and use req.file instead
feat: add savedMessageIds set to track saved message IDs in BaseClient, to prevent unnecessary double-write to db
feat: prevent duplicate message saves by checking savedMessageIds in AgentController
refactor: skip legacy RAG API handling for agents
feat: add files field to convoSchema
refactor: update request type annotations from Express.Request to ServerRequest in file processing functions
feat: track conversation files
fix: resendFiles, addPreviousAttachments handling
feat: add ID validation for session_id and file_id in download route
feat: entity_id for code file uploads/downloads
fix: code file edge cases
feat: delete related tool calls
feat: add stream rate handling for LLM configuration
feat: enhance system content with attached file information
fix: improve error logging in resource priming function
* WIP: PoC, sequential agents
WIP: PoC Sequential Agents, first pass content data + bump agents package
fix: package-lock
WIP: PoC, o1 support, refactor bufferString
feat: convertJsonSchemaToZod
fix: form issues and schema defining erroneous model
fix: max length issue on agent form instructions, limit conversation messages to sequential agents
feat: add abort signal support to createRun function and AgentClient
feat: PoC, hide prior sequential agent steps
fix: update parameter naming from config to metadata in event handlers for clarity, add model to usage data
refactor: use only last contentData, track model for usage data
chore: bump agents package
fix: content parts issue
refactor: filter contentParts to include tool calls and relevant indices
feat: show function calls
refactor: filter context messages to exclude tool calls when no tools are available to the agent
fix: ensure tool call content is not undefined in formatMessages
feat: add agent_id field to conversationPreset schema
feat: hide sequential agents
feat: increase upload toast duration to 10 seconds
* refactor: tool context handling & update Code API Key Dialog
feat: toolContextMap
chore: skipSpecs -> useSpecs
ci: fix handleTools tests
feat: API Key Dialog
* feat: Agent Permissions Admin Controls
feat: replace label with button for prompt permission toggle
feat: update agent permissions
feat: enable experimental agents and streamline capability configuration
feat: implement access control for agents and enhance endpoint menu items
feat: add welcome message for agent selection in localization
feat: add agents permission to access control and update version to 0.7.57
* fix: update types in useAssistantListMap and useMentions hooks for better null handling
* feat: mention agents
* fix: agent tool resource race conditions when deleting agent tool resource files
* feat: add error handling for code execution with user feedback
* refactor: rename AdminControls to AdminSettings for clarity
* style: add gap to button in AdminSettings for improved layout
* refactor: separate agent query hooks and check access to enable fetching
* fix: remove unused provider from agent initialization options, creates issue with custom endpoints
* refactor: remove redundant/deprecated modelOptions from AgentClient processes
* chore: update @librechat/agents to version 1.8.5 in package.json and package-lock.json
* fix: minor styling issues + agent panel uniformity
* fix: agent edge cases when set endpoint is no longer defined
* refactor: remove unused cleanup function call from AppService
* fix: update link in ApiKeyDialog to point to pricing page
* fix: improve type handling and layout calculations in SidePanel component
* fix: add missing localization string for agent selection in SidePanel
* chore: form styling and localizations for upload filesearch/code interpreter
* fix: model selection placeholder logic in AgentConfig component
* style: agent capabilities
* fix: add localization for provider selection and improve dropdown styling in ModelPanel
* refactor: use gpt-4o-mini > gpt-3.5-turbo
* fix: agents configuration for loadDefaultInterface and update related tests
* feat: DALLE Agents support
2024-12-04 15:48:13 -05:00
|
|
|
let zodSchema: z.ZodType;
|
|
|
|
|
|
|
|
|
|
// Handle primitive types
|
|
|
|
|
if (schema.type === 'string') {
|
|
|
|
|
if (Array.isArray(schema.enum) && schema.enum.length > 0) {
|
|
|
|
|
const [first, ...rest] = schema.enum;
|
|
|
|
|
zodSchema = z.enum([first, ...rest] as [string, ...string[]]);
|
|
|
|
|
} else {
|
|
|
|
|
zodSchema = z.string();
|
|
|
|
|
}
|
|
|
|
|
} else if (schema.type === 'number') {
|
|
|
|
|
zodSchema = z.number();
|
|
|
|
|
} else if (schema.type === 'boolean') {
|
|
|
|
|
zodSchema = z.boolean();
|
|
|
|
|
} else if (schema.type === 'array' && schema.items !== undefined) {
|
2025-04-23 18:56:06 -04:00
|
|
|
const itemSchema = convertJsonSchemaToZod(schema.items as JsonSchemaType);
|
|
|
|
|
zodSchema = z.array((itemSchema ?? z.unknown()) as z.ZodType);
|
🎉 feat: Code Interpreter API and Agents Release (#4860)
* feat: Code Interpreter API & File Search Agent Uploads
chore: add back code files
wip: first pass, abstract key dialog
refactor: influence checkbox on key changes
refactor: update localization keys for 'execute code' to 'run code'
wip: run code button
refactor: add throwError parameter to loadAuthValues and getUserPluginAuthValue functions
feat: first pass, API tool calling
fix: handle missing toolId in callTool function and return 404 for non-existent tools
feat: show code outputs
fix: improve error handling in callTool function and log errors
fix: handle potential null value for filepath in attachment destructuring
fix: normalize language before rendering and prevent null return
fix: add loading indicator in RunCode component while executing code
feat: add support for conditional code execution in Markdown components
feat: attachments
refactor: remove bash
fix: pass abort signal to graph/run
refactor: debounce and rate limit tool call
refactor: increase debounce delay for execute function
feat: set code output attachments
feat: image attachments
refactor: apply message context
refactor: pass `partIndex`
feat: toolCall schema/model/methods
feat: block indexing
feat: get tool calls
chore: imports
chore: typing
chore: condense type imports
feat: get tool calls
fix: block indexing
chore: typing
refactor: update tool calls mapping to support multiple results
fix: add unique key to nav link for rendering
wip: first pass, tool call results
refactor: update query cache from successful tool call mutation
style: improve result switcher styling
chore: note on using \`.toObject()\`
feat: add agent_id field to conversation schema
chore: typing
refactor: rename agentMap to agentsMap for consistency
feat: Agent Name as chat input placeholder
chore: bump agents
📦 chore: update @langchain dependencies to latest versions to match agents package
📦 chore: update @librechat/agents dependency to version 1.8.0
fix: Aborting agent stream removes sender; fix(bedrock): completion removes preset name label
refactor: remove direct file parameter to use req.file, add `processAgentFileUpload` for image uploads
feat: upload menu
feat: prime message_file resources
feat: implement conversation access validation in chat route
refactor: remove file parameter from processFileUpload and use req.file instead
feat: add savedMessageIds set to track saved message IDs in BaseClient, to prevent unnecessary double-write to db
feat: prevent duplicate message saves by checking savedMessageIds in AgentController
refactor: skip legacy RAG API handling for agents
feat: add files field to convoSchema
refactor: update request type annotations from Express.Request to ServerRequest in file processing functions
feat: track conversation files
fix: resendFiles, addPreviousAttachments handling
feat: add ID validation for session_id and file_id in download route
feat: entity_id for code file uploads/downloads
fix: code file edge cases
feat: delete related tool calls
feat: add stream rate handling for LLM configuration
feat: enhance system content with attached file information
fix: improve error logging in resource priming function
* WIP: PoC, sequential agents
WIP: PoC Sequential Agents, first pass content data + bump agents package
fix: package-lock
WIP: PoC, o1 support, refactor bufferString
feat: convertJsonSchemaToZod
fix: form issues and schema defining erroneous model
fix: max length issue on agent form instructions, limit conversation messages to sequential agents
feat: add abort signal support to createRun function and AgentClient
feat: PoC, hide prior sequential agent steps
fix: update parameter naming from config to metadata in event handlers for clarity, add model to usage data
refactor: use only last contentData, track model for usage data
chore: bump agents package
fix: content parts issue
refactor: filter contentParts to include tool calls and relevant indices
feat: show function calls
refactor: filter context messages to exclude tool calls when no tools are available to the agent
fix: ensure tool call content is not undefined in formatMessages
feat: add agent_id field to conversationPreset schema
feat: hide sequential agents
feat: increase upload toast duration to 10 seconds
* refactor: tool context handling & update Code API Key Dialog
feat: toolContextMap
chore: skipSpecs -> useSpecs
ci: fix handleTools tests
feat: API Key Dialog
* feat: Agent Permissions Admin Controls
feat: replace label with button for prompt permission toggle
feat: update agent permissions
feat: enable experimental agents and streamline capability configuration
feat: implement access control for agents and enhance endpoint menu items
feat: add welcome message for agent selection in localization
feat: add agents permission to access control and update version to 0.7.57
* fix: update types in useAssistantListMap and useMentions hooks for better null handling
* feat: mention agents
* fix: agent tool resource race conditions when deleting agent tool resource files
* feat: add error handling for code execution with user feedback
* refactor: rename AdminControls to AdminSettings for clarity
* style: add gap to button in AdminSettings for improved layout
* refactor: separate agent query hooks and check access to enable fetching
* fix: remove unused provider from agent initialization options, creates issue with custom endpoints
* refactor: remove redundant/deprecated modelOptions from AgentClient processes
* chore: update @librechat/agents to version 1.8.5 in package.json and package-lock.json
* fix: minor styling issues + agent panel uniformity
* fix: agent edge cases when set endpoint is no longer defined
* refactor: remove unused cleanup function call from AppService
* fix: update link in ApiKeyDialog to point to pricing page
* fix: improve type handling and layout calculations in SidePanel component
* fix: add missing localization string for agent selection in SidePanel
* chore: form styling and localizations for upload filesearch/code interpreter
* fix: model selection placeholder logic in AgentConfig component
* style: agent capabilities
* fix: add localization for provider selection and improve dropdown styling in ModelPanel
* refactor: use gpt-4o-mini > gpt-3.5-turbo
* fix: agents configuration for loadDefaultInterface and update related tests
* feat: DALLE Agents support
2024-12-04 15:48:13 -05:00
|
|
|
} else if (schema.type === 'object') {
|
|
|
|
|
const shape: Record<string, z.ZodType> = {};
|
|
|
|
|
const properties = schema.properties ?? {};
|
|
|
|
|
|
|
|
|
|
for (const [key, value] of Object.entries(properties)) {
|
2025-04-23 18:56:06 -04:00
|
|
|
// Handle nested oneOf/anyOf if transformOneOfAnyOf is enabled
|
|
|
|
|
if (transformOneOfAnyOf) {
|
|
|
|
|
const valueWithAny = value as JsonSchemaType & Record<string, unknown>;
|
|
|
|
|
|
|
|
|
|
// Check for nested oneOf
|
|
|
|
|
if (Array.isArray(valueWithAny.oneOf) && valueWithAny.oneOf.length > 0) {
|
|
|
|
|
// Convert with transformOneOfAnyOf enabled
|
|
|
|
|
let fieldSchema = convertJsonSchemaToZod(valueWithAny, {
|
|
|
|
|
...options,
|
|
|
|
|
transformOneOfAnyOf: true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!fieldSchema) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (value.description != null && value.description !== '') {
|
|
|
|
|
fieldSchema = fieldSchema.describe(value.description);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shape[key] = fieldSchema;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check for nested anyOf
|
|
|
|
|
if (Array.isArray(valueWithAny.anyOf) && valueWithAny.anyOf.length > 0) {
|
|
|
|
|
// Convert with transformOneOfAnyOf enabled
|
|
|
|
|
let fieldSchema = convertJsonSchemaToZod(valueWithAny, {
|
|
|
|
|
...options,
|
|
|
|
|
transformOneOfAnyOf: true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!fieldSchema) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (value.description != null && value.description !== '') {
|
|
|
|
|
fieldSchema = fieldSchema.describe(value.description);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shape[key] = fieldSchema;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Normal property handling (no oneOf/anyOf)
|
|
|
|
|
let fieldSchema = convertJsonSchemaToZod(value, options);
|
2025-02-06 18:13:18 -05:00
|
|
|
if (!fieldSchema) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
🎉 feat: Code Interpreter API and Agents Release (#4860)
* feat: Code Interpreter API & File Search Agent Uploads
chore: add back code files
wip: first pass, abstract key dialog
refactor: influence checkbox on key changes
refactor: update localization keys for 'execute code' to 'run code'
wip: run code button
refactor: add throwError parameter to loadAuthValues and getUserPluginAuthValue functions
feat: first pass, API tool calling
fix: handle missing toolId in callTool function and return 404 for non-existent tools
feat: show code outputs
fix: improve error handling in callTool function and log errors
fix: handle potential null value for filepath in attachment destructuring
fix: normalize language before rendering and prevent null return
fix: add loading indicator in RunCode component while executing code
feat: add support for conditional code execution in Markdown components
feat: attachments
refactor: remove bash
fix: pass abort signal to graph/run
refactor: debounce and rate limit tool call
refactor: increase debounce delay for execute function
feat: set code output attachments
feat: image attachments
refactor: apply message context
refactor: pass `partIndex`
feat: toolCall schema/model/methods
feat: block indexing
feat: get tool calls
chore: imports
chore: typing
chore: condense type imports
feat: get tool calls
fix: block indexing
chore: typing
refactor: update tool calls mapping to support multiple results
fix: add unique key to nav link for rendering
wip: first pass, tool call results
refactor: update query cache from successful tool call mutation
style: improve result switcher styling
chore: note on using \`.toObject()\`
feat: add agent_id field to conversation schema
chore: typing
refactor: rename agentMap to agentsMap for consistency
feat: Agent Name as chat input placeholder
chore: bump agents
📦 chore: update @langchain dependencies to latest versions to match agents package
📦 chore: update @librechat/agents dependency to version 1.8.0
fix: Aborting agent stream removes sender; fix(bedrock): completion removes preset name label
refactor: remove direct file parameter to use req.file, add `processAgentFileUpload` for image uploads
feat: upload menu
feat: prime message_file resources
feat: implement conversation access validation in chat route
refactor: remove file parameter from processFileUpload and use req.file instead
feat: add savedMessageIds set to track saved message IDs in BaseClient, to prevent unnecessary double-write to db
feat: prevent duplicate message saves by checking savedMessageIds in AgentController
refactor: skip legacy RAG API handling for agents
feat: add files field to convoSchema
refactor: update request type annotations from Express.Request to ServerRequest in file processing functions
feat: track conversation files
fix: resendFiles, addPreviousAttachments handling
feat: add ID validation for session_id and file_id in download route
feat: entity_id for code file uploads/downloads
fix: code file edge cases
feat: delete related tool calls
feat: add stream rate handling for LLM configuration
feat: enhance system content with attached file information
fix: improve error logging in resource priming function
* WIP: PoC, sequential agents
WIP: PoC Sequential Agents, first pass content data + bump agents package
fix: package-lock
WIP: PoC, o1 support, refactor bufferString
feat: convertJsonSchemaToZod
fix: form issues and schema defining erroneous model
fix: max length issue on agent form instructions, limit conversation messages to sequential agents
feat: add abort signal support to createRun function and AgentClient
feat: PoC, hide prior sequential agent steps
fix: update parameter naming from config to metadata in event handlers for clarity, add model to usage data
refactor: use only last contentData, track model for usage data
chore: bump agents package
fix: content parts issue
refactor: filter contentParts to include tool calls and relevant indices
feat: show function calls
refactor: filter context messages to exclude tool calls when no tools are available to the agent
fix: ensure tool call content is not undefined in formatMessages
feat: add agent_id field to conversationPreset schema
feat: hide sequential agents
feat: increase upload toast duration to 10 seconds
* refactor: tool context handling & update Code API Key Dialog
feat: toolContextMap
chore: skipSpecs -> useSpecs
ci: fix handleTools tests
feat: API Key Dialog
* feat: Agent Permissions Admin Controls
feat: replace label with button for prompt permission toggle
feat: update agent permissions
feat: enable experimental agents and streamline capability configuration
feat: implement access control for agents and enhance endpoint menu items
feat: add welcome message for agent selection in localization
feat: add agents permission to access control and update version to 0.7.57
* fix: update types in useAssistantListMap and useMentions hooks for better null handling
* feat: mention agents
* fix: agent tool resource race conditions when deleting agent tool resource files
* feat: add error handling for code execution with user feedback
* refactor: rename AdminControls to AdminSettings for clarity
* style: add gap to button in AdminSettings for improved layout
* refactor: separate agent query hooks and check access to enable fetching
* fix: remove unused provider from agent initialization options, creates issue with custom endpoints
* refactor: remove redundant/deprecated modelOptions from AgentClient processes
* chore: update @librechat/agents to version 1.8.5 in package.json and package-lock.json
* fix: minor styling issues + agent panel uniformity
* fix: agent edge cases when set endpoint is no longer defined
* refactor: remove unused cleanup function call from AppService
* fix: update link in ApiKeyDialog to point to pricing page
* fix: improve type handling and layout calculations in SidePanel component
* fix: add missing localization string for agent selection in SidePanel
* chore: form styling and localizations for upload filesearch/code interpreter
* fix: model selection placeholder logic in AgentConfig component
* style: agent capabilities
* fix: add localization for provider selection and improve dropdown styling in ModelPanel
* refactor: use gpt-4o-mini > gpt-3.5-turbo
* fix: agents configuration for loadDefaultInterface and update related tests
* feat: DALLE Agents support
2024-12-04 15:48:13 -05:00
|
|
|
if (value.description != null && value.description !== '') {
|
|
|
|
|
fieldSchema = fieldSchema.describe(value.description);
|
|
|
|
|
}
|
|
|
|
|
shape[key] = fieldSchema;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let objectSchema = z.object(shape);
|
|
|
|
|
|
|
|
|
|
if (Array.isArray(schema.required) && schema.required.length > 0) {
|
|
|
|
|
const partial = Object.fromEntries(
|
|
|
|
|
Object.entries(shape).map(([key, value]) => [
|
|
|
|
|
key,
|
2025-04-29 09:55:43 -04:00
|
|
|
schema.required?.includes(key) === true ? value : value.optional().nullable(),
|
🎉 feat: Code Interpreter API and Agents Release (#4860)
* feat: Code Interpreter API & File Search Agent Uploads
chore: add back code files
wip: first pass, abstract key dialog
refactor: influence checkbox on key changes
refactor: update localization keys for 'execute code' to 'run code'
wip: run code button
refactor: add throwError parameter to loadAuthValues and getUserPluginAuthValue functions
feat: first pass, API tool calling
fix: handle missing toolId in callTool function and return 404 for non-existent tools
feat: show code outputs
fix: improve error handling in callTool function and log errors
fix: handle potential null value for filepath in attachment destructuring
fix: normalize language before rendering and prevent null return
fix: add loading indicator in RunCode component while executing code
feat: add support for conditional code execution in Markdown components
feat: attachments
refactor: remove bash
fix: pass abort signal to graph/run
refactor: debounce and rate limit tool call
refactor: increase debounce delay for execute function
feat: set code output attachments
feat: image attachments
refactor: apply message context
refactor: pass `partIndex`
feat: toolCall schema/model/methods
feat: block indexing
feat: get tool calls
chore: imports
chore: typing
chore: condense type imports
feat: get tool calls
fix: block indexing
chore: typing
refactor: update tool calls mapping to support multiple results
fix: add unique key to nav link for rendering
wip: first pass, tool call results
refactor: update query cache from successful tool call mutation
style: improve result switcher styling
chore: note on using \`.toObject()\`
feat: add agent_id field to conversation schema
chore: typing
refactor: rename agentMap to agentsMap for consistency
feat: Agent Name as chat input placeholder
chore: bump agents
📦 chore: update @langchain dependencies to latest versions to match agents package
📦 chore: update @librechat/agents dependency to version 1.8.0
fix: Aborting agent stream removes sender; fix(bedrock): completion removes preset name label
refactor: remove direct file parameter to use req.file, add `processAgentFileUpload` for image uploads
feat: upload menu
feat: prime message_file resources
feat: implement conversation access validation in chat route
refactor: remove file parameter from processFileUpload and use req.file instead
feat: add savedMessageIds set to track saved message IDs in BaseClient, to prevent unnecessary double-write to db
feat: prevent duplicate message saves by checking savedMessageIds in AgentController
refactor: skip legacy RAG API handling for agents
feat: add files field to convoSchema
refactor: update request type annotations from Express.Request to ServerRequest in file processing functions
feat: track conversation files
fix: resendFiles, addPreviousAttachments handling
feat: add ID validation for session_id and file_id in download route
feat: entity_id for code file uploads/downloads
fix: code file edge cases
feat: delete related tool calls
feat: add stream rate handling for LLM configuration
feat: enhance system content with attached file information
fix: improve error logging in resource priming function
* WIP: PoC, sequential agents
WIP: PoC Sequential Agents, first pass content data + bump agents package
fix: package-lock
WIP: PoC, o1 support, refactor bufferString
feat: convertJsonSchemaToZod
fix: form issues and schema defining erroneous model
fix: max length issue on agent form instructions, limit conversation messages to sequential agents
feat: add abort signal support to createRun function and AgentClient
feat: PoC, hide prior sequential agent steps
fix: update parameter naming from config to metadata in event handlers for clarity, add model to usage data
refactor: use only last contentData, track model for usage data
chore: bump agents package
fix: content parts issue
refactor: filter contentParts to include tool calls and relevant indices
feat: show function calls
refactor: filter context messages to exclude tool calls when no tools are available to the agent
fix: ensure tool call content is not undefined in formatMessages
feat: add agent_id field to conversationPreset schema
feat: hide sequential agents
feat: increase upload toast duration to 10 seconds
* refactor: tool context handling & update Code API Key Dialog
feat: toolContextMap
chore: skipSpecs -> useSpecs
ci: fix handleTools tests
feat: API Key Dialog
* feat: Agent Permissions Admin Controls
feat: replace label with button for prompt permission toggle
feat: update agent permissions
feat: enable experimental agents and streamline capability configuration
feat: implement access control for agents and enhance endpoint menu items
feat: add welcome message for agent selection in localization
feat: add agents permission to access control and update version to 0.7.57
* fix: update types in useAssistantListMap and useMentions hooks for better null handling
* feat: mention agents
* fix: agent tool resource race conditions when deleting agent tool resource files
* feat: add error handling for code execution with user feedback
* refactor: rename AdminControls to AdminSettings for clarity
* style: add gap to button in AdminSettings for improved layout
* refactor: separate agent query hooks and check access to enable fetching
* fix: remove unused provider from agent initialization options, creates issue with custom endpoints
* refactor: remove redundant/deprecated modelOptions from AgentClient processes
* chore: update @librechat/agents to version 1.8.5 in package.json and package-lock.json
* fix: minor styling issues + agent panel uniformity
* fix: agent edge cases when set endpoint is no longer defined
* refactor: remove unused cleanup function call from AppService
* fix: update link in ApiKeyDialog to point to pricing page
* fix: improve type handling and layout calculations in SidePanel component
* fix: add missing localization string for agent selection in SidePanel
* chore: form styling and localizations for upload filesearch/code interpreter
* fix: model selection placeholder logic in AgentConfig component
* style: agent capabilities
* fix: add localization for provider selection and improve dropdown styling in ModelPanel
* refactor: use gpt-4o-mini > gpt-3.5-turbo
* fix: agents configuration for loadDefaultInterface and update related tests
* feat: DALLE Agents support
2024-12-04 15:48:13 -05:00
|
|
|
]),
|
|
|
|
|
);
|
|
|
|
|
objectSchema = z.object(partial);
|
|
|
|
|
} else {
|
2025-04-29 09:55:43 -04:00
|
|
|
const partialNullable = Object.fromEntries(
|
|
|
|
|
Object.entries(shape).map(([key, value]) => [key, value.optional().nullable()]),
|
|
|
|
|
);
|
|
|
|
|
objectSchema = z.object(partialNullable);
|
🎉 feat: Code Interpreter API and Agents Release (#4860)
* feat: Code Interpreter API & File Search Agent Uploads
chore: add back code files
wip: first pass, abstract key dialog
refactor: influence checkbox on key changes
refactor: update localization keys for 'execute code' to 'run code'
wip: run code button
refactor: add throwError parameter to loadAuthValues and getUserPluginAuthValue functions
feat: first pass, API tool calling
fix: handle missing toolId in callTool function and return 404 for non-existent tools
feat: show code outputs
fix: improve error handling in callTool function and log errors
fix: handle potential null value for filepath in attachment destructuring
fix: normalize language before rendering and prevent null return
fix: add loading indicator in RunCode component while executing code
feat: add support for conditional code execution in Markdown components
feat: attachments
refactor: remove bash
fix: pass abort signal to graph/run
refactor: debounce and rate limit tool call
refactor: increase debounce delay for execute function
feat: set code output attachments
feat: image attachments
refactor: apply message context
refactor: pass `partIndex`
feat: toolCall schema/model/methods
feat: block indexing
feat: get tool calls
chore: imports
chore: typing
chore: condense type imports
feat: get tool calls
fix: block indexing
chore: typing
refactor: update tool calls mapping to support multiple results
fix: add unique key to nav link for rendering
wip: first pass, tool call results
refactor: update query cache from successful tool call mutation
style: improve result switcher styling
chore: note on using \`.toObject()\`
feat: add agent_id field to conversation schema
chore: typing
refactor: rename agentMap to agentsMap for consistency
feat: Agent Name as chat input placeholder
chore: bump agents
📦 chore: update @langchain dependencies to latest versions to match agents package
📦 chore: update @librechat/agents dependency to version 1.8.0
fix: Aborting agent stream removes sender; fix(bedrock): completion removes preset name label
refactor: remove direct file parameter to use req.file, add `processAgentFileUpload` for image uploads
feat: upload menu
feat: prime message_file resources
feat: implement conversation access validation in chat route
refactor: remove file parameter from processFileUpload and use req.file instead
feat: add savedMessageIds set to track saved message IDs in BaseClient, to prevent unnecessary double-write to db
feat: prevent duplicate message saves by checking savedMessageIds in AgentController
refactor: skip legacy RAG API handling for agents
feat: add files field to convoSchema
refactor: update request type annotations from Express.Request to ServerRequest in file processing functions
feat: track conversation files
fix: resendFiles, addPreviousAttachments handling
feat: add ID validation for session_id and file_id in download route
feat: entity_id for code file uploads/downloads
fix: code file edge cases
feat: delete related tool calls
feat: add stream rate handling for LLM configuration
feat: enhance system content with attached file information
fix: improve error logging in resource priming function
* WIP: PoC, sequential agents
WIP: PoC Sequential Agents, first pass content data + bump agents package
fix: package-lock
WIP: PoC, o1 support, refactor bufferString
feat: convertJsonSchemaToZod
fix: form issues and schema defining erroneous model
fix: max length issue on agent form instructions, limit conversation messages to sequential agents
feat: add abort signal support to createRun function and AgentClient
feat: PoC, hide prior sequential agent steps
fix: update parameter naming from config to metadata in event handlers for clarity, add model to usage data
refactor: use only last contentData, track model for usage data
chore: bump agents package
fix: content parts issue
refactor: filter contentParts to include tool calls and relevant indices
feat: show function calls
refactor: filter context messages to exclude tool calls when no tools are available to the agent
fix: ensure tool call content is not undefined in formatMessages
feat: add agent_id field to conversationPreset schema
feat: hide sequential agents
feat: increase upload toast duration to 10 seconds
* refactor: tool context handling & update Code API Key Dialog
feat: toolContextMap
chore: skipSpecs -> useSpecs
ci: fix handleTools tests
feat: API Key Dialog
* feat: Agent Permissions Admin Controls
feat: replace label with button for prompt permission toggle
feat: update agent permissions
feat: enable experimental agents and streamline capability configuration
feat: implement access control for agents and enhance endpoint menu items
feat: add welcome message for agent selection in localization
feat: add agents permission to access control and update version to 0.7.57
* fix: update types in useAssistantListMap and useMentions hooks for better null handling
* feat: mention agents
* fix: agent tool resource race conditions when deleting agent tool resource files
* feat: add error handling for code execution with user feedback
* refactor: rename AdminControls to AdminSettings for clarity
* style: add gap to button in AdminSettings for improved layout
* refactor: separate agent query hooks and check access to enable fetching
* fix: remove unused provider from agent initialization options, creates issue with custom endpoints
* refactor: remove redundant/deprecated modelOptions from AgentClient processes
* chore: update @librechat/agents to version 1.8.5 in package.json and package-lock.json
* fix: minor styling issues + agent panel uniformity
* fix: agent edge cases when set endpoint is no longer defined
* refactor: remove unused cleanup function call from AppService
* fix: update link in ApiKeyDialog to point to pricing page
* fix: improve type handling and layout calculations in SidePanel component
* fix: add missing localization string for agent selection in SidePanel
* chore: form styling and localizations for upload filesearch/code interpreter
* fix: model selection placeholder logic in AgentConfig component
* style: agent capabilities
* fix: add localization for provider selection and improve dropdown styling in ModelPanel
* refactor: use gpt-4o-mini > gpt-3.5-turbo
* fix: agents configuration for loadDefaultInterface and update related tests
* feat: DALLE Agents support
2024-12-04 15:48:13 -05:00
|
|
|
}
|
2025-04-03 20:42:56 -04:00
|
|
|
|
|
|
|
|
// Handle additionalProperties for open-ended objects
|
|
|
|
|
if (schema.additionalProperties === true) {
|
|
|
|
|
// This allows any additional properties with any type
|
|
|
|
|
zodSchema = objectSchema.passthrough();
|
|
|
|
|
} else if (typeof schema.additionalProperties === 'object') {
|
|
|
|
|
// For specific additional property types
|
|
|
|
|
const additionalSchema = convertJsonSchemaToZod(
|
|
|
|
|
schema.additionalProperties as JsonSchemaType,
|
|
|
|
|
);
|
2025-04-23 18:56:06 -04:00
|
|
|
zodSchema = objectSchema.catchall((additionalSchema ?? z.unknown()) as z.ZodType);
|
2025-04-03 20:42:56 -04:00
|
|
|
} else {
|
|
|
|
|
zodSchema = objectSchema;
|
|
|
|
|
}
|
🎉 feat: Code Interpreter API and Agents Release (#4860)
* feat: Code Interpreter API & File Search Agent Uploads
chore: add back code files
wip: first pass, abstract key dialog
refactor: influence checkbox on key changes
refactor: update localization keys for 'execute code' to 'run code'
wip: run code button
refactor: add throwError parameter to loadAuthValues and getUserPluginAuthValue functions
feat: first pass, API tool calling
fix: handle missing toolId in callTool function and return 404 for non-existent tools
feat: show code outputs
fix: improve error handling in callTool function and log errors
fix: handle potential null value for filepath in attachment destructuring
fix: normalize language before rendering and prevent null return
fix: add loading indicator in RunCode component while executing code
feat: add support for conditional code execution in Markdown components
feat: attachments
refactor: remove bash
fix: pass abort signal to graph/run
refactor: debounce and rate limit tool call
refactor: increase debounce delay for execute function
feat: set code output attachments
feat: image attachments
refactor: apply message context
refactor: pass `partIndex`
feat: toolCall schema/model/methods
feat: block indexing
feat: get tool calls
chore: imports
chore: typing
chore: condense type imports
feat: get tool calls
fix: block indexing
chore: typing
refactor: update tool calls mapping to support multiple results
fix: add unique key to nav link for rendering
wip: first pass, tool call results
refactor: update query cache from successful tool call mutation
style: improve result switcher styling
chore: note on using \`.toObject()\`
feat: add agent_id field to conversation schema
chore: typing
refactor: rename agentMap to agentsMap for consistency
feat: Agent Name as chat input placeholder
chore: bump agents
📦 chore: update @langchain dependencies to latest versions to match agents package
📦 chore: update @librechat/agents dependency to version 1.8.0
fix: Aborting agent stream removes sender; fix(bedrock): completion removes preset name label
refactor: remove direct file parameter to use req.file, add `processAgentFileUpload` for image uploads
feat: upload menu
feat: prime message_file resources
feat: implement conversation access validation in chat route
refactor: remove file parameter from processFileUpload and use req.file instead
feat: add savedMessageIds set to track saved message IDs in BaseClient, to prevent unnecessary double-write to db
feat: prevent duplicate message saves by checking savedMessageIds in AgentController
refactor: skip legacy RAG API handling for agents
feat: add files field to convoSchema
refactor: update request type annotations from Express.Request to ServerRequest in file processing functions
feat: track conversation files
fix: resendFiles, addPreviousAttachments handling
feat: add ID validation for session_id and file_id in download route
feat: entity_id for code file uploads/downloads
fix: code file edge cases
feat: delete related tool calls
feat: add stream rate handling for LLM configuration
feat: enhance system content with attached file information
fix: improve error logging in resource priming function
* WIP: PoC, sequential agents
WIP: PoC Sequential Agents, first pass content data + bump agents package
fix: package-lock
WIP: PoC, o1 support, refactor bufferString
feat: convertJsonSchemaToZod
fix: form issues and schema defining erroneous model
fix: max length issue on agent form instructions, limit conversation messages to sequential agents
feat: add abort signal support to createRun function and AgentClient
feat: PoC, hide prior sequential agent steps
fix: update parameter naming from config to metadata in event handlers for clarity, add model to usage data
refactor: use only last contentData, track model for usage data
chore: bump agents package
fix: content parts issue
refactor: filter contentParts to include tool calls and relevant indices
feat: show function calls
refactor: filter context messages to exclude tool calls when no tools are available to the agent
fix: ensure tool call content is not undefined in formatMessages
feat: add agent_id field to conversationPreset schema
feat: hide sequential agents
feat: increase upload toast duration to 10 seconds
* refactor: tool context handling & update Code API Key Dialog
feat: toolContextMap
chore: skipSpecs -> useSpecs
ci: fix handleTools tests
feat: API Key Dialog
* feat: Agent Permissions Admin Controls
feat: replace label with button for prompt permission toggle
feat: update agent permissions
feat: enable experimental agents and streamline capability configuration
feat: implement access control for agents and enhance endpoint menu items
feat: add welcome message for agent selection in localization
feat: add agents permission to access control and update version to 0.7.57
* fix: update types in useAssistantListMap and useMentions hooks for better null handling
* feat: mention agents
* fix: agent tool resource race conditions when deleting agent tool resource files
* feat: add error handling for code execution with user feedback
* refactor: rename AdminControls to AdminSettings for clarity
* style: add gap to button in AdminSettings for improved layout
* refactor: separate agent query hooks and check access to enable fetching
* fix: remove unused provider from agent initialization options, creates issue with custom endpoints
* refactor: remove redundant/deprecated modelOptions from AgentClient processes
* chore: update @librechat/agents to version 1.8.5 in package.json and package-lock.json
* fix: minor styling issues + agent panel uniformity
* fix: agent edge cases when set endpoint is no longer defined
* refactor: remove unused cleanup function call from AppService
* fix: update link in ApiKeyDialog to point to pricing page
* fix: improve type handling and layout calculations in SidePanel component
* fix: add missing localization string for agent selection in SidePanel
* chore: form styling and localizations for upload filesearch/code interpreter
* fix: model selection placeholder logic in AgentConfig component
* style: agent capabilities
* fix: add localization for provider selection and improve dropdown styling in ModelPanel
* refactor: use gpt-4o-mini > gpt-3.5-turbo
* fix: agents configuration for loadDefaultInterface and update related tests
* feat: DALLE Agents support
2024-12-04 15:48:13 -05:00
|
|
|
} else {
|
|
|
|
|
zodSchema = z.unknown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add description if present
|
|
|
|
|
if (schema.description != null && schema.description !== '') {
|
|
|
|
|
zodSchema = zodSchema.describe(schema.description);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return zodSchema;
|
|
|
|
|
}
|