Skip to content

Commit

Permalink
chore: add validation for hooks and guardrails config keys
Browse files Browse the repository at this point in the history
  • Loading branch information
VisargD committed Dec 27, 2024
1 parent c5abbfd commit 98ffb08
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/middlewares/requestValidator/schema/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,28 @@ export const configSchema: any = z
// Google Vertex AI specific
vertex_project_id: z.string().optional(),
vertex_region: z.string().optional(),
after_request_hooks: z.any().optional(),
before_request_hooks: z.any().optional(),
after_request_hooks: z
.array(z.object({}).catchall(z.any())) // Allows any object structure
.optional(),
before_request_hooks: z
.array(z.object({}).catchall(z.any())) // Allows any object structure
.optional(),
input_guardrails: z
.union([
z.array(z.string()),
z.array(
z.object({}).catchall(z.any()) // Allows any object structure
),
])
.optional(),
output_guardrails: z
.union([
z.array(z.string()),
z.array(
z.object({}).catchall(z.any()) // Allows any object structure
),
])
.optional(),
vertex_service_account_json: z.object({}).catchall(z.string()).optional(),
// OpenAI specific
openai_project: z.string().optional(),
Expand Down Expand Up @@ -115,7 +135,9 @@ export const configSchema: any = z
hasAWSDetails ||
isVertexAIProvider ||
value.after_request_hooks ||
value.before_request_hooks
value.before_request_hooks ||
value.input_guardrails ||
value.output_guardrails
);
},
{
Expand Down

0 comments on commit 98ffb08

Please sign in to comment.