Skip to content

Commit

Permalink
Create delete_parameter endpoint (#691)
Browse files Browse the repository at this point in the history
Create delete_parameter 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/delete_parameter -d '{"prompt_name":"get_activities", "parameter_name": "city"}' -X POST -H 'Content-Type: application/json'
```
Notice that the parameters are now deleted

Prompt-level


https://github.com/lastmile-ai/aiconfig/assets/151060367/866db51d-6b84-438d-ac4e-483d0cfbaa40

AIConfig-level


https://github.com/lastmile-ai/aiconfig/assets/151060367/dcd47f62-875c-40ac-9e81-efcd8cf9b45a

---
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with
[ReviewStack](https://reviewstack.dev/lastmile-ai/aiconfig/pull/691).
* #693
* #692
* __->__ #691
* #690
* #688
* #670
* #668
  • Loading branch information
rossdanlm authored Jan 2, 2024
2 parents 3fc6435 + 86f90a7 commit 9d0d971
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion 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, Dict, Type
from typing import Any, Dict, Type, Union

import lastmile_utils.lib.core.api as core_utils
import result
Expand Down Expand Up @@ -241,3 +241,35 @@ def update_model() -> FlaskResponse:
operation = make_op_run_method(MethodName("update_model"))
operation_args: Result[OpArgs, str] = result.Ok(OpArgs({"model_name": model_name, "settings": settings, "prompt_name": prompt_name}))
return run_aiconfig_operation_with_op_args(aiconfig, "update_model", operation, operation_args)


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

parameter_name: str | None = request_json.get("parameter_name")
parameter_value: Union[str, Dict[str, Any]] | None = request_json.get("parameter_value")
prompt_name: str | None = request_json.get("prompt_name")

operation = make_op_run_method(MethodName("set_parameter"))
operation_args: Result[OpArgs, str] = result.Ok(
OpArgs({"parameter_name": parameter_name, "parameter_value": parameter_value, "prompt_name": prompt_name})
)
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)
aiconfig = state.aiconfig
request_json = request.get_json()

parameter_name: str | None = request_json.get("parameter_name")
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})
)
return run_aiconfig_operation_with_op_args(aiconfig, "delete_parameter", operation, operation_args)

0 comments on commit 9d0d971

Please sign in to comment.