Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -326,7 +326,25 @@ query = st.text_input("What are you looking for?")
|
|
| 326 |
|
| 327 |
if query:
|
| 328 |
results = st.session_state.engine.search_documents(query, top_k=5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 329 |
st.subheader("Top Relevant Documents")
|
|
|
|
| 330 |
if not results: st.info("No documents found.")
|
| 331 |
for res in results:
|
| 332 |
score = res['score']
|
|
|
|
| 326 |
|
| 327 |
if query:
|
| 328 |
results = st.session_state.engine.search_documents(query, top_k=5)
|
| 329 |
+
|
| 330 |
+
# --- LLM INTEGRATION START ---
|
| 331 |
+
if results:
|
| 332 |
+
# We grab the text from the #1 result to feed the AI
|
| 333 |
+
top_match = results[0]
|
| 334 |
+
top_context = f"Source: {top_match['source']}\nContent: {top_match['snippet']}"
|
| 335 |
+
|
| 336 |
+
# Create a container for the AI Answer
|
| 337 |
+
with st.container():
|
| 338 |
+
st.markdown("### 🤖 AI Summary")
|
| 339 |
+
if st.button("✨ Summarize Top Result"):
|
| 340 |
+
with st.spinner("Reading document..."):
|
| 341 |
+
ai_response = ask_llm(query, top_context)
|
| 342 |
+
st.success(ai_response)
|
| 343 |
+
st.divider()
|
| 344 |
+
# --- LLM INTEGRATION END ---
|
| 345 |
+
|
| 346 |
st.subheader("Top Relevant Documents")
|
| 347 |
+
|
| 348 |
if not results: st.info("No documents found.")
|
| 349 |
for res in results:
|
| 350 |
score = res['score']
|