Agent Zero AI framework
RFC error messages
frdelbad39516462c
diff --git a/python/helpers/rfc.py b/python/helpers/rfc.pyindex dd5cbb720..aeee03dee 100644--- a/python/helpers/rfc.py+++ b/python/helpers/rfc.py@@ -74,7 +74,15 @@ async def _send_json_data(url: str, data: str):url,json=data,) as response:- return await response.json()+ if response.status == 200:+ result = await response.json()+ if result["ok"]:+ return result["result"]+ else:+ raise Exception(result["message"])+ else:+ error = await response.text()+ raise Exception(error)def hash_data(data: str, password: str):diff --git a/python/helpers/runtime.py b/python/helpers/runtime.pyindex e9b9d7de5..e60f2b18f 100644--- a/python/helpers/runtime.py+++ b/python/helpers/runtime.py@@ -70,7 +70,7 @@ def _get_rfc_url() -> str:url = settings.get_settings()["rfc_url"]if not url.endswith("/"):url += "/"- url += "url"+ url += "rfc"return url# if get_arg("rfc_url"):# return str(get_arg("rfc_url"))diff --git a/run_ui.py b/run_ui.pyindex 9e87d2746..fd65ae964 100644--- a/run_ui.py+++ b/run_ui.py@@ -530,7 +530,7 @@ async def transcribe():"message": str(e),}PrintStyle.error(str(e))-+# respond with jsonreturn jsonify(response)@@ -539,12 +539,26 @@ async def transcribe():@app.route("/rfc", methods=["POST"])@requires_authasync def handle_rfc():- # data sent to the server- input = json.loads(request.get_json())+ try:+ # data sent to the server+ input = json.loads(request.get_json())++ # handle RFC+ result = await runtime.handle_rfc(input)- # handle RFC- result = await runtime.handle_rfc(input)- return jsonify(result)+ response = {+ "ok": True,+ "result": result,+ }++ return jsonify(response)+ except Exception as e:+ response = {+ "ok": False,+ "message": str(e),+ }+ PrintStyle.error(str(e))+ return jsonify(response), 500def run():