Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

fix(server): temporary workaround for multiple prompts #199

Merged
merged 1 commit into from
Jun 2, 2023
Merged
Changes from all 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
19 changes: 18 additions & 1 deletion basaran/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,26 @@ def parse_options(schema):
# body, the former takes precedence.
if key in request.args:
options[key] = request.args.get(key, dtype(), type=dtype_fn)
elif payload and key in payload and isinstance(payload[key], dtypes):
elif (
isinstance(payload, dict)
and key in payload
and isinstance(payload[key], dtypes)
):
options[key] = dtype(payload[key])

# Temporary workaround for multiple prompts (#198).
if (
key == "prompt"
and isinstance(payload, dict)
and key in payload
and isinstance(payload[key], list)
):
prompts = payload[key]
if len(prompts) == 1:
options[key] = prompts[0]
elif len(prompts) > 1:
abort(400, description="only one prompt is supported")

return options


Expand Down