Dify is an engine and development platform for AI applications.
If you need to develop an enterprise-grade AI application, or an intelligent body application, you generally have the following options:
- Handwrite all the code and interface with various API interfaces of big model vendors by yourself.
- Use some SDKs that encapsulate a layer, such as Vercel's AI SDK.
- Use an AI app development platform like Dify.
Products that are more similar to Dify have "buckle". But Buckle is pure cloud SaaS and not well suited to be taken and delivered to customers as part of a solution. Therefore, Dify, with its open source code and easy private deployment, is a better choice.
Dify's License is commercially available
Although Dify uses the Apache open source protocol, there are some additional restrictions on commercialization:
1. Multi-tenancy services are not allowed;
2. Changes to the logo and copyright information of the Dify Web Console interface are not allowed.
Overall, this open source agreement is still very loose. As long as you deploy a separate set of dedicated to each enterprise customer and don't let them use the Dify Web Console, you're not violating it.
In other words, you can build out the smartbody application without writing a single line of code, using the Dify Web Console's visualization tools, and then integrate the auto-generated APIs into your own solution.
Does my project need to use Dify
You don't have to use Dify to develop a smart body application; essentially, you can integrate OpenAI's APIs with an old Java 8 and Spring Boot backend just as well.
However, there are some characteristics of smart body applications that go to constant debugging of cue words and processing of knowledge base data. Using Dify can greatly improve the development experience and efficiency. You can't just change the prompts and release a new version.
The Dify backend is developed in Python, as most of the AI-related component ecosystem has Python packages directly available. Unlike Java backends, which are common in enterprise applications, it is recommended that they be deployed standalone, separate from the business clusters.
Dify Component Overview
Dify uses a common front-end and back-end separation architecture, with a very large number of components and a fairly flexible deployment approach.
Dify official website recommended Docker Compose deployment program, in fact, can only be used for local development and experience. In a production environment, you should use K8s or other highly available deployment options according to your needs.
Taking Dify version 0.15.3 as an example, a production environment deployment requires the following components:
essential component
- api
- worker
- web
basic component
- postgres
- redis
- sandbox
- ssrf_proxy
- certbot
- nginx
- weaviate
The relationship between the components is shown in the following diagram
Detailed description of the architectural layering
back end
Dify's backend includes
- "api", the Python flask service started with gunicorn;
- "worker", started with celery, consumes asynchronous tasks from the redis queue. These tasks are things like dataset file imports and dataset document updates.
forward part of sth.
The frontend "web" is developed with Next.js. It is built and started with pm2 (node).
access layer
Nginx is used to forward web requests to the api or web, and certbot is used to automatically manage HTTPS certificates.
storage layer
Dify's storage layer uses
- Relational Database PostgreSQL
- NoSQL Database/Cache Redis
- vector databaseThe default is Weaviate.
safety
Dify, as an application development platform, is available as a visual tool to orchestrate workflow nodes to handle business logic.
The workflow node allows users to execute Python/NodeJS code, so a Sandbox mechanism is needed to restrict users from performing high-risk operations.
The following two modules are involved
- "sandbox" is developed in Go.
- "ssrf_proxy" is the network outlet configured with squid.
Comparison with LangChain
LangChain is the oldest LLM application development framework. As you can see from the figure below, Dify outperforms LangChain in every aspect.
Private Deployment of Dify in Production Environments
If you need to customize AI Intelligent Body applications for your customers and provide AI solutions for vertical industries, consider privately deploying Dify in your production environment.
For the following two reasons, it may also be necessary to modify and deeply customize Dify's code:
1. To open up the internal data of the enterprise, in particular to organize structured internal data into a form that can be used to RAG of the knowledge base.
2. Open up login authentication so that intelligences understand their identity and can provide personalized services.