mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-04-06 07:47:20 +02:00
🪆 fix: Allow Nested addParams in Config Schema (#12526)
* fix: allow nested addParams in config schema * Respect no-op task constraint Constraint: Task 2 explicitly forbids code changes Directive: Keep this worker branch code-identical to the assigned base for this task Confidence: high Scope-risk: narrow Tested: git status --short (clean) * fix: align addParams web_search validation with runtime * test: cover addParams edge cases * chore: ignore .codex directory
This commit is contained in:
parent
6ecd1b510f
commit
ed02fe40e0
3 changed files with 199 additions and 3 deletions
|
|
@ -115,13 +115,39 @@ export const modelConfigSchema = z
|
|||
|
||||
export type TAzureModelConfig = z.infer<typeof modelConfigSchema>;
|
||||
|
||||
const paramValueSchema: z.ZodType<unknown> = z.lazy(() =>
|
||||
z.union([
|
||||
z.string(),
|
||||
z.number(),
|
||||
z.boolean(),
|
||||
z.null(),
|
||||
z.array(paramValueSchema),
|
||||
z.record(z.string(), paramValueSchema),
|
||||
]),
|
||||
);
|
||||
|
||||
/** Validates addParams while keeping web_search aligned with current runtime boolean handling. */
|
||||
const addParamsSchema: z.ZodType<Record<string, unknown>> = z
|
||||
.record(z.string(), paramValueSchema)
|
||||
.superRefine((params, ctx) => {
|
||||
if (params.web_search === undefined || typeof params.web_search === 'boolean') {
|
||||
return;
|
||||
}
|
||||
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ['web_search'],
|
||||
message: '`web_search` must be a boolean in addParams',
|
||||
});
|
||||
});
|
||||
|
||||
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.union([z.string(), z.number(), z.boolean(), z.null()])).optional(),
|
||||
addParams: addParamsSchema.optional(),
|
||||
dropParams: z.array(z.string()).optional(),
|
||||
version: z.string().optional(),
|
||||
baseURL: z.string().optional(),
|
||||
|
|
@ -361,7 +387,7 @@ export const endpointSchema = baseEndpointSchema.merge(
|
|||
iconURL: z.string().optional(),
|
||||
modelDisplayLabel: z.string().optional(),
|
||||
headers: z.record(z.string()).optional(),
|
||||
addParams: z.record(z.union([z.string(), z.number(), z.boolean(), z.null()])).optional(),
|
||||
addParams: addParamsSchema.optional(),
|
||||
dropParams: z.array(z.string()).optional(),
|
||||
customParams: z
|
||||
.object({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue