File size: 598 Bytes
8a3374d
 
 
 
00d1644
8a3374d
00d1644
8a3374d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from fastapi import FastAPI
from google import genai
from pydantic import BaseModel

from app import agent, config

gemini = genai.Client(api_key=config.settings.google_api_key)
app = FastAPI()



class Source(BaseModel):
    title: str
    url: str


class Statement(BaseModel):
    text: str
    sources: list[Source] | None = None


class Statements(BaseModel):
    statements: list[Statement]


@app.get("/health")
def health_check():
    return "ok"


@app.get("/ask", response_model=Statements)
def ask(query: str):
    output = agent.respond(gemini, query)
    return {"statements": output}