AGTGreg
01/31/2025, 2:14 PMjson
...
"model": {
"provider": "openai",
"model": "gpt-4o",
"maxTokens": 250,
"messages": [{"role": "system", "content": "..."}],
"temperature": 0,
"knowledgeBaseId": "knowledge_base_id"
}, ...
2. I made the assistant in Vapi dashboard and updated it with the knowledgebase id:
python
assistant = client.assistants.get(id=assistant_id)
updated_model = assistant.model.model_copy(update={"knowledge_base_id": knowledge_base_id})
client.assistants.update(id=assistant_id, model=updated_model)
When I get the assistant, I can see that the knowledge_base_id is attached but it's responses show that it has no idea about that knowledgebase.
In contrast, if I attach the file (that I used to make the knowledgebase) to the assistant in the dashboard and then test it, it seems to work OK. Although I'm not entirely sure because the assistant's messages show no source
.
This is how I create the knowledgebase in Python:
python
data = {
"name": name,
"provider": "trieve",
"searchPlan": {
"scoreThreshold": 0.2,
"searchType": "semantic"
},
"createPlan": {
"type": "create",
"chunkPlans": [
{
"fileIds": file_ids,
"websites": [],
"targetSplitsPerChunk": 50,
"rebalanceChunks": True
}
]
}
}
response = requests.post('https://api.vapi.ai/knowledge-base', headers=headers, json=data)
What am I doing wrong?Atlas
01/31/2025, 2:14 PMChowderr
01/31/2025, 3:06 PMAGTGreg
01/31/2025, 3:08 PMpython
response = requests.patch(
f'https://api.vapi.ai/assistant/{assistant_id}',
headers=headers,
json={
"model": {
"knowledgeBaseId": knowledge_base_id,
"temperature": 0.2,
"provider": "openai",
"model": "gpt-4o",
"messages": [
{
"content": "You are a smart assistant who responds to user queries using the information you know, or information supplied by outside context.",
"role": "system"
}
]
}
}
)
I get no error or warnings and all messages from bot in the logs do not have a source:
json
{
"role": "bot",
"time": 1738335597677,
"source": "",
"endTime": 1738335613467,
"message": "...",
"duration": 14120,
"secondsFromStart": 10.14
}
I am not sure if knowledgebase works at all.Chowderr
01/31/2025, 3:10 PMAGTGreg
01/31/2025, 3:12 PMYou are a smart assistant who responds to user queries using the information you know, or information supplied by outside context. If you don't have any information say "I don't know"
You are a smart assistant who responds to user queries using the information you know, or information supplied by outside context.
AGTGreg
01/31/2025, 3:17 PM"model": {
"model": "gpt-4o",
"messages": [
{
"role": "system",
"content": "You are a smart assistant who responds to user queries using the information you know, or information supplied by outside context."
}
],
"provider": "openai",
"temperature": 0.2,
"knowledgeBaseId": "54aaba05-f5fe-4580-9bff-8a4745e10202"
},
AGTGreg
01/31/2025, 3:20 PMsource
has nothing to do with knowledgebase):
{
"role": "bot",
"time": 1738336498004,
"source": "",
"endTime": 1738336519474,
"message": "...",
"duration": 17929.9990234375,
"secondsFromStart": 13.33
}
Chowderr
01/31/2025, 3:29 PMChowderr
01/31/2025, 3:30 PMAGTGreg
01/31/2025, 3:35 PMAGTGreg
01/31/2025, 3:45 PMYou are a smart assistant who responds to user queries using the information from your KnowledgeBase. If the answer is not in the KnowledgeBase say 'I do not know'.
Not better.
Also, if it should not have a source, then how will I know what context it used (if any) to answer the question?Chowderr
01/31/2025, 3:50 PMAGTGreg
01/31/2025, 4:00 PMChowderr
01/31/2025, 4:04 PMAGTGreg
01/31/2025, 4:07 PMAGTGreg
01/31/2025, 4:09 PMChowderr
01/31/2025, 5:22 PMShubham Bajaj
02/01/2025, 10:11 AMShubham Bajaj
02/03/2025, 8:31 AMAGTGreg
02/03/2025, 10:30 AMYou are a smart assistant who responds to user queries using the information from your KnowledgeBase. If the answer is not in the KnowledgeBase say 'I do not know'.
Test 1:
Call ID: 90a8d16e-84d0-49b3-b09c-ab1a0e74baa9
If I use an assistant that was created in Vapi Dashboard and I update it programmatically with the knowledgebase I get good results. The assistant follows the knowledgebase correctly.
Test 2:
Call ID: b0c051db-5124-442a-9cfe-b55ca94dff43
If I make a temporary assistant and pass the knowledgebase I get mixed results. The assistant is aware of the knowledgebase but it's not allways following it. For example:
TS: 1738573301379
Q: What is the color of the sky?
A: I do not know.
TS: 1738573307989
Q: What is the color of the grass?
A: According to the provided context, the color of the grass is black.
Test 3:
Call ID: 86013be6-e946-4994-ae3a-83210f64c42d
If I add to that prompt some conversation history I get some funny responses. The assistant is aware of the knowledgebase but chooses to ignore it:
TS: 1738573089949
Q: What do you need in order to play football?
A: To play football, you need a round ball made out of leather or a similar material, not a square ball made out of stone.AGTGreg
02/03/2025, 10:50 AMjson
"model": {
"knowledgeBaseId": knowledge_base_id,
"temperature": 0.2,
"provider": "openai",
"model": "gpt-4o",
"messages": [
{
"content": "You are a smart assistant who responds to user queries using the information from your KnowledgeBase. If the answer is not in the KnowledgeBase say 'I do not know'.",
"role": "system"
}
]
}
Shubham Bajaj
02/04/2025, 10:34 AM