Introduction to Dify
Are you looking for the perfect tool to create chat bots and AI assistants? Discover Dify, a free open-source platform to create autonomous AI agents by leveraging the LLM of your choice combined to a set of tools. Create the chat bots you have in mind in a few clicks. Start from one of the ready-to-use templates or create yours from scratch with the visual workflow editor.
Stand out from the generic AI bots using the knowledge base to make it become an expert in any field you want to train it for. Ideal for private and confidential enterprise data.
Deployment Options & Elestio Setup
Before diving into the platform overview, let's see the different options available for us to use it. You can use the cloud version by clicking on the get started button. It contains a free tier perfect to grasp the potential of Dify. You can also self-host it by following their GitHub installation guide or use a platform like ours, Elestio, to take care of the installation, backups, updates, and maintenance for you on the cloud provider of your choice.
To install Dify on our platform, head to elest.io and click on login. Deploy my first service. Search for Dify and click on select. Choose between the different cloud provider, region, and service plan based on your need. I will choose two CPU and 4 GB of RAM and then next. Adjust your level of support. I will keep the free included one and then create service.
Once your instance is ready, you will receive an email. Follow the click here to get the password link. You arrive on your administration panel on Elestio. Copy the password to your clipboard and follow your instance link by following the admin UI here.
Creating Your First Agent from a Template
Let's start using Dify. So, first we need to login. You can change the language one of those available here. The email address is the one of your account and paste the password from your clipboard and sign in.
We land on studio. Currently we don't have any chatbot. So we need to create our first one. We have the choice between creating one from scratch which is from blank or from a template. Let's start by using a template. It's spread across different categories recommended, programming, HR, assistant, workflow, writing, and agent. And you can add an additional filter because you can create three different things. Chatbots, agent, or workflow.
I will keep it like this in the agent section. And let's use SVG logo design. You can rename it and change the icon, but because it is a demo, I will keep the default template settings.
Configuring the LLM Provider (OpenAI)
We arrive on this page. Don't be overwhelmed because the UI is pretty well done and everything makes sense. We have a warning on the right because we don't have any LLM provider key because it's not Dify on its own that is having AI capabilities but we need to use different tools and API. So first let's go to settings.
We can use any model provider of our choice. You can see that the list is large and contains the most famous one such as Gemini, Nvidia, Olama and the most famous one that we will be using is OpenAI. So first we need to do setup and write our API key here. But because the field is visible when I will paste it, I will go to save right after. So see you in a second.
Welcome back. So now we have OpenAI and we have our API key that is working. We can close it and go back to our agent.
There are two main blocks. On the left of the orchestrate panel, you have the instruction and a lot of options and on the right debug and preview. So first let's have a look at the instruction. You can see we have this syntax here with the task of what it is doing and some prompt. Basically it's your prompt and because we are using a template we can assume it is well done. Then you can add some variables. Basically, it's just input that you will pass directly inside your prompt after by using this syntax here.
Then you can add some context. It's coming from your knowledge base. We will see it later in the video. And then we are leveraging some tools. So currently we are using OpenAI language model to run the prompt here and our agent. But then it leverage other tools which are DALL-E and Vectorizer AI. But we have warning because we didn't configure them yet.
DALL-E should be quick to set up because it's using OpenAI key too. So we need to add our tool and to authorize it. So we have already added it. Go to authorize. We need to enter our OpenAI API key. I will do it and save. Okay. Now you can see on the top right we have authorized.
Next one will be Vectorizer AI. You can see we will need to reload the page but it's not a big issue. Again the same process to authorize. This time it's a tool I didn't even know before. So we can follow the how to get link. We arrive on the API documentation of vectorizer.ai. So you can create an account and get your key. Don't worry if I leaked mine because it's a test account. It's split into two parts. The name and the secret. Then save.
Okay. We can see it is authorized here. But here it's not auto reloading. So let's do command R. And we now see that the two tools are enabled here. Perfect.
Exploring Chat Enhancement Features
Let's have a look at debug and preview. So by default our agent is telling us different things what it can do for us. And we have three different button we can select instead of typing directly. And this is one of the five great features. It is the chat enhance section here. And you have that conversation opener. So this is the text you see here. And then you can choose the different options that you can click on. So it will guide your users or if you create tools for automation, it will speed up your process instead of writing it down every time. But we are happy with the template. So we can cancel and let's see the different other option we have in chat enhance before trying it.
So we have followup and we have citations and attributions. So these are the enabled chat enhance feature but we can add others. The currently we have conversation remakers. You can have a preview on the right when you hover it. Followup. So it will be further questions. If you want to enable text to speech or speech-to-text very useful, not in our case but in general and citations and attributions. Then you have two tools that you can leverage. Content moderation. So it can secure the output by using moderation API or annotation reply which is here to enhance the next answer. So the more you will use it and use annotation the more it will have context to go from it and iterate in the right direction. But again we'll be using that template in the way it was provided to us. So let's try it.
Live Demo: Generating an SVG Logo
Can you give me a logo design for a coffee shop in Los Angeles, a new city? So here it's giving us four different options. Vibrant, neutral, serious, kind or we skip it. Then it's telling us what is the default option. And we also have this feature that is giving us suggestion. But let's say we want a neutral logo. So we hit B and enter.
Then okay, great choice. On a scale of 1 to 10, how would you like the complexity of your logo? Let's say we want something quite simple. So let's use three. And final question, we can choose a different color palette. So espresso, brown and cream, charcoal, gray and white, vintage, mint and coral or custom palette. So let's use vintage mint and coral.
Now we can see it is using DALL-E. So it's generating our image. And we now have our logo generated. We can ask for another one, but currently it only used DALL-E. And we have vectorizer.ai and it's talking about SVG. So I guess if we want to go further and have this image into a SVG file, we can ask our agent and it will generate it using that other API. So let's try it. So can you provide me the SVG version?
Okay. All right now it's using Vectorizer tool and it generated the SVG version because I'm using a free API key. You can see that it added the Vectorizer AI test image but you can see it worked correctly which is perfect.
API Access and Documentation
So currently we are in the orchestrate section where we can edit our prompt and preview it. You can have different option but let's have a look at the different menu on the left. You have API access and automatically on any chatbot that you create on Dify it will generate you endpoints that you can use as an API and automatically you will have your documentation page generated with code that you can copy paste and try it directly.
Logs and Annotations for Improvement
Then the third menu is logs and annotations. So logs it's where you can retrieve all the conversation made by all the different users. Currently we only made the test once so it's not very useful but still you can see what is the potential within it. You have all the history of what has been done. At each step you can copy what has been saved. Open the prompt log so you can see all the prompt that was used by Dify and not only what is displayed to the screen of the users.
And to enhance the experience over time based on the answer of the agent you can say it was a good or bad answer and based on that it will change the answers accordingly some kind of machine learning.
Application Overview and Deployment
And last menu on the left is the overview panel. This is the place to manage your chatbot and to have some analytics. So first you can enable or disable it. You can preview it but it's what we did in orchestrate. You can customize it. What it is is instead of embedding it into a website you can fork a project ready to use. So you will create a complete web app based on the chatbot that you created. It's a repository you can clone. You have the environment variables to use and you iterate from this Next.js project to create your app based on your chatbot. And this is if you are creating a product around your chatbot.
If you want the more traditional approach, you can click on embedded and you have three different options to embed it in your existing websites or apps. So you have iFrame like a model here or a bubble on your website. So you have the script to integrate it or as a Chrome extension. Perfect if you are using it as automation tooling.
We saw that it automatically generated an API for your chatbot. But if you don't want it to be accessible, you can just disable it. But you also have an API key protection, so no risks. Then below you have the analytics. I only used it once, so it's not very visual, but it's a good place to see all the different users, the different usage. And you also have an estimation of the cost by the token used here. It's very useful, especially because we are using different tools, OpenAI and Vector Razor AI. And here is the synthesis of all of it.
So this was a quick overview of the studio. Now let's have a look at the knowledge.
Creating a Custom Knowledge Base
What it is is to provide some content to your chatbot. So they can rely on it instead of generic data that everyone have access to. So let's create knowledge. And you have three options to import content into your Dify instance. Either from text file supporting text, markdown, PDF, HTML and so on. Synchronize it from notion and soon they will have synchronized form website which will be huge.
I will import lessons for my online course. So let's say I take the 10 first lessons of my course and it's MD files. Open and you can see it's processing all of them. So next you have a preview on the right of the different chunks that it will grasp from my files. It's not specially one file second file but it's more chapters sections. You can choose the automatic one or customize it. You can choose a high quality one but it will use more token but still the price is very low.
And you can decide to have it just as a knowledge base or to segment it in question and answer format. Let's enable it. Then you can adjust the vector search. So when we will type something how it will relate to the different content we have. So you can customize all of it but I will keep it simple and just click on save and process. Now it is processing all of the files one by one.
Testing the Knowledge Base Retrieval
Let's go to document. Currently it is indexing all the different files. So two are currently available. Is doing the third one. It will take some time maybe just a few minutes. To make it faster you can disable question and answer. It's taking way more time to do it.
Let's try the retrieval testing. So what it is is we will type some text and it will try to find related content within our knowledge base within our documents. So let's say what is React 3 fiber testing and we have a score based on the different paragraph that could match. So let's open the second one. What is React 3 fiber? It's showing us the answer based on the content of our text. And we have a graph here to know how it find those values. It found some content within three different files. The intro, React3 fiber and objects.
So now almost all the files have been done. Let's open one of them to see what it looks like. So you can see from a big file it generated 40 paragraph and inside it generated question and answer. So in what context is a cube camera typically used? A cube camera is typically used to create environment maps for reflection and lighting effects. And it's perfectly done because it's not a sentence or a question I wrote, but it grasp the information from the MD file and created this knowledge base. Awesome. You can have it for a lot of content within your files. You can open different ones. And this is content that you can use inside your different chat bots. And it's content that only you will have. It's not generic content you will have access to online.
And let's open the last section, the tools section. We have seen together for our logo generator. We used two tools. So if we go on the left, we used vectorizer.ai and also that I don't know where it is. Oh, here. So we used those two tools, the third version and vectorzer. You can see there are a bunch of tools available and you can leverage them to create nice application by combining it with the language model you want and those different tools to create very powerful chatbots and because it is open source you can contribute to it create your own custom tools and put them at disposal of other users or keep them for you.
Conclusion
Thank you for watching. We hope you enjoyed discovering Dify with us and we'll give it a try. If you find our content useful, please hit the like button to make it more visible to other open-source lovers. Don't forget to subscribe to not miss our upcoming platform overviews. In the meantime, you can continue your opensource journey with this video available here.