-
Notifications
You must be signed in to change notification settings - Fork 66
VAP-3952 Add query tool to kb docs #246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| **/.definition | ||
| **/.preview/** | ||
| .env | ||
| .DS_Store |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| --- | ||
| title: Using the Query Tool for Knowledge Bases | ||
| subtitle: >- | ||
| Learn how to configure and use the query tool to enhance your voice AI assistants with custom knowledge bases. | ||
| slug: knowledge-base/using-query-tool | ||
| --- | ||
|
|
||
| ## **What is the Query Tool?** | ||
|
|
||
| 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. | ||
|
|
||
| ### **Benefits of Using the Query Tool** | ||
|
|
||
| - **Enhanced contextual understanding**: Your assistant can access specific knowledge to answer domain-specific questions. | ||
| - **Improved response accuracy**: Responses are based on your verified information rather than general knowledge. | ||
| - **Customizable knowledge retrieval**: Configure multiple knowledge bases for different topics or domains. | ||
|
|
||
| <Info> | ||
| Currently, the Query Tool only supports Google as a provider with the | ||
| gemini-1.5-flash model for knowledge base retrieval. | ||
| </Info> | ||
|
|
||
| ## **How to Configure a Query Tool for Knowledge Bases** | ||
|
|
||
| ### **Step 1: Upload Your Files** | ||
|
|
||
| Before creating a query tool, you need to upload the files that will form your knowledge base. You can upload files via the API: | ||
|
|
||
| ```bash | ||
| curl --location 'https://api.vapi.ai/file' \ | ||
| --header 'Authorization: Bearer <YOUR_API_KEY>' \ | ||
| --form 'file=@"<PATH_TO_YOUR_FILE>"' | ||
| ``` | ||
|
|
||
| After uploading, you'll receive file IDs that you'll need for the next step. | ||
|
|
||
| ### **Step 2: Create a Query Tool** | ||
|
|
||
| Use the following API call to create a query tool that references your knowledge base files: | ||
|
|
||
| ```bash | ||
| curl --location 'https://api.vapi.ai/tool/' \ | ||
| --header 'Content-Type: application/json' \ | ||
| --header 'Authorization: Bearer <YOUR_API_KEY>' \ | ||
| --data '{ | ||
| "type": "query", | ||
| "function": { | ||
| "name": "product-query" | ||
| }, | ||
| "knowledgeBases": [ | ||
| { | ||
| "provider": "google", | ||
| "name": "product-kb", | ||
| "description": "Use this knowledge base when the user asks or queries about the product or services", | ||
| "fileIds": [ | ||
| "41a2bd44-d13c-4914-bbf7-b19807dd2cf4", | ||
| "ef82ae15-21b2-47bd-bde4-dea3922c1e49" | ||
| ] | ||
| } | ||
| ] | ||
| }' | ||
| ``` | ||
|
|
||
| <Note> | ||
| The `description` field in the knowledge base configuration helps your | ||
| assistant understand when to use this particular knowledge base. Make it | ||
| descriptive of the content. | ||
| </Note> | ||
|
|
||
| ### **Step 3: Attach the Query Tool to Your Assistant** | ||
|
|
||
| After creating the query tool, you'll receive a tool ID. Use this ID to attach the tool to your assistant: | ||
|
|
||
| #### Option 1: Using the API | ||
|
|
||
| ```bash | ||
| curl --location --request PATCH 'https://api.vapi.ai/assistant/ASSISTANT_ID' \ | ||
| --header 'Authorization: Bearer <YOUR_API_KEY>' \ | ||
| --data '{ | ||
| "model": { | ||
| "temperature": 0.2, | ||
| "provider": "openai", | ||
| "model": "gpt-4o", | ||
| "toolIds": [ | ||
| "9441840b-6f2f-4b0f-a0fc-de8512549a0c" | ||
| ] | ||
| } | ||
| }' | ||
| ``` | ||
|
|
||
| <Warning> | ||
| When using the PATCH request, you must include the entire model object, not | ||
| just the toolIds field. This will overwrite any existing model configuration. | ||
| </Warning> | ||
|
|
||
| #### Option 2: Using the Dashboard | ||
|
|
||
| 1. Navigate to the Assistant section in your Vapi dashboard | ||
| 2. Select the assistant you want to configure | ||
| 3. Go to the Tools section | ||
| 4. Add the query tool by selecting it from the available tools | ||
| 5. Save and publish your assistant | ||
|
|
||
| <Frame caption="Adding a query tool to your assistant"> | ||
| <img | ||
| src="../static/images/knowledge-base/query-tool.png" | ||
| alt="Adding a query tool to your assistant" | ||
| /> | ||
| </Frame> | ||
|
|
||
| ## **Advanced Configuration Options** | ||
|
|
||
| ### **Multiple Knowledge Bases** | ||
|
|
||
| You can configure multiple knowledge bases within a single query tool: | ||
|
|
||
| ```json | ||
| "knowledgeBases": [ | ||
| { | ||
| "provider": "google", | ||
| "name": "product-documentation", | ||
| "description": "Use this knowledge base for product specifications and features", | ||
| "fileIds": ["file-id-1", "file-id-2"] | ||
| }, | ||
| { | ||
| "provider": "google", | ||
| "name": "troubleshooting-guide", | ||
| "description": "Use this knowledge base for troubleshooting and support questions", | ||
| "fileIds": ["file-id-3", "file-id-4"] | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| ### **Knowledge Base Description** | ||
|
|
||
| The description field helps your assistant understand when to use a particular knowledge base. Make it specific and clear: | ||
|
|
||
| ```json | ||
| "description": "Use this knowledge base when the user asks about pricing, subscription plans, or billing information" | ||
| ``` | ||
|
|
||
| ## **Best Practices for Query Tool Configuration** | ||
|
|
||
| - **Organize by topic**: Create separate knowledge bases for distinct topics to improve retrieval accuracy. | ||
| - **Use descriptive names**: Name your knowledge bases clearly to help your assistant understand their purpose. | ||
| - **Keep descriptions specific**: Write clear descriptions that tell the assistant exactly when to use each knowledge base. | ||
| - **Update regularly**: Refresh your knowledge bases as information changes to ensure accuracy. | ||
| - **Test thoroughly**: After configuration, test your assistant with various queries to ensure it retrieves information correctly. | ||
|
|
||
| <Tip> | ||
| For optimal performance, keep individual files under 300KB and ensure they | ||
| contain clear, well-structured information. | ||
| </Tip> | ||
|
|
||
| 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. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.