Spaces:
Runtime error
Runtime error
update app.py
Browse files
app.py
CHANGED
@@ -48,16 +48,11 @@ def display_chat_history():
|
|
48 |
message(st.session_state["past"][i], is_user=True, key=str(i) + '_user', avatar_style="thumbs")
|
49 |
message(st.session_state["generated"][i], key=str(i), avatar_style="fun-emoji")
|
50 |
|
51 |
-
def create_conversational_chain(vector_store, text_chunks
|
|
|
52 |
replicate_api_token = "r8_AA3K1fhDykqLa5M74E5V0w5ss1z0P9S3foWJl" # Replace with your actual token
|
53 |
os.environ["REPLICATE_API_TOKEN"] = replicate_api_token
|
54 |
|
55 |
-
print("Length of text_chunks:", len(text_chunks))
|
56 |
-
print("Content of text_chunks:", text_chunks)
|
57 |
-
|
58 |
-
print("Length of embeddings:", len(embeddings))
|
59 |
-
print("Content of embeddings:", embeddings)
|
60 |
-
|
61 |
llm = Replicate(
|
62 |
streaming=True,
|
63 |
model="replicate/llama-2-70b-chat:58d078176e02c219e11eb4da5a02a7830a283b14cf8f94537af893ccff5ee781",
|
@@ -102,10 +97,12 @@ def main():
|
|
102 |
text_splitter = CharacterTextSplitter(separator="\n", chunk_size=1000, chunk_overlap=100, length_function=len)
|
103 |
text_chunks = text_splitter.split_documents(text)
|
104 |
|
|
|
105 |
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2", model_kwargs={'device': 'cpu'})
|
106 |
vector_store = FAISS.from_documents(text_chunks, embedding=embeddings)
|
107 |
|
108 |
-
|
|
|
109 |
|
110 |
display_chat_history()
|
111 |
|
|
|
48 |
message(st.session_state["past"][i], is_user=True, key=str(i) + '_user', avatar_style="thumbs")
|
49 |
message(st.session_state["generated"][i], key=str(i), avatar_style="fun-emoji")
|
50 |
|
51 |
+
def create_conversational_chain(vector_store, text_chunks):
|
52 |
+
st.write("Text chunks lengths:", [len(chunk) for chunk in text_chunks]) # Add this line to print lengths
|
53 |
replicate_api_token = "r8_AA3K1fhDykqLa5M74E5V0w5ss1z0P9S3foWJl" # Replace with your actual token
|
54 |
os.environ["REPLICATE_API_TOKEN"] = replicate_api_token
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
llm = Replicate(
|
57 |
streaming=True,
|
58 |
model="replicate/llama-2-70b-chat:58d078176e02c219e11eb4da5a02a7830a283b14cf8f94537af893ccff5ee781",
|
|
|
97 |
text_splitter = CharacterTextSplitter(separator="\n", chunk_size=1000, chunk_overlap=100, length_function=len)
|
98 |
text_chunks = text_splitter.split_documents(text)
|
99 |
|
100 |
+
# Create embeddings
|
101 |
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2", model_kwargs={'device': 'cpu'})
|
102 |
vector_store = FAISS.from_documents(text_chunks, embedding=embeddings)
|
103 |
|
104 |
+
# Create the chain object
|
105 |
+
chain = create_conversational_chain(vector_store, text_chunks)
|
106 |
|
107 |
display_chat_history()
|
108 |
|