elna / app /main.py
David Chu
refactor: use pydantic settings
00d1644 unverified
raw
history blame
598 Bytes
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}