Spaces:
Sleeping
Sleeping
Download app.py from ItsMa8di/MongoCraftAI: direct link, hf CLI and curl.
- Browser
- Download file 713 Bytes
-
https://huggingface.co/spaces/ItsMa8di/MongoCraftAI/resolve/main/app.py
- Command line
-
hf download hf://spaces/ItsMa8di/MongoCraftAI/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ItsMa8di/MongoCraftAI/resolve/main/app.py
713 Bytes
| from fastapi import FastAPI, HTTPException | |
| from utils.ai_runner import run_llm | |
| from models.ai_request import AIRequest | |
| app = FastAPI() | |
| def greet_json(): | |
| return {"Hello": "World!"} | |
| 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") |