Skip to content

Commit a631534

Browse files
Merge pull request #29 from epsilla-cloud/dev
update query fuction for cloud client as well as readme.md
2 parents 4ed9f23 + 6a891c6 commit a631534

5 files changed

Lines changed: 76 additions & 21 deletions

File tree

.github/workflows/pypi-dev.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,43 @@ on:
77
push:
88
branches: [ "dev" ]
99

10+
permissions:
11+
contents: write
12+
1013
jobs:
1114
deploy:
1215

1316
runs-on: ubuntu-latest
14-
17+
# permissions:
18+
# contents: write
19+
# pull-requests: write
20+
# repository-projects: write
21+
1522
steps:
1623
- uses: actions/checkout@v3
24+
- name: Bump version and push tag
25+
id: tag_version
26+
uses: mathieudutour/github-tag-action@v6.1
27+
with:
28+
github_token: ${{ secrets.PAT_TOKEN }}
29+
tag_prefix: ""
30+
dry_run: false
31+
1732
- name: Set up Python
1833
uses: actions/setup-python@v3
1934
with:
2035
python-version: '3.x'
36+
2137
- name: Install dependencies
2238
run: |
39+
echo "new tag: " ${{ steps.tag_version.outputs.new_tag }} "," ${{ steps.tag_version.outputs.new_version }}
2340
pip install -r requirements.txt
2441
python -m pip install --upgrade pip twine build
2542
python -m build --sdist --wheel --outdir dist/ .
2643
44+
# - name: Create a GitHub release
45+
# uses: ncipollo/release-action@v1
46+
# with:
47+
# tag: ${{ steps.tag_version.outputs.new_tag }}
48+
# name: Release ${{ steps.tag_version.outputs.new_tag }}
49+
# body: ${{ steps.tag_version.outputs.changelog }}

README.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ pip3 install --upgrade pyepsilla
1414

1515
## Documentation
1616

17-
### Run epsilla vectordb on localhost
17+
### 1.1 Run epsilla vectordb on localhost
1818
```shell
1919
docker pull epsilla/vectordb
2020
docker run -d -p 8888:8888 epsilla/vectordb
2121
```
2222

23-
### Use pyepsilla to connect to and interact with vector database
23+
### 1.2 Use pyepsilla to connect to and interact with local vector database
2424

2525
```python
2626
from pyepsilla import vectordb
@@ -67,7 +67,7 @@ status_code, response = client.query(
6767
)
6868
print(response)
6969

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

7979

80+
81+
## delete records by primary_keys (and filter)
82+
# status_code, response = client.delete(table_name="MyTable", ids=[3])
83+
status_code, response = client.delete(table_name="MyTable", primary_keys=[3, 4])
84+
# status_code, response = client.delete(table_name="MyTable", filter="Doc <> 'San Francisco'")
85+
print(response)
86+
87+
8088
## drop a table
8189
#client.drop_table("MyTable")
8290

8391
## unload a database from memory
8492
#client.unload_db("MyDB")
8593
```
8694

95+
96+
97+
### 2 Run epsilla vectordb on epsilla cloud
98+
99+
```python3
100+
101+
from pyepsilla import cloud
102+
103+
# Connect to Epsilla Cloud
104+
client = cloud.Client(project_id="32ef3a3f-****-****-****-************", api_key="epsilla*****")
105+
106+
# Connect to Vectordb
107+
db = client.vectordb(db_id="df7431d0-****-****-****-************")
108+
109+
```
110+
Please check https://github.com/epsilla-cloud/epsilla-python-client/blob/main/examples/hello_epsilla_cloud.py for detail.
111+
112+
113+
114+
87115
## Contributing
88116
Bug reports and pull requests are welcome on GitHub at https://github.com/epsilla-cloud/epsilla-python-client/
89117

examples/hello_epsilla.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010
from pyepsilla import vectordb
1111

1212
# Connect to Epsilla VectorDB
13-
client = vectordb.Client(host='127.0.0.1', port='8888')
13+
client = vectordb.Client(protocol='http', host='127.0.0.1', port='8888')
14+
15+
# You can also use Epsilla Cloud
16+
# client = vectordb.Client(protocol='https', host='demo.epsilla.com', port='443')
1417

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

2023
# Set DB to current DB

pyepsilla/cloud/client.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,22 @@ def insert(self, table_name: str, records: list[dict]):
9898

9999

100100
## query data from table
101-
def query(self, table_name: str, query_field: str = "", query_vector: list = None, response_fields: list = None, limit: int = 1, with_distance: bool = False):
101+
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):
102102
req_url = "{}/data/query".format(self._baseurl)
103-
req_data = {
104-
"table": table_name,
105-
"queryField": query_field,
106-
"queryVector": query_vector,
107-
"response": response_fields,
108-
"limit": limit,
109-
"withDistance": with_distance
110-
}
103+
req_data = { "table": table_name }
104+
if query_field != None:
105+
req_data["queryField"] = query_field
106+
if query_vector != None:
107+
req_data["queryVector"] = query_vector
108+
if response_fields != None:
109+
req_data["response"] = response_fields
110+
if limit != None:
111+
req_data["limit"] = limit
112+
if filter != None:
113+
req_data["filter"] = filter
114+
if with_distance != None:
115+
req_data["withDistance"] = with_distance
116+
111117
res = requests.post(url=req_url, data=json.dumps(req_data), headers=self._header)
112118
status_code = res.status_code
113119
body = res.json()
@@ -155,19 +161,14 @@ def get(self, table_name: str, response_fields: Optional[list] = None, primary_k
155161
primary_keys = ids
156162

157163
req_data = {"table": table_name}
158-
159164
if response_fields != None:
160165
req_data["response"] = response_fields
161-
162166
if primary_keys != None:
163167
req_data["primaryKeys"] = primary_keys
164-
165168
if filter != None:
166169
req_data["filter"] = filter
167-
168170
if skip != None:
169171
req_data["skip"] = skip
170-
171172
if limit != None:
172173
req_data["limit"] = limit
173174

pyepsilla/vectordb/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.1.20'
1+
__version__ = '0.1.21'

0 commit comments

Comments
 (0)