Dify Tutorial

Welcome to the Dify tutorial. Based on the official Dify docs and the open-source langgenius/dify project, this guide shows how to build agents, agentic workflows, and chatbots on your own data with a visual, low-code studio—then publish them as a web app or REST API.

The name Dify comes from Do It For You.


Table of Contents

Basics

  1. Introduction — Positioning vs LangChain and Coze
  2. Installation — Cloud vs Docker Compose, hardware, first admin user
  3. Quick Start — One model, first chatbot, first conversation

Capabilities

  1. Model Providers — API keys, Ollama, multi-model compare
  2. Knowledge Base — Upload, chunk, embed, retrieve, citations
  3. Workflow — Visual graph, nodes, when not to use an agent
  4. Agent — Tools, ReAct / Function Calling, vs workflow

Publish & integrate

  1. Publish & API — Web App, API keys, /v1/chat-messages
  2. Ollama Integration — Local models, Docker networking, embeddings

Practice

  1. Practical Examples — FAQ bot, classify-then-answer workflow, Python API
  2. Resources — Official docs and related tutorials on this site

Learning path

StageGoalChapters
Day 1Run a chatbotIntro → Install → Quick Start
Days 2–3Models & RAGProviders → Knowledge Base
Week 1OrchestrationWorkflow → Agent → Publish API
Week 2Local models & shipOllama → Examples

Prerequisites

  • Basic LLM / Chat API ideas (messages, tokens, prompts)
  • At least one model source: a cloud API key, or local Ollama
  • Self-hosting also needs Docker / Docker Compose (see the Docker tutorial)
TutorialHow it relates
LangChainSame RAG / agent ideas, but code-first
OllamaRun models locally, then plug them into Dify
MCPDify can also publish an app as an MCP server for Cursor and similar clients

Two ways to run Dify

OptionBest forTrade-off
Dify CloudInstant start, free SandboxData lives on the managed platform
Community Edition (self-host)Intranet, compliance, local OllamaYou own the machine and ops

Pick a path, then continue at Installation.


What you will have built

After the later chapters (especially Practical Examples) you should be able to demo three things:

  1. FAQ Chatbot — upload an internal policy, cite passages, refuse when retrieval is empty
  2. Classify-then-answer flow — bucket “policy / chitchat / other”, retrieve only when needed
  3. Backend integration — Python calls official POST /v1/chat-messages; the key never enters the browser

For a fully local stack, point chat and embeddings at Ollama. Inside Docker the base URL must be host.docker.internal:11434, not localhost.


How to read this guide

  • Studio labels drift; we follow flows and concepts from official docs, not unverified button names
  • Comparisons with LangChain mean “same RAG / agent ideas, different delivery”
  • Commands match upstream: clone the latest release tag, cd dify/docker, cp .env.example .env, docker compose up -d

评论