File size: 996 Bytes
ba9f758
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e6cc48e
 
 
ba9f758
 
 
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
28
import torch
from fastapi import FastAPI, Depends
from fastapi.responses import JSONResponse
from authenticator import authenticate_token
from payload_model import PayloadModel
from models import InternVL3
from internvl_utils import internvl_inference


app = FastAPI()

model = InternVL3("OpenGVLab/InternVL3-1B-Instruct")

@app.get("/healthcheck")
def healthcheck():
    return JSONResponse(status_code=200, content={"status": "ok"})

@app.post("/internvl_inference")
async def inference(payload: PayloadModel, token: str = Depends(authenticate_token)):
    try:
        model_response = await internvl_inference(model, payload)
        model_response = "True" if model_response else "False"
        final_response = {"1":{"query_status": model_response}}
        return JSONResponse(status_code=200, content={"final_response": final_response})
    except Exception as e:
        print(f"Error: {e}")
        return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})