diginoron commited on
Commit
e4cb7b4
·
verified ·
1 Parent(s): 3f48f52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -16,11 +16,12 @@ pc = Pinecone(api_key="pcsk_6p6AmJ_Qua4tQN69badNHEGZTj3tt5Bd7LiyiDGcXDj92LxSaBzK
16
  index = pc.Index("tiyam-chat") # ایندکس از قبل ساخته‌شده
17
 
18
  # تابع پاسخ‌گو
19
- def retrieve_answer(query, threshold=0.4, top_k=1):
20
  query_embedding = model.encode([query])[0]
21
  result = index.query(vector=query_embedding.tolist(), top_k=top_k, include_metadata=True)
22
 
23
  if result['matches'] and result['matches'][0]['score'] > threshold:
 
24
  metadata = result['matches'][0]['metadata']
25
  return metadata.get('answer', 'پاسخ یافت نشد')
26
  else:
 
16
  index = pc.Index("tiyam-chat") # ایندکس از قبل ساخته‌شده
17
 
18
  # تابع پاسخ‌گو
19
+ def retrieve_answer(query, threshold=0.65, top_k=1):
20
  query_embedding = model.encode([query])[0]
21
  result = index.query(vector=query_embedding.tolist(), top_k=top_k, include_metadata=True)
22
 
23
  if result['matches'] and result['matches'][0]['score'] > threshold:
24
+ print(f"📊 Similarity: {result['matches'][0]['score']:.3f}")
25
  metadata = result['matches'][0]['metadata']
26
  return metadata.get('answer', 'پاسخ یافت نشد')
27
  else: