writinwaters commited on
Commit
2bf4151
·
1 Parent(s): 5b47d62

Initial draft of Create a General-purpose chatbot (#2411)

Browse files

### What problem does this PR solve?


### Type of change

- [x] Documentation Update

docs/guides/agentic_rag/agentic_rag_introduction.md CHANGED
@@ -51,9 +51,9 @@ Please review the flowing description of the RAG-specific components before you
51
 
52
  | Component | Description |
53
  | -------------- | ------------------------------------------------------------ |
54
- | **Retrieval** | A component that retrieves information from a specified knowledge base and returns 'Empty response' if no information is found. Ensure the correct knowledge base is selected. |
55
  | **Generate** | A component that prompts the LLM to generate responses. You must ensure the prompt is set correctly. |
56
- | **Answer** | A component that serves as the interface between human and bot, receiving user inputs and displaying the agent's responses. |
57
  | **Categorize** | A component that uses the LLM to classify user inputs into predefined categories. Ensure you specify the name, description, and examples for each category, along with the corresponding next component. |
58
  | **Message** | A component that sends out a static message. If multiple messages are supplied, it randomly selects one to send. Ensure its downstream is **Answer**, the interface component. |
59
  | **Relevant** | A component that uses the LLM to assess whether the upstream output is relevant to the user's latest query. Ensure you specify the next component for each judge result. |
 
51
 
52
  | Component | Description |
53
  | -------------- | ------------------------------------------------------------ |
54
+ | **Retrieval** | A component that retrieves information from specified knowledge bases and returns 'Empty response' if no information is found. Ensure the correct knowledge bases are selected. |
55
  | **Generate** | A component that prompts the LLM to generate responses. You must ensure the prompt is set correctly. |
56
+ | **Answer** | A component that serves as the interface between human and the bot, receiving user inputs and displaying the agent's responses. |
57
  | **Categorize** | A component that uses the LLM to classify user inputs into predefined categories. Ensure you specify the name, description, and examples for each category, along with the corresponding next component. |
58
  | **Message** | A component that sends out a static message. If multiple messages are supplied, it randomly selects one to send. Ensure its downstream is **Answer**, the interface component. |
59
  | **Relevant** | A component that uses the LLM to assess whether the upstream output is relevant to the user's latest query. Ensure you specify the next component for each judge result. |
docs/guides/agentic_rag/general_purpose_chatbot.md ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ sidebar_position: 2
3
+ slug: /general_purpose_chatbot
4
+ ---
5
+
6
+ # Create and configure a general-purpose chatbot agent
7
+
8
+ Chatbot is one of the most common AI scenarios. However, effectively understanding user queries and responding appropriately remains a challenge. RAGFlow's general-purpose chatbot agent is our attempt to tackle this longstanding issue.
9
+
10
+ This chatbot closely resembles the chatbot introduced in [Start an AI chat](../start_chat.md), but with a key difference - it introduces a reflective mechanism that allows it to improve the retrieval from the target knowledge bases by rewriting the user's query.
11
+
12
+ This document provides guides on creating such a chatbot using our chatbot template.
13
+
14
+ ## Prerequisites
15
+
16
+ 1. Ensure you have properly set the LLM to use. See the guides on [Configure your API key](../llm_api_key_setup.md) or [Deploy a local LLM](../deploy_local_llm.mdx) for more information.
17
+ 2. Ensure you have a knowledge base configured and the corresponding files properly parsed. See the guide on [Configure a knowledge base](../configure_knowledge_base.md) for more information.
18
+ 3. Make sure you have read the [Introduction to Agentic RAG](./agentic_rag_introduction.md).
19
+
20
+ ## Create a chatbot agent from template
21
+
22
+ To create a general-purpose chatbot agent using our template:
23
+
24
+ 1. Click the **Agent** tab in the middle top of the page to show the **Agent** page.
25
+ 2. Click **+ Create agent** on the top right of the page to show the **agent template** page.
26
+ 3. On the **agent template** page, hover over the card on **General-purpose chatbot** and click **Use this template**.
27
+ *You are now directed to the **no-code workflow editor** page.*
28
+
29
+ ![workflow_editor](https://github.com/user-attachments/assets/9fc6891c-7784-43b8-ab4a-3b08a9e551c4)
30
+
31
+ :::tip NOTE
32
+ RAGFlow's no-code editor spares you the trouble of coding, making agent development effortless.
33
+ :::
34
+
35
+ ## Understand each component in the template
36
+
37
+ Here’s a breakdown of each component and its role and requirements in the chatbot template:
38
+
39
+ - **Begin**
40
+ - Function: Sets the opening greeting for the user.
41
+ - Purpose: Establishes a welcoming atmosphere and prepares the user for interaction.
42
+
43
+ - **Answer**
44
+ - Function: Serves as the interface between human and the bot.
45
+ - Role: Acts as the downstream component of **Begin**.
46
+ - Note: Though named "Answer", it does not engage with the LLM.
47
+
48
+ - **Retrieval**
49
+ - Function: Retrieves information from specified knowledge base(s).
50
+ - Requirement: Must have `knowledgebases` set up to function.
51
+
52
+ - **Relevant**
53
+ - Function: Assesses the relevance of the retrieved information from the **Retrieval** component to the user query.
54
+ - Process:
55
+ - If relevant, it directs the data to the **Generate** component for final response generation.
56
+ - Otherwise, it triggers the **Rewrite** component to refine the user query and redo the retrival process.
57
+
58
+ - **Generate**
59
+ - Function: Prompts the LLM to generate responses based on the retrieved information.
60
+ - Note: The prompt settings allow you to control the way in which the LLM generates responses. Be sure to review the prompts and make necessary changes.
61
+
62
+ - **Rewrite**:
63
+ - Function: Refines a user query when no relevant information from the knowledge base is retrieved.
64
+ - Usage: Often used in conjunction with **Relevant** and **Retrieval** to create a reflective/feedback loop.
65
+
66
+ ## Configure your chatbot agent
67
+
68
+ 1. Click **Begin** to set an opening greeting:
69
+ ![opener](https://github.com/user-attachments/assets/4416bc16-2a84-4f24-a19b-6dc8b1de0908)
70
+
71
+ 2. Click **Retrieval** to select the right knowledge base(s) and make any necessary adjustments:
72
+ ![setting_knowledge_bases](https://github.com/user-attachments/assets/5f694820-5651-45bc-afd6-cf580ca0228d)
73
+
74
+ 3. Click **Generate** to configure the LLM's summarization behavior:
75
+ 3.1. Confirm the model.
76
+ 3.2. Review the prompt settings. If there are variables, ensure they match the correct component IDs:
77
+ ![prompt_settings](https://github.com/user-attachments/assets/19e94ea7-7f62-4b73-b526-32fcfa62f1e9)
78
+
79
+ 4. Click **Relevant** to review or change its settings:
80
+ *You may retain the current settings, but feel free to experiment with changes to understand how the agent operates.*
81
+ ![relevant_settings](https://github.com/user-attachments/assets/f582cc1c-0dd5-499c-813a-294dbfb941dd)
82
+
83
+ 5. Click **Rewrite** to select a different model for query rewriting or update the maximum loop times for query rewriting:
84
+ ![choose_model](https://github.com/user-attachments/assets/2bac1d6c-c4f1-42ac-997b-102858c3f550)
85
+ ![loop_time](https://github.com/user-attachments/assets/09a4ce34-7aac-496f-aa59-d8aa33bf0b1f)
86
+
87
+ :::danger NOTE
88
+ Increasing the maximum loop times may significantly extend the time required to receive the final response.
89
+ :::
90
+
91
+ 1. Update your workflow where you see necessary.
92
+
93
+ 2. Click to **Save** to apply your changes.
94
+ *Your agent appears as one of the agent cards on the **Agent** page.*
95
+
96
+ ## Test your chatbot agent
97
+
98
+ 1. Find your chatbot agent on the **Agent** page:
99
+ ![find_chatbot](https://github.com/user-attachments/assets/6e6382c6-9a86-4190-9fdd-e363b7f64ba9)
100
+
101
+ 2. Experiment with your questions to verify if this chatbot functions as intended:
102
+ ![test_chatbot](https://github.com/user-attachments/assets/c074d3bd-4c39-4b05-a68b-1fd361f256b3)