Skip to main content
Loading navigation
Back to prompt library

Implement AI SDK Rapid WGS Endpoint

Linked challenge: AI SDK Pediatric Rapid WGS Triage Agent with AutoGPT

Prompt source

implementation19 lines4 sectionsNo variables0 checklist items
import { streamText, tool } from 'ai';
import { openai } from '@ai-sdk/openai';
import { z } from 'zod';

export async function POST(req: Request) {
  const { hpoTerms, variants } = await req.json();

  const result = streamText({
    model: openai('gpt-4o'),
    system: 'You are a pediatric clinical geneticist specializing in rapid WGS triage.',
    prompt: `Analyze HPO terms: ${JSON.stringify(hpoTerms)} with variants: ${JSON.stringify(variants)}`,
    tools: {
      searchPubMed: tool({
        description: 'Search PubMed for gene phenotype associations',
        parameters: z.object({ query: z.string() }),
        execute: async ({ query }) => ({ results: [] })
      })
    }
  });

  return result.toDataStreamResponse();
}