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.

optimizations

LearningCircuit02042634506c
diff --git a/.env.template b/.env.template
new file mode 100644
index 0000000000..de2807baf8
--- /dev/null
+++ b/.env.template
@@ -0,0 +1,5 @@
+# API Keys
+ANTHROPIC_API_KEY=your-api-key-here
+# Add other API keys as needed
+# OPENAI_API_KEY=your-openai-key-here
+# GOOGLE_API_KEY=your-google-key-here
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index d7d40879af..4e6bd3611a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,6 +38,8 @@ temp_output.txt
temp_output_findings.txt
formatted_output.txt
Output.txt
+research_outputs
+report.md
# Logs
*.log
diff --git a/config.py b/config.py
new file mode 100644
index 0000000000..a4f4ccb0c2
--- /dev/null
+++ b/config.py
@@ -0,0 +1,99 @@
+from langchain_community.tools import DuckDuckGoSearchResults
+from langchain_anthropic import ChatAnthropic
+from langchain_openai import ChatOpenAI
+from langchain_ollama import ChatOllama
+from dotenv import load_dotenv
+import os
+
+# Load environment variables
+load_dotenv()
+
+# LLM Configuration
+DEFAULT_MODEL = "deepseek-r1:14b"
+DEFAULT_TEMPERATURE = 0.7
+MAX_TOKENS = 20000
+
+# Search Configuration
+MAX_SEARCH_RESULTS = 40
+SEARCH_REGION = "us-en"
+TIME_PERIOD = "y"
+SAFE_SEARCH = True
+
+# Research Parameters
+MAX_ITERATIONS = 4
+CONTEXT_LIMIT = 5000
+MIN_CONFIDENCE_SCORE = 0.7
+ENABLE_CITATIONS = True
+SAVE_INTERIM_RESULTS = True
+
+# Output Configuration
+OUTPUT_DIR = "research_outputs"
+CACHE_DIR = ".cache"
+MAX_CACHE_AGE = 24 * 60 * 60 # 24 hours
+ENABLE_PDF = True # PDF generation disabled by default
+ENABLE_DEBUG_LOGS = False # Debug logging disabled by default
+
+# PDF Configuration (only used if ENABLE_PDF is True)
+PDF_STYLING = {
+ 'page_size': 'A4',
+ 'margin_left': 25,
+ 'margin_right': 25,
+ 'margin_top': 20,
+ 'margin_bottom': 20,
+ 'font_size': 11,
+ 'title_font_size': 24,
+ 'heading_font_size': 16,
+ 'subheading_font_size': 14
+}
+
+def get_llm(model_name=DEFAULT_MODEL, temperature=DEFAULT_TEMPERATURE):
+ """Get LLM instance - easy to switch between models"""
+
+ common_params = {
+ "temperature": temperature,
+ "max_tokens": MAX_TOKENS,
+ }
+
+ if "claude" in model_name:
+ api_key = os.getenv('ANTHROPIC_API_KEY')
+ if not api_key:
+ raise ValueError("ANTHROPIC_API_KEY not found in environment variables")
+ return ChatAnthropic(
+ model=model_name,
+ anthropic_api_key=api_key,
+ **common_params
+ )
+
+ elif "gpt" in model_name:
+ api_key = os.getenv('OPENAI_API_KEY')
+ if not api_key:
+ raise ValueError("OPENAI_API_KEY not found in environment variables")
+ return ChatOpenAI(
+ model=model_name,
+ api_key=api_key,
+ **common_params
+ )
+
+ else:
+ return ChatOllama(
+ model=model_name,
+ **common_params
+ )
+
+def get_search():
+ """Get search tool instance"""
+ return DuckDuckGoSearchResults(
+ max_results=MAX_SEARCH_RESULTS,
+ region=SEARCH_REGION,
+ time=TIME_PERIOD,
+ safesearch=SAFE_SEARCH
+ )
+
+def ensure_directories():
+ """Ensure required directories exist"""
+ for directory in [OUTPUT_DIR, CACHE_DIR]:
+ if not os.path.exists(directory):
+ os.makedirs(directory)
+
+# Create necessary directories on import
+ensure_directories()
\ No newline at end of file
diff --git a/main.py b/main.py
index b038350fb7..5b1009eead 100644
--- a/main.py
+++ b/main.py
@@ -75,7 +75,7 @@ def main():
print(f"\nNumber of sources analyzed: {len(results['findings'])}")
else:
# Full Report
- final_report = report_generator.generate_report(results["findings"], ["query"])
+ final_report = report_generator.generate_report(results["findings"], query)
print("\n=== RESEARCH REPORT ===")
print_report(final_report)
diff --git a/report_generator.py b/report_generator.py
index 8754b523b4..ad1798159e 100644
--- a/report_generator.py
+++ b/report_generator.py
@@ -1,13 +1,12 @@
from typing import Dict, List, Optional
-from langchain_ollama import ChatOllama
+from config import get_llm
import re
from datetime import datetime
from search_system import AdvancedSearchSystem
class IntegratedReportGenerator:
- def __init__(self, model_name: str = "deepseek-r1:14b", temperature: float = 0.7,
- searches_per_section: int = 2):
- self.model = ChatOllama(model=model_name, temperature=temperature)
+ def __init__(self, searches_per_section: int = 2):
+ self.model = get_llm()
self.search_system = AdvancedSearchSystem()
self.searches_per_section = searches_per_section # Control search depth per section
diff --git a/search_system.py b/search_system.py
index ea207289f0..f773b1ebf9 100644
--- a/search_system.py
+++ b/search_system.py
@@ -4,10 +4,11 @@ from typing import Dict, List
from datetime import datetime
from utilities import remove_think_tags, format_findings_to_text
import os
+from config import get_llm
class AdvancedSearchSystem:
def __init__(self):
self.search = DuckDuckGoSearchResults(max_results=40)
- self.model = ChatOllama(model="deepseek-r1:14b", temperature=0.7)
+ self.model = get_llm()
self.max_iterations = 2
self.context_limit = 5000
self.questions_by_iteration = {}