improve reasoning toggle tests and refactor model capability checks
This commit is contained in:
+6
-2
@@ -17,13 +17,15 @@ const messageValidator = (body) => {
|
||||
};
|
||||
|
||||
const sendMessageValidator = (body) => {
|
||||
const message = String(body?.message || "").trim();
|
||||
const attachments = body?.attachments ?? [];
|
||||
if (!Array.isArray(attachments) || attachments.some(id => typeof id !== "string" || !/^[a-f0-9-]{36}$/.test(id))) return {error: "Invalid attachment IDs"};
|
||||
const message = String(body?.message || "").trim() || (attachments.length ? "Describe the attached images." : "");
|
||||
const chatId = Number(body?.chatId);
|
||||
if (!chatId) return {error: "chatId is required"};
|
||||
if (!message) return {error: "message is required"};
|
||||
if (body.webSearch !== undefined && typeof body.webSearch !== "boolean") return {error: "webSearch must be a boolean"};
|
||||
if (body.reasoning !== undefined && typeof body.reasoning !== "boolean") return {error: "reasoning must be a boolean"};
|
||||
return {value: {message, chatId, model: String(body?.model || "qwen3:14b"), webSearch: body.webSearch === true, reasoning: body.reasoning === true}};
|
||||
return {value: {message, chatId, attachments, model: String(body?.model || "qwen3:14b"), webSearch: body.webSearch === true, reasoning: body.reasoning === true}};
|
||||
};
|
||||
|
||||
const organizationValidator = (body) => ({
|
||||
@@ -413,6 +415,7 @@ export function createChatsRouter({repositories, chatService, modelService, conf
|
||||
user: req.session.user,
|
||||
chatId: req.validatedBody.chatId,
|
||||
message: req.validatedBody.message,
|
||||
attachments: req.validatedBody.attachments,
|
||||
model: req.validatedBody.model,
|
||||
webSearch: req.validatedBody.webSearch,
|
||||
reasoning: req.validatedBody.reasoning
|
||||
@@ -449,6 +452,7 @@ export function createChatsRouter({repositories, chatService, modelService, conf
|
||||
user: req.session.user,
|
||||
chatId: req.validatedBody.chatId,
|
||||
message: req.validatedBody.message,
|
||||
attachments: req.validatedBody.attachments,
|
||||
model: req.validatedBody.model,
|
||||
onChunk: (chunk, fullReply) => sendEvent("chunk", {chunk, fullReply}),
|
||||
onThinking: (chunk, fullThinking) => sendEvent("thinking", {chunk, fullThinking}),
|
||||
|
||||
Reference in New Issue
Block a user