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