BaRiDo commited on
Commit
a5c9751
Β·
verified Β·
1 Parent(s): 96e47ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -38
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
- # Streamlit UI
10
- st.title("πŸ” IBM Watson RAG Chatbot")
11
-
12
- # User input in Streamlit
13
- question = st.text_input("Enter your question:")
14
-
15
- if question:
16
- # Retrieve relevant grounding context
17
- grounding = RAG_proximity_search(question)
18
-
19
- # Format the question with retrieved context
20
- formatted_question = f"""<|start_of_role|>user<|end_of_role|>Use the following pieces of context to answer the question.
21
-
22
- {grounding}
23
-
24
- Question: {question}<|end_of_text|>
25
- <|start_of_role|>assistant<|end_of_role|>"""
26
-
27
- # Placeholder for a prompt input (Optional)
28
- prompt_input = "" # Set this dynamically if needed
29
- prompt = f"""{prompt_input}{formatted_question}"""
30
-
31
- # Simulated AI response (Replace with actual model call)
32
- generated_response = f"AI Response based on: {prompt}"
33
-
34
- # Display results
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()