File size: 606 Bytes
cfc0cce |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
from contextlib import asynccontextmanager
from typing import AsyncIterator, TypedDict
from fastapi import FastAPI
import httpx
from .routers import duckduckgo
class State(TypedDict):
http_client: httpx.AsyncClient
@asynccontextmanager
async def lifespan(app: FastAPI) -> AsyncIterator[State]:
async with httpx.AsyncClient() as http_client:
yield {'http_client': http_client}
app = FastAPI(title='Freedom LLM', description='Free AI for everyone', lifespan=lifespan)
app.include_router(duckduckgo.router)
@app.get('/')
async def root():
return {'message': 'Hello, my name is Ging'}
|