Skip to content

Commit f8c992c

Browse files
committed
update
1 parent 3f30ac0 commit f8c992c

File tree

4 files changed

+33
-24
lines changed

4 files changed

+33
-24
lines changed

examples/Question_Answering_Pipeline_with_LangChain_and_Epsilla.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
# Step2. Configure the OpenAI API Key
1818
import os
19+
1920
os.environ["OPENAI_API_KEY"] = "Your-OpenAI-API-Key"
2021

2122

@@ -24,9 +25,13 @@
2425
from langchain.text_splitter import CharacterTextSplitter
2526
from langchain_openai import OpenAIEmbeddings
2627

27-
loader = WebBaseLoader("https://raw.githubusercontent.com/hwchase17/chat-your-data/master/state_of_the_union.txt")
28+
loader = WebBaseLoader(
29+
"https://raw.githubusercontent.com/hwchase17/chat-your-data/master/state_of_the_union.txt"
30+
)
2831
documents = loader.load()
29-
documents = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0).split_documents(documents)
32+
documents = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0).split_documents(
33+
documents
34+
)
3035
embeddings = OpenAIEmbeddings()
3136

3237

@@ -49,8 +54,6 @@
4954
)
5055

5156

52-
53-
5457
# Step4. Create the QA for Retrieval
5558
from langchain.chains import RetrievalQA
5659
from langchain_openai import OpenAI

examples/Question_Answering_Pipeline_with_LangChain_and_EpsillaCloud.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,55 +18,61 @@
1818
import os
1919

2020
os.environ["OPENAI_API_KEY"] = "Your-OpenAI-API-Key"
21-
epsilla_api_key = os.getenv("EPSILLA_API_KEY", "Your-Epsilla-API-Key")
22-
project_id = os.getenv("EPSILLA_PROJECT_ID", "Your-Project-ID")
23-
db_id = os.getenv("EPSILLA_DB_ID", "Your-DB-ID")
24-
db_sharding_id = os.getenv("EPSILLA_DB_SHARDING_ID", 0)
2521

22+
EPSILLA_PROJECT_ID = os.getenv("EPSILLA_PROJECT_ID", "Your-Epsilla-Project-ID")
23+
EPSILLA_API_KEY = os.getenv("EPSILLA_API_KEY", "Your-Epsilla-API-Key")
24+
EPSILLA_DB_ID = os.getenv("EPSILLA_DB_ID", "Your-Epsilla-DB-ID")
25+
EPSILLA_DB_SHARDING_ID = os.getenv("EPSILLA_DB_SHARDING_ID", 0)
26+
27+
TABLE_NAME = os.getenv("TABLE_NAME", "MyTable")
28+
29+
db_name = f"db_{EPSILLA_DB_ID.replace('-', '_')}"
30+
db_path = f"/data/{EPSILLA_PROJECT_ID}/{db_name}/s{EPSILLA_DB_SHARDING_ID}"
31+
32+
33+
from langchain.text_splitter import CharacterTextSplitter
2634

2735
# Step3. Load the documents
2836
from langchain_community.document_loaders import WebBaseLoader
29-
from langchain.text_splitter import CharacterTextSplitter
3037
from langchain_openai import OpenAIEmbeddings
3138

32-
loader = WebBaseLoader("https://raw.githubusercontent.com/hwchase17/chat-your-data/master/state_of_the_union.txt")
39+
loader = WebBaseLoader(
40+
"https://raw.githubusercontent.com/hwchase17/chat-your-data/master/state_of_the_union.txt"
41+
)
3342
documents = loader.load()
34-
documents = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0).split_documents(documents)
43+
documents = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0).split_documents(
44+
documents
45+
)
3546
embeddings = OpenAIEmbeddings()
3647

3748

3849
# Step4. Load the vector store
3950
from langchain_community.vectorstores import Epsilla
4051
from pyepsilla import cloud
4152

42-
db_name = f"db_{db_id.replace('-', '_')}"
43-
db_path = f"/data/{project_id}/{db_name}/s{db_sharding_id}"
44-
table_name = "MyCollection"
45-
4653
# Step4.1 Connect to Epsilla Cloud
4754
cloud_client = cloud.Client(
48-
project_id=project_id,
49-
api_key=epsilla_api_key,
55+
project_id=EPSILLA_PROJECT_ID,
56+
api_key=EPSILLA_API_KEY,
5057
)
5158

5259
# Step4.2 Connect to Vectordb
53-
db_client = cloud_client.vectordb(db_id)
60+
db_client = cloud_client.vectordb(EPSILLA_DB_ID)
5461

5562
vector_store = Epsilla.from_documents(
5663
documents,
5764
embeddings,
5865
db_client,
5966
db_path=db_path,
6067
db_name=db_name,
61-
collection_name=table_name,
68+
collection_name=TABLE_NAME,
6269
)
6370

6471
# query = "What did the president say about Ketanji Brown Jackson"
6572
# docs = vector_store.similarity_search(query)
6673
# print(docs[0].page_content)
6774

6875

69-
7076
# Step5. Create the QA for Retrieval
7177
from langchain.chains import RetrievalQA
7278
from langchain_openai import OpenAI

examples/hello_epsilla_cloud.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111

1212
from pyepsilla import cloud
1313

14-
EPSILLA_PROJECT_ID = os.getenv("EPSILLA_PROJECT_ID", "Your-Project-ID")
14+
EPSILLA_PROJECT_ID = os.getenv("EPSILLA_PROJECT_ID", "Your-Epsilla-Project-ID")
1515
EPSILLA_API_KEY = os.getenv("EPSILLA_API_KEY", "Your-Epsilla-API-Key")
1616

17-
DB_ID = os.getenv("DB_ID", "Your-DB-ID")
17+
DB_ID = os.getenv("EPSILLA_DB_ID", "Your-Epsilla-DB-ID")
1818
DB_NAME = os.getenv("DB_NAME", "MyDB")
1919
DB_PATH = os.getenv("DB_PATH", "/tmp/epsilla_demo")
2020
TABLE_NAME = os.getenv("TABLE_NAME", "MyTable")
2121

2222

2323
if not EPSILLA_PROJECT_ID or not EPSILLA_API_KEY or not DB_ID:
2424
print(
25-
"Please set the environment variables: EPSILLA_PROJECT_ID, EPSILLA_API_KEY, DB_ID"
25+
"Please set the environment variables: EPSILLA_PROJECT_ID, EPSILLA_API_KEY, EPSILLA_DB_ID"
2626
)
2727
sys.exit(1)
2828

examples/hello_epsilla_rag.py

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

1111
from pyepsilla import cloud
1212

13-
EPSILLA_PROJECT_ID = os.getenv("EPSILLA_PROJECT_ID", "Your-Project-ID")
13+
EPSILLA_PROJECT_ID = os.getenv("EPSILLA_PROJECT_ID", "Your-Epsilla-Project-ID")
1414
EPSILLA_API_KEY = os.getenv("EPSILLA_API_KEY", "Your-Epsilla-API-Key")
1515
EPSILLA_RAGAPP_ID = os.getenv("EPSILLA_RAGAPP_ID", "Your-Epsilla-RAGAPP-ID")
1616
EPSILLA_CONVERSATION_ID = os.getenv("EPSILLA_CONVERSATION_ID", None)

0 commit comments

Comments
 (0)