File size: 1,089 Bytes
66b3608
72a6b8a
a5c9751
303d925
 
 
 
 
 
a5c9751
303d925
a5c9751
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
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
36
import streamlit as st
from rag import RAGinit, RAG_proximity_search

# Wrap RAGinit() inside a function that shows a spinner
def load_resources():
    with st.spinner("Loading resources..."):
        client, model, emb, chroma_collection, vector_index_properties, top_n = RAGinit()
    return client, model, emb, chroma_collection, vector_index_properties, top_n

# Initialize everything once at startup
client, model, emb, chroma_collection, vector_index_properties, top_n = load_resources()

def main():
    st.title("RAG-based QA App")

    question = st.text_input("Ask a question:")
    
    if st.button("Search"):
        if question.strip():
            answer = RAG_proximity_search(
                question,
                client,
                model,
                emb,
                chroma_collection,
                vector_index_properties,
                top_n
            )
            st.markdown("**Answer:**")
            st.write(answer)
        else:
            st.warning("Please enter a question before searching.")

if __name__ == "__main__":
    main()