利用Dify+SearXNG实现Deepseek联网知识查询

DeepSeek大模型本地化部署最大的痛点是不知道现在时间,不知道最新发生的事情,本文利用SearXNG综合搜索引擎,结合利用Dify提供的获取当前时间及SearXNG插件。实现最新时间获取和信息查询:

前提条件:已正确安装并可以正常使用Dify和SearXNG,且Dify已经正确下载获取当前时间及SearXNG插件,计算机可连接互联网(需获取最新时间和信息查询)。

SearXNG安装参考:使用Docker实现客户化本地部署集成搜索引擎SearXNG-CSDN博客

1、打开Dify,找到工作室,点击创建空白应用,新建Chatflow,填写比如“联网信息查询”

2、添加获取当前时间和SearXNG搜索工具,连接流程,完成后流程图如下:

3、配置时间工具,时区选择“亚洲/上海”

4、配置SearXNG工具,查询语句选择获取当前时间和开始用户需求sys.query,类型使用默认综合即可。

5、配置大模型,上下文选择SearXNG的搜索结果(json格式),参考下图提示词输入:严格依据上下文,回答用户问题(插入上下文),不允许自己编造,现在时间:(插入获取当前使劲按变量)。

6、配置直接回复,添加获取当前时间

7、配置完成后选择发布

8、流程测试,输入“今天最新财经新闻”,对回复进行验证,可看到提供的新闻的确是最新的新闻。

9、确认没有问题后可导出DSL,方便交流分享

下面代码仅供参考,保持为yml格式导入后注意调整一下大模型配置。

app:
  description: ''
  icon: 🤖
  icon_background: '#FFEAD5'
  mode: advanced-chat
  name: 联网信息查询
  use_icon_as_answer_icon: false
dependencies:
- current_identifier: null
  type: package
  value:
    plugin_unique_identifier: langgenius/openai_api_compatible:0.0.5@188b29121e708c1d0b26841bc2e66874a06c6cae73a2049c9215f57cb6cbca44
- current_identifier: null
  type: marketplace
  value:
    marketplace_plugin_unique_identifier: langgenius/searxng:0.0.2@cb5502d22b7d12f0cfc52280269a0594ff2ea4ac4d55e1d6c2620ea04f42a5f5
kind: app
version: 0.1.5
workflow:
  conversation_variables: []
  environment_variables: []
  features:
    file_upload:
      allowed_file_extensions:
      - .JPG
      - .JPEG
      - .PNG
      - .GIF
      - .WEBP
      - .SVG
      allowed_file_types:
      - image
      allowed_file_upload_methods:
      - local_file
      - remote_url
      enabled: false
      fileUploadConfig:
        audio_file_size_limit: 50
        batch_count_limit: 5
        file_size_limit: 15
        image_file_size_limit: 10
        video_file_size_limit: 100
        workflow_file_upload_limit: 10
      image:
        enabled: false
        number_limits: 3
        transfer_methods:
        - local_file
        - remote_url
      number_limits: 3
    opening_statement: ''
    retriever_resource:
      enabled: true
    sensitive_word_avoidance:
      enabled: false
    speech_to_text:
      enabled: false
    suggested_questions: []
    suggested_questions_after_answer:
      enabled: false
    text_to_speech:
      enabled: false
      language: ''
      voice: ''
  graph:
    edges:
    - data:
        sourceType: llm
        targetType: answer
      id: llm-answer
      source: llm
      sourceHandle: source
      target: answer
      targetHandle: target
      type: custom
    - data:
        isInLoop: false
        sourceType: start
        targetType: tool
      id: 1743147534581-source-1743147549233-target
      source: '1743147534581'
      sourceHandle: source
      target: '1743147549233'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInLoop: false
        sourceType: tool
        targetType: tool
      id: 1743147549233-source-1743147573705-target
      source: '1743147549233'
      sourceHandle: source
      target: '1743147573705'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInLoop: false
        sourceType: tool
        targetType: llm
      id: 1743147573705-source-llm-target
      source: '1743147573705'
      sourceHandle: source
      target: llm
      targetHandle: target
      type: custom
      zIndex: 0
    nodes:
    - data:
        desc: ''
        selected: false
        title: 开始
        type: start
        variables: []
      height: 54
      id: '1743147534581'
      position:
        x: 287.10801372802956
        y: 288.2854028646748
      positionAbsolute:
        x: 287.10801372802956
        y: 288.2854028646748
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        context:
          enabled: true
          variable_selector:
          - '1743147573705'
          - json
        desc: ''
        memory:
          query_prompt_template: '{{#sys.query#}}'
          role_prefix:
            assistant: ''
            user: ''
          window:
            enabled: false
            size: 10
        model:
          completion_params:
            temperature: 0.7
          mode: chat
          name: deepseek-r1
          provider: langgenius/openai_api_compatible/openai_api_compatible
        prompt_template:
        - id: 56d4534f-dbc2-4204-a5ec-24cb7961e92c
          role: system
          text: 严格依据上下文,回答用户问题{{#context#}},不允许自己编造,现在时间:{{#1743147549233.text#}}
        selected: false
        title: LLM
        type: llm
        variables: []
        vision:
          enabled: false
      height: 90
      id: llm
      position:
        x: 799.1873464526994
        y: 37.451669368846126
      positionAbsolute:
        x: 799.1873464526994
        y: 37.451669368846126
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        answer: '{{#1743147549233.text#}}

          {{#llm.text#}}'
        desc: ''
        selected: true
        title: 直接回复
        type: answer
        variables: []
      height: 124
      id: answer
      position:
        x: 903.0323371163845
        y: 234.98769776932238
      positionAbsolute:
        x: 903.0323371163845
        y: 234.98769776932238
      selected: true
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        desc: ''
        is_team_authorization: true
        output_schema: null
        paramSchemas:
        - auto_generate: null
          default: '%Y-%m-%d %H:%M:%S'
          form: form
          human_description:
            en_US: Time format in strftime standard.
            ja_JP: Time format in strftime standard.
            pt_BR: Time format in strftime standard.
            zh_Hans: strftime 标准的时间格式。
          label:
            en_US: Format
            ja_JP: Format
            pt_BR: Format
            zh_Hans: 格式
          llm_description: null
          max: null
          min: null
          name: format
          options: []
          placeholder: null
          precision: null
          required: false
          scope: null
          template: null
          type: string
        - auto_generate: null
          default: UTC
          form: form
          human_description:
            en_US: Timezone
            ja_JP: Timezone
            pt_BR: Timezone
            zh_Hans: 时区
          label:
            en_US: Timezone
            ja_JP: Timezone
            pt_BR: Timezone
            zh_Hans: 时区
          llm_description: null
          max: null
          min: null
          name: timezone
          options:
          - label:
              en_US: UTC
              ja_JP: UTC
              pt_BR: UTC
              zh_Hans: UTC
            value: UTC
          - label:
              en_US: America/New_York
              ja_JP: America/New_York
              pt_BR: America/New_York
              zh_Hans: 美洲/纽约
            value: America/New_York
          - label:
              en_US: America/Los_Angeles
              ja_JP: America/Los_Angeles
              pt_BR: America/Los_Angeles
              zh_Hans: 美洲/洛杉矶
            value: America/Los_Angeles
          - label:
              en_US: America/Chicago
              ja_JP: America/Chicago
              pt_BR: America/Chicago
              zh_Hans: 美洲/芝加哥
            value: America/Chicago
          - label:
              en_US: America/Sao_Paulo
              ja_JP: America/Sao_Paulo
              pt_BR: América/São Paulo
              zh_Hans: 美洲/圣保罗
            value: America/Sao_Paulo
          - label:
              en_US: Asia/Shanghai
              ja_JP: Asia/Shanghai
              pt_BR: Asia/Shanghai
              zh_Hans: 亚洲/上海
            value: Asia/Shanghai
          - label:
              en_US: Asia/Ho_Chi_Minh
              ja_JP: Asia/Ho_Chi_Minh
              pt_BR: Ásia/Ho Chi Minh
              zh_Hans: 亚洲/胡志明市
            value: Asia/Ho_Chi_Minh
          - label:
              en_US: Asia/Tokyo
              ja_JP: Asia/Tokyo
              pt_BR: Asia/Tokyo
              zh_Hans: 亚洲/东京
            value: Asia/Tokyo
          - label:
              en_US: Asia/Dubai
              ja_JP: Asia/Dubai
              pt_BR: Asia/Dubai
              zh_Hans: 亚洲/迪拜
            value: Asia/Dubai
          - label:
              en_US: Asia/Kolkata
              ja_JP: Asia/Kolkata
              pt_BR: Asia/Kolkata
              zh_Hans: 亚洲/加尔各答
            value: Asia/Kolkata
          - label:
              en_US: Asia/Seoul
              ja_JP: Asia/Seoul
              pt_BR: Asia/Seoul
              zh_Hans: 亚洲/首尔
            value: Asia/Seoul
          - label:
              en_US: Asia/Singapore
              ja_JP: Asia/Singapore
              pt_BR: Asia/Singapore
              zh_Hans: 亚洲/新加坡
            value: Asia/Singapore
          - label:
              en_US: Europe/London
              ja_JP: Europe/London
              pt_BR: Europe/London
              zh_Hans: 欧洲/伦敦
            value: Europe/London
          - label:
              en_US: Europe/Berlin
              ja_JP: Europe/Berlin
              pt_BR: Europe/Berlin
              zh_Hans: 欧洲/柏林
            value: Europe/Berlin
          - label:
              en_US: Europe/Moscow
              ja_JP: Europe/Moscow
              pt_BR: Europe/Moscow
              zh_Hans: 欧洲/莫斯科
            value: Europe/Moscow
          - label:
              en_US: Australia/Sydney
              ja_JP: Australia/Sydney
              pt_BR: Australia/Sydney
              zh_Hans: 澳大利亚/悉尼
            value: Australia/Sydney
          - label:
              en_US: Pacific/Auckland
              ja_JP: Pacific/Auckland
              pt_BR: Pacific/Auckland
              zh_Hans: 太平洋/奥克兰
            value: Pacific/Auckland
          - label:
              en_US: Africa/Cairo
              ja_JP: Africa/Cairo
              pt_BR: Africa/Cairo
              zh_Hans: 非洲/开罗
            value: Africa/Cairo
          placeholder: null
          precision: null
          required: false
          scope: null
          template: null
          type: select
        params:
          format: ''
          timezone: ''
        provider_id: time
        provider_name: time
        provider_type: builtin
        selected: false
        title: 获取当前时间
        tool_configurations:
          format: '%Y-%m-%d %H:%M:%S'
          timezone: Asia/Shanghai
        tool_label: 获取当前时间
        tool_name: current_time
        tool_parameters: {}
        type: tool
      height: 116
      id: '1743147549233'
      position:
        x: 452.6021091295129
        y: 37.451669368846126
      positionAbsolute:
        x: 452.6021091295129
        y: 37.451669368846126
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        desc: ''
        is_team_authorization: true
        output_schema: null
        paramSchemas:
        - auto_generate: null
          default: null
          form: llm
          human_description:
            en_US: Enter your search query
            ja_JP: Enter your search query
            pt_BR: Enter your search query
            zh_Hans: 输入搜索关键词
          label:
            en_US: Query string
            ja_JP: Query string
            pt_BR: Query string
            zh_Hans: 查询语句
          llm_description: Key words for searching
          max: null
          min: null
          name: query
          options: []
          placeholder: null
          precision: null
          required: true
          scope: null
          template: null
          type: string
        - auto_generate: null
          default: general
          form: form
          human_description:
            en_US: Search the web using SearXNG, a privacy-respecting metasearch engine
            ja_JP: Search the web using SearXNG, a privacy-respecting metasearch engine
            pt_BR: Search the web using SearXNG, a privacy-respecting metasearch engine
            zh_Hans: 使用注重隐私的元搜索引擎 SearXNG 搜索网页
          label:
            en_US: search type
            ja_JP: search type
            pt_BR: search type
            zh_Hans: 搜索类型
          llm_description: ''
          max: null
          min: null
          name: search_type
          options:
          - label:
              en_US: General
              ja_JP: General
              pt_BR: General
              zh_Hans: 综合
            value: general
          - label:
              en_US: Images
              ja_JP: Images
              pt_BR: Images
              zh_Hans: 图片
            value: images
          - label:
              en_US: Videos
              ja_JP: Videos
              pt_BR: Videos
              zh_Hans: 视频
            value: videos
          - label:
              en_US: News
              ja_JP: News
              pt_BR: News
              zh_Hans: 新闻
            value: news
          - label:
              en_US: Map
              ja_JP: Map
              pt_BR: Map
              zh_Hans: 地图
            value: map
          - label:
              en_US: Music
              ja_JP: Music
              pt_BR: Music
              zh_Hans: 音乐
            value: music
          - label:
              en_US: It
              ja_JP: It
              pt_BR: It
              zh_Hans: 信息技术
            value: it
          - label:
              en_US: Science
              ja_JP: Science
              pt_BR: Science
              zh_Hans: 科学
            value: science
          - label:
              en_US: Files
              ja_JP: Files
              pt_BR: Files
              zh_Hans: 文件
            value: files
          - label:
              en_US: Social Media
              ja_JP: Social Media
              pt_BR: Social Media
              zh_Hans: 社交媒体
            value: social_media
          placeholder: null
          precision: null
          required: true
          scope: null
          template: null
          type: select
        params:
          query: ''
          search_type: ''
        provider_id: langgenius/searxng/searxng
        provider_name: langgenius/searxng/searxng
        provider_type: builtin
        selected: false
        title: SearXNG 搜索
        tool_configurations:
          search_type: general
        tool_label: SearXNG 搜索
        tool_name: searxng_search
        tool_parameters:
          query:
            type: mixed
            value: '{{#1743147549233.text#}}{{#sys.query#}}'
        type: tool
      height: 90
      id: '1743147573705'
      position:
        x: 611.8172231229488
        y: 258.73884016323444
      positionAbsolute:
        x: 611.8172231229488
        y: 258.73884016323444
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    viewport:
      x: -171.29665382091798
      y: 185.87832151380223
      zoom: 1.148698354997035

<think>好的,用户的问题是关于如何配置SearXNG实现开机自启动的。我需要先回顾一下用户提供的引用内容,看看有没有相关的信息可以借鉴。在用户提供的引用中,引用[1]提到了使用Docker运行SearXNG的命令,引用[4]提到Docker QuickStart Terminal启动问题的解决方法。这可能意味着用户已经通过Docker部署了SearXNG,现在希望设置自启动。 首先,我应该考虑不同的系统环境,比如Linux和Windows,因为自启动的配置方法在不同操作系统中差异较大。对于Linux系统,通常可以使用systemd来管理服务自启动,而Windows则可以通过任务计划程序或修改快捷方式。不过根据引用[4]中提到的Docker QuickStart Terminal问题,用户可能是在Windows上使用Docker,但Docker在Windows上通常需要Docker Desktop,而自启动可能需要配置Docker服务本身以及容器。 在Linux环境下,使用systemd创建服务文件是一个标准做法。用户需要创建一个.service文件,定义如何启动容器,并启用该服务。这需要确保Docker服务本身已经设置为开机启动,否则容器无法自动运行。步骤包括创建服务文件、设置权限、启用服务等。 对于Windows用户,可能需要配置Docker Desktop开机启动,然后使用--restart unless-stopped参数运行容器,这样Docker会在启动时自动重启容器。此外,用户可能需要通过任务计划程序来确保Docker和相关脚本在登录时运行。不过Windows下的配置可能更复杂,尤其是如果用户使用的是Docker Toolbox(如引用[4]中的Git路径问题),但Docker Toolbox已经比较老旧,建议使用Docker Desktop。 另外,用户可能需要了解如何让容器在系统启动时自动运行,Docker提供了--restart参数,可以设置为always或者unless-stopped,这需要在运行容器时指定,或者修改已有容器的配置。如果用户之前没有使用这个参数,可能需要重新创建容器。 还需要注意,用户可能对Docker和系统服务管理不太熟悉,因此步骤需要详细,并提醒常见的注意事项,比如权限问题、路径是否正确、防火墙设置等。同时,引用相关的用户提供的资料,如引用[1]中的docker run命令,可能需要调整该命令加入--restart参数。 最后,用户可能遇到的典型问题包括:容器没有自动启动,可能是因为Docker服务未设置自启动,或者.service文件配置错误,或者Windows中的任务计划没有正确设置。需要提示用户检查日志,使用systemctl status或docker ps来确认容器状态。</think>配置SearXNG实现开机自启动可通过以下分步方案实现,具体操作根据系统环境选择对应方法: ### 一、Linux系统(使用systemd服务) 1. **创建systemd服务文件** 在`/etc/systemd/system/`目录下新建文件`searxng.service`,内容如下: ```bash [Unit] Description=SearXNG Docker Container After=docker.service Requires=docker.service [Service] Restart=always ExecStart=/usr/bin/docker run --name searxng -d -p 8888:8080 searxng/searxng ExecStop=/usr/bin/docker stop searxng ExecStopPost=/usr/bin/docker rm searxng [Install] WantedBy=multi-user.target ``` 该配置会自动启动并管理容器生命周期[^1][^4]。 2. **设置权限并启用服务** ```bash sudo chmod 644 /etc/systemd/system/searxng.service sudo systemctl daemon-reload sudo systemctl enable searxng.service # 启用开机自启动 ``` 3. **验证服务状态** ```bash sudo systemctl start searxng # 手动启动测试 sudo systemctl status searxng # 检查运行状态 ``` --- ### 二、Windows系统(Docker Desktop) 1. **设置Docker Desktop开机自启动** 在系统设置中启用Docker Desktop的自动启动选项(默认安装后通常已开启)。 2. **修改容器启动命令** 重新运行容器时添加`--restart unless-stopped`参数: ```powershell docker run -d --restart unless-stopped -p 8888:8080 searxng/searxng ``` 若已有容器,需先删除旧容器再重新创建[^4]。 --- ### 三、通用注意事项 1. **防火墙设置** 确保宿主机防火墙开放8888端口(或其他自定义端口)。 2. **日志排查** 若启动失败,可通过以下命令查看日志: ```bash docker logs searxng # Linux Get-EventLog -LogName Application -Source Docker -Newest 10 # Windows PowerShell ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值