remove dead RAG tutor module and stale config notes
rag/services/tutor.py
- deleted: answer_question() had no callers (AskAIView calls
retrieve_context + generate_answer directly) and carried an unused
import.
rag/services/config.py
- docstring: drop the claim that the lesson-filter key is settings-driven
(it is auto-selected per subject in known_collections.py).
.env.example
- drop the leftover note about the removed RAG_QDRANT_LESSON_FILTER_KEY.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
"""
|
||||
همخوانیِ نامِ collection و کلیدِ فیلترِ Qdrant با دادهٔ موجودِ تیمِ دیگر.
|
||||
تنظیماتِ RAG و همخوانیِ نامِ collection با دادهٔ موجودِ تیمِ دیگر.
|
||||
|
||||
در Rag_backend نامِ collection اینطور ساخته میشه:
|
||||
f"{subject.name} {subject.grade.title}".lower()
|
||||
و فیلترِ درس با کلیدِ payloadِ "lesson_number" (برای درسهای متنی) یا
|
||||
"chapter" (برای ریاضی) انجام میشه. اینجا هر دو از settings قابلِ تنظیمان
|
||||
چون اسمِ دقیقِ گرید حساسه (کاربر قبلاً با اسمِ نادرست به مشکل خورده بود).
|
||||
قالبِ نام و نگاشتِ گرید از settings قابلِ تنظیمان چون اسمِ دقیقِ گرید حساسه
|
||||
(کاربر قبلاً با اسمِ نادرست به مشکل خورده بود). کلیدِ فیلترِ درس/فصل خودکار
|
||||
از روی subject انتخاب میشه — نگاه کنید به rag/services/known_collections.py.
|
||||
"""
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
"""
|
||||
نقطهی ورودِ RAG برای ai_tutor.
|
||||
|
||||
ai_tutor.views.generate_tutor_answer وقتی rag_is_configured() باشه این را
|
||||
صدا میزنه؛ در غیرِ اینصورت به همون پاسخِ stubِ قبلی برمیگرده.
|
||||
"""
|
||||
import logging
|
||||
|
||||
from .config import rag_is_configured # noqa: F401 (re-export برای ai_tutor)
|
||||
from .generation import generate_answer
|
||||
from .retrieval import retrieve_context
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def answer_question(user_question: str, *, subject: str = '', grade_id=None,
|
||||
lesson_number=None) -> tuple[str, list[str], list[dict]]:
|
||||
"""
|
||||
خروجی: (answer, follow_ups, used_chunks)
|
||||
|
||||
used_chunks = [{title, summary, score}, ...] — ممکنه خالی باشه وقتی
|
||||
subject/lesson_number ارسال نشده یا اون درس هنوز در Qdrant نیست؛ در این
|
||||
حالت پاسخ بهصورتِ «تدریسِ عمومی» تولید میشه (بدونِ استناد به کتاب).
|
||||
|
||||
استثناهای شبکه/provider اینجا خفه نمیشن؛ لایهی بالا (AskAIView) اونها
|
||||
رو به 503 AIProviderUnavailable تبدیل میکنه.
|
||||
"""
|
||||
context, _meta = retrieve_context(
|
||||
user_question,
|
||||
subject=subject,
|
||||
grade_id=grade_id,
|
||||
lesson_number=lesson_number,
|
||||
)
|
||||
answer, follow_ups = generate_answer(user_question, context)
|
||||
return answer, follow_ups, context
|
||||
Reference in New Issue
Block a user