Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

upd: better result formatting

hashedviking105e1febe8e6
diff --git a/app.py b/app.py
index 544052940d..3eb7ca1092 100644
--- a/app.py
+++ b/app.py
@@ -548,7 +548,11 @@ def run_research_process(research_id, query, mode):
if results.get('findings'):
#initial_analysis = [finding['content'] for finding in results['findings']]
summary = ""
- summary = summary + results['formatted_findings']
+ raw_formatted_findings = results['formatted_findings']
+
+ # ADDED CODE: Convert debug output to clean markdown
+ clean_markdown = convert_debug_to_markdown(raw_formatted_findings, query)
+
# Save as markdown file
output_dir = "research_outputs"
if not os.path.exists(output_dir):
@@ -561,7 +565,7 @@ def run_research_process(research_id, query, mode):
with open(report_path, "w", encoding="utf-8") as f:
f.write("# Quick Research Summary\n\n")
f.write(f"Query: {query}\n\n")
- f.write(summary)
+ f.write(clean_markdown) # Use clean markdown instead of raw findings
f.write("\n\n## Research Metrics\n")
f.write(f"- Search Iterations: {results['iterations']}\n")
f.write(f"- Generated at: {datetime.utcnow().isoformat()}\n")
@@ -842,6 +846,51 @@ def app_serve_static(path):
def favicon():
return send_from_directory(app.static_folder, 'favicon.ico', mimetype='image/x-icon')
+# Add this function to app.py
+def convert_debug_to_markdown(raw_text, query):
+ """
+ Convert the debug-formatted text to clean markdown.
+
+ Args:
+ raw_text: The raw formatted findings with debug symbols
+ query: Original research query
+
+ Returns:
+ Clean markdown formatted text
+ """
+ # If there's a "DETAILED FINDINGS:" section, extract everything after it
+ if "DETAILED FINDINGS:" in raw_text:
+ detailed_index = raw_text.index("DETAILED FINDINGS:")
+ content = raw_text[detailed_index + len("DETAILED FINDINGS:"):].strip()
+ else:
+ content = raw_text
+
+ # Remove divider lines with === symbols
+ content = "\n".join([line for line in content.split("\n")
+ if not line.strip().startswith("===") and not line.strip() == "="*80])
+
+ # If COMPLETE RESEARCH OUTPUT exists, remove that section
+ if "COMPLETE RESEARCH OUTPUT" in content:
+ content = content.split("COMPLETE RESEARCH OUTPUT")[0].strip()
+
+ # Remove SEARCH QUESTIONS BY ITERATION section
+ if "SEARCH QUESTIONS BY ITERATION:" in content:
+ search_index = content.index("SEARCH QUESTIONS BY ITERATION:")
+ next_major_section = -1
+ for marker in ["DETAILED FINDINGS:", "COMPLETE RESEARCH:"]:
+ if marker in content[search_index:]:
+ marker_pos = content.index(marker, search_index)
+ if next_major_section == -1 or marker_pos < next_major_section:
+ next_major_section = marker_pos
+
+ if next_major_section != -1:
+ content = content[:search_index] + content[next_major_section:]
+ else:
+ # If no later section, just remove everything from SEARCH QUESTIONS onwards
+ content = content[:search_index].strip()
+
+ return content.strip()
+
if __name__ == '__main__':
# Check for OpenAI availability but don't import it unless necessary
try: