mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(api): app/config
route returns available infill methods
This commit is contained in:
parent
d6c914eedc
commit
4d25d702a1
@ -1,29 +1,36 @@
|
|||||||
from fastapi.routing import APIRouter
|
from fastapi.routing import APIRouter
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel, Field
|
||||||
from invokeai.backend.image_util.patchmatch import PatchMatch
|
|
||||||
|
|
||||||
|
from invokeai.backend.image_util.patchmatch import PatchMatch
|
||||||
from invokeai.version import __version__
|
from invokeai.version import __version__
|
||||||
|
|
||||||
app_router = APIRouter(prefix="/v1/app", tags=['app'])
|
app_router = APIRouter(prefix="/v1/app", tags=["app"])
|
||||||
|
|
||||||
|
|
||||||
class AppVersion(BaseModel):
|
class AppVersion(BaseModel):
|
||||||
"""App Version Response"""
|
"""App Version Response"""
|
||||||
version: str
|
|
||||||
|
version: str = Field(description="App version")
|
||||||
|
|
||||||
|
|
||||||
class AppConfig(BaseModel):
|
class AppConfig(BaseModel):
|
||||||
"""App Config Response"""
|
"""App Config Response"""
|
||||||
patchmatch_enabled: bool
|
|
||||||
|
infill_methods: list[str] = Field(description="List of available infill methods")
|
||||||
|
|
||||||
|
|
||||||
@app_router.get('/version', operation_id="app_version",
|
@app_router.get(
|
||||||
status_code=200,
|
"/version", operation_id="app_version", status_code=200, response_model=AppVersion
|
||||||
response_model=AppVersion)
|
)
|
||||||
async def get_version() -> AppVersion:
|
async def get_version() -> AppVersion:
|
||||||
return AppVersion(version=__version__)
|
return AppVersion(version=__version__)
|
||||||
|
|
||||||
@app_router.get('/config', operation_id="get_config",
|
|
||||||
status_code=200,
|
@app_router.get(
|
||||||
response_model=AppConfig)
|
"/config", operation_id="get_config", status_code=200, response_model=AppConfig
|
||||||
|
)
|
||||||
async def get_config() -> AppConfig:
|
async def get_config() -> AppConfig:
|
||||||
return AppConfig(patchmatch_enabled=PatchMatch.patchmatch_available())
|
infill_methods = ['tile']
|
||||||
|
if PatchMatch.patchmatch_available():
|
||||||
|
infill_methods.append('patchmatch')
|
||||||
|
return AppConfig(infill_methods=infill_methods)
|
||||||
|
Loading…
Reference in New Issue
Block a user