OmniDim Logo

    Knowledge Base

    The Knowledge Base module allows you to upload, manage, and attach PDF documents to your agents. These documents provide context and information that your agents can reference during conversations.

    Overview

    The Knowledge Base API enables you to:

    • Upload PDF documents to your knowledge base
    • Attach documents to agents for use during conversations
    • Manage your document library with listing and deletion capabilities
    • Check upload capabilities based on file size and type

    List Knowledge Base Files

    Get all knowledge base files for the authenticated user.

    Example

    1 2 3 # List all knowledge base files response = client.knowledge_base.list() print(response)

    Check File Upload Capability

    Validate if a file can be uploaded based on size and type.

    Parameters

    file_size
    int
    Required

    Size of the file in bytes

    file_type
    string
    Optional

    Type of the file (only 'pdf' is supported, default: 'pdf')

    Example

    1 2 3 4 # Check if a file of the given size can be uploaded file_size = 1024 * 1024 # 1MB file response = client.knowledge_base.can_upload(file_size) print(response)

    Upload File to Knowledge Base

    Upload a PDF file to the knowledge base.

    Parameters

    file_data
    string
    Required

    Base64 encoded file content

    filename
    string
    Required

    Name of the file (must end with .pdf)

    Example

    1 2 3 4 5 6 7 8 9 10 11 # Upload a file to the knowledge base import base64 file_path = "sample.pdf" # Path to your PDF file file_name = "sample.pdf" # Name for the file in the knowledge base with open(file_path, "rb") as file: file_data = base64.b64encode(file.read()).decode('utf-8') response = client.knowledge_base.create(file_data, file_name) print(response)

    Attach Files to Agent

    Attach multiple files to an agent for use during conversations.

    Parameters

    file_ids
    list
    Required

    List of file IDs to attach

    agent_id
    int
    Required

    ID of the agent to attach files to

    Example

    1 2 3 4 5 6 # Attach files to an agent file_ids = [123, 456] # Replace with your file IDs agent_id = 789 # Replace with your agent ID response = client.knowledge_base.attach(file_ids, agent_id) print(response)

    Detach Files from Agent

    Detach multiple files from an agent.

    Parameters

    file_ids
    list
    Required

    List of file IDs to detach

    agent_id
    int
    Required

    ID of the agent to detach files from

    Example

    1 2 3 4 5 6 # Detach files from an agent file_ids = [123, 456] # Replace with your file IDs agent_id = 789 # Replace with your agent ID response = client.knowledge_base.detach(file_ids, agent_id) print(response)

    Delete File from Knowledge Base

    Delete a file from the knowledge base.

    Parameters

    file_id
    int
    Required

    ID of the file to delete

    Example

    1 2 3 4 5 # Delete a file from the knowledge base file_id = 123 # Replace with your file ID response = client.knowledge_base.delete(file_id) print(response)