36 lines
851 B
Python
36 lines
851 B
Python
from fastapi import FastAPI
|
|
from pydantic import BaseModel
|
|
from .backend import orquestrador
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/")
|
|
def health():
|
|
return {"status": "ok"}
|
|
|
|
|
|
class QueryRequest(BaseModel):
|
|
query: str
|
|
history: str = ""
|
|
model: str = "anthropic.claude-haiku-4-5-20251001-v1:0"
|
|
base: str = "bacio_transacional_loja_app"
|
|
|
|
|
|
class QueryResponse(BaseModel):
|
|
response: str
|
|
input_tokens: int
|
|
output_tokens: int
|
|
total_tokens: int
|
|
|
|
|
|
@app.post("/agent", response_model=QueryResponse)
|
|
def run_agent(request: QueryRequest):
|
|
result = orquestrador.main(request.query, request.history, request.model, request.base)
|
|
return QueryResponse(
|
|
response=result["response"],
|
|
input_tokens=result["input_tokens"],
|
|
output_tokens=result["output_tokens"],
|
|
total_tokens=result["total_tokens"],
|
|
)
|