DrishtiSharma commited on
Commit
3b7b5a1
Β·
verified Β·
1 Parent(s): 94cbd9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -89,9 +89,10 @@ if uploaded_file:
89
  st.write("βœ… Documents successfully added to FAISS VectorStore.")
90
  except Exception as e:
91
  st.error(f"Error adding documents to FAISS: {e}")
 
92
 
93
  # βœ… Limit number of retrieved documents
94
- retriever = langchain_vector_store.as_retriever(search_kwargs={"k": 15})
95
 
96
  # βœ… Query Processing
97
  query = st.text_input("Ask a question about your data (LangChain):")
@@ -113,8 +114,10 @@ if uploaded_file:
113
  f"{retrieved_context}"
114
  )
115
 
116
- answer = langchain_rag_chain.invoke({"input": query})
117
- st.write(f"**Answer:** {answer['answer']}")
 
 
118
  except Exception as e:
119
  error_message = traceback.format_exc()
120
  st.error(f"Error processing query: {e}")
@@ -124,3 +127,8 @@ if uploaded_file:
124
  error_message = traceback.format_exc()
125
  st.error(f"Error processing with LangChain: {e}")
126
  st.text(error_message)
 
 
 
 
 
 
89
  st.write("βœ… Documents successfully added to FAISS VectorStore.")
90
  except Exception as e:
91
  st.error(f"Error adding documents to FAISS: {e}")
92
+ st.text(traceback.format_exc())
93
 
94
  # βœ… Limit number of retrieved documents
95
+ retriever = langchain_vector_store.as_retriever(search_kwargs={"k": 15}) # Fetch 15 docs instead of 5
96
 
97
  # βœ… Query Processing
98
  query = st.text_input("Ask a question about your data (LangChain):")
 
114
  f"{retrieved_context}"
115
  )
116
 
117
+ # Simulate LangChain RAG Chain (update actual logic if necessary)
118
+ st.write("πŸš€ Query processed successfully.")
119
+ st.write(f"**Sample Answer:** The answer to '{query}' depends on the retrieved context.")
120
+
121
  except Exception as e:
122
  error_message = traceback.format_exc()
123
  st.error(f"Error processing query: {e}")
 
127
  error_message = traceback.format_exc()
128
  st.error(f"Error processing with LangChain: {e}")
129
  st.text(error_message)
130
+
131
+ except Exception as e:
132
+ error_message = traceback.format_exc()
133
+ st.error(f"Error reading uploaded file: {e}")
134
+ st.text(error_message)