Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sdks): implement SDK-specific API customizations #191

Merged
merged 7 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions runner/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ async def lifespan(app: FastAPI):
app.pipeline = load_pipeline(pipeline, model_id)
app.include_router(load_route(pipeline))

use_route_names_as_operation_ids(app)

logger.info(f"Started up with pipeline {app.pipeline}")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still need to update the https://github.com/livepeer/ai-worker/blob/main/runner/gen_openapi.py file but this has low priority. We currently don't use the model deployment.

yield
logger.info("Shutting down")
Expand Down
13 changes: 13 additions & 0 deletions runner/app/routes/audio_to_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
logger = logging.getLogger(__name__)

RESPONSES = {
status.HTTP_200_OK: {
"content": {
"application/json": {
"schema": {
"x-speakeasy-name-override": "data",
}
}
},
},
status.HTTP_400_BAD_REQUEST: {"model": HTTPError},
status.HTTP_401_UNAUTHORIZED: {"model": HTTPError},
status.HTTP_413_REQUEST_ENTITY_TOO_LARGE: {"model": HTTPError},
Expand Down Expand Up @@ -52,6 +61,10 @@ def handle_pipeline_error(e: Exception) -> JSONResponse:
response_model=TextResponse,
responses=RESPONSES,
description="Transcribe audio files to text.",
operation_id="genAudioToText",
summary="Audio To Text",
tags=["generate"],
openapi_extra={"x-speakeasy-name-override": "audioToText"},
)
@router.post(
"/audio-to-text/",
Expand Down
13 changes: 13 additions & 0 deletions runner/app/routes/image_to_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@


RESPONSES = {
status.HTTP_200_OK: {
"content": {
"application/json": {
"schema": {
"x-speakeasy-name-override": "data",
}
}
},
},
status.HTTP_400_BAD_REQUEST: {"model": HTTPError},
status.HTTP_401_UNAUTHORIZED: {"model": HTTPError},
status.HTTP_500_INTERNAL_SERVER_ERROR: {"model": HTTPError},
Expand All @@ -32,6 +41,10 @@
response_model=ImageResponse,
responses=RESPONSES,
description="Apply image transformations to a provided image.",
operation_id="genImageToImage",
summary="Image To Image",
tags=["generate"],
openapi_extra={"x-speakeasy-name-override": "imageToImage"},
)
@router.post(
"/image-to-image/",
Expand Down
13 changes: 13 additions & 0 deletions runner/app/routes/image_to_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
logger = logging.getLogger(__name__)

RESPONSES = {
status.HTTP_200_OK: {
"content": {
"application/json": {
"schema": {
"x-speakeasy-name-override": "data",
}
}
},
},
status.HTTP_400_BAD_REQUEST: {"model": HTTPError},
status.HTTP_401_UNAUTHORIZED: {"model": HTTPError},
status.HTTP_500_INTERNAL_SERVER_ERROR: {"model": HTTPError},
Expand All @@ -31,6 +40,10 @@
response_model=VideoResponse,
responses=RESPONSES,
description="Generate a video from a provided image.",
operation_id="genImageToVideo",
summary="Image To Video",
tags=["generate"],
openapi_extra={"x-speakeasy-name-override": "imageToVideo"},
)
@router.post(
"/image-to-video/",
Expand Down
13 changes: 13 additions & 0 deletions runner/app/routes/segment_anything_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
logger = logging.getLogger(__name__)

RESPONSES = {
status.HTTP_200_OK: {
"content": {
"application/json": {
"schema": {
"x-speakeasy-name-override": "data",
}
}
},
},
status.HTTP_400_BAD_REQUEST: {"model": HTTPError},
status.HTTP_401_UNAUTHORIZED: {"model": HTTPError},
status.HTTP_500_INTERNAL_SERVER_ERROR: {"model": HTTPError},
Expand All @@ -37,6 +46,10 @@
response_model=MasksResponse,
responses=RESPONSES,
description="Segment objects in an image.",
operation_id="genSegmentAnything2",
summary="Segment Anything 2",
tags=["generate"],
openapi_extra={"x-speakeasy-name-override": "segmentAnything2"},
)
@router.post(
"/segment-anything-2/",
Expand Down
22 changes: 22 additions & 0 deletions runner/app/routes/text_to_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,24 @@ class TextToImageParams(BaseModel):


RESPONSES = {
status.HTTP_200_OK: {
"content": {
"application/json": {
"schema": {
"x-speakeasy-name-override": "data",
}
}
},
},
status.HTTP_200_OK: {
"content": {
"application/json": {
"schema": {
"x-speakeasy-name-override": "data",
}
}
},
},
status.HTTP_400_BAD_REQUEST: {"model": HTTPError},
status.HTTP_401_UNAUTHORIZED: {"model": HTTPError},
status.HTTP_500_INTERNAL_SERVER_ERROR: {"model": HTTPError},
Expand All @@ -103,6 +121,10 @@ class TextToImageParams(BaseModel):
response_model=ImageResponse,
responses=RESPONSES,
description="Generate images from text prompts.",
operation_id="genTextToImage",
summary="Text To Image",
tags=["generate"],
openapi_extra={"x-speakeasy-name-override": "textToImage"},
)
@router.post(
"/text-to-image/",
Expand Down
13 changes: 13 additions & 0 deletions runner/app/routes/upscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@


RESPONSES = {
status.HTTP_200_OK: {
"content": {
"application/json": {
"schema": {
"x-speakeasy-name-override": "data",
}
}
},
},
status.HTTP_400_BAD_REQUEST: {"model": HTTPError},
status.HTTP_401_UNAUTHORIZED: {"model": HTTPError},
status.HTTP_500_INTERNAL_SERVER_ERROR: {"model": HTTPError},
Expand All @@ -32,6 +41,10 @@
response_model=ImageResponse,
responses=RESPONSES,
description="Upscale an image by increasing its resolution.",
operation_id="genUpscale",
summary="Upscale",
tags=["generate"],
openapi_extra={"x-speakeasy-name-override": "upscale"},
)
@router.post(
"/upscale/",
Expand Down
Loading
Loading