Spaces:
Configuration error
Configuration error
| ```typescript | |
| import { Router } from "express"; | |
| import { z } from "zod"; | |
| import { rosalindaRespond } from "../core/agent.js"; | |
| export const chatRouter = Router(); | |
| chatRouter.post("/", async (req, res) => { | |
| const body = z.object({ | |
| projectId: z.string().min(1), | |
| text: z.string().min(1) | |
| }).safeParse(req.body); | |
| if (!body.success) return res.status(400).json({ ok: false, error: body.error.message }); | |
| const out = await rosalindaRespond({ projectId: body.data.projectId, userText: body.data.text }); | |
| res.json({ ok: true, reply: out.reply, toolResult: out.toolResult }); | |
| }); | |
| ``` |