-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathacademicResearchFlow.ts
More file actions
23 lines (22 loc) · 901 Bytes
/
academicResearchFlow.ts
File metadata and controls
23 lines (22 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { ai } from '../config.js';
import { UserFacingError } from '../errors/UserFacingError.js';
import { AcademicResearchInputSchema, AcademicResearchOutputSchema } from '../schemas/index.js';
import type { Flow } from '@genkit-ai/core';
export const academicResearchFlow: Flow<typeof AcademicResearchInputSchema, typeof AcademicResearchOutputSchema> = ai.defineFlow(
{
name: 'academicResearchFlow',
inputSchema: AcademicResearchInputSchema,
outputSchema: AcademicResearchOutputSchema,
},
async (input) => {
const prompt = ai.prompt('academic_research');
const { output } = await prompt(input);
const parsed = AcademicResearchOutputSchema.safeParse(output);
if (!parsed.success) {
throw new UserFacingError('Schema validation failed for academicResearchFlow output', {
details: parsed.error.flatten(),
});
}
return parsed.data;
}
);