Spaces:
Sleeping
Sleeping
Update CosmosDBHandlers/cosmosChatHistoryHandler.py
Browse files
CosmosDBHandlers/cosmosChatHistoryHandler.py
CHANGED
|
@@ -104,7 +104,7 @@ class ChatMemoryHandler():
|
|
| 104 |
except Exception as e:
|
| 105 |
self.logger.error(f"Failed to log SQL query: {str(e)}")
|
| 106 |
|
| 107 |
-
async def get_semantic_faqs(self, limit: int =
|
| 108 |
"""Retrieve FAQs using vector embeddings for semantic similarity"""
|
| 109 |
try:
|
| 110 |
query = """
|
|
@@ -116,7 +116,6 @@ class ChatMemoryHandler():
|
|
| 116 |
max_item_count=-1
|
| 117 |
))
|
| 118 |
|
| 119 |
-
# Group by question in Python
|
| 120 |
from collections import Counter
|
| 121 |
question_counts = Counter(item['question'] for item in raw_results)
|
| 122 |
top_questions = question_counts.most_common(limit)
|
|
|
|
| 104 |
except Exception as e:
|
| 105 |
self.logger.error(f"Failed to log SQL query: {str(e)}")
|
| 106 |
|
| 107 |
+
async def get_semantic_faqs(self, limit: int = 6, threshold: float = 0.1) -> List[Dict]:
|
| 108 |
"""Retrieve FAQs using vector embeddings for semantic similarity"""
|
| 109 |
try:
|
| 110 |
query = """
|
|
|
|
| 116 |
max_item_count=-1
|
| 117 |
))
|
| 118 |
|
|
|
|
| 119 |
from collections import Counter
|
| 120 |
question_counts = Counter(item['question'] for item in raw_results)
|
| 121 |
top_questions = question_counts.most_common(limit)
|