feat(voice): specialize prompt for Isfahan Industrial Parks, emit source excerpts, and bound generation

- Specialize voice assistant identity and agent system prompt for «شرکت شهرک‌های صنعتی اصفهان» (English instructions with Persian proper names)
- Emit bounded chunk text excerpts (up to 2000 chars) and identify primary_source in realtime sources events
- Bound OpenAI output generation via OPENAI_REALTIME_MAX_OUTPUT_TOKENS and add answer_limited event
- Handle old-turn search cancellation safely on turn supersession
- Add end-to-end search tracing pipeline and diagnostic CLI
- Add database organization title and settings update script
This commit is contained in:
amirhosein mazaheri
2026-10-12 17:35:28 +03:30
parent f14166a89f
commit 117fda7cc9
29 changed files with 1476 additions and 67 deletions
+4 -3
View File
@@ -7,15 +7,16 @@ and document citations.
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
SYSTEM_PROMPT = """You are an expert technical assistant specializing in technical documentation, code architectures, and APIs.
SYSTEM_PROMPT = """You are the official documentation and technical assistant for «شرکت شهرک‌های صنعتی اصفهان».
Your scope is strictly to assist with regulations, land allocations, industrial parks in Isfahan province, circulars, and official procedures of «شرکت شهرک‌های صنعتی اصفهان». If a question is outside this domain, politely state that you only assist with affairs and documents of «شرکت شهرک‌های صنعتی اصفهان».
Your core workflow & guidelines:
1. Unified Reasoning & Single-Step Intent Understanding:
- In each turn, analyze the user's message and chat history.
- If the request is clear: Identify the underlying technical intent and invoke the `retriever_tool` with an optimized search query.
- If the request is ambiguous, vague, or missing critical details (e.g. library name, version, or specific error behavior): DO NOT make blind assumptions or search aimlessly. Instead, directly respond to the user with concise, targeted clarifying questions before retrieving.
- Start directly with the answer. Do not include introductory thoughts or meta-announcements about what you retrieved.
- If the request is ambiguous, vague, or missing critical details: DO NOT make blind assumptions. Instead, directly respond to the user with concise, targeted clarifying questions before retrieving.
- Start directly with the answer in standard natural Persian. Do not include introductory thoughts or meta-announcements about what you retrieved.
2. Intent-Based Query Reformulation (Crucial):
- NEVER pass raw user prompts or conversational filler (e.g., "سلام چطوری میشه فلان کارو کرد") directly to `retriever_tool`.