What is Dify AI?
Hello everyone, welcome to AI Anytime channel. In this video, we are going to look at Dify AI. So Dify AI is a low-code no-code platform where you can build AI applications faster. So they say it's an innovation engine for Gen applications.
See this as more of a drag and drop where you can just, you know, create a workflow, you can add components, for example for a chatbot, for a summarization task, for you know, if you want to build AI agents, you can just drag and drop on the dashboard and you can have an AI applications in the end. I already have a couple of videos on Dify AI where I have shown them how you can access the dashboard and build it there, but in this video we are going to set this up through Docker. So we're going to do this locally and you do not have to, uh, go on their Cloud dashboard and do it. So this is a local setup video that we're going to do for Dify AI. So let's jump in and see how we can do that.
Dify AI & Competitor Overview
So if you look at here on the screen, I am currently on their website called Dify AI. It says an innovation engine, and they are fantastic, guys. Dify is not the only one where you can build AI applications without writing code. You have it started with Flowise. Flowise is also backed by Y Combinator, you can also check it out. I have a video on that as well. Then there is make.com, it's an automation platform where you can build very similar to Dify where you can build AI applications if you don't have coding expertise or if you don't have technical knowledge of how to build AI apps. You can just try it out and build some hobby projects faster, and of course, you can also use this for different use cases and validations. But if you want to take this in production, you should have at least understanding of AI. We also have Gumloop. Gumloop is again backed by YC if I'm not wrong. I also have videos on Gumloop, a couple of videos, where I have shown tasks like OCR optical character recognition and also how to do blog post automation on LinkedIn.
Now here on Dify, it's available through their cloud and also through Docker. As I said, we're going to set this up locally. You can access the GitHub here, it's called Lang-Genus/Dify.
Why Use Docker? A Quick Primer
Now I have a video as I said on Dify, you can see on AI agents how you can create AI agents without writing any codes. Okay. Now I'm just going to... I'm going to give this link in description.
If you don't know Docker, amazing technology, one of my favorite technology ever. I have been using Docker when when it was started so and I was in college that time. So, build with the number one most used developer tool. It should be number one. Docker makes our life easier. You know if you want to, you know, build once and then ship it in any other systems which supports Docker, and it's fantastic right? Because it basically removes the version conflicts, dependencies from the equation. So we're going to use Docker to set this up and specifically we're going to use Docker Compose, and let's jump in now.
Cloning the Dify AI Repository
So what I'm going to do here, open my terminal. You can see this is the terminal. If you are on Windows, you can have Docker desktop. If you are on Linux, you can just use to to install Docker on command line and that's it. You can add some user groups on Linux, for example, if you're using it. On Windows you need Hyper-V, the virtualization needs to be enabled, so you have to go to BIOS and then you have to enable virtualization to use Docker.
Now what I'm going to do here first, so I have a lot of images. So the command to see image, it's not a Docker tutorial but I'm going to explain a few things. Now if you want to find out how many images you already have, okay, you can just do Docker images, and you can see I have a bunch of images, right for that. Now if you want to find out if there is already a running container, okay, now your program or the software or the code that you have written, it runs within a container if you use Docker. Okay, and you can use docker ps to find out if there is any running container. You can see I'm running Open Web UI, like an earlier it used to be known as Olama Web UI. So this this is already running and this is what it is. Now what I'm going to do is you can also use docker it to have you know more interactive ways. Now the first thing that we're going to do is get clone the repository so let me just do git clone here and then I'm going to copy this and let's let's copy this thingy here and then I'm just going to, excuse me, paste it here. So what I'm doing here, I'm doing git clone and then giving the GitHub repo and then just I will hit enter. You can see it says cloning into Dify. You know it will take a bit of time, the repo is huge. They have a lot of examples. It's a complete, you know, open-source no-code low-code platform. They have a lot of configurations, presets already done for you so you do not have to kind of worry about it. So that's what that's what I'm doing here, I'm cloning it out and you can see it takes a bit of time. The next thing is, let me show you here, we are going to go inside this repository of Docker. We're going to CD into this. So if I open this you can see it says Docker and I'm going to use this file called docker-compose.yml. So it's a config file and that will help us run this piece of code or this entire Dify within a container. And this is an entire Docker compose file. And I'm just going to come here, come back, and you can see this is done.
Starting Dify with Docker Compose
The next thing that I'm going to do is cd dy/docker because that's the folder. So let's do that and you can see I am now inside Docker. If you do ls, you can find it out all the files that we have within this particular directory. And now the next thing that I'm going to do is I'm going to use docker-compose up -d. So let me just do that. I'm using hyphen d to run this in a detach mode.
And for the first time it will take a lot of time, guys, because it has to pull different images from official Docker Hub or the GitHub container registry or Azure Container Registry or AWS container registry from wherever. Container registries are something where, you see a lot of these organizations, they already have created their images. So you can just download or pull that image and run within a container so you do not have to go and, you know, build it yourself. They have the image, pull it and use it in your application. So that's what it is doing. Let me pause the video and come back once this is done.
Initial Dify Setup and User Creation
Alright guys, as you can see, we have our Docker, like it started. I started, it's on Localhost install. You can see all the images have been pulled successfully, everything is running. It says running 11 out of 11. So the network, proxy network, Docker default, and multiple containers running, vector databases, server, web servers, and whatnot, right? Caching databases and whatnot. You will not require everything so do not worry about it.
Now you have to come here and says localhost/install and then you have to give your email addresses to do that. So I can, you know, give some of my email address for example, if I just give my email address, I give a username, and I give a password, so I'm just going to give any password here. Excuse me. Okay, oh sorry, email address. It's not that okay, I just clicked on auto saved. Yeah, and now you can logged in on this Dify dashboard. You can see it says Localhost/apps and this is fantastic because we do not have to worry about a lot of things guys here.
Creating a Basic Chatbot
Now if you look at here, it says Create from blank, create from template or import DSL file. Now DSL file is something that for example if I create a chatbot on Dify, so I will have an entire flow, you know, from a start to end, all the components. Now I can save that as a file and I can give it to you so you can just import that file and use it as it is. So that's what DSL, import DSL file is here.
I'm going to click on create blank. You can create blank, that's what you should do. You should click on create blank and just start working with it. So let me just do that. You can look at chatbot, let's just create blank. Now once you click on create blank it it has different types of apps: chatbot, text generator, agent, and workflow. So I'm going to keep it chatbot, basic just for this, just for the demo purpose here guys. I'm going to call it trial bot or something and just click on Create. Now once you click on create, you can see LLM provider key has not been set. I'm going to, you can see all the models. So right now, you know, if I just do Groq, do not have that. You have to set that model by the way. So for example, if it says GPT-4o and LLM provider key has not been set, I have to set the key here. You know, we have to go in the, go to settings and then set it.
Configuring an LLM Provider (Groq)
But we'll go there. Before that, if you look at here on the left-hand side, we have something called Orchestrate, API Access, Logs, so you can also find out logs. They also have observability so you can also monitor it, whatever is happening. Now here you have instructions, variables, context, citations, you can add tools. I'm going to show that in a bit. Let's go on settings and in the settings you can find it out, all these LLMs guys. OpenAI, Anthropic, Azure, OpenAI, you know, Cohere, Llama, Replicate, Groq, blah blah blah blah blah. Okay.
Now I'm going to click on Groq Cloud. So let's set it up and I can just get a... let's go to Groq. Groq Cloud because Groq can give us an API key so we can use that just for the demo purpose here. Yeah yeah yeah, verifying you are a human app. I'm a human app. I have to see how they deal with AI in near future. The console.groq, create an API key. I'm going to call it Dify demo or something and submit and it will give me a key. So I'm just, and I'm going to delete this of course after the video so that's not a problem. And save. Now you can see I have saved. So my Groq is set. I'm just going to say no thanks. And you can see it has been, you can also remove it, cancel it if you want to remove from here. And if you're in the model setting you can find out all the models. Okay. Now members, if you want to add more people, you can also connect your data source, notions, website but that's I think premium thingy. You can have an API extension, blah blah blah. This is the model provider.
Building and Testing the Chatbot
Now let's do a restart here. I'm going to select, let's select any model. So you have Llama 3 and Mistral 8x7B. I'm going to click on Llama 3 8B, 8192 context window. These are fine. You can keep a bit high if you want, you know, and Max new tokens, you can, yeah, you can increase that a bit and that's fine. Okay.
Now here you have, you can also build a RAG chatbot where you can bring up your own knowledge base. So here you have something called Knowledge and I'm not going into it guys because I will recommend you to watch my previous videos because the main purpose of this video is to set it up through Docker and get it up and running and the rest of the flow is same as what I have shown in the previous video on the Dify Cloud. Now here you can do a few things so here you can set up your instructions. You can give some role or instructions whatever you want to do it, different types of prompt engineering you can do here. And the next is, let me just bring up my charger here. Okay.
Now the next what you can also do, you can add variables. Variables are nothing but where you pass your context so you can also do that. You know if you have some knowledge bases you can, you can see this input. Now you can input knowledge as context, you know, you can create a knowledge base and do that here as well. I'm not going to do it. Citations and attributions, not, but you can add features. Now you can have a followup where you have, you know, followup inbuilt where you can ask followup questions. I'll just remove this here. These are all good, you know, you can have one welcome, you can define some questions but I'm just going to get rid of it. So I have add one feature and let's publish.
Now when you run this app it says trial bot, start chat and it says powered by Dify. Okay? Now I'm going to start chat. We don't have any, you know, default questions or preset, you can define it. Now I'm going to ask a question, what is AI for example? It says model GPT-4 credentials. Let me update this guys here and run app again. And I'm going to ask write a Fast API code snippet to call an API using request modules.
Yeah, so you can see I have asked a question and it's pretty fast because Groq provide you that faster inference due to their tensor processing units, that's what they call it. Now one thing you have to do it that you have to update once you select the model, I forgot to do that. Now you can see it says here is an example of how you can use the request library with Fast API to call an external API and you can find it out the code and it explains that a bit blah blah blah. It also suggest you the follow, it also suggest you some other question that you can ask. So you can also ask some follow-up questions. Can I use post request? And you can see instead of get and it's pretty fast guys. So it's running it locally within your system without writing any code guys. What else you need, right? Get it get it up and running quickly with Dify or any other platform like Gumloop or anything that you want to do. So if you look at, but Dify is uh powerful, I recommend you use Dify.
Exploring Dify's Features (Embed, Logs, API)
The next thing that what you can do, you can also embed this. So you can embed into site, you can have website where you have the right hand side or on top, you can embed this as a chatbot. You have to use this script, this is Javascript code that you can use it and you can also do that here. You can also embed anywhere you want to embed it.
It also have logs and annotations so for each question that you ask, the logs get recorded over here, you can see. And you also have annotations. Annotations are helpful if you want to further use this data to fine tune it. In the monitoring part you can find it out everything. And you can also use this as an API endpoint. You can see there's something called backend service API. Now imagine if you want to use this in any existing applications or a mobile devices, you can just call this to this end point and it will work. You can see it over here. This is a public URL you can share with your friends. You can do that, guys, that's not a problem. Let's go back to orchestrate.
Followup when you create tools, you know, if you look at there so many tools available, okay, DuckDuckGo, you can search it on internet. A lot of tools that you can use it, you know. So DuckDuckGo can be used to search. There is arXiv which brings a paper, there is PubMed you can use PubMed which is a biomedical literature. PubMed Central you can bring up information, and variables. You can add variabl as I said, you can add context.
I don't have any knowledge base as I said, but you can create it, guys, very pretty easy. Click on Knowledge, create knowledge, you know, it says input from file, sync from website, sync from Notion. Notion is a database that you can use. Now here you can upload your files. You can upload any files, guys, you know, it depends on you what kind of files you want to upload. I don't seems like I don't have any file so I'm not going to use that. Okay, so you can use it and just sync up with your bot here and that's what it is, guys.
Conclusion and Community Invitation
You know, this is how easy it is to set it up on your local machine through Docker. So you don't have to worry about, you know, connecting with internet and so on and so forth. When you use Groq Cloud API, you need internet to do that but you can also set it up models locally if you want to do it. So that's up to you, I leave it up to you to do that. Okay.
Now if you have any question, thoughts or feedbacks about this video, let me know in the comment box. You can also join our Discord community, guys, you know, that is available, that is available for you to join in free. We have lot of opportunities, job updates, internships, we do hackathons, we do coding session, jamming sessions, town halls, you know, we have help channels, we have freelancing opportunities as well. So please join our Discord, I will give the link in description.
Now, if you like the content I'm creating, please hit the like icon. And if you haven't subscribed the channel yet, please do subscribe the channel, guys. That motivates me to create more such videos in your future. That's all for this video, guys. Thank you so much for watching. See you in the next one.