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

[editor][server endpoints][2/n]: Add params arg to run command and check for undefined prompt_name #613

Merged
merged 1 commit into from
Jan 2, 2024
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
16 changes: 13 additions & 3 deletions python/src/aiconfig/editor/server/server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
import logging
from typing import Any, Dict, Type, Union

Expand Down Expand Up @@ -169,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