Skip to content

Commit

Permalink
Create set_name endpoint (#692)
Browse files Browse the repository at this point in the history
Create set_name endpoint


TSIA

## Test Plan
Follow dev README to setup the local editor:
https://github.com/lastmile-ai/aiconfig/tree/main/python/src/aiconfig/editor#dev,
then run this command
```
curl http://localhost:8080/api/set_name -d '{"name":"cool_new_name"}' -X POST -H 'Content-Type: application/json'
```


https://github.com/lastmile-ai/aiconfig/assets/151060367/efcb7ceb-e390-4208-93b3-3effd5d66f8b

---
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with
[ReviewStack](https://reviewstack.dev/lastmile-ai/aiconfig/pull/692).
* #693
* __->__ #692
* #691
* #690
* #688
* #670
* #668
  • Loading branch information
rossdanlm authored Jan 2, 2024
2 parents 9d0d971 + ce5dff6 commit 700e977
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions python/src/aiconfig/editor/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ def set_parameter() -> FlaskResponse:
)
return run_aiconfig_operation_with_op_args(aiconfig, "set_parameter", operation, operation_args)


@app.route("/api/delete_parameter", methods=["POST"])
def delete_parameter() -> FlaskResponse:
state = get_server_state(app)
Expand All @@ -269,7 +270,18 @@ def delete_parameter() -> FlaskResponse:
prompt_name: str | None = request_json.get("prompt_name")

operation = make_op_run_method(MethodName("delete_parameter"))
operation_args: Result[OpArgs, str] = result.Ok(
OpArgs({"parameter_name": parameter_name, "prompt_name": prompt_name})
)
operation_args: Result[OpArgs, str] = result.Ok(OpArgs({"parameter_name": parameter_name, "prompt_name": prompt_name}))
return run_aiconfig_operation_with_op_args(aiconfig, "delete_parameter", operation, operation_args)


@app.route("/api/set_name", methods=["POST"])
def set_name() -> FlaskResponse:
state = get_server_state(app)
aiconfig = state.aiconfig
request_json = request.get_json()

name: str | None = request_json.get("name")

operation = make_op_run_method(MethodName("set_name"))
operation_args: Result[OpArgs, str] = result.Ok(OpArgs({"name": name}))
return run_aiconfig_operation_with_op_args(aiconfig, "set_name", operation, operation_args)

0 comments on commit 700e977

Please sign in to comment.