Skip to content

Commit

Permalink
[editor][server endpoints][2/n]: Add params arg to run command and ch…
Browse files Browse the repository at this point in the history
…eck for undefined prompt_name

TSIA, pretty simple otherwise we'd be using empty params field and that would error. For the future, I created issue #671 where we shouldn't even need to pass in params into run and this works implicitly

See #612 for example on how to test (will do this tomorrow, just tired now)
  • Loading branch information
Rossdan Craig [email protected] committed Jan 2, 2024
1 parent 7917449 commit e0c8f59
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions python/src/aiconfig/editor/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,19 @@ async def run() -> FlaskResponse:
request_json = request.get_json()

try:
prompt_name = request_json["prompt_name"]
params = request_json.get("params", {})
prompt_name: Union[str, None] = request_json.get("prompt_name")
if prompt_name is None:
return HttpResponseWithAIConfig(
message="No prompt name provided, cannot execute `run` command",
code=400,
aiconfig=None,
).to_flask_format()

# TODO (rossdanlm): Refactor aiconfig.run() to not take in `params`
# as a function arg since we can now just call
# aiconfig.get_parameters(prompt_name) directly inside of run. See:
# https://github.com/lastmile-ai/aiconfig/issues/671
params = request_json.get("params", aiconfig.get_parameters(prompt_name)) # type: ignore
stream = request_json.get("stream", False)
options = InferenceOptions(stream=stream)
run_output = await aiconfig.run(prompt_name, params, options) # type: ignore
Expand Down

0 comments on commit e0c8f59

Please sign in to comment.