fix(feedback): force the AI model to generate x questions instead of "max x"

This commit is contained in:
AnotiaWang
2025-02-12 17:01:03 +08:00
parent 9b99058b24
commit 5a973b5d63

View File

@ -21,13 +21,11 @@ export function generateFeedback({
const schema = z.object({ const schema = z.object({
questions: z questions: z
.array(z.string()) .array(z.string())
.describe( .describe(`Follow up questions to clarify the research direction`),
`Follow up questions to clarify the research direction, max of ${numQuestions}`,
),
}) })
const jsonSchema = JSON.stringify(zodToJsonSchema(schema)) const jsonSchema = JSON.stringify(zodToJsonSchema(schema))
const prompt = [ const prompt = [
`Given the following query from the user, ask some follow up questions to clarify the research direction. Return a maximum of ${numQuestions} questions, but feel free to return less if the original query is clear: <query>${query}</query>`, `Given the following query from the user, ask ${numQuestions} follow up questions to clarify the research direction. Return a maximum of ${numQuestions} questions, but feel free to return less if the original query is clear: <query>${query}</query>`,
`You MUST respond in JSON with the following schema: ${jsonSchema}`, `You MUST respond in JSON with the following schema: ${jsonSchema}`,
].join('\n\n') ].join('\n\n')