Coverage for src/fastoai/routers/models.py: 80%

1 from fastapi import APIRouter

2 from openai.pagination import AsyncPage

3 from openai.types import Model

4 from openai.types.model_deleted import ModelDeleted

5

6 from ..dependencies import OpenAIDependency

7

8 router = APIRouter(tags=["Models"])

9

10

11@router.get("/models", response_model=AsyncPage[Model])

12 async def get_models(*, openai: OpenAIDependency):

13 return await openai.models.list()

14

15

16@router.get("/models/{model:path}", response_model=Model)

17 async def retrieve_model(*, model: str, openai: OpenAIDependency) -> Model:

18 return await openai.models.retrieve(model)

19

20

21@router.delete("/models/{model:path}", response_model=ModelDeleted)

22 async def delete_model(*, model: str, openai: OpenAIDependency) -> ModelDeleted:

23 return await openai.models.delete(model)