Spaces:
Runtime error
Runtime error
Nyha15 commited on
Commit ·
5d862db
1
Parent(s): f3ba91e
Refactored
Browse files
app.py
CHANGED
|
@@ -189,7 +189,7 @@ class KnowledgeBase:
|
|
| 189 |
|
| 190 |
# Split texts into chunks
|
| 191 |
# Split texts into chunks
|
| 192 |
-
splits = self.splitter.split_text("".join(texts))
|
| 193 |
if not splits:
|
| 194 |
log_workflow(f"No splits generated for domain '{self.domain}' and country '{country}'")
|
| 195 |
with self.lock:
|
|
@@ -289,28 +289,29 @@ class CoordinatorAgent:
|
|
| 289 |
advice = {d: self.specialists[d].run(query, country) for d in self.specialists}
|
| 290 |
# 2. plan (omitted)
|
| 291 |
# 3. synthesis
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 304 |
|
| 305 |
-
#
|
| 306 |
-
|
| 307 |
-
output.append(json.dumps(plans, indent=2))
|
| 308 |
-
output.append("\n```")
|
| 309 |
|
| 310 |
-
synthesis = "\n".join(output)
|
| 311 |
-
log_workflow("Synthesis complete")
|
| 312 |
-
# 4. return
|
| 313 |
-
return synthesis
|
| 314 |
|
| 315 |
# =======================================
|
| 316 |
# Main Portal Interface
|
|
|
|
| 189 |
|
| 190 |
# Split texts into chunks
|
| 191 |
# Split texts into chunks
|
| 192 |
+
splits = self.splitter.split_text("\n\n".join(texts))
|
| 193 |
if not splits:
|
| 194 |
log_workflow(f"No splits generated for domain '{self.domain}' and country '{country}'")
|
| 195 |
with self.lock:
|
|
|
|
| 289 |
advice = {d: self.specialists[d].run(query, country) for d in self.specialists}
|
| 290 |
# 2. plan (omitted)
|
| 291 |
# 3. synthesis
|
| 292 |
+
# 4. Synthesize and pretty–print
|
| 293 |
+
lines = ["# Your Personalized Financial Advice\n"]
|
| 294 |
+
|
| 295 |
+
# Add each specialist’s section
|
| 296 |
+
for domain, text in specialist_advice.items():
|
| 297 |
+
lines.append(f"## {domain.capitalize()}\n")
|
| 298 |
+
# Indent each paragraph for readability
|
| 299 |
+
for para in text.strip().split("\n\n"):
|
| 300 |
+
lines.append(" " + para.strip().replace("\n", "\n "))
|
| 301 |
+
lines.append("") # blank line
|
| 302 |
+
|
| 303 |
+
# Append Multi-Path Plans as a JSON code block
|
| 304 |
+
lines.append("## Multi-Path Financial Plans\n")
|
| 305 |
+
lines.append("```json")
|
| 306 |
+
lines.append(json.dumps(plans, indent=2))
|
| 307 |
+
lines.append("```")
|
| 308 |
+
|
| 309 |
+
formatted = "\n".join(lines)
|
| 310 |
+
log_workflow("Synthesis complete")
|
| 311 |
|
| 312 |
+
# 5. Return formatted advice + workflow log
|
| 313 |
+
return formatted + "\n\n---\n" + get_workflow_log()
|
|
|
|
|
|
|
| 314 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
|
| 316 |
# =======================================
|
| 317 |
# Main Portal Interface
|