update message flow
Browse files- app/config.py +2 -2
- app/message_processor.py +4 -0
- app/reranker.py +4 -3
app/config.py
CHANGED
|
@@ -38,8 +38,8 @@ class Settings(BaseSettings):
|
|
| 38 |
log_level: str = os.getenv("LOG_LEVEL", "DEBUG") or "DEBUG"
|
| 39 |
|
| 40 |
# Search Configuration
|
| 41 |
-
match_count: int = int(os.getenv("MATCH_COUNT", "
|
| 42 |
-
max_docs_to_rerank: int = int(os.getenv("MAX_DOCS_TO_RERANK", "
|
| 43 |
|
| 44 |
# Gemini Configuration
|
| 45 |
# Hỗ trợ nhiều API key và model cho Gemini
|
|
|
|
| 38 |
log_level: str = os.getenv("LOG_LEVEL", "DEBUG") or "DEBUG"
|
| 39 |
|
| 40 |
# Search Configuration
|
| 41 |
+
match_count: int = int(os.getenv("MATCH_COUNT", "20")) or 20
|
| 42 |
+
max_docs_to_rerank: int = int(os.getenv("MAX_DOCS_TO_RERANK", "20")) or 20
|
| 43 |
|
| 44 |
# Gemini Configuration
|
| 45 |
# Hỗ trợ nhiều API key và model cho Gemini
|
app/message_processor.py
CHANGED
|
@@ -395,8 +395,12 @@ class MessageProcessor:
|
|
| 395 |
logger.info(f"[DEBUG] tạo embedding: {action}")
|
| 396 |
embedding = await self.channel.embedder.create_embedding(action)
|
| 397 |
logger.info(f"[DEBUG] embedding: {embedding[:5]} ... (total {len(embedding)})")
|
|
|
|
|
|
|
|
|
|
| 398 |
matches = self.channel.supabase.match_documents(
|
| 399 |
embedding,
|
|
|
|
| 400 |
# vehicle_keywords=keywords,
|
| 401 |
user_question=action
|
| 402 |
)
|
|
|
|
| 395 |
logger.info(f"[DEBUG] tạo embedding: {action}")
|
| 396 |
embedding = await self.channel.embedder.create_embedding(action)
|
| 397 |
logger.info(f"[DEBUG] embedding: {embedding[:5]} ... (total {len(embedding)})")
|
| 398 |
+
# Lấy match_count từ config
|
| 399 |
+
from app.config import get_settings
|
| 400 |
+
match_count = get_settings().match_count
|
| 401 |
matches = self.channel.supabase.match_documents(
|
| 402 |
embedding,
|
| 403 |
+
match_count=match_count,
|
| 404 |
# vehicle_keywords=keywords,
|
| 405 |
user_question=action
|
| 406 |
)
|
app/reranker.py
CHANGED
|
@@ -101,9 +101,10 @@ class Reranker:
|
|
| 101 |
# Không giới hạn content length, giữ nguyên nội dung luật
|
| 102 |
docs_content = []
|
| 103 |
for i, doc in enumerate(docs):
|
| 104 |
-
tieude = (doc.get('tieude') or '').strip()
|
| 105 |
-
noidung = (doc.get('noidung') or '').strip()
|
| 106 |
-
content = f"{tieude} {noidung}".strip()
|
|
|
|
| 107 |
docs_content.append(f"{i+1}. {content}")
|
| 108 |
|
| 109 |
batch_prompt = (
|
|
|
|
| 101 |
# Không giới hạn content length, giữ nguyên nội dung luật
|
| 102 |
docs_content = []
|
| 103 |
for i, doc in enumerate(docs):
|
| 104 |
+
# tieude = (doc.get('tieude') or '').strip()
|
| 105 |
+
# noidung = (doc.get('noidung') or '').strip()
|
| 106 |
+
# content = f"{tieude} {noidung}".strip()
|
| 107 |
+
content = (doc.get('fullcontent') or '').strip()
|
| 108 |
docs_content.append(f"{i+1}. {content}")
|
| 109 |
|
| 110 |
batch_prompt = (
|