feat(nlu): clean up entity leakage and add generic Isfahan acoustic rules
This commit is contained in:
@@ -4,7 +4,6 @@ import logging
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Add project root to sys.path
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
|
||||
from app.config import settings
|
||||
@@ -14,6 +13,7 @@ from app.runtime import BotContext, LinkedUser
|
||||
from app.nlu import understand
|
||||
from app.handlers import quote
|
||||
from app.defaults import AUTHORIZED_USERS
|
||||
from app import drafts as draft_store
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s — %(message)s")
|
||||
logger = logging.getLogger("send_analysis")
|
||||
@@ -47,7 +47,12 @@ async def run():
|
||||
is_admin=user_info.get("is_admin", True),
|
||||
)
|
||||
|
||||
print("Sending transcripts to NLU (LLM) for multi-model consensus and entity extraction...")
|
||||
# Cancel previous active draft to ensure fresh card
|
||||
active = await draft_store.get_active(CHAT_ID)
|
||||
if active:
|
||||
await draft_store.set_status(active.id, "cancelled")
|
||||
|
||||
print("Sending transcripts to NLU (LLM) with upgraded Isfahan dialect prompt...")
|
||||
result = await understand(settings, TRANSCRIPTS)
|
||||
print("NLU Result:")
|
||||
print(json.dumps(result, ensure_ascii=False, indent=2))
|
||||
@@ -56,13 +61,13 @@ async def run():
|
||||
patch = result.get("patch") or {}
|
||||
|
||||
intro_msg = (
|
||||
f"🤖 **تحلیل هوشمند فایل صوتی (تجمیع خروجی چند مدل STT):**\n\n"
|
||||
f"📝 **متن استخراجشده و تصحیحشده (Consensus):**\n«{consensus_text}»\n\n"
|
||||
f"🤖 **تحلیل هوشمند فایل صوتی (تجمیع خروجی چند مدل با لحاظ لهجه اصفهانی):**\n\n"
|
||||
f"📝 **متن پالایششده و رسمی (Consensus):**\n«{consensus_text}»\n\n"
|
||||
f"📋 پیشنویس استعلام خرید با مشخصات استخراجشده صادر گردید:"
|
||||
)
|
||||
await ctx.send(CHAT_ID, intro_msg)
|
||||
|
||||
# Create and render the draft quote
|
||||
# Create and render the new draft quote
|
||||
await quote.handle_entities(
|
||||
ctx,
|
||||
CHAT_ID,
|
||||
|
||||
Reference in New Issue
Block a user