Skip to content

Commit

Permalink
fix(runner): handle empty prompt in T2I input (#244)
Browse files Browse the repository at this point in the history
This commit adds a check to the T2I route to ensure the 'prompt' input valueis non-empty. This is necessary because request body validation was disabled in go-livepeer due to issues with optional parameters not showing up correctly. See [this go-livepeer commit](livepeer/go-livepeer@3fcc300) for more details.
  • Loading branch information
rickstaa authored Oct 28, 2024
1 parent 3e2b1ee commit 0c4e0a8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions runner/app/routes/text_to_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ async def text_to_image(
pipeline: Pipeline = Depends(get_pipeline),
token: HTTPAuthorizationCredentials = Depends(HTTPBearer(auto_error=False)),
):
# Ensure required parameters are non-empty.
# TODO: Remove if go-livepeer validation is fixed. Was disabled due to optional
# params issue.
if not params.prompt:
return JSONResponse(
status_code=status.HTTP_400_BAD_REQUEST,
content=http_error("Prompt must be provided."),
)

auth_token = os.environ.get("AUTH_TOKEN")
if auth_token:
if not token or token.credentials != auth_token:
Expand Down

0 comments on commit 0c4e0a8

Please sign in to comment.