TESTING / src /validators.js
API-Handler's picture
Upload 6 files
567f740 verified
raw
history blame
827 Bytes
const Joi = require('joi');
const messageSchema = Joi.object({
role: Joi.string().required(),
content: Joi.string().required()
});
const chatRequestSchema = Joi.object({
model: Joi.string().required(),
messages: Joi.array().items(messageSchema).required(),
temperature: Joi.number().min(0).max(2).default(0.7),
max_tokens: Joi.number().integer().min(1).default(4096),
top_p: Joi.number().min(0).max(1).default(1.0),
frequency_penalty: Joi.number().min(-2).max(2).default(0.0),
presence_penalty: Joi.number().min(-2).max(2).default(0.0),
stop: Joi.array().items(Joi.string()).default([]),
stream: Joi.boolean().default(false)
});
function validateChatRequest(data) {
return chatRequestSchema.validate(data);
}
module.exports = { validateChatRequest };