Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,39 +1,29 @@
|
|
1 |
-
import os
|
2 |
-
import getpass
|
3 |
-
|
4 |
-
import sentence_transformers
|
5 |
-
|
6 |
import streamlit as st
|
7 |
-
|
8 |
-
|
9 |
-
#
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
st.subheader("π Retrieved Context")
|
36 |
-
st.write(grounding)
|
37 |
-
|
38 |
-
st.subheader("π€ AI Response")
|
39 |
-
st.write(generated_response)
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
from RAG import RAGinit, RAG_proximity_search
|
3 |
+
|
4 |
+
# Initialize everything once at startup
|
5 |
+
client, model, emb, chroma_collection, vector_index_properties, top_n = RAGinit()
|
6 |
+
|
7 |
+
def main():
|
8 |
+
st.title("RAG-based QA App")
|
9 |
+
|
10 |
+
question = st.text_input("Ask a question:")
|
11 |
+
|
12 |
+
if st.button("Search"):
|
13 |
+
if question.strip():
|
14 |
+
answer = RAG_proximity_search(
|
15 |
+
question,
|
16 |
+
client,
|
17 |
+
model,
|
18 |
+
emb,
|
19 |
+
chroma_collection,
|
20 |
+
vector_index_properties,
|
21 |
+
top_n
|
22 |
+
)
|
23 |
+
st.markdown("**Answer:**")
|
24 |
+
st.write(answer)
|
25 |
+
else:
|
26 |
+
st.warning("Please enter a question before searching.")
|
27 |
+
|
28 |
+
if __name__ == "__main__":
|
29 |
+
main()
|
|
|
|
|
|
|
|
|
|