Spaces:
Sleeping
Sleeping
File size: 713 Bytes
c5f7db4 84d142d c5f7db4 84d142d c5f7db4 | 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 | from fastapi import FastAPI, HTTPException
from utils.ai_runner import run_llm
from models.ai_request import AIRequest
app = FastAPI()
@app.get("/")
def greet_json():
return {"Hello": "World!"}
@app.post("/api/v1/ai")
async def ai_json(request: AIRequest):
try:
response = await run_llm(request.text,request.model_name)
if not response:
return HTTPException(status_code=400,detail="Couldn't retrive response on server")
return {
"data":
{
"answer": response["answer"]
}
}
except Exception as e:
print(e)
return HTTPException(status_code=500,detail="Internal server error occured") |