Skip to content

Commit 344fb57

Browse files
committed
Merge branch 'main' into dev
2 parents b172f5e + f4f2767 commit 344fb57

8 files changed

Lines changed: 200 additions & 66 deletions

CODE_OF_CONDUCT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ representative at an online or offline event.
6161

6262
Instances of abusive, harassing, or otherwise unacceptable behavior may be
6363
reported to the community leaders responsible for enforcement at
64-
[team@hegel-ai.com](team@hegel-ai.com).
64+
[info@epsilla.com](info@epsilla.com).
6565
All complaints will be reviewed and investigated promptly and fairly.
6666

6767
All community leaders are obligated to respect the privacy and security of the
@@ -84,4 +84,4 @@ For answers to common questions about this code of conduct, see the FAQ at
8484
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
8585
[Mozilla CoC]: https://github.com/mozilla/diversity
8686
[FAQ]: https://www.contributor-covenant.org/faq
87-
[translations]: https://www.contributor-covenant.org/translations
87+
[translations]: https://www.contributor-covenant.org/translations

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

README.md

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,23 @@ docker run -d -p 18888:8888 epsilla/vectordb
3838
```python
3939
from pyepsilla import vectordb
4040

41+
db_name = "MyDB"
42+
db_path = "/tmp/epsilla"
43+
table_name = "MyTable"
44+
4145
## 1.Connect to vectordb
4246
client = vectordb.Client(
4347
host='localhost',
4448
port='8888'
4549
)
4650

4751
## 2.Load and use a database
48-
client.load_db(db_name="MyDB", db_path="/tmp/epsilla")
49-
client.use_db(db_name="MyDB")
52+
client.load_db(db_name, db_path)
53+
client.use_db(db_name)
5054

5155
## 3.Create a table in the current database
5256
client.create_table(
53-
table_name="MyTable",
57+
table_name=table_name,
5458
table_fields=[
5559
{"name": "ID", "dataType": "INT", "primaryKey": True},
5660
{"name": "Doc", "dataType": "STRING"},
@@ -60,7 +64,7 @@ client.create_table(
6064

6165
## 4.Insert records
6266
client.insert(
63-
table_name="MyTable",
67+
table_name=table_name,
6468
records=[
6569
{"ID": 1, "Doc": "Berlin", "Embedding": [0.05, 0.61, 0.76, 0.74]},
6670
{"ID": 2, "Doc": "London", "Embedding": [0.19, 0.81, 0.75, 0.11]},
@@ -72,7 +76,7 @@ client.insert(
7276

7377
## 5.Search with specific response field
7478
status_code, response = client.query(
75-
table_name="MyTable",
79+
table_name=table_name,
7680
query_field="Embedding",
7781
query_vector=[0.35, 0.55, 0.47, 0.94],
7882
response_fields = ["Doc"],
@@ -82,24 +86,24 @@ print(response)
8286

8387
## 6.Search without specific response field, then it will return all fields
8488
status_code, response = client.query(
85-
table_name="MyTable",
89+
table_name=table_name,
8690
query_field="Embedding",
8791
query_vector=[0.35, 0.55, 0.47, 0.94],
8892
limit=2
8993
)
9094
print(response)
9195

9296
## 7.Delete records by primary_keys (and filter)
93-
status_code, response = client.delete(table_name="MyTable", primary_keys=[3, 4])
94-
status_code, response = client.delete(table_name="MyTable", filter="Doc <> 'San Francisco'")
97+
status_code, response = client.delete(table_name=table_name, primary_keys=[3, 4])
98+
status_code, response = client.delete(table_name=table_name, filter="Doc <> 'San Francisco'")
9599
print(response)
96100

97101

98102
## 8.Drop a table
99-
client.drop_table("MyTable")
103+
client.drop_table(table_name)
100104

101105
## 9.Unload a database from memory
102-
client.unload_db("MyDB")
106+
client.unload_db(db_name)
103107
```
104108

105109

@@ -119,7 +123,7 @@ db_id = os.getenv("EPSILLA_DB_ID", "Your-DB-ID")
119123

120124

121125
# 1.Connect to Epsilla Cloud
122-
client = cloud.Client(project_id="*****-****-****-****-************", api_key="eps_**********")
126+
cloud_client = cloud.Client(project_id="*****-****-****-****-************", api_key="eps_**********")
123127

124128
# 2.Connect to Vectordb
125129
db_client = cloud_client.vectordb(db_id)
@@ -180,12 +184,17 @@ The resp will contains answer as well as contexts, like {"answer": "****", "cont
180184
```python3
181185
from pyepsilla import cloud
182186

187+
epsilla_api_key = os.getenv("EPSILLA_API_KEY", "Your-Epsilla-API-Key")
188+
project_id = os.getenv("EPSILLA_PROJECT_ID", "Your-Project-ID")
189+
ragapp_id = os.getenv("EPSILLA_RAGAPP_ID", "Your-RAGAPP-ID")
190+
conversation_id = os.getenv("EPSILLA_CONVERSATION_ID", "Your-CONVERSATION-ID")
191+
183192
# 1.Connect to Epsilla RAG
184193
client = cloud.RAG(
185-
project_id="ce07c6fc-****-****-b7bd-b7819f22bcff",
186-
api_key="eps_**********",
187-
ragapp_id="153a5a49-****-****-b2b8-496451eda8b5",
188-
conversation_id="6fa22a6a-****-****-b1c3-5c795d0f45ef",
194+
project_id=project_id,
195+
api_key=epsilla_api_key,
196+
ragapp_id=ragapp_id,
197+
conversation_id=conversation_id,
189198
)
190199

191200
# 2.Start a new conversation with RAG

SECURITY.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
| Version | Supported |
6+
| ------- | ------------------ |
7+
| 0.3.15 | :white_check_mark: |
8+
| 0.3.14 | :white_check_mark: |
9+
| 0.3.13 | :white_check_mark: |
10+
| 0.3.12 | :white_check_mark: |
11+
| 0.3.11 | :white_check_mark: |
12+
| 0.3.10 | :white_check_mark: |
13+
14+
15+
## Reporting a Vulnerability
16+
17+
If you find a vulnerability, please tell us info#epsilla.com

examples/Question_Answering_Pipeline_with_LangChain_and_EpsillaCloud.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
pip install langchain
99
pip install openai
1010
pip install tiktoken
11-
pip install pyepsilla
11+
pip install -U pyepsilla
1212
pip install -U langchain-openai
1313
pip install -U langchain-community
1414
"""
@@ -25,7 +25,7 @@
2525

2626

2727
# Step3. Load the documents
28-
from langchain.document_loaders import WebBaseLoader
28+
from langchain_community.document_loaders import WebBaseLoader
2929
from langchain.text_splitter import CharacterTextSplitter
3030
from langchain_openai import OpenAIEmbeddings
3131

@@ -43,13 +43,13 @@
4343
db_path = f"/data/{project_id}/{db_name}/s{db_sharding_id}"
4444
table_name = "MyCollection"
4545

46-
# Connect to Epsilla Cloud
46+
# Step4.1 Connect to Epsilla Cloud
4747
cloud_client = cloud.Client(
4848
project_id=project_id,
4949
api_key=epsilla_api_key,
5050
)
5151

52-
# Connect to Vectordb
52+
# Step4.2 Connect to Vectordb
5353
db_client = cloud_client.vectordb(db_id)
5454

5555
vector_store = Epsilla.from_documents(
@@ -67,7 +67,7 @@
6767

6868

6969

70-
# Step4. Create the QA for Retrieval
70+
# Step5. Create the QA for Retrieval
7171
from langchain.chains import RetrievalQA
7272
from langchain_openai import OpenAI
7373

examples/hello_epsilla_cloud.py

Lines changed: 71 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,61 +4,89 @@
44
# Try this simple example for epsilla cloud
55
# 1. create project and db on epsilla cloud
66
# 2. create a table with schema in db
7-
# 3. get the api key with project id, run this program
7+
# 3. get the epsilla cloud api key with project id, run this program
88

9+
import sys
10+
import os
911
from pyepsilla import cloud
1012

13+
project_id = os.getenv("EPSILLA_PROJECT_ID", "Your-Project-ID")
14+
epsilla_api_key = os.getenv("EPSILLA_API_KEY", "Your-Epsilla-API-Key")
15+
db_id = os.getenv("EPSILLA_DB_ID", "Your-DB-ID")
16+
17+
if not project_id or not api_key or not db_id:
18+
print("Please set the environment variables: EPSILLA_PROJECT_ID, EPSILLA_API_KEY, EPSILLA_DB_ID")
19+
sys.exit(1)
20+
1121
# Connect to Epsilla Cloud
12-
client = cloud.Client(
13-
project_id="7a68814c-f839-4a67-9ec6-93c027c865e0",
14-
api_key="epsilla-cloud-api-key",
22+
cloud_client = cloud.Client(
23+
project_id=project_id,
24+
api_key=epsilla_api_key,
1525
)
1626

1727
# Connect to Vectordb
18-
db = client.vectordb(db_id="6accafb1-476d-43b0-aa64-12ebfbf7441d")
28+
db_cloud = cloud_client.vectordb(db_id=db_id)
1929

2030

21-
# Create a table with schema
22-
status_code, response = db.create_table(
23-
table_name="MyTable",
24-
table_fields=[
25-
{"name": "ID", "dataType": "INT", "primaryKey": True},
26-
{"name": "Doc", "dataType": "STRING"},
27-
{"name": "Embedding", "dataType": "VECTOR_FLOAT", "dimensions": 4},
28-
],
29-
)
30-
print(status_code, response)
3131

32+
try:
33+
# Create a table with schema
34+
status_code, response = db.create_table(
35+
table_name="MyTable",
36+
table_fields=[
37+
{"name": "ID", "dataType": "INT", "primaryKey": True},
38+
{"name": "Doc", "dataType": "STRING"},
39+
{"name": "Embedding", "dataType": "VECTOR_FLOAT", "dimensions": 4},
40+
],
41+
)
42+
print(status_code, response)
43+
if status_code != 200:
44+
raise Exception("Failed to create table")
3245

33-
# Insert new vector records into table
34-
status_code, response = db.insert(
35-
table_name="MyTable",
36-
records=[
37-
{"ID": 1, "Doc": "Berlin", "Embedding": [0.05, 0.61, 0.76, 0.74]},
38-
{"ID": 2, "Doc": "London", "Embedding": [0.19, 0.81, 0.75, 0.11]},
39-
{"ID": 3, "Doc": "Moscow", "Embedding": [0.36, 0.55, 0.47, 0.94]},
40-
{"ID": 4, "Doc": "San Francisco", "Embedding": [0.18, 0.01, 0.85, 0.80]},
41-
{"ID": 5, "Doc": "Shanghai", "Embedding": [0.24, 0.18, 0.22, 0.44]},
42-
],
43-
)
44-
print(status_code, response)
46+
# Insert new vector records into table
47+
status_code, response = db.insert(
48+
table_name="MyTable",
49+
records=[
50+
{"ID": 1, "Doc": "Berlin", "Embedding": [0.05, 0.61, 0.76, 0.74]},
51+
{"ID": 2, "Doc": "London", "Embedding": [0.19, 0.81, 0.75, 0.11]},
52+
{"ID": 3, "Doc": "Moscow", "Embedding": [0.36, 0.55, 0.47, 0.94]},
53+
{"ID": 4, "Doc": "San Francisco", "Embedding": [0.18, 0.01, 0.85, 0.80]},
54+
{"ID": 5, "Doc": "Shanghai", "Embedding": [0.24, 0.18, 0.22, 0.44]},
55+
],
56+
)
57+
print(status_code, response)
58+
if status_code != 200:
59+
raise Exception("Failed to insert records")
60+
61+
# Query Vectors with specific response field, otherwise it will return all fields
62+
status_code, response = db.query(
63+
table_name="MyTable",
64+
query_field="Embedding",
65+
query_vector=[0.35, 0.55, 0.47, 0.94],
66+
response_fields=["Doc"],
67+
limit=2,
68+
)
69+
print(status_code, response)
70+
if status_code != 200:
71+
raise Exception("Failed to query table")
4572

46-
# Query Vectors with specific response field, otherwise it will return all fields
47-
status_code, response = db.query(
48-
table_name="MyTable",
49-
query_field="Embedding",
50-
query_vector=[0.35, 0.55, 0.47, 0.94],
51-
response_fields=["Doc"],
52-
limit=2,
53-
)
54-
print(status_code, response)
5573

74+
# Delete specific records from table
75+
status_code, response = db.delete(table_name="MyTable", primary_keys=[4, 5])
76+
print(status_code, response)
77+
if status_code != 200:
78+
raise Exception("Failed to delete records by primary keys")
5679

57-
# Delete specific records from table
58-
status_code, response = db.delete(table_name="MyTable", primary_keys=[4, 5])
59-
status_code, response = db.delete(table_name="MyTable", filter="Doc <> 'San Francisco'")
60-
print(status_code, response)
80+
status_code, response = db.delete(table_name="MyTable", filter="Doc <> 'San Francisco'")
81+
print(status_code, response)
82+
if status_code != 200:
83+
raise Exception("Failed to delete records by filter")
6184

62-
# Drop table
63-
status_code, response = db.drop_table(table_name="MyTable")
64-
print(status_code, response)
85+
# Drop table
86+
status_code, response = db.drop_table(table_name="MyTable")
87+
print(status_code, response)
88+
if status_code != 200:
89+
raise Exception("Failed to drop table")
90+
except Exception as e:
91+
print(f"An error occurred: {e}")
92+
sys.exit(1)

examples/hello_epsilla_rag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from pyepsilla import cloud
1010

11-
# Connect to Epsilla RAG
11+
# Connect to Epsilla RAG, conversation_id is not a must
1212
client = cloud.RAG(
1313
project_id="**********",
1414
api_key="eps_**********",

0 commit comments

Comments
 (0)