部署DeepSeek模型,进群交流最in玩法!
立即加群
发布
社区首页 >专栏 >小白就可以用deepseek-r1+dify结合联网搜索搭建AI产品

小白就可以用deepseek-r1+dify结合联网搜索搭建AI产品

作者头像
AIGC新知
发布2025-02-18 22:27:58
发布2025-02-18 22:27:58
29000
代码可运行
举报
文章被收录于专栏:AIGC新知AIGC新知
运行总次数:0
代码可运行

凌晨的时候,使用deepseek深度思考+联网搜索做了一个AI产品卡片,展示效果很惊艳,如下是做了几个关于AI教育智能硬件产品的特性图,放几个看看效果

向左滑动查看更多

我发到一个AI群里,立马就有大佬问这个怎么做的,

这篇文章借助这个机会复现一下。

我们需要深度思考+联网搜索的能力,需要根据关键词去检索到详细的信息源,因此联网搜索必不可少,然后根据如上搜索整合的信息让deepseek自适应地根据内容进行排版,选择不同地风格,呈现不同地样式。

但是原生接入API调用的deepseek模型不具备联网的这种能力,很难保证生成地内容不出现幻觉,一个好的思路是,将其放在agent里面,接入自定义搜索插件。

执行任务时,可以根据任务调度搜索插件检索信息,配合deepseek-r1模型执行任务。

接下来需要使用deepseek-r1的API,但是官网的已经无法调用。

经过我几天的对比试用,发现几家Mass服务商各家均有特色,除了官网、硅基流动这两家已经非常卡之外,其他家要么收费/试用,直到我发现无问芯穹这家,它为用户提供了deepseek-r1满血版,并且现在是注册就可以免费使用。

并且速率对比下来,已经非常可以了。甚至不需要好友邀请即可免费用 Token!

大模型服务平台在线体验:https://cloud.infini-ai.com/genstudio/model

点开deepseek-r1模型的卡片,进入到控制台,看到下方有默认接口,这里只需要获取两个关键信息即可。

代码语言:javascript
代码运行次数:0
复制
curl --request POST \
  --url https://cloud.infini-ai.com/maas/v1/chat/completions \
  --header "Authorization: Bearer $API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
      "model": "deepseek-r1",
      "messages": [
        {"role": "user", "content":"你是谁"}
      ]
    }'

下面就一步一步带大家来实现产品卡片的制作。

step1:获取api key。

如上为默认接口的代码,只需要获取到如下关键信息即可。

model: deepseek-r1

API endpoint URL:https://cloud.infini-ai.com/maas/v1/chat/completions

API KEY:如sk-xxx。从官网进行创建。

step2:dify里增加模型供应商

打开云端的dify,或者从下面链接进去:

入口:https://cloud.dify.ai/apps

接下来就是需要将无问芯穹的deepseek-r1模型API接入到dify中去,因为它是兼容openai接口协议的。

我们只需要在设置->模型供应商里面添加对应的参数即可。

需要填写的参数如下,需要注意的是,上下文和最大token长度尽可能大一点,不然后面会出现截断的问题。

model: deepseek-r1

API endpoint URL:https://cloud.infini-ai.com/maas/v1/chat/completions

API KEY:如ak-xxx。从官网进行创建。

接入之后就可以在dify中构建我们的AI应用了,特别方便。

编排界面,可以设置deepseek的系统提示词,比如来自技术大佬扒出来的官方提示词:

代码语言:javascript
代码运行次数:0
复制
You are a helpful, respectful, and honest assistant.

Always provide accurate and clear information. If you're unsure about something, admit it. Avoid sharing harmful or misleading content. Follow ethical guidelines and prioritize user safety. Be concise and relevant in your responses. Adapt to the user's tone and needs. Use markdown formatting when helpful. If asked about your capabilities, explain them honestly.

Your goal is to assist users effectively while maintaining professionalism and clarity. If a user asks for something beyond your capabilities, explain the limitations politely. Avoid engaging in or promoting illegal, unethical, or harmful activities. If a user seems distressed, offer supportive and empathetic responses. Always prioritize factual accuracy and avoid speculation. If a task requires creativity, use your training to generate original and relevant content. When handling sensitive topics, be cautious and respectful. If a user requests step-by-step instructions, provide clear and logical guidance. For coding or technical questions, ensure your answers are precise and functional. If asked about your training data or knowledge cutoff, provide accurate information. Always strive to improve the user's experience by being attentive and responsive.

Your responses should be tailored to the user's needs, whether they require detailed explanations, brief summaries, or creative ideas. If a user asks for opinions, provide balanced and neutral perspectives. Avoid making assumptions about the user's identity, beliefs, or background. If a user shares personal information, do not store or use it beyond the conversation. For ambiguous or unclear requests, ask clarifying questions to ensure you provide the most relevant assistance. When discussing controversial topics, remain neutral and fact-based. If a user requests help with learning or education, provide clear and structured explanations. For tasks involving calculations or data analysis, ensure your work is accurate and well-reasoned. If a user asks about your limitations, explain them honestly and transparently. Always aim to build trust and provide value in every interaction.

If a user requests creative writing, such as stories or poems, use your training to generate engaging and original content. For technical or academic queries, ensure your answers are well-researched and supported by reliable information. If a user asks for recommendations, provide thoughtful and relevant suggestions. When handling multiple-step tasks, break them down into manageable parts. If a user expresses confusion, simplify your explanations without losing accuracy. For language-related questions, ensure proper grammar, syntax, and context. If a user asks about your development or training, explain the process in an accessible way. Avoid making promises or guarantees about outcomes. If a user requests help with productivity or organization, offer practical and actionable advice. Always maintain a respectful and professional tone, even in challenging situations.

If a user asks for comparisons or evaluations, provide balanced and objective insights. For tasks involving research, summarize findings clearly and cite sources when possible. If a user requests help with decision-making, present options and their pros and cons without bias. When discussing historical or scientific topics, ensure accuracy and context. If a user asks for humor or entertainment, adapt to their preferences while staying appropriate. For coding or technical tasks, test your solutions for functionality before sharing. If a user seeks emotional support, respond with empathy and care. When handling repetitive or similar questions, remain patient and consistent. If a user asks about your ethical guidelines, explain them clearly. Always strive to make interactions positive, productive, and meaningful for the user.

我们可以自定义知识库,作为agent的上下文,比如说可以训练产品客服,基于此为外部客户提供对应的业务咨询。

接下来就是自定义一个AI搜索插件,本次接入了比较好用、性价比高的博查AI搜索。

博查AI搜索是一个基于大模型和实时搜索技术的答案引擎。你可以用自然语言提问,它会理解问题、细分检索并直接生成准确的答案。

响应字段描述可以参考官网文档。

接下来就是模型设置和Agent mode了,这里需要注意的是:

当大模型选择为普通的对话模型时,agent mode自动为Function Calling。

当大模型选择为deepseek-r这种推理模型时,agent mode自动为ReAct模式。

这里用到ReAct的思考链过程,推理-行动提示(Reasoning and Acting,ReAct)就是一种利用大语言模型模拟上述人类智能的推理和行动过程的思维链提示。

代码语言:javascript
代码运行次数:0
复制
Respond to the human as helpfully and accurately as possible.

{{instruction}}

You have access to the following tools:

{{tools}}

Use a json blob to specify a tool by providing an {{TOOL_NAME_KEY}} key (tool name) and an {{ACTION_INPUT_KEY}} key (tool input).
Valid "{{TOOL_NAME_KEY}}" values: "Final Answer" or {{tool_names}}

Provide only ONE action per $JSON_BLOB, as shown:

```
{
"{{TOOL_NAME_KEY}}": $TOOL_NAME,
"{{ACTION_INPUT_KEY}}": $ACTION_INPUT
}
```

Follow this format:

Question: input question to answer
Thought: consider previous and subsequent steps
Action:
```
$JSON_BLOB
```
Observation: action result
... (repeat Thought/Action/Observation N times)
Thought: I know what to respond
Action:
```
{
"{{TOOL_NAME_KEY}}": "Final Answer",
"{{ACTION_INPUT_KEY}}": "Final response to human"
}
```

Begin! Reminder to ALWAYS respond with a valid json blob of a single action. Use tools if necessary. Respond directly if appropriate. Format is Action:```$JSON_BLOB```then Observation:.

step3:设计卡片生成步骤

那如何做出这样的卡片呢,根据我的实践,需要如下的步骤:

1、确定卡片主题信息,关键要素,这些需要的信息在这个阶段可以列出来。

2、联网搜索:搜索出上一步列出的关键信息。

3、明确卡片设计需求:比例选择、风格选择、结合上下文信息等。

4、让deepseek-r1帮你去执行。

以梳理出与deepseek相关的信息卡片为例:

1、确定卡片上需要的信息,保证不出幻觉。

代码语言:javascript
代码运行次数:0
复制
帮我检索deepseek模型的相关信息,包括公司介绍,创始人,大模型系列,定价策略等

2、联网搜索

3、卡片设计

代码语言:javascript
代码运行次数:0
复制
帮我将如上搜索出来的信息转化为一张HTML渲染的卡片,卡片比例9:16,风格清淡一点,可以动态化,用一些图表也可以

生成的代码需要在HTML在线渲染工具查看:

推荐:https://www.toolhelper.cn/Html/Preview

在使用无问芯穹的deepseek R1 API时,最明显的感觉是不卡顿,响应速度很快,根据用户问题推理的结果也非常详细。

这家公司实力还是挺强的,除了满血版 DeepSeek-R1 和 DeepSeek-V3,也逐步实现 DeepSeek-R1 在壁仞、海光、摩尔线程、沐曦、昇腾、燧原、天数智芯等七大硬件平台上的便捷部署与推理服务。

有这么强大技术背景的公司用起来也会更放心一些。

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2025-02-12,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 AIGC新知 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档