Spaces:
Running
Running
File size: 811 Bytes
ca56e6a |
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 29 30 31 32 33 34 35 36 37 38 39 |
import time
from typing import List
from fastapi import APIRouter, Depends
from openai.types.model import Model
from pydantic import BaseModel
from api.config import SETTINGS
from api.utils.request import check_api_key
model_router = APIRouter()
class ModelList(BaseModel):
object: str = "list"
data: List[Model] = []
available_models = ModelList(
data=[
Model(
id=SETTINGS.model_name or "",
object="model",
created=int(time.time()),
owned_by="open"
)
]
)
@model_router.get("/models", dependencies=[Depends(check_api_key)])
async def show_available_models():
return available_models
@model_router.get("/models/{model}", dependencies=[Depends(check_api_key)])
async def retrieve_model():
return ModelList.data[0]
|