Skip to content

Commit

Permalink
Add parameter validation to LiteLLM LISA params
Browse files Browse the repository at this point in the history
  • Loading branch information
petermuller committed Jun 5, 2024
1 parent 9d36c78 commit 8454967
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -690,10 +690,25 @@ const LiteLLMModel = z.object({
api_key: z.string().optional(),
aws_region_name: z.string().optional(),
}),
lisa_params: z.object({
streaming: z.boolean().nullable().default(null),
model_type: z.nativeEnum(ModelType),
}),
lisa_params: z
.object({
streaming: z.boolean().nullable().default(null),
model_type: z.nativeEnum(ModelType),
})
.refine(
(data) => {
// 'textgen' type must have boolean streaming, 'embedding' type must have null streaming
const isValidForTextgen = data.model_type === 'textgen' && typeof data.streaming === 'boolean';
const isValidForEmbedding = data.model_type === 'embedding' && data.streaming === null;

return isValidForTextgen || isValidForEmbedding;
},
{
message: `For 'textgen' models, 'streaming' must be true or false.
For 'embedding' models, 'streaming' must not be set.`,
path: ['streaming'],
},
),
model_info: z
.object({
id: z.string().optional(),
Expand Down

0 comments on commit 8454967

Please sign in to comment.