API Reference
Detailed API documentation for DataBridge Python SDK
API Reference
This page provides detailed documentation for all classes and methods in the DataBridge Python SDK.
DataBridge
The main client class for synchronous operations.
Parameters
uri
: Optional connection URI in formatdatabridge://owner_id:token@host
timeout
: Request timeout in seconds (default: 30)is_local
: Whether connecting to a local development server (default: False)
Methods
ingest_text
Ingest a text document into DataBridge.
Parameters:
content
: Text content to ingestmetadata
: Optional document metadata dictionaryrules
: Optional list of rules to apply during ingestionuse_colpali
: Whether to use ColPali-style embedding model (default: True)
Returns: A Document
object representing the ingested document
ingest_file
Ingest a file document into DataBridge.
Parameters:
file
: File to ingest (path string, bytes, file object, or Path)filename
: Name of the file (required if file is bytes or file object)metadata
: Optional document metadata dictionaryrules
: Optional list of rules to apply during ingestionuse_colpali
: Whether to use ColPali-style embedding model (default: True)
Returns: A Document
object representing the ingested document
retrieve_chunks
Retrieve relevant chunks based on a query.
Parameters:
query
: Search query textfilters
: Optional metadata filters dictionaryk
: Number of results to return (default: 4)min_score
: Minimum similarity threshold (default: 0.0)use_colpali
: Whether to use ColPali-style embedding model (default: True)
Returns: List of FinalChunkResult
objects
retrieve_docs
Retrieve relevant documents based on a query.
Parameters:
query
: Search query textfilters
: Optional metadata filters dictionaryk
: Number of results to return (default: 4)min_score
: Minimum similarity threshold (default: 0.0)use_colpali
: Whether to use ColPali-style embedding model (default: True)
Returns: List of DocumentResult
objects
query
Generate a completion using relevant chunks as context.
Parameters:
query
: Query textfilters
: Optional metadata filters dictionaryk
: Number of chunks to use as context (default: 4)min_score
: Minimum similarity threshold (default: 0.0)max_tokens
: Maximum tokens in completion (optional)temperature
: Model temperature (optional)use_colpali
: Whether to use ColPali-style embedding model (default: True)
Returns: A CompletionResponse
object
list_documents
List accessible documents.
Parameters:
skip
: Number of documents to skip (default: 0)limit
: Maximum number of documents to return (default: 100)filters
: Optional filters dictionary
Returns: List of Document
objects
get_document
Get document metadata by ID.
Parameters:
document_id
: ID of the document
Returns: A Document
object
create_cache
Create a new cache with specified configuration.
Parameters:
name
: Name of the cache to createmodel
: Name of the model to use (e.g., “llama2”)gguf_file
: Name of the GGUF file to usefilters
: Optional metadata filters for document selectiondocs
: Optional list of specific document IDs to include
Returns: Dictionary with cache configuration
get_cache
Get a cache by name.
Parameters:
name
: Name of the cache to retrieve
Returns: A Cache
object
AsyncDataBridge
The main client class for asynchronous operations. Has the same methods as DataBridge
but with async/await support.
Cache
Class for interacting with a cache.
Methods
update
Update the cache with the latest documents.
Returns: Boolean indicating success
add_docs
Add specific documents to the cache.
Parameters:
docs
: List of document IDs to add to the cache
Returns: Boolean indicating success
query
Query the cache.
Parameters:
query
: Query textmax_tokens
: Maximum tokens in completion (optional)temperature
: Model temperature (optional)
Returns: A CompletionResponse
object
AsyncCache
Asynchronous version of Cache
. Has the same methods but with async/await support.
Rule Classes
MetadataExtractionRule
Rule for extracting metadata using a schema.
Parameters:
schema
: Pydantic model class or dictionary schema
NaturalLanguageRule
Rule for transforming content using natural language.
Parameters:
prompt
: Instruction for how to transform the content
Data Models
Document
Represents a document in DataBridge.
ChunkResult
Represents a chunk result from a query.
FinalChunkResult
Represents a processed chunk result from a query, with support for images.
DocumentResult
Represents a document result from a query.
CompletionResponse
Represents a completion response from a query.
Exceptions
DataBridgeError
Base exception for all DataBridge SDK errors.
AuthenticationError
Exception raised for authentication-related issues.
ConnectionError
Exception raised for connection-related issues.