Spaces:
Runtime error
Runtime error
Update rag.py
Browse files
rag.py
CHANGED
@@ -13,8 +13,6 @@ from langchain.chains import ConversationalRetrievalChain
|
|
13 |
import os
|
14 |
import csv
|
15 |
|
16 |
-
import api_key
|
17 |
-
|
18 |
def read_csv_to_dict(filename):
|
19 |
data_dict = {}
|
20 |
with open(filename, mode='r', encoding='utf-8') as file:
|
@@ -44,8 +42,7 @@ def generate_embeddings_and_vectorstore(path):
|
|
44 |
#print('docs')
|
45 |
#print(docs)
|
46 |
|
47 |
-
|
48 |
-
fc_embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key)
|
49 |
vectorstore = Chroma.from_documents(docs, fc_embeddings)
|
50 |
|
51 |
return vectorstore
|
@@ -74,7 +71,7 @@ class Rag:
|
|
74 |
self.qa = ConversationalRetrievalChain.from_llm(
|
75 |
llm=ChatOpenAI(model_name="gpt-3.5-turbo",
|
76 |
temperature=0.3,
|
77 |
-
openai_api_key=
|
78 |
max_tokens=int(int(max_words) + (int(max_words) / 2))), #número máximo de tokens para a resposta
|
79 |
memory=self.memory,
|
80 |
retriever=vectorstore.as_retriever(), #search_kwargs={'k': 3}
|
|
|
13 |
import os
|
14 |
import csv
|
15 |
|
|
|
|
|
16 |
def read_csv_to_dict(filename):
|
17 |
data_dict = {}
|
18 |
with open(filename, mode='r', encoding='utf-8') as file:
|
|
|
42 |
#print('docs')
|
43 |
#print(docs)
|
44 |
|
45 |
+
fc_embeddings = OpenAIEmbeddings(openai_api_key=OPENAI_KEY)
|
|
|
46 |
vectorstore = Chroma.from_documents(docs, fc_embeddings)
|
47 |
|
48 |
return vectorstore
|
|
|
71 |
self.qa = ConversationalRetrievalChain.from_llm(
|
72 |
llm=ChatOpenAI(model_name="gpt-3.5-turbo",
|
73 |
temperature=0.3,
|
74 |
+
openai_api_key=OPENAI_KEY,
|
75 |
max_tokens=int(int(max_words) + (int(max_words) / 2))), #número máximo de tokens para a resposta
|
76 |
memory=self.memory,
|
77 |
retriever=vectorstore.as_retriever(), #search_kwargs={'k': 3}
|