#how to link the knowldge base to the assistant
1 messages · Page 1 of 1 (latest)
To link a knowledge base to your conversational AI assistant, follow these steps:
-
Create the Agent: Use the Create Agent API (
POST /v1/convai/agents) to set up the assistant. this stage, you don't need to attach a knowledge base. -
Add to the Knowledge Base: After the agent is created, use the Add To Agent’s Knowledge Base API (
POST /v1/convai/agents/{agent_id}/add-to-knowledge-base) to upload a document or reference a webpage. This step will generate a document ID. -
Update the Agent: Once the document is added, update the agent to include the new document IDs in its knowledge base.
Keep in mind:
- Non-enterprise users can add up to 5 files/links with a combined size of 20MB or 300,000 characters.
- The process is sequential: create the agent first, then build and link its knowledge base.
Let me know if you need further clarification!
How to update the agent with the document
To link a knowledge base to your assistant and update the agent with the document, follow these steps:
-
Create the Knowledge Base Document: Use the
POST /v1/convai/agents/{agent_id}/add-to-knowledge-baseendpoint to upload a file or reference a URL. This will generate adocument_id. For example:from elevenlabs import ElevenLabs client = ElevenLabs(api_key="YOUR_API_KEY") client.conversational_ai.add_to_agent_knowledge_base( agent_id="YOUR_AGENT_ID", file="path/to/your/file" # or use `url="https://example.com"` ) -
Patch the Agent with the Document ID: After creating the document, you need to update the agent to use the new document. Use the
PATCHmethod to attach thedocument_idto the agent's knowledge base. For example:{ "conversation_config": { "agent": { "prompt": { "knowledge_base": ["DOCUMENT_ID"] } } } }This step ensures the knowledge base is linked to the assistant and the changes take effect.
Let me know if you need further clarification!
cant find "knowledge_base" in the patch
To update an agent with a knowledge base document, need to use the PATCH method. If the knowledge_base field is not appearing in your patch request, ensure you're following these steps:
-
Detach Existing Knowledge Base Documents: First, you need to patch the agent with an empty array for the
knowledge_basefield. This clears any previously linked documents. Here's an example of the payload:{ "conversation_config": { "agent": { "prompt": { "knowledge_base": [] } } } } -
Re-upload or Add the Updated Document: Use the appropriate API endpoint to upload the new document or URL.
-
Patch the Agent with the New Document: After uploading the updated document, patch the agent again with the new document ID to link it.
If you're still unable to find the knowledge_base field, double-check the API documentation or ensure the agent and document IDs are correct. Let us know if you need further assistance!
I have created the knowledge base, now what to do
Once you have created the knowledge base, you need to link it to your agent. Here's the process:
-
Create the Agent: If you haven't already, use the Create Agent API (
POST /v1/convai/agents) to set up your agent. At this stage, you don't need to attach the knowledge base. -
Add Documents to the Knowledge Base: Use the Add to Agent’s Knowledge Base API (
POST /v1/convai/agents/{agent_id}/add-to-knowledge-base) to upload documents or reference web pages. This step will generate document IDs. -
Update the Agent: Once the documents are added, update the agent to use the new document IDs in its knowledge base. This ensures the agent can access the knowledge base during conversations.
Keep in mind:
- Non-enterprise users can add up to 5 files/links with a combined size of 20MB or 300,000 characters.
- The process is sequential: create the agent first, then build and link the knowledge base.
Let me know if you need further clarification!
hwo can I add the knowledge to an existing agent