Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -97,43 +97,3 @@ if uploaded_file:
|
|
97 |
# Maintain and display the chat history
|
98 |
message(st.session_state["generated"][i], key=str(i), avatar_style="thumbs")
|
99 |
|
100 |
-
# Split the text into Chunks
|
101 |
-
text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=20)
|
102 |
-
text_chunks = text_splitter.split_documents(data)
|
103 |
-
|
104 |
-
|
105 |
-
# COnverting the text Chunks into embeddings and saving the embeddings into FAISS Knowledge Base
|
106 |
-
docsearch = FAISS.from_documents(text_chunks, embeddings)
|
107 |
-
|
108 |
-
docsearch.save_local(DB_FAISS_PATH)
|
109 |
-
|
110 |
-
|
111 |
-
#query = "What is the value of GDP per capita of Finland provided in the data?"
|
112 |
-
|
113 |
-
#docs = docsearch.similarity_search(query, k=3)
|
114 |
-
|
115 |
-
#print("Result", docs)
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
qa = ConversationalRetrievalChain.from_llm(llm, retriever=docsearch.as_retriever())
|
120 |
-
|
121 |
-
# Insert a chat message container.
|
122 |
-
with st.chat_message("user"):
|
123 |
-
st.write("Hello 👋")
|
124 |
-
st.line_chart(np.random.randn(30, 3))
|
125 |
-
|
126 |
-
# Display a chat input widget.
|
127 |
-
st.chat_input("Say something")
|
128 |
-
|
129 |
-
while True:
|
130 |
-
chat_history = []
|
131 |
-
#query = "What is the value of GDP per capita of Finland provided in the data?"
|
132 |
-
query = input(f"Input Prompt: ")
|
133 |
-
if query == 'exit':
|
134 |
-
print('Exiting')
|
135 |
-
sys.exit()
|
136 |
-
if query == '':
|
137 |
-
continue
|
138 |
-
result = qa({"question":query, "chat_history":chat_history})
|
139 |
-
print("Response: ", result['answer'])
|
|
|
97 |
# Maintain and display the chat history
|
98 |
message(st.session_state["generated"][i], key=str(i), avatar_style="thumbs")
|
99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|