centaur-client 0.0.11
Centaur Client Python Sdk Library
License: Apache 2.0
Requires Python: >=3.7.0

# Centaur Client Python Library

Centaur provides fully-managed, serverless, scalable vector-database service for building various machine learning applications. The Centaur client SDK is your gateway to access the Centaur service.

## Installation
To install the Centaur client Python SDK, simply run:
```shell
pip install centaur-client
```

## QuickStart
You can use `Client` api to communicate with Centaur service.

```python
import centaur

client = centaur.Client(api_key='YOUR-CENTAUR-API-KEY')
```

## Sample Code

### Create a Collection
`Client` host various `Collection` APIs for interacting with Centaur service.

```python
import centaur

client = centaur.Client(api_key='YOUR-CENTAUR-API-KEY')
client.create('YOUR-COLLECTION-NAME', dimension=4)
```

### List Collections

```python
import centaur

client = centaur.Client(api_key='YOUR-CENTAUR-API-KEY')
collections = client.list()
print(collections)
```

### Describe Collection

```python
import centaur

client = centaur.Client(api_key='YOUR-CENTAUR-API-KEY')
rsp = client.describe('YOUR-COLLECTION-NAME')
print(rsp)
```

### Delete Collection
```python
import centaur

client = centaur.Client(api_key='YOUR-CENTAUR-API-KEY')
client.delete('YOUR-COLLECTION-NAME')
```

### Get a Collection Instance

`Collection` provides APIs for accessing `Doc` and `Partition`

```python
import centaur

client = centaur.Client(api_key='YOUR-CENTAUR-API-KEY')
collection = client.get('YOUR-COLLECTION-NAME')
if collection:
    print('collection:', collection)
```

### Describe Collection Statistics
```python
import centaur

client = centaur.Client(api_key='YOUR-CENTAUR-API-KEY')
collection = client.get('YOUR-COLLECTION-NAME')
rsp = collection.stats()
print(rsp)
```

### Insert/Update/Upsert Docs
```python
import centaur

client = centaur.Client(api_key='YOUR-CENTAUR-API-KEY')
collection = client.get('YOUR-COLLECTION-NAME')
collection.upsert(('YOUR-DOC-ID', [0.1, 0.2], {'price': 100, 'type': 'dress'}))
```

### Query a Collection
```python
import centaur

client = centaur.Client(api_key='YOUR-CENTAUR-API-KEY')
collection = client.get('YOUR-COLLECTION-NAME')
match_docs = collection.query([0.1, 0.2, 0.3, 0.4], 
                       topk=100, 
                       include_vector=True)
if match_docs:
    for doc in match_docs:
        print(doc)
```

### Delete Docs
```python
import centaur

client = centaur.Client(api_key='YOUR-CENTAUR-API-KEY')
collection = client.get('YOUR-COLLECTION-NAME')
collection.delete('YOUR-DOC-ID')
```

### Fetch Docs
```python
import centaur

client = centaur.Client(api_key='YOUR-CENTAUR-API-KEY')
collection = client.get('YOUR-COLLECTION-NAME')
fetch_docs = collection.fetch(['YOUR-DOC-ID1', 'YOUR-DOC-ID2'])
if fetch_docs:
    for doc_id in fetch_docs:
        print(fetch_docs[doc_id])
```

### Create a Collection Partition
```python
import centaur

client = centaur.Client(api_key='YOUR-CENTAUR-API-KEY')
collection = client.get('YOUR-COLLECTION-NAME')
collection.create_partition('YOUR-PARTITION-NAME')
```

## Centaur Response
```python
from centaur import CentaurCode

@dataclasses
class CentaurResponse(object):
    code: CentaurCode
    message: str
    request_id: str
    output: Any
```

## License
This project is licensed under the Apache License (Version 2.0).