Sathvika-Alla commited on
Commit
52f3d08
·
verified ·
1 Parent(s): 02b86d2

improved FAQ retrival

Browse files
Files changed (1) hide show
  1. plugins/chatMemoryPlugin.py +9 -3
plugins/chatMemoryPlugin.py CHANGED
@@ -31,12 +31,18 @@ class ChatMemoryPlugin:
31
  self.logger.error(f"Failed to log SQL query: {str(e)}")
32
 
33
 
34
- async def get_semantic_faqs(self, limit:int=5, threshold: float = 0.1) -> List[Dict]:
 
35
  """Retrieve FAQs using vector embeddings for semantic similarity"""
36
  try:
37
- faqs_dict = await self.chat_memory_handler.get_semantic_faqs(limit=limit, threshold=threshold)
38
  faqs = [faq["representative_question"] for faq in faqs_dict]
39
- self.logger.info(faqs)
 
 
 
 
 
40
  except Exception as e:
41
  self.logger.error(f"Semantic FAQ retrieval failed: {str(e)}")
42
  return []
 
31
  self.logger.error(f"Failed to log SQL query: {str(e)}")
32
 
33
 
34
+ @kernel_function(name="get_semantic_faqs")
35
+ async def get_semantic_faqs(self, limit:int=6, threshold: float = 0.1) -> List[str]:
36
  """Retrieve FAQs using vector embeddings for semantic similarity"""
37
  try:
38
+ faqs_dict = await self.chat_memory_handler.get_semantic_faqs(limit=limit+5, threshold=threshold)
39
  faqs = [faq["representative_question"] for faq in faqs_dict]
40
+
41
+ # Remove duplicates while preserving order
42
+ unique_faqs = list(dict.fromkeys(faqs))
43
+
44
+ self.logger.info(unique_faqs)
45
+ return unique_faqs[:limit]
46
  except Exception as e:
47
  self.logger.error(f"Semantic FAQ retrieval failed: {str(e)}")
48
  return []