This page defines key terms, jargon, abbreviations, and domain concepts specific to the Dify codebase. Understanding these terms is crucial for new engineers to quickly grasp the system's architecture, data models, and operational workflows.
A "Tenant" represents a workspace or an organization within Dify. It acts as a logical isolation boundary for resources such as applications, datasets, and models. Each tenant has its own set of configurations, users, and data.
Code Pointers:
Tenant class api/models/account.py32_resolve_app_tenant_id function api/models/model.py73-77tenant_id field api/models/model.py300-305An "App" in Dify is a deployable application built using Dify's capabilities, such as a chatbot or a completion application. Apps are associated with a specific tenant and can have different execution modes (e.g., Chat, Completion, Workflow).
Code Pointers:
App class api/models/model.py300AppModelConfigDict TypedDict: api/models/model.py240-252AppStatus api/models/model.py38A "Dataset" is a collection of documents or knowledge sources used for Retrieval-Augmented Generation (RAG). Datasets are tenant-specific and can be configured with various indexing techniques, retrieval models, and processing rules.
Code Pointers:
Dataset class api/models/dataset.py165-211DatasetPermissionEnum api/models/dataset.py162-163DatasetService class api/services/dataset_service.py1-50A "Document" is a single unit of content within a Dataset. It can be a text file, a web page, a Notion page, or other data sources. Documents undergo an indexing process to be made retrievable.
Code Pointers:
Document class api/models/dataset.py240-280IndexingStatus api/models/enums.py56A "Workflow" in Dify represents a graph-based execution flow for AI applications. It consists of interconnected nodes, each performing a specific task (e.g., LLM call, tool execution, knowledge retrieval).
Code Pointers:
Workflow class api/models/workflow.py176-210WORKFLOW, CHAT, RAG_PIPELINE): WorkflowType enum api/models/workflow.py115-123WorkflowContentDict TypedDict api/models/workflow.py99-105The DatasetRetrieval class orchestrates the retrieval process across one or more datasets, handling metadata filtering, reranking, and hit testing.
Code Pointers:
DatasetRetrieval class api/core/rag/retrieval/dataset_retrieval.py102knowledge_retrieval method: knowledge_retrieval method api/core/rag/retrieval/dataset_retrieval.py119-157Sources: api/core/rag/retrieval/dataset_retrieval.py119-157 api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py1-50 api/core/rag/datasource/vdb/vector_factory.py1-50
A DocumentSegment represents a chunk of a document after it has been split and processed. These segments are what get indexed and retrieved during RAG.
Code Pointers:
DocumentSegment class api/models/dataset.py320SegmentStatus api/models/enums.py56KnowledgeFS refers to the new frontend module (web/features/new-rag) that provides a unified interface for managing knowledge bases. It supports creating knowledge bases from various sources (empty, file upload, web, Notion, Google Drive, S3) and offers detailed document management, chunk viewing, and processing task tracking.
Code Pointers:
web/features/new-rag web/app/components/base/icons/src/index.ts1-50 (indirectly, as a feature module)ENABLE_WEBSITE_FIRECRAWL docker/.env.example158The ModelManager is the primary entry point for obtaining model instances and checking provider configurations.
Code Pointers:
ModelManager class api/core/model_manager.py28ModelManager import api/core/rag/retrieval/dataset_retrieval.py28The ProviderManager handles the lifecycle and configuration of LLM providers. It assembles ProviderConfiguration objects which encapsulate all settings for a given provider.
Code Pointers:
LargeLanguageModel (base for providers) api/core/model_runtime/model_providers/base/large_language_model.py1-50Provider class api/models/provider.py10Sources: api/core/model_manager.py28-30 api/core/rag/retrieval/dataset_retrieval.py102-118 api/models/model.py227-231
The ToolManager is a central component for discovering and managing tools. It provides methods to retrieve different types of tool providers and their corresponding tool runtimes.
Code Pointers:
ToolManager class api/core/tools/tool_manager.py1-50Tool class api/models/tools.py1-50Dify manages tools through various controllers based on the provider type. These controllers abstract the specifics of each tool type.
Code Pointers:
BuiltinToolManageService api/services/tools/builtin_tools_manage_service.py1-50sign_tool_file function api/core/tools/signature.py22An enum defining the roles an account can have within a tenant. These roles dictate the permissions and access levels for users within a workspace.
Code Pointers:
TenantAccountRole enum api/models/account.py12-18account_role_required decorator api/controllers/console/wraps.py22-32An enum defining the visibility and access permissions for a dataset. This controls who can view, edit, or use a dataset in applications.
Code Pointers:
DatasetPermissionEnum api/models/dataset.py49The MODE environment variable determines the entry point of the Dify API container. It can be set to api for the main web server, worker for Celery background tasks, beat for Celery scheduler, or job for one-off tasks.
Code Pointers:
x-shared-worker-config anchor docker/docker-compose.yaml74-79x-shared-worker-beat-config anchor docker/docker-compose.yaml140-145x-shared-api-worker-config anchor docker/docker-compose-template.yaml2-8Dify supports over 23 vector databases through a plugin-like architecture, managed by the VectorFactory.
Code Pointers:
VectorFactory class api/core/rag/datasource/vdb/vector_factory.py1-50VECTOR_STORE environment variable api/.env.example207-208[tool.uv.sources] section api/pyproject.toml65-94An "Agent" in Dify is an AI entity capable of reasoning, planning, and executing tasks using tools and knowledge.
Code Pointers:
AgentToolConfig api/models/model.py142-147AgentModeConfig api/models/model.py149-154NEXT_PUBLIC_ENABLE_AGENT_V2 environment variable docker/.env.example160A Pydantic model representing the core configuration of an Agent's "soul," including its model, prompt, tools, knowledge, and memory settings. This configuration defines the agent's behavior and capabilities.
Code Pointers:
AgentSoulConfig class api/services/entities/agent_entities.py100test_agent_soul_config_validation api/tests/unit_tests/services/agent/test_agent_services.py102-111AgentSoulConfig import api/services/agent/composer_validator.py1-50A snapshot of an AgentSoulConfig at a specific point in time. This allows for versioning and reproducibility of agent configurations.
Code Pointers:
AgentConfigSnapshot class api/models/agent.py100AgentRosterService to retrieve published agent souls: get_published_agent_soul_config method api/services/agent/roster_service.py1-50A draft version of an AgentSoulConfig that is actively being edited by a user. This allows for iterative development and testing before publishing.
Code Pointers:
AgentConfigDraft class api/models/agent.py120AgentComposerService for managing draft configurations: AgentComposerService class api/services/agent/composer_service.py1-50A service responsible for managing the creation, editing, and validation of agent configurations, both for roster agents and workflow-embedded agents. It handles saving drafts, publishing, and managing different variants of agent configurations.
Code Pointers:
AgentComposerService class api/services/agent/composer_service.py1-50test_load_workflow_composer_state api/tests/unit_tests/services/agent/test_agent_services.py138-156A service that manages the lifecycle of "roster" agents, which are standalone agents available for use across different applications and workflows. It handles CRUD operations, publishing, and versioning of these agents.
Code Pointers:
AgentRosterService class api/services/agent/roster_service.py1-50test_get_published_agent_soul_config api/tests/unit_tests/services/agent/test_agent_services.py120-127Represents the binding of an agent to a workflow node. This can be either a reference to a roster agent or an inline agent configuration specific to the workflow.
Code Pointers:
WorkflowAgentBinding class api/models/agent.py160WorkflowAgentBindingType enum api/models/agent.py150AgentComposerService to load workflow agent configurations: AgentComposerService class api/services/agent/composer_service.py1-50Sources: api/services/agent/composer_service.py1-50 api/services/agent/roster_service.py1-50 api/models/agent.py100-160 api/models/workflow.py176-210 api/models/model.py300
A standalone FastAPI-based service built on the Agenton framework for executing Pydantic AI agents.
Code Pointers:
dify-agent api/pyproject.toml63dify-agent package dify-agent/uv.lock12-13A Go-based agent runtime that provides a secure and isolated environment for executing agent code. It features a shellctl HTTP server for managing shell jobs, tmux-backed shell job lifecycle, Landlock filesystem sandboxing, SQLite persistence for runner-exit, and a sanitize-pty PTY filter.
Code Pointers:
dify-agent-runtime image: langgenius/dify-agent-runtime docker/docker-compose.middleware.yaml105 (This is an older reference, the current one is langgenius/dify-sandbox)SANDBOX_API_KEY, SANDBOX_GIN_MODE, SANDBOX_WORKER_TIMEOUT docker/.env.example198-200CODE_EXECUTION_ENDPOINT api/configs/feature/__init__.py109-111The "Deployments" feature (web/features/deployments) in the frontend manages the lifecycle of application releases. This includes creating new releases, maintaining version history, importing/exporting workflow DSL, and managing deployments across different environments (production, staging, development). It also handles access channels (webapp, CLI) and environment-specific permission policies.
Code Pointers:
web/features/deployments (implied by feature name)jotai-tanstack-query dependency web/package.json102packages/contracts/generated/api/console/apps/orpc.gen.ts packages/contracts/generated/api/console/apps/orpc.gen.ts1-50packages/contracts/generated/api/console/apps/types.gen.ts packages/contracts/generated/api/console/apps/types.gen.ts1-50packages/contracts/generated/api/console/apps/zod.gen.ts packages/contracts/generated/api/console/apps/zod.gen.ts1-50A state management layer used in the Dify web frontend. It combines Jotai for atomic state management with TanStack Query for data fetching.
Code Pointers:
jotai-tanstack-query dependency: web/package.json102@tanstack/query-core dependency web/package.json68A shared component library used across the Dify web frontend.
Code Pointers:
@langgenius/dify-ui dependency: web/package.json159Sources: api/models/model.py1-248 api/models/workflow.py1-210 api/models/account.py1-100 api/core/rag/retrieval/dataset_retrieval.py102-157 docker/docker-compose.yaml1-206 api/pyproject.toml1-100 api/.env.example1-211 web/package.json1-200 api/models/dataset.py1-320 api/services/entities/agent_entities.py100 api/tests/unit_tests/services/agent/test_agent_services.py102-156 api/services/agent/composer_validator.py1-50 api/models/agent.py100-160 api/services/agent/roster_service.py1-50 api/services/agent/composer_service.py1-50 dify-agent/uv.lock12-13 docker/docker-compose.middleware.yaml105 api/configs/feature/__init__.py109-111 packages/contracts/generated/api/console/apps/orpc.gen.ts1-50 packages/contracts/generated/api/console/apps/types.gen.ts1-50 packages/contracts/generated/api/console/apps/zod.gen.ts1-50
Refresh this wiki
This wiki was recently refreshed. Please wait 6 days to refresh again.