mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
[api] Add models router and list model API.
This commit is contained in:
parent
1654269125
commit
c025d0521d
@ -2,11 +2,7 @@
|
||||
|
||||
from typing import Annotated, Any, List, Literal, Optional, Union
|
||||
|
||||
<<<<<<< HEAD
|
||||
from fastapi.routing import APIRouter, HTTPException
|
||||
=======
|
||||
from fastapi.routing import APIRouter
|
||||
>>>>>>> 5f92f290 ([api] Add models router and list model API.)
|
||||
from pydantic import BaseModel, Field, parse_obj_as
|
||||
|
||||
from ..dependencies import ApiDependencies
|
||||
@ -19,17 +15,9 @@ class VaeRepo(BaseModel):
|
||||
path: Optional[str] = Field(description="The path to the VAE")
|
||||
subfolder: Optional[str] = Field(description="The subfolder to use for this VAE")
|
||||
|
||||
<<<<<<< HEAD
|
||||
class ModelInfo(BaseModel):
|
||||
description: Optional[str] = Field(description="A description of the model")
|
||||
|
||||
=======
|
||||
|
||||
class ModelInfo(BaseModel):
|
||||
description: Optional[str] = Field(description="A description of the model")
|
||||
|
||||
|
||||
>>>>>>> 5f92f290 ([api] Add models router and list model API.)
|
||||
class CkptModelInfo(ModelInfo):
|
||||
format: Literal['ckpt'] = 'ckpt'
|
||||
|
||||
@ -39,10 +27,6 @@ class CkptModelInfo(ModelInfo):
|
||||
width: Optional[int] = Field(description="The width of the model")
|
||||
height: Optional[int] = Field(description="The height of the model")
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
>>>>>>> 5f92f290 ([api] Add models router and list model API.)
|
||||
class DiffusersModelInfo(ModelInfo):
|
||||
format: Literal['diffusers'] = 'diffusers'
|
||||
|
||||
@ -50,7 +34,6 @@ class DiffusersModelInfo(ModelInfo):
|
||||
repo_id: Optional[str] = Field(description="The repo ID to use for this model")
|
||||
path: Optional[str] = Field(description="The path to the model")
|
||||
|
||||
<<<<<<< HEAD
|
||||
class CreateModelRequest (BaseModel):
|
||||
name: str = Field(description="The name of the model")
|
||||
info: Union[CkptModelInfo, DiffusersModelInfo] = Field(..., discriminator="format", description="The model details and configuration")
|
||||
@ -59,17 +42,10 @@ class CreateModelResponse (BaseModel):
|
||||
name: str = Field(description="The name of the new model")
|
||||
info: Union[CkptModelInfo, DiffusersModelInfo] = Field(..., discriminator="format", description="The model details and configuration")
|
||||
status: str = Field(description="The status of the API response")
|
||||
=======
|
||||
>>>>>>> 5f92f290 ([api] Add models router and list model API.)
|
||||
|
||||
class ModelsList(BaseModel):
|
||||
models: dict[str, Annotated[Union[(CkptModelInfo,DiffusersModelInfo)], Field(discriminator="format")]]
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
|
||||
>>>>>>> 5f92f290 ([api] Add models router and list model API.)
|
||||
@models_router.get(
|
||||
"/",
|
||||
operation_id="list_models",
|
||||
@ -81,7 +57,6 @@ async def list_models() -> ModelsList:
|
||||
models = parse_obj_as(ModelsList, { "models": models_raw })
|
||||
return models
|
||||
|
||||
<<<<<<< HEAD
|
||||
#Update Model
|
||||
@models_router.post(
|
||||
"/",
|
||||
@ -137,8 +112,6 @@ async def delete_model(model_name: str) -> None:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
=======
|
||||
>>>>>>> 5f92f290 ([api] Add models router and list model API.)
|
||||
# @socketio.on("requestSystemConfig")
|
||||
# def handle_request_capabilities():
|
||||
# print(">> System config requested")
|
||||
|
Loading…
Reference in New Issue
Block a user