feat: respond in user's language, style fixes and research depth fixes
This commit is contained in:
@ -2,7 +2,7 @@ import { streamText } from 'ai'
|
||||
import { z } from 'zod'
|
||||
import { zodToJsonSchema } from 'zod-to-json-schema'
|
||||
|
||||
import { systemPrompt } from './prompt'
|
||||
import { languagePrompt, systemPrompt } from './prompt'
|
||||
import { useAiModel } from '~/composables/useAiProvider'
|
||||
|
||||
type PartialFeedback = DeepPartial<z.infer<typeof feedbackTypeSchema>>
|
||||
@ -13,9 +13,11 @@ export const feedbackTypeSchema = z.object({
|
||||
|
||||
export function generateFeedback({
|
||||
query,
|
||||
language,
|
||||
numQuestions = 3,
|
||||
}: {
|
||||
query: string
|
||||
language: string
|
||||
numQuestions?: number
|
||||
}) {
|
||||
const schema = z.object({
|
||||
@ -27,6 +29,7 @@ export function generateFeedback({
|
||||
const prompt = [
|
||||
`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}`,
|
||||
languagePrompt(language),
|
||||
].join('\n\n')
|
||||
|
||||
const stream = streamText({
|
||||
|
Reference in New Issue
Block a user