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 Dec 29, 2023
1 parent c572942 commit 5b11f67
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions python/src/aiconfig/editor/server/server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import Any, Type
from typing import Any, Type, Union

import lastmile_utils.lib.core.api as core_utils
import result
Expand Down Expand Up @@ -168,8 +168,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 5b11f67

Please sign in to comment.