Skills MCP Model 博客 提交 Skills

DeepSeek + Dify Build AI Applications

Build AI applications with low-code, without writing a single line of code. Visual orchestration interface, drag-and-drop workflow design, build knowledge base Q&A, Agent intelligent agents, and enterprise-level AI applications from scratch.

Start Learning
60K+
GitHub Stars
Apache 2.0
Open Source License (Commercial Use Allowed)
3 Types
Application Types

Data Source: github.com/langgenius/dify Official Repository

Why Choose Dify to Build AI Applications?

Dify is an open-source LLM application development platform that quickly turns DeepSeek models into AI applications. Visual orchestration, drag-and-drop workflows, support for knowledge bases, agents, and chatbots, perfectly suited for DeepSeek models.

Official Repository github.com/langgenius/dify
Open Source License Apache 2.0 (Commercial Use Allowed)
Deployment Docker Compose / Official Cloud Service
Core Features Visual Prompt Orchestration, RAG Knowledge Base, Agent Workflows, API Publishing
DeepSeek Support Native integration via OpenAI-API-compatible, supports all V3 and R1 series

Core Advantages of Dify

  • Visual prompt orchestration, drag-and-drop workflow design, no coding required
  • Built-in RAG engine, supports PDF / Word / TXT / Markdown / Web pages and more
  • Agent: tool calling, code execution, conditional branching
  • Conversation logs and analytics to continuously optimize application performance
  • One-click API publishing, supports iframe embedding and shareable links
  • Seamless integration with DeepSeek via OpenAI-API-compatible

Dify Introduction and Installation

Dify is an open-source LLM application development platform that helps you quickly build large language models (such as DeepSeek) into usable AI applications. With one-click deployment via Docker Compose, installation can be completed in 5 minutes.

What is Dify?

Dify, developed by the LangGenius team, is a full-lifecycle development platform for LLM applications. It provides a one-stop solution from Prompt orchestration, knowledge base management, Agent workflows to application deployment. You can think of Dify as the "WordPress for AI applications" - through a visual interface, you can quickly build various AI applications without writing code.

Environment Requirements

  • Docker and Docker Compose (required)
  • At least 4GB of available memory (8GB or more recommended)
  • At least 20GB of available disk space
  • Supports Windows / macOS / Linux

One-Click Deployment with Docker Compose

The following commands will clone the Dify repository and start all services via Docker Compose:

# Clone the Dify repository git clone https://github.com/langgenius/dify.git # Enter the Docker directory cd dify/docker # Copy the environment variable configuration file cp .env.example .env # Start all services (PostgreSQL, Redis, Weaviate, Nginx, Dify API, Dify Web) docker compose up -d # View service status docker compose ps

After deployment, open your browser and visit http://localhost:3000 to enter the Dify management interface. On first visit, you will need to set up the administrator email and password.

Tip

If you don't want to deploy locally, Dify also offers an official cloud service (cloud.dify.ai). You can register and use it without the deployment steps. However, self-deployment gives you full control over your data, which is suitable for scenarios with privacy requirements.

Connect DeepSeek Model

Dify supports connecting DeepSeek models via OpenAI-API-compatible method. Whether it's the DeepSeek official API or DeepSeek deployed locally with Ollama, you can configure and use it in Dify.

Configuration Steps

  1. After logging into the Dify management interface, click the avatar in the top right corner and select "Settings"
  2. In the left menu, click "Model Providers"
  3. In the model provider list, find "OpenAI-API-compatible"
  4. Click the "Add to Providers" button
  5. Fill in the following configuration information

Method 1: Connect DeepSeek Official API

If you use the DeepSeek official API, configure as follows:

Provider Type OpenAI-API-compatible
Provider Name DeepSeek (Custom)
API Base URL https://api.deepseek.com/v1
API Key sk-your-deepseek-api-key

API Key acquisition address: platform.deepseek.com/api_keys. You can create one after registration; new users have free credits.

Method 2: Connect DeepSeek Deployed Locally with Ollama

If you run DeepSeek models locally using Ollama, configure as follows:

API Base URL http://localhost:11434/v1
API Key Any value (Ollama local does not require verification)

If Dify and Ollama run on the same machine, use localhost. If Ollama is on another machine, replace with the corresponding IP address. Ensure Ollama has set the OLLAMA_HOST=0.0.0.0:11434 environment variable.

Add Model

After configuration, on the "Model Providers" page, click on the DeepSeek provider you just added, then click the "Add Model" button:

  • Model Type: LLM (Large Language Model)
  • Model Name: deepseek-chat (V3) or deepseek-reasoner (R1)
  • If using Ollama, fill in the Ollama model name such as deepseek-r1:8b
  • After saving, the DeepSeek model will appear in the available model list and can be selected when creating applications.

    Create Your First Chat Application

    After integrating the DeepSeek model, let's create your first AI chat application. Dify offers three application types: Chat Assistant, Text Generation, and Agent. We'll start with the simplest: Chat Assistant.

    Step 1: Create an Application

    1. On the Dify homepage, click the "Create Application" button
    2. Select the "Chat Assistant" application type
    3. Enter an application name (e.g., "DeepSeek Smart Assistant")
    4. Choose an application icon (optional)
    5. Click "Create"

    Step 2: Configure the Model

    After entering the application editing page, in the "Model Settings" area on the right:

    • In the "Model" dropdown, select the DeepSeek model you just added (deepseek-chat or deepseek-reasoner)
    • Set model parameters:
      • Temperature: 0.7 (conversation) / 0.1 (code) / 0.9 (creative writing)
      • Max Tokens: Set according to needs; 2048 is usually sufficient
      • Context Window: It is recommended to keep the default value

    Step 3: Set the System Prompt

    The system prompt defines the AI's role and behavior. In the "Orchestrate" page, in the "Prompt" area, enter the following:

    You are a professional AI assistant powered by the DeepSeek model. Your response style: - Be concise and to the point, without unnecessary verbosity - If the question involves code, provide complete runnable examples - If the question involves math or logic, show the reasoning process - If the user's description is unclear, proactively ask for details - Respond in Chinese; technical terms may include the English original Your limitations: - If you don't know, say you don't know; do not fabricate information - For professional advice involving medical, legal, etc., remind users to consult professionals

    Step 4: Test the Chat

    In the "Preview" area on the right side of the page, you can directly test the chat. Enter a question and observe whether DeepSeek's response meets expectations. If the effect is not ideal, you can adjust the Temperature parameter or optimize the system prompt.

    Debugging Tips

    • If responses are too brief, try lowering Temperature and increasing max_tokens
    • If responses deviate from the topic, optimize the system prompt to describe the role more clearly
    • If using the R1 model, note that it outputs a chain of thought (thinking), which is a normal reasoning process
    • Click "Logs & Annotations" to view historical conversations and analyze performance

    For more tips on designing system prompts, please refer to the prompt engineering section in DeepSeek Usage Tutorial.

    Knowledge Base Setup

    The knowledge base is the core of RAG (Retrieval-Augmented Generation). Upload your documents to the Dify knowledge base, and DeepSeek can answer questions based on the document content, greatly improving the accuracy and professionalism of responses.

    Upload Documents

    In the Dify top navigation bar, click "Knowledge Base" to enter the knowledge base management page:

    1. Click the "Create Knowledge Base" button
    2. Fill in the knowledge base name (e.g., "Company Product Manual")
    3. Click "Upload Documents" and select the files to upload

    Supported Document Formats

    Document Types

    PDF / Word / PPT

    Supports .pdf, .docx, .pptx formats, automatically extracts text content.

    Plain Text

    TXT / Markdown / CSV

    Supports .txt, .md, .csv formats, suitable for structured data.

    Web Pages

    Web Scraping

    Enter a URL, Dify automatically scrapes the web content and imports it into the knowledge base.

    Code

    Code Files

    Supports .py, .js, .java and other code files, suitable for technical documentation.

    Chunk Settings

    After uploading documents, Dify automatically splits the document into multiple "chunks", each chunk is independently vectorized and stored for retrieval. Chunk settings directly affect retrieval performance:

    Chunk Size Recommended 500-1000 characters. Too small may lose information, too large may reduce retrieval precision.
    Overlap Recommended 50-100 characters. Overlap between chunks prevents key information from being cut off.

    Retrieval Settings

    In the "Retrieval Settings" of the knowledge base, you can configure the following parameters:

    Retrieval Method Vector Retrieval (semantic matching) / Full-Text Retrieval (keyword matching) / Hybrid Retrieval (recommended)
    Top K Returns the top K relevant document chunks, recommended 3-5. Larger values provide richer context but may introduce noise.
    Similarity Threshold Only returns results with similarity above this threshold, recommended 0.5-0.7. Higher thresholds yield more precise results but may miss relevant content.

    Best Practices

    • The higher the document quality, the better the retrieval results. It is recommended to clean up irrelevant content in documents first.
    • If the document contains many tables, it is recommended to convert them to Markdown table format before uploading.
    • When the knowledge base has a large amount of documents (100,000+ characters), it is recommended to use hybrid retrieval mode.
    • After uploading, it is recommended to test a few questions to confirm retrieval performance, then adjust parameters.

    For more on RAG architecture, please refer to the Dify integration section in the DeepSeek Deployment Tutorial.

    Knowledge Base Q&A Application

    Combine the knowledge base with DeepSeek to build a professional document Q&A bot. When a user asks a question, Dify first retrieves relevant document chunks from the knowledge base, then hands them to DeepSeek to generate accurate answers based on these chunks.

    Create a Knowledge Base Q&A Application

    1. On the Dify homepage, click "Create Application" and select "Chat Assistant"
    2. Fill in the application name (e.g., "Product Documentation Q&A")
    3. Go to the application orchestration page, and in the "Context" area, click "Add"
    4. Select the knowledge base you just created
    5. In the model settings on the right, select the DeepSeek model

    Configure System Prompt

    A knowledge base Q&A application requires a special system prompt to let the AI know how to use the retrieved documents:

    You are a professional knowledge base Q&A assistant. Your answers must be based on the provided document content. Answering rules: 1. Prioritize using information from the documents to answer questions 2. If the documents contain relevant information, directly cite and answer 3. If the documents do not contain relevant information, clearly tell the user "This content is not included in the documents" 4. When answering, indicate the source of information (e.g., "According to Chapter 3 of the product manual...") 5. Do not fabricate information not present in the documents Document content: {{#context#}} User question: {{#query#}} Please answer the user's question based on the above document content.

    RAG Workflow

    The complete workflow of knowledge base Q&A is as follows:

    1. User Question: The user inputs a question
    2. Vector Retrieval: Dify converts the question into a vector and retrieves the most relevant document chunks from the knowledge base
    3. Context Assembly: The retrieved document chunks are used as context and assembled with the user question into a Prompt
    4. LLM Inference: DeepSeek generates an answer based on the context and question
    5. Return Result: The answer is returned to the user, with cited sources

    Testing and Optimization

    Test a few questions in the preview area to check the answer quality:

    • If the answers are not accurate enough, check the document chunking and retrieval settings of the knowledge base
    • If the answers are irrelevant to the documents, the variable references in the system prompt may be incorrect
    • If relevant content cannot be retrieved, try lowering the similarity threshold or increasing the Top K value
    • Check the "Logs & Annotations" page to see the specific document chunks retrieved each time

    Agent Workflow

    Agent is the most powerful feature of Dify. Through visual workflow orchestration, you can build AI agents that can make autonomous decisions, call tools, and execute code. DeepSeek acts as the reasoning engine, driving the entire decision logic of the Agent.

    Create an Agent Application

    1. On the Dify homepage, click "Create Application"
    2. Select the "Agent" application type
    3. Fill in the application name (e.g., "Data Analysis Assistant")
    4. Go to the workflow orchestration page

    Workflow Node Introduction

    Node Type Function Description Use Case
    Start Node The entry point of the workflow, defines input variables Each workflow must have exactly one
    LLM Node Calls the DeepSeek model for reasoning and generation Text generation, analysis, summarization, translation
    Tool Node Calls external APIs or built-in tools Search, calculation, sending emails, database queries
    Code Node Executes Python or JavaScript code Data processing, format conversion, custom logic
    Conditional Branch Branches based on conditions Classification, routing, multi-scenario handling
    Knowledge Retrieval Retrieves relevant documents from the knowledge base Knowledge base Q&A, document analysis
    End Node The exit of the workflow, defines output variables Each workflow must have at least one output

    Hands-on: Build a Data Analysis Agent

    Below is a complete data analysis Agent workflow example:

    Workflow Structure:

    1. Start Node: Receives the user's data analysis request
    2. LLM Node (Intent Analysis): DeepSeek analyzes the user's intent and determines the analysis type (descriptive analysis / trend analysis / comparative analysis)
    3. Conditional Branch: Routes to different processing flows based on the analysis type
    4. Code Node (Data Processing): Executes Python code for data cleaning, aggregation, and calculation
    5. LLM Node (Generate Report): DeepSeek generates an analysis report based on the processing results
    6. End Node: Outputs the final analysis report

    LLM Node Configuration Example

    In the LLM node, select the DeepSeek model and configure the following prompt:

    You are a data analysis expert. Please analyze the user's data analysis needs and determine which of the following types it belongs to: 1. Descriptive analysis: The user wants to understand the basic situation of the data (e.g., "What is the sales amount?") 2. Trend analysis: The user wants to understand the trend of the data (e.g., "Changes in the last three months") 3. Comparative analysis: The user wants to compare different dimensions (e.g., "Comparison between Product A and Product B") User requirement: {{#query#}} Please output only the analysis type number (1, 2, or 3), and do not output any other content.

    Code Node Example

    In the code node, you can write Python code for data processing:

    def main(data: str) -> dict: """Process input data and return analysis results""" import json # Parse input data records = json.loads(data) # Calculate basic statistical indicators values = [r["value"] for r in records] total = sum(values) avg = total / len(values) if values else 0 max_val = max(values) if values else 0 min_val = min(values) if values else 0 return { "total": total, "average": round(avg, 2), "max": max_val, "min": min_val, "count": len(values), "summary": f"Total {len(values)} records, sum {total}, average {avg:.2f}" }

    Conditional Branch Configuration

    The conditional branch node routes based on the output of the LLM node:

    • Condition 1: LLM output == "1" -> Enter descriptive analysis flow
    • Condition 2: LLM output == "2" -> Enter trend analysis flow
    • Condition 3: LLM output == "3" -> Enter comparative analysis flow
    • Default branch: Other cases -> Enter general analysis flow

    Agent Debugging Tips

    • Use the "Run" function to debug the workflow step by step, viewing the input and output of each node
    • Setting Temperature=0.1 in the LLM node can make classification more stable
    • Logs printed in the code node can be viewed in the run logs for easy debugging
    • For complex workflows, it is recommended to draw a flowchart first, then implement it in Dify

    Publish and Embed

    After the application development is complete, Dify provides multiple publishing methods: API publishing (for program calls), iframe embedding (for embedding in web pages), and share links (for direct sharing). No additional development is required; it can go live with one click.

    Method 1: API Publishing

    Publish the application as a REST API, which can be called from any backend program:

    1. In the application editing page, click the "Publish" button in the top right corner
    2. Select "Access API"
    3. Obtain the API key and interface documentation

    # Call the Dify application API curl -X POST https://your-dify-host/v1/chat-messages \ -H "Authorization: Bearer app-xxxxxxxxxxxxx" \ -H "Content-Type: application/json" \ -d '{ "inputs": {}, "query": "Hello, please help me analyze the recent sales data", "response_mode": "streaming", "user": "user-001" }'

    Method 2: iframe Embedding

    Embed the application into your website so users can use it directly on the web page:

    1. In the application editing page, click "Publish" in the top right corner
    2. Select "Embed in Website"
    3. Copy the generated iframe code

    <!-- Paste the following code into your web page --> <iframe src="https://your-dify-host/chatbot/xxxxxxxxxxxxx" style="width: 100%; height: 600px; border: none; border-radius: 12px;" allow="microphone"> </iframe>

    Method 3: Share Link

    Generate a public share link that anyone can use to access your application:

    1. In the application editing page, click "Publish" in the top right corner
    2. Select "Run"
    3. Copy the generated share link

    Access Control Settings

    API Key Used as authentication credential when calling the API; can be managed on the "API Access" page
    IP Whitelist Restrict API calls to specific IP addresses only
    Rate Limit Set the maximum number of requests per minute/hour to prevent abuse
    Conversation Logs View all user conversations in "Logs & Annotations" to analyze usage

    Real-World Cases

    Below are three real-world DeepSeek + Dify application cases, from simple to complex, covering the most common application scenarios. Each case includes complete configuration ideas and parameter references.

    Case 1: Intelligent Customer Service Bot

    Application Type: Chat Assistant + Knowledge Base

    Scenario Description: Build an intelligent customer service for a corporate website to automatically answer user inquiries about product usage, after-sales policies, and frequently asked questions.

    Configuration Points:

    • Knowledge Base: Upload product manuals, FAQ documents, and after-sales policy files
    • Model Selection: DeepSeek V3 (deepseek-chat), Temperature=0.3
    • System Prompt: Set as "professional customer service", requiring politeness, patience, and accuracy
    • Deployment: Embed via iframe into the official website's customer service page
    • Performance Optimization: Regularly review logs and supplement knowledge base documents for high-frequency questions

    Case 2: Document Q&A Assistant

    Application Type: Chat Assistant + Knowledge Base

    Scenario Description: Build an internal document Q&A system for the team, allowing colleagues to directly ask about company policies, project documents, technical specifications, etc.

    Configuration Points:

    • Knowledge Base: Upload all internal documents, chunk size 800, overlap 100
    • Retrieval Settings: Hybrid retrieval, Top K=5, similarity threshold 0.6
    • Model Selection: DeepSeek V3 (deepseek-chat), Temperature=0.1
    • System Prompt: Emphasize "answer based on documents, do not fabricate information"
    • Variable Settings: Use {{#context#}} and {{#query#}} variables

    Case 3: Data Analysis Assistant

    Application Type: Agent

    Scenario Description: Build a data analysis Agent where users can upload data files, and the Agent automatically completes data cleaning, analysis, and report generation.

    Workflow Configuration:

    • Start Node -> Receive user input and data files
    • LLM Node -> Analyze user intent, determine analysis type
    • Conditional Branch -> Select different processing flows based on analysis type
    • Code Node -> Execute Python data processing (pandas, numpy)
    • LLM Node -> Generate analysis report based on processed results
    • End Node -> Output formatted report

    Key Parameters:

    • Model Selection: DeepSeek R1 (deepseek-reasoner) for complex reasoning, V3 for report generation
    • Code Node Timeout: Set to 60 seconds to avoid timeout on large data processing
    • Tool Configuration: Add web search tool to support querying external data

    More Application Scenarios

    Education

    AI Tutor

    Upload textbooks and exercise books, DeepSeek answers students' questions based on the knowledge base and explains problem-solving approaches.

    E-commerce

    Product Recommendation Assistant

    Combined with the product database, DeepSeek recommends suitable products based on user needs, improving conversion rates.

    Healthcare

    Health Consultation Assistant

    Upload medical knowledge base to provide popular science consultation on common illnesses (note: not a substitute for professional doctor diagnosis).

    Legal

    Regulation Query Assistant

    Upload legal and regulatory documents to help users quickly query relevant provisions and explanations.

    DeepSeek + Dify FAQ

    What is the difference between Dify and Open WebUI? Which should I use? +
    Open WebUI is a chat interface that provides a ChatGPT-like conversation experience, suitable for personal daily use. Dify is an application development platform that not only supports conversation but also enables building knowledge base Q&A, Agent workflows, publishing APIs, etc. If you just want to chat with DeepSeek, use Open WebUI; if you want to build AI applications or services, use Dify.
    Does Dify support DeepSeek R1's chain of thought? +
    Yes. When you use the deepseek-reasoner (R1) model, Dify will fully display R1's chain-of-thought reasoning process. In Agent workflows, R1's reasoning capability can significantly improve the accuracy of complex decisions. However, note that R1's chain of thought consumes more tokens, so it is recommended to use the R1 model only in scenarios requiring deep reasoning.
    Does Dify knowledge base support Chinese documents? How effective is it? +
    Fully supported. Dify's built-in embedding models support Chinese, and combined with DeepSeek's Chinese capabilities, Chinese document Q&A works very well. It is recommended to use hybrid retrieval (vector retrieval + full-text retrieval) mode for higher retrieval accuracy on Chinese documents. If using Ollama local deployment, ensure the embedding model also supports Chinese.
    Is Dify free? What are the limitations? +
    Dify Community Edition (self-hosted) is completely free and open-source under Apache 2.0, and can be used commercially. There are no functional limitations; all features are available. Dify Cloud (cloud.dify.ai) offers a free tier but has limitations (such as knowledge base count, team collaboration, etc.). If you need unlimited usage, it is recommended to self-host the Community Edition.
    DeepSeek official API vs. Ollama local deployment: which is better for Dify? +
    It depends on your needs. The DeepSeek official API uses the full version V3/R1 (671B parameters), offering the best performance and pay-as-you-go pricing with low cost. Ollama local deployment runs distilled models (e.g., 8B/32B), which are slightly less effective but keep data fully local for better privacy. Recommendation: First validate your scenario with the official API; if data is sensitive or you have high concurrency, consider Ollama local deployment.
    What are the limitations of the code node in Dify workflows? +
    The code node supports Python and JavaScript and runs in a sandbox environment. Main limitations: 1) Default timeout for a single execution is 15 seconds (adjustable); 2) Cannot access external networks (unless an HTTP request library is configured); 3) Limited third-party libraries available (Python pre-installs common libraries like pandas, numpy); 4) Memory limits depend on the resource allocation of the Dify container. If processing large data, it is recommended to do data preprocessing in the code node and analysis in the LLM node.

    Related Tutorials

    Dive deeper into DeepSeek model usage, deployment, and development tips.

    每日精选 Skill 推荐,免费送到你邮箱

    输入邮箱,每天接收一个精选 AI Agent 技能推荐。完全免费,持续更新。

    完全免费,取消任意时间。我们不会发送垃圾邮件。