BagelDB is a Python library for interacting with the BagelDB API.
Project description
BagelDB Python Client Example
This README provides steps on how to use the BagelDB python client example code.
Prerequisites
- Python 3.6+
- pip package manager
- BagelDB account and API key
Installation
Install the BagelDB python client:
pip install bagel
Usage
- Import the necessary modules:
import uuid
import bagel
from bagel.config import Settings
- Define the BagelDB server settings:
server_settings = Settings(
bagel_api_impl="rest",
bagel_server_host="api2.bageldb.ai",
bagel_server_http_port="8000"
)
- Create the BagelDB client:
client = bagel.Client(server_settings)
- Ping the BagelDB server:
print(client.ping())
- Get the BagelDB server version:
print(client.get_version())
- Create and delete a cluster:
name = str(uuid.uuid4())
client.create_cluster(name)
client.delete_cluster(name)
- Create, add documents, and query a cluster:
cluster = client.get_or_create_cluster("testing")
cluster.add(documents=["doc1", "doc2"])
results = cluster.find(query_texts=["query"], n_results=5)
- Add embeddings and query:
cluster.add(embeddings=[[1.1, 2.3], [4.5, 6.9]])
results = cluster.find(query_embeddings=[[1.1, 2.3]], n_results=2)
- Modify cluster name:
cluster.modify(name="new_name")
- Update document metadata:
cluster.update(ids=["doc1"], metadatas=[{"new":"metadata"}])
- Upsert documents:
cluster.upsert(documents=["new doc"], ids=["doc1"])
See the example code for more details on using the BagelDB python client.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
betabageldb-0.1.6.tar.gz
(2.3 kB
view hashes)
Built Distribution
Close
Hashes for betabageldb-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b5e96bcf6f10063ff7bb317364318e763eb0650ab335b321bb3141c897c0c8c |
|
MD5 | 503e2a65c2843c1e43ca9d98e21f828e |
|
BLAKE2b-256 | 2f9711e681b334f65ee217ad614774e03a8827e06f5af21e06a07fa0b8b3b0d6 |