Agentic APP 技术栈总结- SearXNG

简介

Welcome to SearXNG --- SearXNG Documentation (2025.3.29+50f92779b) SearXNG 是一个免费的互联网元搜索引擎,可聚合多达 231 个搜索服务的结果。用户不会被追踪或分析。此外,SearXNG 可以通过 Tor 使用,以保证在线匿名性。通过使用 searx.space 上列出的实例开始使用 SearXNG。如果您不信任任何人,您可以搭建自己的实例。

安装

自建部署 SearXNG (推荐)

最佳使用方式:强烈建议您自托管自己的 SearXNG 实例:

使用 Docker

arduino 复制代码
# Pull the SearXNG Docker image
docker pull searxng/searxng

# Run SearXNG (will be available at http://localhost:8080)
docker run -d -p 8080:8080 --name searxng searxng/searxng

使用 Docker Compose (推荐)

可以 clone GitHub - searxng/searxng-docker: The docker-compose files for setting up a SearXNG instance with docker. 使用其中的 docker-compose.yml,或者手动编辑。

  1. 创建 docker-compose.yml ,输入下面内容
yaml 复制代码
version: '3'
services:
  searxng:
    container_name: searxng
    image: searxng/searxng
    ports:
      - "8080:8080"
    volumes:
      - ./searxng:/etc/searxng
    environment:
      - SEARXNG_BASE_URL=http://localhost:8080/
    restart: unless-stopped
  1. 后台运行 Docker Compose:

    docker-compose up -d

使用公开服务实例

如果你必须使用公开服务实例

  • Get Permission: 始终联系任何公共实例的管理员
  • Respect Resources: 在请求之间使用更长的延迟(至少 4-5 秒)
  • Limited Usage: 尽量在有必要时才 search

公有实例的示例配置:

ini 复制代码
SEARXNG_INSTANCE=https://instance.example.com
SEARXNG_DELAY=5.0

配置

配置文件在 searxng/settings.yml

输出格式配置

yaml 复制代码
  # remove format to deny access, use lower case.
  # formats: [html, csv, json, rss]
  formats:
    - html
    - json

查询参数中增加 format=json ,则会使用 json 格式返回查询结果

bash 复制代码
[localhost:8081/search?format=json&q=Hello](http://localhost:8081/search?format=json&q=Hello)

local-deep-research 中配置 searXNG

local-deep-research/docs/SearXNG-Setup.md at main · LearningCircuit/local-deep-research · GitHub

Setting Up Access

You have two ways to enable the SearXNG search engine:

  1. Environment Variable (Recommended) :

    ini 复制代码
    # Add to your .env file or set in your environment
    SEARXNG_INSTANCE=http://localhost:8080
    
    # Optional: Set custom delay between requests (in seconds)
    SEARXNG_DELAY=2.0
  2. Configuration Parameter : Add to your config.py:

    makefile 复制代码
    # In config.py
    SEARXNG_CONFIG = {
        "instance_url": "http://localhost:8080",
        "delay_between_requests": 2.0
    }

Checking Configuration

To verify if SearXNG is properly configured:

python 复制代码
from local_deep_research.web_search_engines.search_engine_factory import create_search_engine
from local_deep_research.web_search_engines.search_engines_config import SEARCH_ENGINES

# Create the engine
engine = create_search_engine("searxng")

# Check if available
if engine and hasattr(engine, 'is_available') and engine.is_available:
    print(f"SearXNG configured with instance: {engine.instance_url}")
    print(f"Delay between requests: {engine.delay_between_requests} seconds")
else:
    print("SearXNG is not properly configured or is disabled")

结果是找不到 searXNG

sql 复制代码
local_deep_research.web_search_engines.search_engine_factory:Search engine 'searxng' not found, using default: wikipedia
INFO:local_deep_research.web_search_engines.search_engine_factory:Creating wikipedia with filtered parameters: dict_keys(['max_results', 'include_content'])

search_engines.toml

搜索引擎配置文件中,未添加 searxng 配置

ini 复制代码
[searxng]
module_path = "local_deep_research.web_search_engines.engines.search_engine_searxng"
class_name = "SearXNGSearchEngine"
requires_api_key = false
reliability = 0.95
strengths = [
    "web search", "product information", "reviews", "recent information", 
    "news", "general queries", "broad coverage"
]
weaknesses = ["inconsistent due to rate limits", "not specialized for academic content"]

[searxng.default_params]
format = json

python module load

ini 复制代码
module = importlib.import_module(module_path)
engine_class = getattr(module, class_name)

local_deep_research.web_search_engines.engines.search_engine_searxng module 路径错误, 查看 local_deep_research.web_search_engines.engines.search_engine_searxng 文件,文件存在,但其中有 import 报错, 将 import 报错的引用增加 local_deep_research.

diff 复制代码
(deep-researcher) λ git diff                                                                                      
diff --git a/src/local_deep_research/web_search_engines/engines/full_search.py b/src/local_deep_research/web_searc
_engines/engines/full_search.py                                                                                   
index 8b5a0cb..02d0744 100644                                                                                     
--- a/src/local_deep_research/web_search_engines/engines/full_search.py                                           
+++ b/src/local_deep_research/web_search_engines/engines/full_search.py                                           
@@ -4,7 +4,7 @@ from langchain_community.document_transformers import BeautifulSoupTransformer                    
 from langchain_core.language_models import BaseLLM                                                               
 from typing import List, Dict                                                                                    
 import json, os                                                                                                  
-from .utilties.search_utilities import remove_think_tags                                                         
+from local_deep_research.utilties.search_utilities import remove_think_tags                                      
 from datetime import datetime                                                                                    
 from local_deep_research import config                                                                           
 import logging                                                                                                   
diff --git a/src/local_deep_research/web_search_engines/engines/search_engine_searxng.py b/src/local_deep_research
web_search_engines/engines/search_engine_searxng.py                                                               
index 2ce1621..4561ebd 100644                                                                                     
--- a/src/local_deep_research/web_search_engines/engines/search_engine_searxng.py                                 
+++ b/src/local_deep_research/web_search_engines/engines/search_engine_searxng.py                                 
@@ -6,9 +6,9 @@ from langchain_core.language_models import BaseLLM                                                
 import time                                                                                                      
 import json                                                                                                      
                                                                                                                  
-from web_search_engines.search_engine_base import BaseSearchEngine                                               
-from web_search_engines.engines.full_search import FullSearchResults                                             
-import config                                                                                                    
+from local_deep_research.web_search_engines.search_engine_base import BaseSearchEngine                           
+from local_deep_research.web_search_engines.engines.full_search import FullSearchResults                         
+from local_deep_research import config                                                                           
                                                                                                                  
 # Setup logging                                                                                                  
 logging.basicConfig(level=logging.INFO)                                                                          
diff --git a/tests/searxng_test.py b/tests/searxng_test.py                                                        

SEARXNG_INSTANCE

python 复制代码
No SearXNG instance URL provided. The engine is disabled. Set SEARXNG_INSTANCE environment variable or provide instance_url parameter.

测试代码未加载环境变量配置 searXNG 的访问地址,修改测试代码加载 .env 环境变量配置文件。load_dotenv(dotenv_path=settings.env_file)

python 复制代码
from local_deep_research.web_search_engines.search_engine_factory import create_search_engine
from local_deep_research.web_search_engines.search_engines_config import SEARCH_ENGINES
from local_deep_research.config import settings

from dotenv import load_dotenv

load_dotenv(dotenv_path=settings.env_file)

# Create the engine
engine = create_search_engine("searxng")

# Check if available
if engine and hasattr(engine, 'is_available') and engine.is_available:
    print(f"SearXNG configured with instance: {engine.instance_url}")
    print(f"Delay between requests: {engine.delay_between_requests} seconds")
else:
    print("SearXNG is not properly configured or is disabled")

Done

less 复制代码
INFO:local_deep_research.web_search_engines.search_engine_factory:Creating searxng with filtered parameters: dict_keys(['max_results'])
INFO:local_deep_research.web_search_engines.engines.search_engine_searxng:SearXNG init - Instance URL sources: api_key=None, env=http://localhost:8081, param=None      
INFO:local_deep_research.web_search_engines.engines.search_engine_searxng:SearXNG initialized with instance URL: http://localhost:8081
INFO:local_deep_research.web_search_engines.engines.search_engine_searxng:SearXNG init params: max_results=50, language=en, max_filtered_results=None, is_available=True
INFO:local_deep_research.web_search_engines.engines.search_engine_searxng:SearXNG engine initialized with instance: http://localhost:8081
INFO:local_deep_research.web_search_engines.engines.search_engine_searxng:Rate limiting set to 2.0 seconds between requests
SearXNG configured with instance: http://localhost:8081
Delay between requests: 2.0 seconds
相关推荐
过期动态2 小时前
【动手学深度学习】卷积神经网络(CNN)入门
人工智能·python·深度学习·pycharm·cnn·numpy
蔗理苦5 小时前
2025-04-05 吴恩达机器学习5——逻辑回归(2):过拟合与正则化
人工智能·python·机器学习·逻辑回归
程序猿阿伟6 小时前
《SQL赋能人工智能:解锁特征工程的隐秘力量》
数据库·人工智能·sql
csssnxy6 小时前
叁仟数智指路机器人是否支持远程监控和管理?
大数据·人工智能
车斗7 小时前
win10 笔记本电脑安装 pytorch+cuda+gpu 大模型开发环境过程记录
人工智能·pytorch·电脑
KY_chenzhao7 小时前
数据驱动防灾:AI 大模型在地质灾害应急决策中的关键作用。基于DeepSeek/ChatGPT的AI智能体开发
人工智能·chatgpt·智能体·deepseek·本地化部署
大多_C7 小时前
量化方法分类
人工智能·分类·数据挖掘
www_pp_7 小时前
# 基于 OpenCV 的人脸识别实战:从基础到进阶
人工智能·opencv·计算机视觉
三月七(爱看动漫的程序员)8 小时前
LLM面试题六
数据库·人工智能·gpt·语言模型·自然语言处理·llama·milvus
蹦蹦跳跳真可爱5899 小时前
Python----计算机视觉处理(Opencv:道路检测之车道线拟合)
开发语言·人工智能·python·opencv·计算机视觉