You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: fern/knowledge-base/knowledge-base.mdx
+77-100
Original file line number
Diff line number
Diff line change
@@ -8,27 +8,38 @@ slug: knowledge-base
8
8
9
9
## **What is Vapi's Knowledge Base?**
10
10
11
-
A [**Knowledge Base**](/api-reference/knowledge-bases/create) is a collection of custom files that contain information on specific topics or domains. By integrating a Knowledge Base into your voice AI assistant, you can enable it to provide more accurate and informative responses to user queries. This is currently available in Vapi via the API, and will be on the dashboard soon.
11
+
A [**Knowledge Base**](/api-reference/knowledge-bases/create) is a collection of custom files that contain information on specific topics or domains. By integrating a Knowledge Base into your voice AI assistant, you can enable it to provide more accurate and informative responses to user queries based on your own data. Knowledge Bases are available through both the Vapi API and dashboard.
12
12
13
13
### **Why Use a Knowledge Base?**
14
14
15
15
Using a Knowledge Base with your voice AI assistant offers several benefits:
16
16
17
-
-**Improved accuracy**: By integrating custom files into your assistant, you can ensure that it provides accurate and up-to-date information to users.
18
-
-**Enhanced capabilities**: A Knowledge Base enables your assistant to answer complex queries and provide detailed responses to user inquiries.
19
-
-**Customization**: With a Knowledge Base, you can tailor your assistant's responses to specific domains or topics, making it more effective and informative.
17
+
-**Improved accuracy**: Your assistant can provide responses based on your verified information rather than general knowledge.
18
+
-**Enhanced capabilities**: A Knowledge Base enables your assistant to answer complex domain-specific queries with detailed, contextually relevant responses.
19
+
-**Customization**: With a Knowledge Base, you can tailor your assistant's responses to specific domains or topics, making it more effective for your particular use case.
20
+
-**Up-to-date information**: You control the content, ensuring your assistant always has access to the latest information.
20
21
21
22
<Info>
22
-
Knowledge Bases are configured through the API, view all configurable properties in the [API Reference](/api-reference/knowledge-bases/create-knowledge-base).
23
+
Knowledge Bases are configured through the API or dashboard. For advanced
24
+
configuration options, view all configurable properties in the [API
There are two main approaches to creating a Knowledge Base in Vapi:
28
31
29
-
### **Step 1: Upload Your Files**
32
+
1.**Dashboard method**: A simplified approach using the Vapi UI
33
+
2.**API method**: A more customizable approach using direct API calls
30
34
31
-
Navigate to Platform > Files and upload your custom files in Markdown, PDF, plain text, or Microsoft Word (.doc and .docx) format to Vapi's Knowledge Base.
35
+
### **Method 1: Using the Dashboard**
36
+
37
+
#### **Step 1: Upload Your Files**
38
+
39
+
1. Navigate to `Build > Files` in your Vapi dashboard
40
+
2. Click the "Upload" button to add your files
41
+
3. Select files in supported formats (`.txt`, `.pdf`, `.docx`, etc.)
42
+
4. Wait for the upload to complete - you'll see your files listed in the Files section
32
43
33
44
<Framecaption="Adding files to your Knowledge Base">
34
45
<img
@@ -37,101 +48,62 @@ Navigate to Platform > Files and upload your custom files in Markdown, PDF, plai
37
48
/>
38
49
</Frame>
39
50
40
-
Alternatively you can upload your files via the API.
41
-
42
-
```bash
43
-
curl --location 'https://api.vapi.ai/file' \
44
-
--header 'Authorization: Bearer <YOUR_API_KEY>' \
45
-
--form 'file=@"<PATH_TO_YOUR_FILE>"'
46
-
```
47
-
48
-
### **Step 2: Create a Knowledge Base**
49
-
50
-
Use the ID of the uploaded file to create a Knowledge Base along with the KB configurations.
-**searchType** (required): The search method used for finding relevant chunks. Available options:
87
-
-`fulltext`: Traditional text search
88
-
-`semantic`: Semantic similarity search
89
-
-`hybrid`: Combines fulltext and semantic search
90
-
-`bm25`: BM25 ranking algorithm
91
-
-**topK** (optional): Number of top chunks to return. Default varies by implementation
92
-
-**removeStopWords** (optional): When true, removes common stop words from the search query. Default: `false`
93
-
-**scoreThreshold** (optional): Filters out chunks based on their similarity score:
94
-
- For cosine distance: Excludes chunks below the threshold
95
-
- For Manhattan Distance, Euclidean Distance, and Dot Product: Excludes chunks above the threshold
96
-
- Set to 0 or omit for no threshold
97
-
98
-
##### Chunk Plan Options
99
-
100
-
-**fileIds** (optional): Array of file IDs to include in the vector store
101
-
-**websites** (optional): Array of website URLs to crawl and include in the vector store
102
-
-**targetSplitsPerChunk** (optional): Number of splits per chunk. Default: `20`
103
-
-**splitDelimiters** (optional): Array of delimiters used to split text before chunking. Default: `[".!?\n"]`
104
-
-**rebalanceChunks** (optional): When true, evenly distributes remainder splits across chunks. For example, 66 splits with `targetSplitsPerChunk: 20` will create 3 chunks with 22 splits each. Default: `true`
105
-
106
-
### **Step 3: Create an Assistant**
107
-
108
-
Create a new assistant in Vapi and, on the right sidebar menu. Add the Knowledge Base to your assistant via the PATCH endpoint. Also make sure you customize your assistant's system prompt to utilize the Knowledge Base for responding to user queries.
For more advanced configurations, you can create and configure Knowledge Bases using the API through the Query Tool. This method offers greater flexibility and control over your knowledge base setup.
81
+
82
+
<Info>
83
+
For detailed instructions on creating and configuring knowledge bases via the
84
+
API, please refer to our dedicated guide: [Using the Query Tool for Knowledge
85
+
Bases](/knowledge-base/using-query-tool).
86
+
</Info>
87
+
88
+
The API method allows you to:
89
+
90
+
- Upload files and obtain file IDs
91
+
- Create custom query tools with specific knowledge base configurations
92
+
- Configure multiple knowledge bases within a single query tool
93
+
- Attach query tools to your assistants
94
+
- Set advanced parameters for knowledge retrieval
95
+
96
+
This approach is recommended for developers and users who need precise control over their knowledge base implementation or are integrating Vapi into existing systems programmatically.
129
97
130
98
## **Best Practices for Creating Effective Knowledge Bases**
131
99
132
-
-**Organize Your files**: Organize your files by topic or category to ensure that your assistant can quickly retrieve relevant information.
133
-
-**Use Clear and concise language**: Use clear and concise language in your files to ensure that your assistant can accurately understand and respond to user queries.
134
-
-**Keep your files up-to-date**: Regularly update your files to ensure that your assistant provides the most accurate and up-to-date information.
100
+
-**Optimize file size**: Keep individual files smaller than 300KB to ensure quick processing and response times.
101
+
-**Structure content logically**: Organize your files by topic or category with clear headings and sections.
102
+
-**Use clear and concise language**: Write in plain language with well-defined terminology to improve retrieval accuracy.
103
+
-**Update regularly**: Refresh your knowledge base files whenever information changes to maintain accuracy.
104
+
-**Test thoroughly**: After configuration, test your assistant with various queries to ensure it retrieves information correctly.
105
+
-**Provide context**: Include sufficient background information in your files to enable comprehensive responses.
106
+
-**Consider file formats**: While plain text works well, structured formats can improve information retrieval for complex topics.
135
107
136
108
<Tip>
137
109
For more information on creating effective Knowledge Bases, check out our
By following these guidelines, you can create a comprehensive Knowledge Base that enhances the capabilities of your voice AI assistant and provides valuable information to users.
115
+
116
+
<Info>
117
+
Currently, Vapi's Knowledge Base functionality supports Google as a provider
118
+
with the gemini-1.5-flash model for knowledge retrieval.
Learn how to configure and use the query tool to enhance your voice AI assistants with custom knowledge bases.
5
+
slug: knowledge-base/using-query-tool
6
+
---
7
+
8
+
## **What is the Query Tool?**
9
+
10
+
The Query Tool is a powerful feature that allows your voice AI assistant to access and retrieve information from custom knowledge bases. By configuring a query tool with specific file IDs, you can enable your assistant to provide accurate and contextually relevant responses based on your custom data.
11
+
12
+
### **Benefits of Using the Query Tool**
13
+
14
+
-**Enhanced contextual understanding**: Your assistant can access specific knowledge to answer domain-specific questions.
15
+
-**Improved response accuracy**: Responses are based on your verified information rather than general knowledge.
16
+
-**Customizable knowledge retrieval**: Configure multiple knowledge bases for different topics or domains.
17
+
18
+
<Info>
19
+
Currently, the Query Tool only supports Google as a provider with the
20
+
gemini-1.5-flash model for knowledge base retrieval.
21
+
</Info>
22
+
23
+
## **How to Configure a Query Tool for Knowledge Bases**
24
+
25
+
### **Step 1: Upload Your Files**
26
+
27
+
Before creating a query tool, you need to upload the files that will form your knowledge base. You can upload files via the API:
28
+
29
+
```bash
30
+
curl --location 'https://api.vapi.ai/file' \
31
+
--header 'Authorization: Bearer <YOUR_API_KEY>' \
32
+
--form 'file=@"<PATH_TO_YOUR_FILE>"'
33
+
```
34
+
35
+
After uploading, you'll receive file IDs that you'll need for the next step.
36
+
37
+
### **Step 2: Create a Query Tool**
38
+
39
+
Use the following API call to create a query tool that references your knowledge base files:
40
+
41
+
```bash
42
+
curl --location 'https://api.vapi.ai/tool/' \
43
+
--header 'Content-Type: application/json' \
44
+
--header 'Authorization: Bearer <YOUR_API_KEY>' \
45
+
--data '{
46
+
"type": "query",
47
+
"function": {
48
+
"name": "product-query"
49
+
},
50
+
"knowledgeBases": [
51
+
{
52
+
"provider": "google",
53
+
"name": "product-kb",
54
+
"description": "Use this knowledge base when the user asks or queries about the product or services",
55
+
"fileIds": [
56
+
"41a2bd44-d13c-4914-bbf7-b19807dd2cf4",
57
+
"ef82ae15-21b2-47bd-bde4-dea3922c1e49"
58
+
]
59
+
}
60
+
]
61
+
}'
62
+
```
63
+
64
+
<Note>
65
+
The `description` field in the knowledge base configuration helps your
66
+
assistant understand when to use this particular knowledge base. Make it
67
+
descriptive of the content.
68
+
</Note>
69
+
70
+
### **Step 3: Attach the Query Tool to Your Assistant**
71
+
72
+
After creating the query tool, you'll receive a tool ID. Use this ID to attach the tool to your assistant:
You can configure multiple knowledge bases within a single query tool:
116
+
117
+
```json
118
+
"knowledgeBases": [
119
+
{
120
+
"provider": "google",
121
+
"name": "product-documentation",
122
+
"description": "Use this knowledge base for product specifications and features",
123
+
"fileIds": ["file-id-1", "file-id-2"]
124
+
},
125
+
{
126
+
"provider": "google",
127
+
"name": "troubleshooting-guide",
128
+
"description": "Use this knowledge base for troubleshooting and support questions",
129
+
"fileIds": ["file-id-3", "file-id-4"]
130
+
}
131
+
]
132
+
```
133
+
134
+
### **Knowledge Base Description**
135
+
136
+
The description field helps your assistant understand when to use a particular knowledge base. Make it specific and clear:
137
+
138
+
```json
139
+
"description": "Use this knowledge base when the user asks about pricing, subscription plans, or billing information"
140
+
```
141
+
142
+
## **Best Practices for Query Tool Configuration**
143
+
144
+
-**Organize by topic**: Create separate knowledge bases for distinct topics to improve retrieval accuracy.
145
+
-**Use descriptive names**: Name your knowledge bases clearly to help your assistant understand their purpose.
146
+
-**Keep descriptions specific**: Write clear descriptions that tell the assistant exactly when to use each knowledge base.
147
+
-**Update regularly**: Refresh your knowledge bases as information changes to ensure accuracy.
148
+
-**Test thoroughly**: After configuration, test your assistant with various queries to ensure it retrieves information correctly.
149
+
150
+
<Tip>
151
+
For optimal performance, keep individual files under 300KB and ensure they
152
+
contain clear, well-structured information.
153
+
</Tip>
154
+
155
+
By following these steps and best practices, you can effectively configure the query tool to enhance your voice AI assistant with custom knowledge bases, making it more informative and responsive to user queries.
0 commit comments