Fix: respond() now returns history list pairs (tuples), not raw strings
Browse files
app.py
CHANGED
|
@@ -53,7 +53,7 @@ def execute(tool_name: str, tool_args: dict) -> str:
|
|
| 53 |
|
| 54 |
# βββ Response Logic ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 55 |
|
| 56 |
-
def respond(message: str):
|
| 57 |
msg = message.lower()
|
| 58 |
|
| 59 |
if any(k in msg for k in ["calculate", "compute", "math", "roi", "compound", "interest", "%", "$"]):
|
|
@@ -69,12 +69,12 @@ def respond(message: str):
|
|
| 69 |
cmd = m.group(1) if m else message.split()[-1]
|
| 70 |
tool, args = "run_command", {"command": cmd, "cwd": "."}
|
| 71 |
else:
|
| 72 |
-
return "This is a demo of Stack X Ultimate's tool-calling capability. The fine-tuned model processes your message and decides whether to call a tool. Try one of the examples below! π§"
|
| 73 |
|
| 74 |
result = execute(tool, args)
|
| 75 |
call = f"π§ Calling `{tool}`...\n\n```json\n{json.dumps(args, indent=2)}\n```"
|
| 76 |
res = f"β
**{tool}** result:\n\n```\n{result}\n```"
|
| 77 |
-
return [[call, res]]
|
| 78 |
|
| 79 |
# βββ Dark CSS βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 80 |
|
|
|
|
| 53 |
|
| 54 |
# βββ Response Logic ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 55 |
|
| 56 |
+
def respond(message: str, history: list):
|
| 57 |
msg = message.lower()
|
| 58 |
|
| 59 |
if any(k in msg for k in ["calculate", "compute", "math", "roi", "compound", "interest", "%", "$"]):
|
|
|
|
| 69 |
cmd = m.group(1) if m else message.split()[-1]
|
| 70 |
tool, args = "run_command", {"command": cmd, "cwd": "."}
|
| 71 |
else:
|
| 72 |
+
return history + [[message, "This is a demo of Stack X Ultimate's tool-calling capability. The fine-tuned model processes your message and decides whether to call a tool. Try one of the examples below! π§"]]
|
| 73 |
|
| 74 |
result = execute(tool, args)
|
| 75 |
call = f"π§ Calling `{tool}`...\n\n```json\n{json.dumps(args, indent=2)}\n```"
|
| 76 |
res = f"β
**{tool}** result:\n\n```\n{result}\n```"
|
| 77 |
+
return history + [[call, res]]
|
| 78 |
|
| 79 |
# βββ Dark CSS βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 80 |
|