draw a diagram in tutor answers: validated JSON from the model, rendered by the app; add the fourth companion tedi

The model ends a shape question with <diagram>{json}</diagram>; rag/services/diagram.py
splits it off before mathtext, validates it against a whitelist and stores it on
Message.diagram (ai_tutor.0006). It reaches the app in the SSE done event and in
conversation history. Prompt tutor-v6-diagrams; a hint next to the question (shape
words only) raised gpt-4.1-mini from 3/12 to 12/12 diagrams, 0/8 on arithmetic.

progress.0005 adds tedi (600 xp) to the companion catalog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-28 17:44:44 +03:30
parent 74c3ee5e86
commit 33d8f43d74
10 changed files with 581 additions and 9 deletions

View File

@@ -35,6 +35,7 @@ class AskResponseSerializer(serializers.Serializer):
answer = serializers.CharField()
suggestedFollowUps = serializers.ListField(child=serializers.CharField())
remainingQuota = serializers.IntegerField()
diagram = serializers.DictField(required=False, allow_null=True)
# تکه‌های درسیِ بازیابی‌شده از Qdrant که پاسخ بر پایه‌شون ساخته شده؛
# خالی یعنی retrieval انجام نشده (نبودِ subject/lessonNumber یا خاموش‌بودنِ RAG).
usedChunks = UsedChunkSerializer(many=True, required=False, default=list)
@@ -46,6 +47,8 @@ class MessageSerializer(serializers.Serializer):
messageId = serializers.CharField()
role = serializers.CharField()
text = serializers.CharField()
# شکلِ پاسخ؛ شِمایش در rag/services/diagram.py (plane / numberline / fraction).
diagram = serializers.DictField(required=False, allow_null=True)
class ConversationMessagesResponseSerializer(serializers.Serializer):