Update app.py
Browse files
app.py
CHANGED
@@ -50,13 +50,10 @@ def retrieve_context(query, embed_model, index, df, k=3):
|
|
50 |
# Ask the Groq LLM
|
51 |
def ask_groq(query, context):
|
52 |
prompt = f"""You are a helpful assistant. Use the context to answer the question.
|
53 |
-
|
54 |
Context:
|
55 |
{context}
|
56 |
-
|
57 |
Question:
|
58 |
{query}
|
59 |
-
|
60 |
Answer:"""
|
61 |
|
62 |
response = client.chat.completions.create(
|
@@ -74,11 +71,11 @@ st.subheader("π Ask your question")
|
|
74 |
sample_queries = df['query'].dropna().unique().tolist()
|
75 |
col1, col2 = st.columns([3, 1])
|
76 |
with col1:
|
77 |
-
query = st.text_input("Enter your question here:")
|
78 |
with col2:
|
79 |
if st.button("π² Random Sample"):
|
80 |
-
query = random.choice(sample_queries)
|
81 |
-
st.
|
82 |
|
83 |
# Handle query
|
84 |
if query:
|
|
|
50 |
# Ask the Groq LLM
|
51 |
def ask_groq(query, context):
|
52 |
prompt = f"""You are a helpful assistant. Use the context to answer the question.
|
|
|
53 |
Context:
|
54 |
{context}
|
|
|
55 |
Question:
|
56 |
{query}
|
|
|
57 |
Answer:"""
|
58 |
|
59 |
response = client.chat.completions.create(
|
|
|
71 |
sample_queries = df['query'].dropna().unique().tolist()
|
72 |
col1, col2 = st.columns([3, 1])
|
73 |
with col1:
|
74 |
+
query = st.text_input("Enter your question here:", value=st.session_state.get("query", ""))
|
75 |
with col2:
|
76 |
if st.button("π² Random Sample"):
|
77 |
+
st.session_state["query"] = random.choice(sample_queries)
|
78 |
+
st.rerun()
|
79 |
|
80 |
# Handle query
|
81 |
if query:
|