Spaces:
Runtime error
Runtime error
Update processing.py
Browse files- processing.py +4 -4
processing.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
from langchain.schema import HumanMessage
|
2 |
from output_parser import attachment_parser, bigfive_parser, personality_parser
|
3 |
-
from
|
4 |
-
from
|
5 |
-
from langchain.retrievers import RetrievalQA
|
6 |
from llm_loader import load_model # Import the function to load the model
|
7 |
from config import openai_api_key # Import the API key from config.py
|
|
|
8 |
import os
|
9 |
|
10 |
# Initialize embeddings and FAISS index
|
@@ -37,7 +37,7 @@ faiss_index.save_local("faiss_index")
|
|
37 |
llm = load_model(openai_api_key) # Load the model using your custom loader
|
38 |
|
39 |
# Initialize the retrieval chain
|
40 |
-
qa_chain =
|
41 |
|
42 |
def load_text(file_path: str) -> str:
|
43 |
with open(file_path, 'r', encoding='utf-8') as file:
|
|
|
1 |
from langchain.schema import HumanMessage
|
2 |
from output_parser import attachment_parser, bigfive_parser, personality_parser
|
3 |
+
from langchain_community.embeddings import OpenAIEmbeddings
|
4 |
+
from langchain_community.vectorstores import FAISS
|
|
|
5 |
from llm_loader import load_model # Import the function to load the model
|
6 |
from config import openai_api_key # Import the API key from config.py
|
7 |
+
from langchain_community.chains import RetrievalQAChain # Assuming this is the updated class
|
8 |
import os
|
9 |
|
10 |
# Initialize embeddings and FAISS index
|
|
|
37 |
llm = load_model(openai_api_key) # Load the model using your custom loader
|
38 |
|
39 |
# Initialize the retrieval chain
|
40 |
+
qa_chain = RetrievalQAChain(llm=llm, retriever=faiss_index.as_retriever()) # Replace with the correct chain class
|
41 |
|
42 |
def load_text(file_path: str) -> str:
|
43 |
with open(file_path, 'r', encoding='utf-8') as file:
|