Skip to content

knowledge

Classes

KnowledgeModel

Bases: BaseModel

Represents a knowledge base.

Attributes

id
id: str

The unique identifier of the knowledge base.

user_id
user_id: str

The ID of the user who owns the knowledge base.

name
name: str

The name of the knowledge base.

description
description: str

A description of the knowledge base.

meta
meta: Optional[dict] = None

Metadata associated with the knowledge base.

Dict Fields
  • legacy (bool, optional): Whether this is a legacy knowledge base migrated from older versions
  • document (bool, optional): Whether this knowledge base represents a document-type structure
  • tags (list[str], optional): List of tags associated with the knowledge base
  • id (str, optional): Knowledge base ID
  • name (str, optional): Knowledge base name
  • collection_name (str, optional): Collection name
  • type (str, optional): Type of knowledge (e.g., 'file', 'collection')
  • collection_names (list[str], optional): List of collection names for collection-type knowledge

Additional keys may exist. Complete structure not found in reference code.

access_control
access_control: Optional[dict] = None

Access control settings.

  • None: Public access, available to all users with the "user" role. Requires "sharing.public_knowledge" permission for non-admin users to set.
  • {}: Private access, restricted exclusively to the owner.
  • Custom permissions: Specific access control for reading and writing. Can specify group or user-level restrictions. Example:
    {
        "read": {
            "group_ids": ["group_id1", "group_id2"],
            "user_ids":  ["user_id1", "user_id2"]
        },
        "write": {
            "group_ids": ["group_id1", "group_id2"],
            "user_ids":  ["user_id1", "user_id2"]
        }
    }
    
Dict Fields
  • read (dict, optional): Read access permissions
  • write (dict, optional): Write access permissions
  • read.group_ids (list[str], optional): List of group IDs with read access
  • read.user_ids (list[str], optional): List of user IDs with read access
  • write.group_ids (list[str], optional): List of group IDs with write access
  • write.user_ids (list[str], optional): List of user IDs with write access
created_at
created_at: int

Timestamp of creation (epoch).

updated_at
updated_at: int

Timestamp of last update (epoch).

KnowledgeUserModel

Bases: KnowledgeModel

Represents a knowledge base with user information.

Inherits access_control from KnowledgeModel. Access is determined by: - Direct user ownership (user_id matches) - Access control permissions (read/write for groups and users) - Admin users have full access regardless of access_control settings

Attributes

user
user: Optional[UserResponse] = None

The user who owns the knowledge base.

KnowledgeResponse

Bases: KnowledgeModel

Represents a knowledge base response, optionally including files.

Inherits meta from KnowledgeModel. See KnowledgeModel.meta for complete documentation of the metadata structure and valid fields.

Attributes

files
files: Optional[list[Union[FileMetadataResponse, dict]]] = (
    None
)

List of files associated with the knowledge base.

KnowledgeUserResponse

Bases: KnowledgeUserModel

Represents a knowledge base response including user information and files.

Inherits access_control from KnowledgeModel. See KnowledgeModel.access_control for complete documentation of the access control structure and permissions.

Attributes

files
files: Optional[list[Union[FileMetadataResponse, dict]]] = (
    None
)

List of files associated with the knowledge base.

KnowledgeForm

Bases: BaseModel

Form for creating or updating a knowledge base.

Attributes

name
name: str

The name of the knowledge base.

description
description: str

A description of the knowledge base.

access_control
access_control: Optional[dict] = None

Access control settings.

  • None: Public access, available to all users with the "user" role.
  • {}: Private access, restricted exclusively to the owner.
  • Custom permissions: Specific access control for reading and writing. Can specify group or user-level restrictions. Example:
    {
        "read": {
            "group_ids": ["group_id1", "group_id2"],
            "user_ids":  ["user_id1", "user_id2"]
        },
        "write": {
            "group_ids": ["group_id1", "group_id2"],
            "user_ids":  ["user_id1", "user_id2"]
        }
    }
    
Dict Fields
  • read (dict, optional): Read access permissions
  • write (dict, optional): Write access permissions
  • read.group_ids (list[str], optional): List of group IDs with read access
  • read.user_ids (list[str], optional): List of user IDs with read access
  • write.group_ids (list[str], optional): List of group IDs with write access
  • write.user_ids (list[str], optional): List of user IDs with write access

KnowledgeFilesResponse

Bases: KnowledgeResponse

Represents a knowledge base response with full file metadata.

Inherits access_control from KnowledgeModel. Access control determines who can read and write to this knowledge base.

Attributes

files
files: list[FileMetadataResponse]

List of files associated with the knowledge base.

warnings
warnings: Optional[dict] = None

Warnings returned during processing, e.g., if some files failed to process in a batch operation.

Dict Fields
  • message (str, required): Human-readable warning message describing the issue
  • errors (list[str], required): List of specific error details for failed operations

KnowledgeFileIdForm

Bases: BaseModel

Form for adding or removing a file from a knowledge base.

Attributes

file_id
file_id: str

The ID of the file to add or remove.