Update slop_with_models.py. nitpicks
This commit is contained in:
parent
394d1cd512
commit
8d878f779b
1 changed files with 8 additions and 7 deletions
|
|
@ -266,7 +266,7 @@ def list_models():
|
||||||
@app.route("/tools", methods=["GET"])
|
@app.route("/tools", methods=["GET"])
|
||||||
def list_tools():
|
def list_tools():
|
||||||
logger.info("Received /tools request")
|
logger.info("Received /tools request")
|
||||||
tool_list = [{"id": k, "description": v["description"]} for k, v in tools.items()]
|
tool_list = [{"id": k, "description": v["description"], "arguments": v.get("arguments", [])} for k, v in tools.items()]
|
||||||
logger.debug(f"Returning tools: {tool_list}")
|
logger.debug(f"Returning tools: {tool_list}")
|
||||||
return jsonify({"tools": tool_list}), 200
|
return jsonify({"tools": tool_list}), 200
|
||||||
|
|
||||||
|
|
@ -278,12 +278,13 @@ def use_tool(tool_id):
|
||||||
return jsonify({"error": "Tool not found"}), 404
|
return jsonify({"error": "Tool not found"}), 404
|
||||||
data = request.json or {}
|
data = request.json or {}
|
||||||
logger.debug(f"Tool {tool_id} input data: {data}")
|
logger.debug(f"Tool {tool_id} input data: {data}")
|
||||||
if tool_id == "calculator" and "expression" not in data:
|
|
||||||
logger.warning("Missing 'expression' for calculator tool")
|
if "arguments" in tools[tool_id]:
|
||||||
return jsonify({"error": "Missing 'expression'"}), 400
|
for arg in tools[tool_id]["arguments"]:
|
||||||
if tool_id == "greet" and "name" not in data:
|
if arg["name"] not in data:
|
||||||
logger.warning("Missing 'name' for greet tool")
|
logger.warning(f"Missing '{arg['name']}' for {tool_id} tool")
|
||||||
return jsonify({"error": "Missing 'name'"}), 400
|
return jsonify({"error": f"Missing '{arg['name']}' parameter"}), 400
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = tools[tool_id]["execute"](data)
|
result = tools[tool_id]["execute"](data)
|
||||||
logger.debug(f"Tool {tool_id} result: {result}")
|
logger.debug(f"Tool {tool_id} result: {result}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue