Update app.py
Browse files
app.py
CHANGED
@@ -13,10 +13,8 @@ logging.basicConfig(level=logging.DEBUG)
|
|
13 |
def load_faiss_index(index_path):
|
14 |
"""
|
15 |
Load a FAISS index from a specified path.
|
16 |
-
|
17 |
Parameters:
|
18 |
- index_path (str): Path to the FAISS index file.
|
19 |
-
|
20 |
Returns:
|
21 |
- faiss.Index: Loaded FAISS index object.
|
22 |
"""
|
@@ -24,7 +22,6 @@ def load_faiss_index(index_path):
|
|
24 |
logging.error(f"FAISS index not found at {index_path}. Please create the index first.")
|
25 |
st.error(f"FAISS index not found at {index_path}. Please create the index first.")
|
26 |
raise FileNotFoundError(f"FAISS index not found at {index_path}.")
|
27 |
-
|
28 |
try:
|
29 |
logging.info(f"Attempting to load FAISS index from {index_path}.")
|
30 |
index = faiss.read_index(index_path)
|
@@ -57,10 +54,8 @@ def load_llm():
|
|
57 |
def process_answer(question):
|
58 |
"""
|
59 |
Process the user's question using the FAISS index and LLM.
|
60 |
-
|
61 |
Parameters:
|
62 |
- question (str): User's question to be processed.
|
63 |
-
|
64 |
Returns:
|
65 |
- str: The answer generated by the LLM.
|
66 |
"""
|
@@ -86,16 +81,13 @@ def process_answer(question):
|
|
86 |
|
87 |
def main():
|
88 |
st.title("Search Your PDF ππ")
|
89 |
-
|
90 |
with st.expander("About the App"):
|
91 |
st.markdown(
|
92 |
"""
|
93 |
This is a Generative AI powered Question and Answering app that responds to questions about your PDF File.
|
94 |
"""
|
95 |
)
|
96 |
-
|
97 |
question = st.text_area("Enter your Question")
|
98 |
-
|
99 |
if st.button("Ask"):
|
100 |
st.info("Your Question: " + question)
|
101 |
st.info("Your Answer")
|
@@ -107,4 +99,4 @@ def main():
|
|
107 |
st.error(f"An unexpected error occurred: {e}")
|
108 |
|
109 |
if __name__ == '__main__':
|
110 |
-
main()
|
|
|
13 |
def load_faiss_index(index_path):
|
14 |
"""
|
15 |
Load a FAISS index from a specified path.
|
|
|
16 |
Parameters:
|
17 |
- index_path (str): Path to the FAISS index file.
|
|
|
18 |
Returns:
|
19 |
- faiss.Index: Loaded FAISS index object.
|
20 |
"""
|
|
|
22 |
logging.error(f"FAISS index not found at {index_path}. Please create the index first.")
|
23 |
st.error(f"FAISS index not found at {index_path}. Please create the index first.")
|
24 |
raise FileNotFoundError(f"FAISS index not found at {index_path}.")
|
|
|
25 |
try:
|
26 |
logging.info(f"Attempting to load FAISS index from {index_path}.")
|
27 |
index = faiss.read_index(index_path)
|
|
|
54 |
def process_answer(question):
|
55 |
"""
|
56 |
Process the user's question using the FAISS index and LLM.
|
|
|
57 |
Parameters:
|
58 |
- question (str): User's question to be processed.
|
|
|
59 |
Returns:
|
60 |
- str: The answer generated by the LLM.
|
61 |
"""
|
|
|
81 |
|
82 |
def main():
|
83 |
st.title("Search Your PDF ππ")
|
|
|
84 |
with st.expander("About the App"):
|
85 |
st.markdown(
|
86 |
"""
|
87 |
This is a Generative AI powered Question and Answering app that responds to questions about your PDF File.
|
88 |
"""
|
89 |
)
|
|
|
90 |
question = st.text_area("Enter your Question")
|
|
|
91 |
if st.button("Ask"):
|
92 |
st.info("Your Question: " + question)
|
93 |
st.info("Your Answer")
|
|
|
99 |
st.error(f"An unexpected error occurred: {e}")
|
100 |
|
101 |
if __name__ == '__main__':
|
102 |
+
main()
|