eagle0504 commited on
Commit
9b13d7e
1 Parent(s): 1166206

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -151,7 +151,16 @@ if prompt := st.chat_input("Tell me about YSA"):
151
  "distances": results["distances"][0]
152
  }
153
  )
154
- ref_from_db_search = ref["answers"]
 
 
 
 
 
 
 
 
 
155
 
156
  engineered_prompt = f"""
157
  Based on the context: {ref_from_db_search},
 
151
  "distances": results["distances"][0]
152
  }
153
  )
154
+ special_threshold = 0.3
155
+ filtered_ref = ref[ref["distances"] < special_threshold]
156
+ if filtered_ref.shape[0] > 0:
157
+ st.success("There are highly relevant information in our database.")
158
+ ref_from_db_search = filtered_ref["answers"]
159
+ final_ref = filtered_ref
160
+ else:
161
+ st.warning("The database may not have relevant information to help your question so please be aware of hallucinations.")
162
+ ref_from_db_search = ref["answers"]
163
+ final_ref = ref
164
 
165
  engineered_prompt = f"""
166
  Based on the context: {ref_from_db_search},