Abijith commited on
Commit
b771b75
·
verified ·
1 Parent(s): fcb1298

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -0
app.py CHANGED
@@ -148,6 +148,8 @@ if uploaded_files:
148
  classification = classifier(user_input,
149
  ["financial", "other"],
150
  multi_label=False)
 
 
151
  if classification['scores'][0] < 0.2:
152
  st.error("Query not related to financial. Ask about financial related queries")
153
  st.stop()
@@ -163,6 +165,7 @@ if uploaded_files:
163
  ranked_docs = [initial_docs[i] for i in sorted_indices]
164
  filtered_docs = [d for d, s in zip(ranked_docs, rerank_scores)
165
  if s > rerank_threshold][:7]
 
166
 
167
  # Confidence Calculation
168
  confidence_score = np.mean(rerank_scores[sorted_indices][:3]) * 100
@@ -170,6 +173,8 @@ if uploaded_files:
170
 
171
  # Response Generation
172
  context = "\n".join([doc.page_content for doc in filtered_docs])
 
 
173
  analysis = llm_chain.run(
174
  context=context,
175
  question=user_input
 
148
  classification = classifier(user_input,
149
  ["financial", "other"],
150
  multi_label=False)
151
+ print(f"-- Guard rail check is completed for query with prob:{classification['scores'][0]}")
152
+
153
  if classification['scores'][0] < 0.2:
154
  st.error("Query not related to financial. Ask about financial related queries")
155
  st.stop()
 
165
  ranked_docs = [initial_docs[i] for i in sorted_indices]
166
  filtered_docs = [d for d, s in zip(ranked_docs, rerank_scores)
167
  if s > rerank_threshold][:7]
168
+ print(f"-- Retrieved chunks:{filtered_docs}")
169
 
170
  # Confidence Calculation
171
  confidence_score = np.mean(rerank_scores[sorted_indices][:3]) * 100
 
173
 
174
  # Response Generation
175
  context = "\n".join([doc.page_content for doc in filtered_docs])
176
+ print(f"-- Retrieved context:{context}")
177
+
178
  analysis = llm_chain.run(
179
  context=context,
180
  question=user_input