Skip to content

Commit c6c6595

Browse files
committed
git piMerge branch 'main' into dev
2 parents a38969b + 11493ab commit c6c6595

4 files changed

Lines changed: 80 additions & 21 deletions

File tree

.github/workflows/pypi-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ name: Upload Python Package
1111
on:
1212
push:
1313
branches: [ "main" ]
14-
paths: ['pyepsilla/vectordb/version.py']
14+
paths: ['pyepsilla/vectordb/version.py', 'pyproject.toml']
1515

1616
jobs:
1717
deploy:

README.md

Lines changed: 77 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,30 @@ docker pull epsilla/vectordb
2525
docker run -d -p 8888:8888 epsilla/vectordb
2626
```
2727

28+
#### When Port 8888 conflicted with Jupyter Notebook
29+
If you are using Jupyter Notebook on localhost, the port 8888 maybe conflict!
30+
31+
So you can change the vectordb port to another number, such as 18888
32+
```
33+
docker run -d -p 18888:8888 epsilla/vectordb
34+
```
35+
2836
#### Use pyepsilla to connect to and interact with local vector database
2937

3038
```python
3139
from pyepsilla import vectordb
3240

33-
## connect to vectordb
41+
## 1.Connect to vectordb
3442
client = vectordb.Client(
3543
host='localhost',
3644
port='8888'
3745
)
3846

39-
## load and use a database
47+
## 2.Load and use a database
4048
client.load_db(db_name="MyDB", db_path="/tmp/epsilla")
4149
client.use_db(db_name="MyDB")
4250

43-
## create a table in the current database
51+
## 3.Create a table in the current database
4452
client.create_table(
4553
table_name="MyTable",
4654
table_fields=[
@@ -50,7 +58,7 @@ client.create_table(
5058
]
5159
)
5260

53-
## insert records
61+
## 4.Insert records
5462
client.insert(
5563
table_name="MyTable",
5664
records=[
@@ -62,7 +70,7 @@ client.insert(
6270
]
6371
)
6472

65-
## search with specific response field
73+
## 5.Search with specific response field
6674
status_code, response = client.query(
6775
table_name="MyTable",
6876
query_field="Embedding",
@@ -72,7 +80,7 @@ status_code, response = client.query(
7280
)
7381
print(response)
7482

75-
## search without specific response field, then it will return all fields
83+
## 6.Search without specific response field, then it will return all fields
7684
status_code, response = client.query(
7785
table_name="MyTable",
7886
query_field="Embedding",
@@ -81,16 +89,16 @@ status_code, response = client.query(
8189
)
8290
print(response)
8391

84-
## delete records by primary_keys (and filter)
92+
## 7.Delete records by primary_keys (and filter)
8593
status_code, response = client.delete(table_name="MyTable", primary_keys=[3, 4])
8694
status_code, response = client.delete(table_name="MyTable", filter="Doc <> 'San Francisco'")
8795
print(response)
8896

8997

90-
## drop a table
98+
## 8.Drop a table
9199
client.drop_table("MyTable")
92100

93-
## unload a database from memory
101+
## 9.Unload a database from memory
94102
client.unload_db("MyDB")
95103
```
96104

@@ -101,34 +109,86 @@ client.unload_db("MyDB")
101109
https://cloud.epsilla.com
102110

103111
#### Use Epsilla Cloud module to connect with the vectordb
104-
Please check <a href="https://github.com/epsilla-cloud/epsilla-python-client/blob/main/examples/hello_epsilla_cloud.py">example</a> for detail.
112+
Please get the project_id, db_id, epsilla_api_key from Epsilla Cloud at first
105113
```python3
106114
from pyepsilla import cloud
107115

108-
# Connect to Epsilla Cloud
109-
client = cloud.Client(project_id="32ef3a3f-****-****-****-************", api_key="eps_**********")
116+
epsilla_api_key = os.getenv("EPSILLA_API_KEY", "Your-Epsilla-API-Key")
117+
project_id = os.getenv("EPSILLA_PROJECT_ID", "Your-Project-ID")
118+
db_id = os.getenv("EPSILLA_DB_ID", "Your-DB-ID")
119+
120+
121+
# 1.Connect to Epsilla Cloud
122+
client = cloud.Client(project_id="*****-****-****-****-************", api_key="eps_**********")
123+
124+
# 2.Connect to Vectordb
125+
db_client = cloud_client.vectordb(db_id)
126+
127+
# 3.Create a table with schema
128+
status_code, response = db.create_table(
129+
table_name="MyTable",
130+
table_fields=[
131+
{"name": "ID", "dataType": "INT", "primaryKey": True},
132+
{"name": "Doc", "dataType": "STRING"},
133+
{"name": "Embedding", "dataType": "VECTOR_FLOAT", "dimensions": 4},
134+
],
135+
)
136+
print(status_code, response)
137+
138+
# 4.Insert new vector records into table
139+
status_code, response = db.insert(
140+
table_name="MyTable",
141+
records=[
142+
{"ID": 1, "Doc": "Berlin", "Embedding": [0.05, 0.61, 0.76, 0.74]},
143+
{"ID": 2, "Doc": "London", "Embedding": [0.19, 0.81, 0.75, 0.11]},
144+
{"ID": 3, "Doc": "Moscow", "Embedding": [0.36, 0.55, 0.47, 0.94]},
145+
{"ID": 4, "Doc": "San Francisco", "Embedding": [0.18, 0.01, 0.85, 0.80]},
146+
{"ID": 5, "Doc": "Shanghai", "Embedding": [0.24, 0.18, 0.22, 0.44]},
147+
],
148+
)
149+
print(status_code, response)
150+
151+
152+
# 5.Query Vectors with specific response field, otherwise it will return all fields
153+
status_code, response = db.query(
154+
table_name="MyTable",
155+
query_field="Embedding",
156+
query_vector=[0.35, 0.55, 0.47, 0.94],
157+
response_fields=["Doc"],
158+
limit=2,
159+
)
160+
print(status_code, response)
161+
162+
163+
# 6.Delete specific records from table
164+
status_code, response = db.delete(table_name="MyTable", primary_keys=[4, 5])
165+
status_code, response = db.delete(table_name="MyTable", filter="Doc <> 'San Francisco'")
166+
print(status_code, response)
167+
168+
# 7.Drop table
169+
status_code, response = db.drop_table(table_name="MyTable")
170+
print(status_code, response)
171+
110172

111-
# Connect to Vectordb
112-
db = client.vectordb(db_id="df7431d0-****-****-****-************")
113173
```
114174

115175

116176
## Connect to Epsilla RAG
117-
177+
Please get the project_id, epsilla_api_key, ragapp_id, converstation_id(optional) from Epsilla Cloud at first
118178
The resp will contains answer as well as contexts, like {"answer": "****", "contexts": ['context1','context2', ...]}
119179

120180
```python3
121181
from pyepsilla import cloud
122182

123-
# Connect to Epsilla RAG
183+
# 1.Connect to Epsilla RAG
124184
client = cloud.RAG(
125185
project_id="ce07c6fc-****-****-b7bd-b7819f22bcff",
126186
api_key="eps_**********",
127187
ragapp_id="153a5a49-****-****-b2b8-496451eda8b5",
128188
conversation_id="6fa22a6a-****-****-b1c3-5c795d0f45ef",
129189
)
130190

131-
# Start a new conversation with RAG
191+
# 2.Start a new conversation with RAG
132192
client.start_new_conversation()
133193
resp = client.query("What's RAG?")
134194

pyepsilla/vectordb/readme.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
##https://github.com/hegelai/prompttools/blob/main/examples/notebooks/ChromaDBExperiment.ipynb
2-
## torch/sentence_transformers/sentence-transformers_paraphrase-MiniLM-L3-v2
1+

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ readme = "README.md"
88
[tool.poetry.dependencies]
99
python = ">=3.10"
1010
boto3 = "^1.35.5"
11-
posthog = "^3.6.0"
11+
posthog = "^3.6.3"
1212
py-machineid = "^0.6.0"
1313
sentry-sdk = "^2.13.0"
1414
requests = "^2.32.3"

0 commit comments

Comments
 (0)