refactor: make requests purely client-side
This commit is contained in:
@ -19,7 +19,7 @@ export interface WriteFinalReportParams {
|
||||
prompt: string;
|
||||
learnings: string[];
|
||||
}
|
||||
|
||||
// useRuntimeConfig()
|
||||
// Used for streaming response
|
||||
export type SearchQuery = z.infer<typeof searchQueriesTypeSchema>['queries'][0];
|
||||
export type PartialSearchQuery = DeepPartial<SearchQuery>;
|
||||
|
@ -5,6 +5,8 @@ import { zodToJsonSchema } from 'zod-to-json-schema'
|
||||
import { o3MiniModel } from './ai/providers';
|
||||
import { systemPrompt } from './prompt';
|
||||
|
||||
type PartialFeedback = DeepPartial<z.infer<typeof feedbackTypeSchema>>
|
||||
|
||||
export const feedbackTypeSchema = z.object({
|
||||
questions: z.array(z.string())
|
||||
})
|
||||
@ -28,10 +30,16 @@ export function generateFeedback({
|
||||
`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>`,
|
||||
`You MUST respond in JSON with the following schema: ${jsonSchema}`,
|
||||
].join('\n\n');
|
||||
return streamText({
|
||||
|
||||
const stream = streamText({
|
||||
model: o3MiniModel,
|
||||
system: systemPrompt(),
|
||||
prompt,
|
||||
});
|
||||
// return userFeedback.object.questions.slice(0, numQuestions);
|
||||
|
||||
return parseStreamingJson(
|
||||
stream.textStream,
|
||||
feedbackTypeSchema,
|
||||
(value: PartialFeedback) => !!value.questions && value.questions.length > 0
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user