Skip to content

Commit 7828d20

Browse files
authored
add docs for TiDB Bot demo (#65)
1 parent 7b20f34 commit 7828d20

10 files changed

Lines changed: 79 additions & 0 deletions
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# How to leverage LinguFlow to build and deploy a demonstration of TiDB Bot in 10 minutes
2+
3+
## 1. Prerequisites
4+
5+
### 1.1 What You Need
6+
7+
- Setting up LinguFlow in your local environment
8+
- Getting an OpenAI API key
9+
- Setting up Google custom search API and getting a key
10+
- Better to have
11+
- Knowledge of Langchain core modules about prompts and models
12+
13+
### 1.2 Limitation
14+
15+
- In this example, we will use `GoogleSearch` block as a simplified retrieval for demonstration.
16+
- This is just a demonstration without chat session management and revision.
17+
- Only LLM from OpenAI is provided now.
18+
19+
## 2. Designing the Business Logic of TiDB Bot Demonstration
20+
21+
The business logic shows as follows:
22+
23+
- Judge whether the question is related to TiDB
24+
- If it is not related to TiDB, refuse to answer it politely.
25+
- Otherwise, retrieve the corpus related to the question and answer it finally
26+
27+
> Notes:
28+
> - Usually the best practice is to use RAG for the judging block and the refusing block too.
29+
30+
## 3. Building the TiDB Bot Demonstration in LinguFlow
31+
32+
### 3.1 Normal procedure
33+
34+
What you should do is to implement the business logic in the above section block by block according to your intuition.
35+
36+
Or you can do as the following section and read the configuration of each block.
37+
38+
### 3.2 Substitute procedure
39+
40+
1. Create a new application and a new version of it
41+
42+
![create TiDB-Bot application](images/create-bot-app.PNG)
43+
![create TiDB-Bot version](images/create-bot-ver.PNG)
44+
45+
2. Importing the given YAML file `TiDB_Bot_demo.linguflow.yaml`
46+
47+
![import yaml](images/import-yaml.png)
48+
49+
3. Filling up with OpenAI API key in 3 LLM blocks
50+
4. Filling up with search_engine_id and key in the GoogleSearch block according to the following post Custom Search JSON API
51+
5. Save
52+
53+
![save app](images/save-app.PNG)
54+
55+
## 4. Testing and Debugging
56+
57+
You can access testing and debugging by clicking the button at the bottom left corner.
58+
59+
![debug](images/debug.png)
60+
61+
Then you can input the testing questions in the input box and get the whole information flow from all valid blocks. You can modify any of them and retry it until you get the proper answer.
62+
63+
![answer1](images/answer1.png)
64+
![answer2](images/answer2.png)
65+
66+
## 5. Deploying the TiDB Bot Demonstration
67+
68+
When the test result is available, you can publish this version from 2 ways. You can deliver the API to your customer or integrate it into your service.
69+
70+
![publish1](images/publish1.png)
71+
![publish2](images/publish2.png)
72+
73+
## 6. Conclusion
74+
75+
It is a quick start of a simplified version of a production application.
76+
77+
It is clear that building applications based on business logic allows for a quicker implementation, debugging, and deployment experience, compared to understanding the construction relationships of entities in the code before organizing the application.
78+
79+
In the future, there will be more usful blocks in this repository. If you have any questions or expectations, please do not hesitate to raise an issue or contact us.

ui/examples/images/answer1.png

205 KB
Loading

ui/examples/images/answer2.png

208 KB
Loading
15.4 KB
Loading
6.19 KB
Loading

ui/examples/images/debug.png

212 KB
Loading

ui/examples/images/import-yaml.png

5.76 KB
Loading

ui/examples/images/publish1.png

217 KB
Loading

ui/examples/images/publish2.png

32.4 KB
Loading

ui/examples/images/save-app.PNG

8.93 KB
Loading

0 commit comments

Comments
 (0)