Welcome to DOFBOT-Ultra repository
7. RAG knowledge base + chatbot
RAG Knowledge Base + Chatbot
Please ensure that the web control program backend process is not running in the background. To close it, refer to the [Get Started Quickly - 2. Access the Terminal] section in [Disable the Auto-Start Web Control Backend Process]. After closing, please restart DofbotUltra!!!
RAG Knowledge Base + Chatbot1. Course Content2. Start Dify Service3. Case 1: Task Planning4. Case 2: Knowledge Management4.1 Create a Knowledge Base4.2 Create an Application
1. Course Content
Based on the previous RAG knowledge base and chatbot, develop an AI application that combines the two, thereby improving the AI large model's response capability in specific domains and reducing AI large model hallucination through the RAG knowledge base.
2. Start Dify Service
The Dify backend runs on the host system of the DofbotUltra motherboard, not inside a Docker container.
After connecting to the device via VNC or SSH, execute the following command in any directory on the host system to start Dify:
bringup_dify
After startup, you can check the device's IP address via the OLED screen,
ifconfig, or directly in the terminal. Enter the IP address in the browser address bar of a computer on the same LAN to access the Dify management page.
Tip
If you have not configured the model provider API Key yet, please complete the previous
02-Configure API-KEYcourse before proceeding with subsequent RAG and chatbot configuration.If the browser cannot access it, execute
docker pson the host system to confirm that thelanggenius/dify-*related containers are in theUpstate.

3. Case 1: Task Planning
Tip
Case 1 simulates the decision layer functionality of ROSMASTER-M3.
Click Create Blank Application on the homepage.

Click on Chat Assistant (suitable for beginners) -> Name the application -> Create.

Example prompt:
xxxxxxxxxxYou are a task planning master. Combine the knowledge you have to break down complex tasks into steps.
After creating the application, fill in the prompt, then click Add in the Knowledge Base option.

Select the knowledge base to add, then click Add.

Then select an AI large model to connect. Here, we take the
qwen-maxmodel as an example.

Then enter test conversation content. Here, taking removing a machine code as an example, we can see that the AI large model can think and respond by combining the content of the knowledge base. By adding training samples to the knowledge base in this way, you can quickly expand the AI large model's response ability and learning ability in different task scenarios and domains.

We can first delete the knowledge base to compare the response effect of the AI large model without the RAG knowledge base. It can be seen that without the knowledge base, the general AI model from the model provider cannot handle vertical domain tasks.
Tip
This hands-on case can be understood and mastered in conjunction with the theoretical knowledge from
2. RAG Retrieval Enhancement and Training Samples.

4. Case 2: Knowledge Management
When we have internal materials that need to be managed by a large model, we can use the AI large model combined with the RAG knowledge base to allow the large model to respond based on actual business materials. This is very helpful for vertical domains such as finance and healthcare.
4.1 Create a Knowledge Base
Here, we use an example material that contains a fictional literary author and a fictional collection of works. The example material can be found in this course's folder.

4.2 Create an Application
Example prompt:
x# Role PositioningYou are a seasoned knowledge management expert with extensive practical experience in knowledge system construction, information filtering and integration, knowledge accumulation, and empowerment. Your core mission is to help users establish a clear and efficient knowledge management system, achieving accurate knowledge collection, systematic organization, in-depth accumulation, and flexible application, thereby helping users improve their learning/work efficiency and avoid knowledge fragmentation.
Fill in the example prompt, select the fictional author's knowledge base, and then ask questions about the works in the material. At this point, the AI large model can answer based on the private knowledge base.
