Classes
Client
Client for interacting with the TopK API. For available regions see regions Methods Constructor| Parameter | Type |
|---|---|
api_key | str |
region | str |
host | str |
https | bool |
retry_config | Optional[RetryConfig | dict[str, Any]] |
collection()
| Parameter | Type |
|---|---|
collection | str |
partition | Optional[str] |
CollectionClient
collections()
CollectionsClient
dataset()
| Parameter | Type |
|---|---|
dataset | str |
DatasetClient
datasets()
DatasetsClient
ask()
| Parameter | Type |
|---|---|
query | str |
datasets | Sequence[Source] | Sequence[str] | Sequence[dict[str, Any]] |
filter | Optional[query.LogicalExpr] |
mode | Optional[Literal[‘auto’, ‘summarize’, ‘research’]] |
select_fields | Optional[Sequence[str]] |
AskIterator
search()
| Parameter | Type |
|---|---|
query | str |
datasets | Sequence[Source] | Sequence[str] | Sequence[dict[str, Any]] |
top_k | int |
filter | Optional[query.LogicalExpr] |
select_fields | Optional[Sequence[str]] |
SearchIterator
AsyncClient
Async client for interacting with the TopK API. For available regions see regions Methods Constructor| Parameter | Type |
|---|---|
api_key | str |
region | str |
host | str |
https | bool |
retry_config | Optional[RetryConfig | dict[str, Any]] |
collection()
| Parameter | Type |
|---|---|
collection | str |
partition | Optional[str] |
AsyncCollectionClient
collections()
AsyncCollectionsClient
dataset()
| Parameter | Type |
|---|---|
dataset | str |
AsyncDatasetClient
datasets()
AsyncDatasetsClient
ask()
| Parameter | Type |
|---|---|
query | str |
datasets | Sequence[Source] | Sequence[str] | Sequence[dict[str, Any]] |
filter | Optional[query.LogicalExpr] |
mode | Optional[Literal[‘auto’, ‘summarize’, ‘research’]] |
select_fields | Optional[Sequence[str]] |
AsyncAskIterator
search()
| Parameter | Type |
|---|---|
query | str |
datasets | Sequence[Source] | Sequence[str] | Sequence[dict[str, Any]] |
top_k | int |
filter | Optional[query.LogicalExpr] |
select_fields | Optional[Sequence[str]] |
AsyncSearchIterator
CollectionClient
Synchronous client for collection operations. Methodsget()
| Parameter | Type |
|---|---|
ids | Sequence[str] |
fields | Optional[Sequence[str]] |
lsn | Optional[str] |
consistency | Optional[ConsistencyLevel | Literal[‘indexed’, ‘strong’]] |
count()
| Parameter | Type |
|---|---|
lsn | Optional[str] |
consistency | Optional[ConsistencyLevel | Literal[‘indexed’, ‘strong’]] |
query()
| Parameter | Type |
|---|---|
query | query.Query |
lsn | Optional[str] |
consistency | Optional[ConsistencyLevel | Literal[‘indexed’, ‘strong’]] |
upsert()
| Parameter | Type |
|---|---|
documents | Sequence[Mapping[str, Any]] |
update()
LSN at which the update was applied.
If no updates were applied, this will be empty.
Parameters
| Parameter | Type |
|---|---|
documents | Sequence[Mapping[str, Any]] |
fail_on_missing | Optional[bool] |
delete()
| Parameter | Type |
|---|---|
expr | Sequence[str] | query.LogicalExpr |
list_partitions()
| Parameter | Type |
|---|---|
prefix | Optional[str] |
PartitionListIterator
delete_partition()
| Parameter | Type |
|---|---|
name | str |
AsyncCollectionClient
Asynchronous client for collection operations. Methodsget()
| Parameter | Type |
|---|---|
ids | Sequence[str] |
fields | Optional[Sequence[str]] |
lsn | Optional[str] |
consistency | Optional[ConsistencyLevel | Literal[‘indexed’, ‘strong’]] |
count()
| Parameter | Type |
|---|---|
lsn | Optional[str] |
consistency | Optional[ConsistencyLevel | Literal[‘indexed’, ‘strong’]] |
query()
| Parameter | Type |
|---|---|
query | query.Query |
lsn | Optional[str] |
consistency | Optional[ConsistencyLevel | Literal[‘indexed’, ‘strong’]] |
upsert()
| Parameter | Type |
|---|---|
documents | Sequence[Mapping[str, Any]] |
update()
LSN at which the update was applied.
If no updates were applied, this will be empty.
Parameters
| Parameter | Type |
|---|---|
documents | Sequence[Mapping[str, Any]] |
fail_on_missing | Optional[bool] |
delete()
| Parameter | Type |
|---|---|
expr | Sequence[str] | query.LogicalExpr |
list_partitions()
| Parameter | Type |
|---|---|
prefix | Optional[str] |
AsyncPartitionListIterator
delete_partition()
| Parameter | Type |
|---|---|
name | str |
Collection
Represents a collection in the TopK system. Properties| Property | Type | |
|---|---|---|
name | str | |
org_id | str | |
project_id | str | |
region | str | |
schema | dict[str, schema.FieldSpec] | |
created_at | str |
Dataset
Represents a dataset in the TopK system. Properties| Property | Type | |
|---|---|---|
name | str | |
description | Optional[str] | |
org_id | str | |
project_id | str | |
region | str | |
created_at | str |
ListEntry
Entry in a dataset. Properties| Property | Type | |
|---|---|---|
id | str | |
name | str | |
size | int | |
mime_type | str | |
status | str | |
status_reason | Optional[str] | |
metadata | dict[str, Any] |
Partition
Represents a partition in a collection. Properties| Property | Type | |
|---|---|---|
name | str | |
created_at | str |
CollectionsClient
Synchronous client for managing collections. Methodsget()
| Parameter | Type |
|---|---|
collection_name | str |
Collection
list()
Collection]
create()
| Parameter | Type |
|---|---|
collection_name | str |
schema | Mapping[str, schema.SchemaFieldSpec] |
Collection
delete()
| Parameter | Type |
|---|---|
collection_name | str |
AsyncCollectionsClient
Asynchronous client for managing collections. Methodsget()
| Parameter | Type |
|---|---|
collection_name | str |
Collection]
list()
Collection]]
create()
| Parameter | Type |
|---|---|
collection_name | str |
schema | Mapping[str, schema.SchemaFieldSpec] |
Collection]
delete()
| Parameter | Type |
|---|---|
collection_name | str |
DatasetsClient
Synchronous client for managing datasets. Methodsget()
| Parameter | Type |
|---|---|
dataset_name | str |
Dataset
list()
Dataset]
create()
| Parameter | Type |
|---|---|
dataset_name | str |
description | Optional[str] |
Dataset
update()
| Parameter | Type |
|---|---|
dataset_name | str |
description | Optional[str] |
Dataset
delete()
| Parameter | Type |
|---|---|
dataset_name | str |
DatasetClient
Synchronous client for dataset operations. Methodsupsert_file()
| Parameter | Type |
|---|---|
doc_id | str |
input | os.PathLike[Any] | Tuple[str, bytes, str] |
metadata | Mapping[str, Any] |
get_metadata()
| Parameter | Type |
|---|---|
ids | Sequence[str] |
fields | Optional[Sequence[str]] |
update_metadata()
| Parameter | Type |
|---|---|
doc_id | str |
metadata | Mapping[str, Any] |
delete()
| Parameter | Type |
|---|---|
doc_id | str |
check_handle()
| Parameter | Type |
|---|---|
handle | str |
wait_for_handle()
| Parameter | Type |
|---|---|
handle | str |
config | Optional[WaitConfig | dict[str, Any]] |
list()
| Parameter | Type |
|---|---|
fields | Optional[Sequence[str]] |
filter | Optional[query.LogicalExpr] |
DatasetListIterator
AsyncDatasetsClient
Asynchronous client for managing datasets. Methodsget()
| Parameter | Type |
|---|---|
dataset_name | str |
Dataset]
list()
Dataset]]
create()
| Parameter | Type |
|---|---|
dataset_name | str |
description | Optional[str] |
Dataset]
update()
| Parameter | Type |
|---|---|
dataset_name | str |
description | Optional[str] |
Dataset]
delete()
| Parameter | Type |
|---|---|
dataset_name | str |
AsyncDatasetClient
Asynchronous client for dataset operations. Methodsupsert_file()
| Parameter | Type |
|---|---|
doc_id | str |
input | os.PathLike[Any] | Tuple[str, bytes, str] |
metadata | Mapping[str, Any] |
get_metadata()
| Parameter | Type |
|---|---|
ids | Sequence[str] |
fields | Optional[Sequence[str]] |
update_metadata()
| Parameter | Type |
|---|---|
doc_id | str |
metadata | Mapping[str, Any] |
delete()
| Parameter | Type |
|---|---|
doc_id | str |
check_handle()
| Parameter | Type |
|---|---|
handle | str |
wait_for_handle()
| Parameter | Type |
|---|---|
handle | str |
config | Optional[WaitConfig | dict[str, Any]] |
list()
| Parameter | Type |
|---|---|
fields | Optional[Sequence[str]] |
filter | Optional[query.LogicalExpr] |
AsyncDatasetListIterator
Source
Represents a dataset with an optional filter. Properties| Property | Type | |
|---|---|---|
dataset | str | |
filter | Optional[query.LogicalExpr] |
Fact
Represents a fact in an ask response. Properties| Property | Type | |
|---|---|---|
fact | str | |
ref_ids | list[str] |
Chunk
Text chunk content. Properties| Property | Type | |
|---|---|---|
text | str | |
doc_pages | list[int] |
Image
Image content. Properties| Property | Type | |
|---|---|---|
data | bytes | |
mime_type | str |
Page
Page content with optional image. Properties| Property | Type | |
|---|---|---|
page_number | int | |
image | Optional[Image] |
Content
Content in a search result. One of chunk, page, or image. PropertiesSearchResult
Represents a search result in an ask response. Properties| Property | Type | |
|---|---|---|
doc_id | str | |
doc_type | str | |
dataset | str | |
content_id | str | |
doc_name | str | |
content | Optional[Content] | |
metadata | dict[str, Any] |
Answer
Represents a final answer in an ask response. Properties| Property | Type | |
|---|---|---|
facts | list[Fact] | |
refs | dict[str, SearchResult] | |
confidence | float |
Progress
Represents a progress update in an ask response. Properties| Property | Type | |
|---|---|---|
update | str |
AskIterator
Iterator for synchronous ask responses.AsyncAskIterator
Iterator for asynchronous ask responses.SearchIterator
Iterator for synchronous search responses.AsyncSearchIterator
Iterator for asynchronous search responses.DatasetListIterator
Iterator for synchronous dataset list responses.AsyncDatasetListIterator
Iterator for asynchronous dataset list responses.PartitionListIterator
Iterator for synchronous partition list responses.AsyncPartitionListIterator
Iterator for asynchronous partition list responses.ConsistencyLevel
Consistency level for read operations. Properties| Property | Type | |
|---|---|---|
Indexed | ConsistencyLevel | |
Strong | ConsistencyLevel |
WaitConfig
Configuration for polling when waiting for a handle to be processed. Properties| Property | Type | |
|---|---|---|
frequency_secs | Optional[int] | How often to poll for the handle status in seconds. Default is 5. |
timeout_secs | Optional[int] | Maximum time to wait before returning a timeout error in seconds. Default is 300. |
| Parameter | Type |
|---|---|
frequency_secs | Optional[int] |
timeout_secs | Optional[int] |
RetryConfig
Configuration for retry behavior. By default, retries occur in two situations:- When the server requests the client to reduce its request rate, resulting in a SlowDownError.
- When using the
query(..., lsn=N)to wait for writes to be available.
| Property | Type | |
|---|---|---|
max_retries | Optional[int] | Maximum number of retries to attempt. Default is 3 retries. |
timeout | Optional[int] | The total timetout for the retry chain in milliseconds. Default is 30,000 milliseconds (30 seconds) |
backoff | Optional[BackoffConfig] | The backoff configuration for the client. |
| Parameter | Type |
|---|---|
max_retries | Optional[int] |
timeout | Optional[int] |
backoff | Optional[BackoffConfig] |
BackoffConfig
Configuration for backoff behavior in retries. Properties| Property | Type | |
|---|---|---|
base | Optional[int] | The base for the backoff. Default is 2x backoff. |
init_backoff | Optional[int] | The initial backoff in milliseconds. Default is 100 milliseconds. |
max_backoff | Optional[int] | The maximum backoff in milliseconds. Default is 10,000 milliseconds (10 seconds). |
| Parameter | Type |
|---|---|
base | Optional[int] |
init_backoff | Optional[int] |
max_backoff | Optional[int] |