Spaces:
Runtime error
Runtime error
Download apps/api/src/services/chat/chat.validator.ts from ClaraSu/llm-router: direct link, hf CLI and curl.
- Browser
- Download file 718 Bytes
-
https://huggingface.co/spaces/ClaraSu/llm-router/resolve/main/apps/api/src/services/chat/chat.validator.ts
- Command line
-
hf download hf://spaces/ClaraSu/llm-router/apps/api/src/services/chat/chat.validator.ts
-
curl -L -o chat.validator.ts https://huggingface.co/spaces/ClaraSu/llm-router/resolve/main/apps/api/src/services/chat/chat.validator.ts
718 Bytes
| import { z } from 'zod' | |
| import type { RequestHandler } from 'express' | |
| import { validate } from '../../middleware/validate' | |
| const ContentPart = z.object({ | |
| type: z.string(), | |
| text: z.string().optional(), | |
| image_url: z.object({ url: z.string() }).optional(), | |
| }) | |
| const chatSchema = z.object({ | |
| messages: z | |
| .array( | |
| z.object({ | |
| role: z.string(), | |
| content: z.union([z.string(), z.array(ContentPart)]), | |
| }) | |
| ) | |
| .min(1, 'messages must be a non-empty array'), | |
| model: z.string().optional().default('smart-router'), | |
| stream: z.boolean().optional().default(false), | |
| }) | |
| export type ChatInput = z.infer<typeof chatSchema> | |
| export const validateChat: RequestHandler = validate(chatSchema) | |