tutor-v7-diagram-kit: anchor short follow-ups to the previous question, new diagram pieces in the prompt

A real chat answered "what if 6 were 4?" with a semicircle problem from the
retrieved book excerpt instead of the parabola asked a moment before. A short
follow-up now carries the previous user question next to it. The catalog
teaches line equations as written, regularPolygon, exteriorAngle, graphs only
through function items and tangents through tangent; fraction words (یک‌پنجم،
نُه‌دهم) pull the fraction section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-29 02:37:50 +03:30
parent 14a4d9cbf1
commit 731dea9bb1
4 changed files with 85 additions and 10 deletions

View File

@@ -38,7 +38,7 @@ _RAW_MARKUP = re.compile(r'\\[A-Za-z(\[]|\$|\*\*|^\s*#{1,6}\s|^\s*\|\s*:?-{3,}',
# بشود گفت «کدام نسخه‌ی پرامپت جوابِ بهتری می‌داد» — بدونِ این، همه‌ی فیدبک‌ها
# در یک کاسه می‌ریزند و مقایسه‌ی نسخه‌ها ممکن نیست. کشِ پاسخ هم با همین نسخه
# کلید می‌خورد، پس جوابِ نسخه‌ی قبلی بعد از دیپلوی دوباره سرو نمی‌شود.
PROMPT_VERSION = 'tutor-v6-diagrams'
PROMPT_VERSION = 'tutor-v7-diagram-kit'
_PRIMARY = {'اول', 'دوم', 'سوم', 'چهارم', 'پنجم', 'ششم'}
_MIDDLE = {'هفتم', 'هشتم', 'نهم'}
@@ -178,6 +178,11 @@ _SLASH_READING = (
def _user_prompt(question: str, contexts: list[str], focus: str = '',
primary: bool = False, previous: str = '') -> str:
asked = f'سوالِ دانش‌آموز: {question}'
# سوالِ کوتاهِ ادامه‌ای («اگه به‌جای ۶ بذاریم ۴؟») بدونِ لنگر، مدل را سراغِ تکه‌ی کتابِ
# نامربوط می‌برد (چتِ واقعی، ۲۰۲۶-۰۹-۲۹: جوابِ یک «نیم‌دایره» به‌جای همان سهمی).
if previous and len(question) <= 80:
asked = (f'{asked}\n(این ادامه‌ی گفتگوست؛ سوالِ قبلیِ دانش‌آموز: «{previous[:300]}». '
'اگر به آن مربوط است، همان مسئله را با تغییرِ خواسته‌شده حل کن.)')
shape_hint = (diagram_mod.hint_for(f'{question}\n{focus}')
or diagram_mod.follow_up_hint_for(question, previous))
if shape_hint:
@@ -188,7 +193,7 @@ def _user_prompt(question: str, contexts: list[str], focus: str = '',
if focus:
asked = f'{focus}\n\n{asked}'
if not contexts:
return asked if (focus or slash_rule or shape_hint) else question
return asked if (focus or slash_rule or shape_hint or previous) else question
# این جمله برای کتاب‌های دبیرستان نوشته شده بود (۳/۱۰۴ = 3.104) ولی به همه
# می‌رفت، و gpt-4.1-mini با آن هر کسرِ دبستانی را ممیز می‌خواند.
slash_note = (