Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion .github/workflows/pypi-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,43 @@ on:
push:
branches: [ "dev" ]

permissions:
contents: write

jobs:
deploy:

runs-on: ubuntu-latest

# permissions:
# contents: write
# pull-requests: write
# repository-projects: write

steps:
- uses: actions/checkout@v3
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.PAT_TOKEN }}
tag_prefix: ""
dry_run: false

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'

- name: Install dependencies
run: |
echo "new tag: " ${{ steps.tag_version.outputs.new_tag }} "," ${{ steps.tag_version.outputs.new_version }}
pip install -r requirements.txt
python -m pip install --upgrade pip twine build
python -m build --sdist --wheel --outdir dist/ .

# - name: Create a GitHub release
# uses: ncipollo/release-action@v1
# with:
# tag: ${{ steps.tag_version.outputs.new_tag }}
# name: Release ${{ steps.tag_version.outputs.new_tag }}
# body: ${{ steps.tag_version.outputs.changelog }}
34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ pip3 install --upgrade pyepsilla

## Documentation

### Run epsilla vectordb on localhost
### 1.1 Run epsilla vectordb on localhost
```shell
docker pull epsilla/vectordb
docker run -d -p 8888:8888 epsilla/vectordb
```

### Use pyepsilla to connect to and interact with vector database
### 1.2 Use pyepsilla to connect to and interact with local vector database

```python
from pyepsilla import vectordb
Expand Down Expand Up @@ -67,7 +67,7 @@ status_code, response = client.query(
)
print(response)

# search without specific response field, then it will return all fields
## search without specific response field, then it will return all fields
status_code, response = client.query(
table_name="MyTable",
query_field="Embedding",
Expand All @@ -77,13 +77,41 @@ status_code, response = client.query(
print(response)



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


## drop a table
#client.drop_table("MyTable")

## unload a database from memory
#client.unload_db("MyDB")
```



### 2 Run epsilla vectordb on epsilla cloud

```python3

from pyepsilla import cloud

# Connect to Epsilla Cloud
client = cloud.Client(project_id="32ef3a3f-****-****-****-************", api_key="epsilla*****")

# Connect to Vectordb
db = client.vectordb(db_id="df7431d0-****-****-****-************")

```
Please check https://github.com/epsilla-cloud/epsilla-python-client/blob/main/examples/hello_epsilla_cloud.py for detail.




## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/epsilla-cloud/epsilla-python-client/

Expand Down
7 changes: 5 additions & 2 deletions examples/hello_epsilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
from pyepsilla import vectordb

# Connect to Epsilla VectorDB
client = vectordb.Client(host='127.0.0.1', port='8888')
client = vectordb.Client(protocol='http', host='127.0.0.1', port='8888')

# You can also use Epsilla Cloud
# client = vectordb.Client(protocol='https', host='demo.epsilla.com', port='443')

# Load DB with path
## pay attention to change db_path to persistent volume for production environment
status_code, response = client.load_db(db_name="MyDB", db_path="/tmp/epsilla")
status_code, response = client.load_db(db_name="MyDB", db_path="/data/epsilla_demo")
print(response)

# Set DB to current DB
Expand Down
29 changes: 15 additions & 14 deletions pyepsilla/cloud/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,22 @@ def insert(self, table_name: str, records: list[dict]):


## query data from table
def query(self, table_name: str, query_field: str = "", query_vector: list = None, response_fields: list = None, limit: int = 1, with_distance: bool = False):
def query(self, table_name: str, query_field: str = None, query_vector: list = None, response_fields: Optional[list] = None, limit: int = 2, filter: Optional[str] = None, with_distance: Optional[bool] = False):
req_url = "{}/data/query".format(self._baseurl)
req_data = {
"table": table_name,
"queryField": query_field,
"queryVector": query_vector,
"response": response_fields,
"limit": limit,
"withDistance": with_distance
}
req_data = { "table": table_name }
if query_field != None:
req_data["queryField"] = query_field
if query_vector != None:
req_data["queryVector"] = query_vector
if response_fields != None:
req_data["response"] = response_fields
if limit != None:
req_data["limit"] = limit
if filter != None:
req_data["filter"] = filter
if with_distance != None:
req_data["withDistance"] = with_distance

res = requests.post(url=req_url, data=json.dumps(req_data), headers=self._header)
status_code = res.status_code
body = res.json()
Expand Down Expand Up @@ -155,19 +161,14 @@ def get(self, table_name: str, response_fields: Optional[list] = None, primary_k
primary_keys = ids

req_data = {"table": table_name}

if response_fields != None:
req_data["response"] = response_fields

if primary_keys != None:
req_data["primaryKeys"] = primary_keys

if filter != None:
req_data["filter"] = filter

if skip != None:
req_data["skip"] = skip

if limit != None:
req_data["limit"] = limit

Expand Down
2 changes: 1 addition & 1 deletion pyepsilla/vectordb/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.20'
__version__ = '0.1.21'