Update app.py
Browse files
app.py
CHANGED
@@ -39,19 +39,23 @@ question_examples = [
|
|
39 |
# === Helper: extract tool name from content
|
40 |
def extract_tool_name_and_clean_content(raw_content):
|
41 |
if isinstance(raw_content, (dict, list)):
|
42 |
-
return "
|
43 |
if not isinstance(raw_content, str):
|
44 |
-
return "
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
55 |
|
56 |
# === Helper: formatted collapsible output
|
57 |
def format_collapsible(content, title="Answer"):
|
|
|
39 |
# === Helper: extract tool name from content
|
40 |
def extract_tool_name_and_clean_content(raw_content):
|
41 |
if isinstance(raw_content, (dict, list)):
|
42 |
+
return "Tool Result", json.dumps(raw_content, indent=2)
|
43 |
if not isinstance(raw_content, str):
|
44 |
+
return "Tool Result", str(raw_content)
|
45 |
+
|
46 |
+
# Check if content starts with something like: [TOOL_CALLS][{"name": "Tool_RAG" ...
|
47 |
+
if '"name": "' in raw_content:
|
48 |
+
try:
|
49 |
+
start = raw_content.index('"name": "') + 9
|
50 |
+
end = raw_content.index('"', start)
|
51 |
+
tool_name = raw_content[start:end]
|
52 |
+
title = f"Tool: {tool_name}"
|
53 |
+
except Exception:
|
54 |
+
title = "Tool Result"
|
55 |
+
else:
|
56 |
+
title = "Tool Result"
|
57 |
+
|
58 |
+
return title, raw_content.strip()
|
59 |
|
60 |
# === Helper: formatted collapsible output
|
61 |
def format_collapsible(content, title="Answer"):
|