InvokeAI/invokeai/app/api/routers/results.py
psychedelicious 9c89d3452c feat(nodes): add high-level images service
feat(nodes): add ResultsServiceABC & SqliteResultsService

**Doesn't actually work bc of circular imports. Can't even test it.**

- add a base class for ResultsService and SQLite implementation
- use `graph_execution_manager` `on_changed` callback to keep `results` table in sync

fix(nodes): fix results service bugs

chore(ui): regen api

fix(ui): fix type guards

feat(nodes): add `result_type` to results table, fix types

fix(nodes): do not shadow `list` builtin

feat(nodes): add results router

It doesn't work due to circular imports still

fix(nodes): Result class should use outputs classes, not fields

feat(ui): crude results router

fix(ui): send to canvas in currentimagebuttons not working

feat(nodes): add core metadata builder

feat(nodes): add design doc

feat(nodes): wip latents db stuff

feat(nodes): images_db_service and resources router

feat(nodes): wip images db & router

feat(nodes): update image related names

feat(nodes): update urlservice

feat(nodes): add high-level images service
2023-05-24 11:30:47 -04:00

43 lines
1.5 KiB
Python

from fastapi import HTTPException, Path, Query
from fastapi.routing import APIRouter
from invokeai.app.services.results import ResultType, ResultWithSession
from invokeai.app.services.item_storage import PaginatedResults
from ..dependencies import ApiDependencies
results_router = APIRouter(prefix="/v1/results", tags=["results"])
@results_router.get("/{result_type}/{result_name}", operation_id="get_result")
async def get_result(
result_type: ResultType = Path(description="The type of result to get"),
result_name: str = Path(description="The name of the result to get"),
) -> ResultWithSession:
"""Gets a result"""
result = ApiDependencies.invoker.services.results.get(
result_id=result_name, result_type=result_type
)
if result is not None:
return result
else:
raise HTTPException(status_code=404)
@results_router.get(
"/",
operation_id="list_results",
responses={200: {"model": PaginatedResults[ResultWithSession]}},
)
async def list_results(
result_type: ResultType = Query(description="The type of results to get"),
page: int = Query(default=0, description="The page of results to get"),
per_page: int = Query(default=10, description="The number of results per page"),
) -> PaginatedResults[ResultWithSession]:
"""Gets a list of results"""
results = ApiDependencies.invoker.services.results.get_many(
result_type=result_type, page=page, per_page=per_page
)
return results