Spaces:
Runtime error
Runtime error
Delete app.py
#1
by microcol - opened
from fastapi import FastAPI
from pydantic import BaseModel
from huggingface_hub import InferenceClient
import os
app = FastAPI()
client = InferenceClient(
api_key=os.getenv("HF_TOKEN")
)
class ChatRequest(BaseModel):
model: str
messages: list
@app .get("/v1/models")
def models():
return {
"data": [
{
"id": "Qwen/Qwen2.5-Coder-7B-Instruct",
"object": "model"
}
]
}
@app .post("/v1/chat/completions")
async def chat(req: ChatRequest):
response = client.chat.completions.create(
model=req.model,
messages=req.messages,
max_tokens=2048
)
return response