Anne31415 commited on
Commit
bfe0aa4
1 Parent(s): 2b39b13

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -525,17 +525,18 @@ def page3():
525
 
526
  # Query the CromA collection
527
  st.text("Querying CromA collection...") # Diagnostic print
 
528
  results = collection.query(
529
  query_texts=[full_query],
530
  n_results=5
531
  )
532
-
533
- st.text(f"Query results: {results}") # Diagnostic print
534
-
535
  # Process and display response from CromA results
536
- if results:
537
  try:
538
- response = f"Top result: {results[0]['text']}"
 
 
539
  except KeyError as ke:
540
  st.error(f"KeyError encountered: {ke}")
541
  response = "Error in processing the response."
 
525
 
526
  # Query the CromA collection
527
  st.text("Querying CromA collection...") # Diagnostic print
528
+ # Query the CromA collection
529
  results = collection.query(
530
  query_texts=[full_query],
531
  n_results=5
532
  )
533
+
 
 
534
  # Process and display response from CromA results
535
+ if results and results['documents']:
536
  try:
537
+ # Accessing the first document of the first result
538
+ top_document = results['documents'][0][0] # Adjusted access
539
+ response = f"Top result: {top_document}"
540
  except KeyError as ke:
541
  st.error(f"KeyError encountered: {ke}")
542
  response = "Error in processing the response."