~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
docs: Add Google Programmable Search Engine to config.py documentation
hashedviking7a1c07f42397
diff --git a/config.py b/config.pyindex d883f6a753..682cffde43 100644--- a/config.py+++ b/config.py@@ -11,6 +11,7 @@ MAIN SETTINGS:- "arxiv": Scientific papers and research- "duckduckgo": General web search (no API key needed)- "serp": Google search via SerpAPI (requires API key)+ - "google_pse": Google Programmable Search Engine for custom search experiences (requires API key)- "guardian": News articles (requires API key)- Any collection name from your local_collections.py@@ -21,6 +22,13 @@ MAIN SETTINGS:- "gpt-4o": OpenAI model (requires API key)- "mpt-7b": MPT model via VLLM+API KEYS:+For search engines requiring API keys, set these in your .env file:+- SERP_API_KEY: For Google search via SerpAPI+- GUARDIAN_API_KEY: For The Guardian news search+- GOOGLE_PSE_API_KEY: For Google Programmable Search Engine+- GOOGLE_PSE_ENGINE_ID: Search Engine ID from Google PSE Control Panel+RESEARCH SETTINGS:- SEARCH_ITERATIONS (int): Number of research cycles- QUESTIONS_PER_ITERATION (int): Questions per cycle@@ -40,6 +48,9 @@ from web_search_engines.search_engine_factory import get_search as factory_get_simport os+import re+from typing import Dict, List, Any, Optional, Callable+# Load environment variablesload_dotenv()# Choose search tool: "serp" or "duckduckgo" (serp requires API key)@@ -85,6 +96,99 @@ SEARCH_LANGUAGE = "English"# Output ConfigurationOUTPUT_DIR = "research_outputs"+# Make OpenAI integration optional with lazy loading+def is_openai_available():+ """Check if OpenAI is available without importing it at module level"""+ try:+ # Only import when checking+ import os+ api_key = os.environ.get("OPENAI_API_KEY")+ if not api_key:+ return False++ # Only try to import if we have an API key+ try:+ from langchain_openai import ChatOpenAI+ return True+ except ImportError:+ return False+ except:+ return False++# Models map+MODELS = {+ # Local models+ "ollama-llama3": "Local Llama3 model (requires Ollama)",+ "ollama-mixtral": "Local Mixtral model (requires Ollama)",+ "ollama-mistral": "Local Mistral model (requires Ollama)",++ # API-based models+ "gpt-4o": "OpenAI model (requires API key)",+ "gpt-3.5-turbo": "OpenAI model (requires API key)",+}++# Available model providers+MODEL_PROVIDERS = ["local", "openai"]++def get_model(model_name: str, **kwargs):+ """Get model instance based on the model name"""+ # Common parameters for all models+ common_params = {+ "temperature": kwargs.get("temperature", 0.0),+ "verbose": kwargs.get("verbose", False),+ }++ # Ollama models (local)+ if model_name.startswith("ollama-"):+ try:+ from langchain_community.llms import Ollama+ base_url = os.getenv("OLLAMA_BASE_URL", "http://localhost:11434")+ return Ollama(model=model_name.replace("ollama-", ""), base_url=base_url, **common_params)+ except ImportError:+ raise ValueError("Langchain Ollama integration not available. Please install it with: pip install langchain-community")++ # OpenAI models+ elif model_name in ["gpt-4o", "gpt-3.5-turbo"]:+ if not is_openai_available():+ raise ValueError("OpenAI integration not available. Please install langchain-openai and set OPENAI_API_KEY environment variable.")++ 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:+ raise ValueError(f"Unsupported model: {model_name}")++def get_available_models() -> Dict[str, str]:+ """Return available models based on installed packages and environment variables"""+ available_models = {}++ # Check Ollama models+ try:+ import langchain_community+ # Check if Ollama is running+ ollama_running = False+ try:+ import requests+ base_url = os.getenv("OLLAMA_BASE_URL", "http://localhost:11434")+ requests.get(f"{base_url}/api/tags", timeout=2)+ ollama_running = True+ except:+ pass++ if ollama_running:+ for model in [k for k in MODELS.keys() if k.startswith("ollama-")]:+ available_models[model] = MODELS[model]+ except ImportError:+ pass++ # Check OpenAI models+ if is_openai_available():+ for model in ["gpt-4o", "gpt-3.5-turbo"]:+ available_models[model] = MODELS[model]++ return available_modelsdef get_llm(model_name=DEFAULT_MODEL, temperature=DEFAULT_TEMPERATURE):"""Get LLM instance - easy to switch between models"""@@ -102,6 +206,9 @@ def get_llm(model_name=DEFAULT_MODEL, temperature=DEFAULT_TEMPERATURE):)elif "gpt" in model_name:+ if not is_openai_available():+ raise ValueError("OpenAI integration not available or API key not set. Please install langchain-openai and set OPENAI_API_KEY.")+api_key = os.getenv("OPENAI_API_KEY")if not api_key:raise ValueError("OPENAI_API_KEY not found in environment variables")