Spaces:
Runtime error
Runtime error
Update rag_engine.py
Browse files- rag_engine.py +7 -2
rag_engine.py
CHANGED
@@ -11,6 +11,11 @@ from langchain.docstore.document import Document
|
|
11 |
import pinecone
|
12 |
import chainlit as cl
|
13 |
from chainlit.types import AskFileResponse
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
pinecone.init(
|
16 |
api_key="2b6aa6bf-2e20-4445-a560-f7dd4952e59e",
|
@@ -19,7 +24,7 @@ pinecone.init(
|
|
19 |
|
20 |
index_name = "skandhaar"
|
21 |
text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
|
22 |
-
embeddings = OpenAIEmbeddings()
|
23 |
|
24 |
namespaces = set()
|
25 |
|
@@ -109,7 +114,7 @@ async def start():
|
|
109 |
)
|
110 |
|
111 |
chain = RetrievalQA.from_chain_type(
|
112 |
-
ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0, streaming=True, openai_api_key=
|
113 |
chain_type="stuff",
|
114 |
retriever=docsearch.as_retriever(),
|
115 |
return_source_documents=True,
|
|
|
11 |
import pinecone
|
12 |
import chainlit as cl
|
13 |
from chainlit.types import AskFileResponse
|
14 |
+
from dotenv import load_dotenv
|
15 |
+
load_dotenv()
|
16 |
+
|
17 |
+
openai_api_key = os.getenv("OPENAI_API_KEY")
|
18 |
+
|
19 |
|
20 |
pinecone.init(
|
21 |
api_key="2b6aa6bf-2e20-4445-a560-f7dd4952e59e",
|
|
|
24 |
|
25 |
index_name = "skandhaar"
|
26 |
text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
|
27 |
+
embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key)
|
28 |
|
29 |
namespaces = set()
|
30 |
|
|
|
114 |
)
|
115 |
|
116 |
chain = RetrievalQA.from_chain_type(
|
117 |
+
ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0, streaming=True, openai_api_key=openai_api_key),
|
118 |
chain_type="stuff",
|
119 |
retriever=docsearch.as_retriever(),
|
120 |
return_source_documents=True,
|