Skip to main content

Epsilla Logo

Python Client for Epsilla Vector Database


Welcome to Python SDK for Epsilla Vector Database!

Install pyepsilla

pip3 install --upgrade pyepsilla

Connect to Epsilla Vector Database

Run epsilla vectordb on localhost

docker pull epsilla/vectordb
docker run -d -p 8888:8888 epsilla/vectordb

When Port 8888 conflicted with Jupyter Notebook

If you are using Jupyter Notebook on localhost, the port 8888 maybe conflict!

So you can change the vectordb port to another number, such as 18888

docker run -d -p 18888:8888 epsilla/vectordb

Use pyepsilla to connect to and interact with local vector database

from pyepsilla import vectordb

db_name = "MyDB"
db_path = "/tmp/epsilla"
table_name = "MyTable"

## 1.Connect to vectordb
client = vectordb.Client(
  host='localhost',
  port='8888'
)

## 2.Load and use a database
client.load_db(db_name, db_path)
client.use_db(db_name)

## 3.Create a table in the current database
client.create_table(
  table_name=table_name,
  table_fields=[
    {"name": "ID", "dataType": "INT", "primaryKey": True},
    {"name": "Doc", "dataType": "STRING"},
    {"name": "Embedding", "dataType": "VECTOR_FLOAT", "dimensions": 4}
  ]
)

## 4.Insert records
client.insert(
  table_name=table_name,
  records=[
    {"ID": 1, "Doc": "Berlin", "Embedding": [0.05, 0.61, 0.76, 0.74]},
    {"ID": 2, "Doc": "London", "Embedding": [0.19, 0.81, 0.75, 0.11]},
    {"ID": 3, "Doc": "Moscow", "Embedding": [0.36, 0.55, 0.47, 0.94]},
    {"ID": 4, "Doc": "San Francisco", "Embedding": [0.18, 0.01, 0.85, 0.80]},
    {"ID": 5, "Doc": "Shanghai", "Embedding": [0.24, 0.18, 0.22, 0.44]}
  ]
)

## 5.Search with specific response field
status_code, response = client.query(
  table_name=table_name,
  query_field="Embedding",
  query_vector=[0.35, 0.55, 0.47, 0.94],
  response_fields = ["Doc"],
  limit=2
)
print(response)

## 6.Search without specific response field, then it will return all fields
status_code, response = client.query(
  table_name=table_name,
  query_field="Embedding",
  query_vector=[0.35, 0.55, 0.47, 0.94],
  limit=2
)
print(response)

## 7.Delete records by primary_keys (and filter)
status_code, response =  client.delete(table_name=table_name, primary_keys=[3, 4])
status_code, response =  client.delete(table_name=table_name, filter="Doc <> 'San Francisco'")
print(response)


## 8.Drop a table
client.drop_table(table_name)

## 9.Unload a database from memory
client.unload_db(db_name)

Connect to Epsilla Cloud

Register and create vectordb on Epsilla Cloud

https://cloud.epsilla.com

Use Epsilla Cloud module to connect with the vectordb

Please get the project_id, db_id, epsilla_api_key from Epsilla Cloud at first

from pyepsilla import cloud

epsilla_api_key = os.getenv("EPSILLA_API_KEY", "Your-Epsilla-API-Key")
project_id = os.getenv("EPSILLA_PROJECT_ID", "Your-Project-ID")
db_id = os.getenv("EPSILLA_DB_ID", "Your-DB-ID")


# 1.Connect to Epsilla Cloud
cloud_client = cloud.Client(project_id="*****-****-****-****-************", api_key="eps_**********")

# 2.Connect to Vectordb
db_client = cloud_client.vectordb(db_id)

# 3.Create a table with schema
status_code, response = db.create_table(
    table_name="MyTable",
    table_fields=[
        {"name": "ID", "dataType": "INT", "primaryKey": True},
        {"name": "Doc", "dataType": "STRING"},
        {"name": "Embedding", "dataType": "VECTOR_FLOAT", "dimensions": 4},
    ],
)
print(status_code, response)

# 4.Insert new vector records into table
status_code, response = db.insert(
    table_name="MyTable",
    records=[
        {"ID": 1, "Doc": "Berlin", "Embedding": [0.05, 0.61, 0.76, 0.74]},
        {"ID": 2, "Doc": "London", "Embedding": [0.19, 0.81, 0.75, 0.11]},
        {"ID": 3, "Doc": "Moscow", "Embedding": [0.36, 0.55, 0.47, 0.94]},
        {"ID": 4, "Doc": "San Francisco", "Embedding": [0.18, 0.01, 0.85, 0.80]},
        {"ID": 5, "Doc": "Shanghai", "Embedding": [0.24, 0.18, 0.22, 0.44]},
    ],
)
print(status_code, response)


# 5.Query Vectors with specific response field, otherwise it will return all fields
status_code, response = db.query(
    table_name="MyTable",
    query_field="Embedding",
    query_vector=[0.35, 0.55, 0.47, 0.94],
    response_fields=["Doc"],
    limit=2,
)
print(status_code, response)


# 6.Delete specific records from table
status_code, response = db.delete(table_name="MyTable", primary_keys=[4, 5])
status_code, response = db.delete(table_name="MyTable", filter="Doc <> 'San Francisco'")
print(status_code, response)

# 7.Drop table
status_code, response = db.drop_table(table_name="MyTable")
print(status_code, response)

Connect to Epsilla RAG

Please get the project_id, epsilla_api_key, ragapp_id, converstation_id(optional) from Epsilla Cloud at first The resp will contains answer as well as contexts, like {"answer": "****", "contexts": ['context1','context2', ...]}

from pyepsilla import cloud

epsilla_api_key = os.getenv("EPSILLA_API_KEY", "Your-Epsilla-API-Key")
project_id = os.getenv("EPSILLA_PROJECT_ID", "Your-Project-ID")
ragapp_id = os.getenv("EPSILLA_RAGAPP_ID", "Your-RAGAPP-ID")
conversation_id = os.getenv("EPSILLA_CONVERSATION_ID", "Your-CONVERSATION-ID")

# 1.Connect to Epsilla RAG
client = cloud.RAG(
    project_id=project_id,
    api_key=epsilla_api_key,
    ragapp_id=ragapp_id,
    conversation_id=conversation_id,
)

# 2.Start a new conversation with RAG
client.start_new_conversation()
resp = client.query("What's RAG?")

print("[INFO] response is", resp)

Contributing

Bug reports and pull requests are welcome on GitHub at here

If you have any question or problem, please join our discord

We love your Feedback!

Release files for pyepsilla 0.3.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyepsilla 0.3.15
File Size Uploaded
pyepsilla-0.3.15.tar.gz 22.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyepsilla 0.3.15
File Interpreter ABI Platform
pyepsilla-0.3.15-py3-none-any.whl Python 3 none any Details

Total release size: 51.7 kB

Release files / pyepsilla-0.3.15.tar.gz

Download URL pyepsilla-0.3.15.tar.gz
Size 22.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c2e12d8cb65a6ae282c919132271fdf14d73b83aa35f0cda544f88e804801e22
BLAKE2b-256 checksum
How to use checksums
1b48cf000696a4a373d85c1fede16b434fd4d84d5ca8834b334ffc610f42d351
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / pyepsilla-0.3.15-py3-none-any.whl

Download URL pyepsilla-0.3.15-py3-none-any.whl
Size 29.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
80cd7f4f942c99fc6890062ca0e77485b9fe6e90e138163aba23f4eaf7fe7bdb
BLAKE2b-256 checksum
How to use checksums
9439be8851fb0abf5c67e0bf9dc93851f689bf63401020e391cae8e80d2fdb49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.3.15 This release

2 release files

0.3.13

2 release files

0.3.12

2 release files

0.3.11

2 release files

0.3.10

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.24

2 release files

0.1.23

2 release files

0.1.20

2 release files

0.1.19

2 release files

0.1.18

2 release files

0.1.17

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.12

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page