diff --git a/data/benchmark.jsonl b/data/benchmark.jsonl index 2ca2150..97cbb5f 100644 --- a/data/benchmark.jsonl +++ b/data/benchmark.jsonl @@ -223,3 +223,36 @@ {"question": "Ders dosyaları hangi sayfada?", "expected_intent": "course_materials_info", "role": "ogrenci"} {"question": "Öğretmenin PDF dosyaları nerede?", "expected_intent": "course_materials_info", "role": "ogrenci"} {"question": "Ders notu dosyalarını nereden indiririm?", "expected_intent": "course_materials_info", "role": "ogrenci"} +{"question": "Nasıl randevu alabilirim", "expected_intent": "appointment_book", "role": "ogrenci"} +{"question": "Randevu almak için ne yapmalıyım", "expected_intent": "appointment_book", "role": "veli"} +{"question": "Yeni bir randevu talebi oluşturayım", "expected_intent": "appointment_book", "role": "ogrenci"} +{"question": "Öğrencilere randevu saatleri açmak istiyorum", "expected_intent": "appointment_slot_open", "role": "ogretmen"} +{"question": "Müsait saatlerimi nasıl yayınlarım", "expected_intent": "appointment_slot_open", "role": "ogretmen"} +{"question": "Randevu için boş saat eklemek istiyorum", "expected_intent": "appointment_slot_open", "role": "ogretmen"} +{"question": "Gelen randevu taleplerini nasıl onaylarım", "expected_intent": "appointment_requests", "role": "ogretmen"} +{"question": "Randevu isteklerini nereden yönetirim", "expected_intent": "appointment_requests", "role": "ogretmen"} +{"question": "Bir randevu talebini kabul etmek istiyorum", "expected_intent": "appointment_requests", "role": "ogretmen"} +{"question": "Yemek menüsünü nereden görebilirim", "expected_intent": "meal_view", "role": "ogrenci"} +{"question": "Öğün menüsünü görmek istiyorum", "expected_intent": "meal_view", "role": "veli"} +{"question": "Haftalık yemek listesi nerede", "expected_intent": "meal_view", "role": "ogrenci"} +{"question": "Öğle yemeği için yer ayırmak istiyorum", "expected_intent": "meal_book", "role": "ogrenci"} +{"question": "Menüden yemek rezerve etmek istiyorum", "expected_intent": "meal_book", "role": "veli"} +{"question": "Öğün için yer ayırtmak istiyorum", "expected_intent": "meal_book", "role": "ogrenci"} +{"question": "Yeni yemek menüsü yayınlamak istiyorum", "expected_intent": "meal_menu_manage", "role": "yonetici"} +{"question": "Öğüne yeni yemek eklemek istiyorum", "expected_intent": "meal_menu_manage", "role": "yonetici"} +{"question": "Öğrenci yemek kredisi girmek istiyorum", "expected_intent": "meal_menu_manage", "role": "yonetici"} +{"question": "Soru havuzunda soru sormak istiyorum", "expected_intent": "question_ask", "role": "ogrenci"} +{"question": "Takıldığım soruyu havuza nasıl sorarım", "expected_intent": "question_ask", "role": "ogrenci"} +{"question": "Soru havuzuna soru göndermek istiyorum", "expected_intent": "question_ask", "role": "ogrenci"} +{"question": "Zor bir soruya çözüm göndermek istiyorum", "expected_intent": "question_solve", "role": "ogrenci"} +{"question": "Bir soruya çözüm önerisi yapmak istiyorum", "expected_intent": "question_solve", "role": "ogrenci"} +{"question": "Havuzdaki soruyu çözmek istiyorum", "expected_intent": "question_solve", "role": "ogrenci"} +{"question": "Bekleyen havuz sorularını onaylayayım", "expected_intent": "question_approve", "role": "ogretmen"} +{"question": "Öğrenci sorularını nasıl onaylarım", "expected_intent": "question_approve", "role": "ogretmen"} +{"question": "Havuzdaki bir soruyu reddetmek istiyorum", "expected_intent": "question_approve", "role": "ogretmen"} +{"question": "Beyaz tahta listesini nereden görürüm", "expected_intent": "board_view", "role": "ogrenci"} +{"question": "Bir tahtayı nasıl açarım", "expected_intent": "board_view", "role": "ogrenci"} +{"question": "Var olan tahtaları nasıl görürüm", "expected_intent": "board_view", "role": "ogretmen"} +{"question": "Beyaz tahta oluşturmak istiyorum", "expected_intent": "board_create", "role": "ogrenci"} +{"question": "Yeni bir çizim tahtası oluşturayım", "expected_intent": "board_create", "role": "ogrenci"} +{"question": "Yeni beyaz tahta eklemek istiyorum", "expected_intent": "board_create", "role": "ogretmen"} diff --git a/src/catalog.py b/src/catalog.py index 5647169..0798576 100644 --- a/src/catalog.py +++ b/src/catalog.py @@ -1599,6 +1599,253 @@ INTENTS: Final[list[dict[str, Any]]] = [ ], "must_not_match": ["note_create", "report_card_view"], }, + # --- Randevu (T1; frontend /appointments, "Randevular" menüsü) ------------ + { + "intent": "appointment_book", + "category": "appointments", + "description": "Öğrenci/velinin randevu alması.", + "response_id": "appointment_book_instructions", + "response_template": ( + "Randevu almak için **Planlama** grubundaki **Randevular** " + "(`/appointments`) sayfasına git. **Öğretmenlerin açık saatleri** " + "bölümünden uygun saati seç, **Randevu al**'a bas. Talebin " + "**Randevularım** altında görünür ve öğretmen onayına düşer. Randevu " + "alma yalnızca Öğrenci ve Veli'ye açıktır." + ), + "auth_required": True, + "min_role": "veli", + "example_questions": [ + "Randevu nasıl alırım?", + "Öğretmenden randevu almak istiyorum", + "Randevu talebi oluşturmak istiyorum", + "Görüşme randevusu talep etmek istiyorum", + "Randevu alma nerede?", + ], + "must_not_match": ["appointment_slot_open", "appointment_requests"], + }, + { + "intent": "appointment_slot_open", + "category": "appointments", + "description": "Öğretmenin müsait randevu saati açması (Öğretmen+).", + "response_id": "appointment_slot_instructions", + "response_template": ( + "**Randevular** (`/appointments`) → **Açtığım " + "saatler** bölümünde **Saat aç** (veya **Yeni saat**) ile müsait " + "randevu saati yayınla. Öğrenci ve veliler bu saatlerden randevu talep " + "eder; gelen talepleri **Randevu talepleri**'nden yönetirsin." + ), + "auth_required": True, + "min_role": "ogretmen", + "example_questions": [ + "Randevu saati nasıl açarım?", + "Öğrencilere müsait saat yayınlamak istiyorum", + "Randevu için saat açma nerede?", + "Müsaitlik saati eklemek istiyorum", + "Öğrencilere randevu saati açmak istiyorum", + ], + "must_not_match": ["appointment_book", "appointment_requests"], + }, + { + "intent": "appointment_requests", + "category": "appointments", + "description": "Öğretmenin randevu taleplerini onaylaması (Öğretmen+).", + "response_id": "appointment_requests_instructions", + "response_template": ( + "**Randevular** (`/appointments`) → **Randevu " + "talepleri** bölümünde gelen talepleri görürsün; her talepte **Onayla** " + "ile kabul et (gerekirse reddet). Onaylanan randevu, ilgili öğrenci/" + "velinin **Randevularım**'ında görünür." + ), + "auth_required": True, + "min_role": "ogretmen", + "example_questions": [ + "Randevu taleplerini nasıl onaylarım?", + "Gelen randevu isteklerini nerede görürüm?", + "Randevu talebini kabul etmek istiyorum", + "Öğrenci randevu talebini onaylama", + "Randevu isteklerini yönetmek istiyorum", + ], + "must_not_match": ["appointment_book", "appointment_slot_open"], + }, + # --- Yemek (T1; frontend /meals, "Yemekler" menüsü) ----------------------- + { + "intent": "meal_view", + "category": "meals", + "description": "Yemek menülerini/rezervasyon durumunu görüntüleme.", + "response_id": "meal_view_info", + "response_template": ( + "Yemek menülerini **Okul hizmetleri** grubundaki **Yemekler** " + "(`/meals`) sayfasından görürsün. Günün **Menü** ve **Öğün**lerini, " + "rezervasyon durumunu (**Rezerve edildi** / **Rezervasyon yok**) " + "görebilirsin. Detay için menü kartına bas (`/meals/$id`)." + ), + "auth_required": True, + "min_role": "veli", + "example_questions": [ + "Yemek menüsü nerede?", + "Yemek menüsünü görmek istiyorum", + "Yemekler sayfası nerede?", + "Öğün menüsü nerede?", + "Yemek listesi nerede?", + ], + "must_not_match": ["meal_book", "meal_menu_manage"], + }, + { + "intent": "meal_book", + "category": "meals", + "description": "Öğün için yer ayırma/iptal (Öğrenci/Veli).", + "response_id": "meal_book_instructions", + "response_template": ( + "Yemek için yer ayırmak üzere **Yemekler** (`/meals`) → ilgili menü/" + "öğüne gir, **Yer ayır**'a bas. Rezervasyonun **Rezerve edildi** olarak " + "görünür; **Rezervasyonu iptal et** ile geri alabilirsin. Yer ayırma " + "Öğrenci (kendisi) ve Veli'ye (bağlı çocuğu) açıktır." + ), + "auth_required": True, + "min_role": "veli", + "example_questions": [ + "Yemek için yer ayırmak istiyorum", + "Öğün rezervasyonu nasıl yapılır?", + "Yer ayırma nerede?", + "Yemek rezervasyonu yapmak istiyorum", + "Yemek rezervasyonumu iptal etmek istiyorum", + ], + "must_not_match": ["meal_view", "meal_menu_manage"], + }, + { + "intent": "meal_menu_manage", + "category": "meals", + "description": "Menü/öğün/kredi yönetimi (Yönetici+).", + "response_id": "meal_menu_instructions", + "response_template": ( + "**Yemekler** (`/meals`) → **Menü yayınla** ile " + "yeni menü/öğün oluştur, **Yemek ekle** ile öğüne yemek ekle. Öğrenci " + "**Kredi** yönetimi için **Kredi kaydet** kullanılır. Menü ve kredi " + "yönetimi yalnızca Yönetici ve ADMIN'e açıktır." + ), + "auth_required": True, + "min_role": "yonetici", + "example_questions": [ + "Menü nasıl yayınlarım?", + "Yeni menü oluşturmak istiyorum", + "Öğüne yemek eklemek istiyorum", + "Yemek kredisi nasıl kaydedilir?", + "Kredi kaydetme nerede?", + ], + "must_not_match": ["meal_book", "meal_view"], + }, + # --- Soru havuzu (T1; frontend /questions "Soru havuzu"; sınav "Soru + # bankası"/question-bank'ten AYRI. Veli havuzdan hariç) -------------------- + { + "intent": "question_ask", + "category": "questions", + "description": "Soru havuzuna soru sorma (Öğrenci+, Veli hariç).", + "response_id": "question_ask_instructions", + "response_template": ( + "**Topluluk** grubundaki **Soru havuzu** (`/questions`) sayfasına git. " + "**Soru sor**'a bas; **Konu**, **Soru detayı** ve isteğe bağlı **Görsel** " + "ekleyip gönder. Sorun önce **Bekliyor** durumundadır; bir öğretmen " + "onaylayınca **Onaylandı** olur ve herkese görünür. Soru havuzu Öğrenci " + "ve üstüne açıktır (Veli hariç)." + ), + "auth_required": True, + "min_role": "ogrenci", + "example_questions": [ + "Soru havuzuna nasıl soru sorarım?", + "Soru havuzu nedir?", + "Havuza yeni soru sormak istiyorum", + "Soru havuzunda soru sorma nerede?", + "Soru havuzuna bir soru sormak istiyorum", + ], + "must_not_match": ["question_solve", "question_approve", "exam_add_question"], + }, + { + "intent": "question_solve", + "category": "questions", + "description": "Havuzdaki bir soruya çözüm gönderme (Öğrenci+).", + "response_id": "question_solve_instructions", + "response_template": ( + "Bir soruya çözüm göndermek için **Soru havuzu** (`/questions`) → soruyu " + "aç (`/questions/$id`) → **Çözümler** bölümünde **Çözüm gönder** ile " + "çözümünü yaz ve paylaş. Çözüm gönderme Öğrenci ve üstüne açıktır." + ), + "auth_required": True, + "min_role": "ogrenci", + "example_questions": [ + "Bir soruya nasıl çözüm gönderirim?", + "Çözüm önermek istiyorum", + "Soruya çözüm yazmak istiyorum", + "Çözüm paylaşmak istiyorum", + "Soruyu nasıl çözerim?", + ], + "must_not_match": ["question_ask", "question_approve"], + }, + { + "intent": "question_approve", + "category": "questions", + "description": "Havuzdaki soruları onaylama/reddetme (Öğretmen+).", + "response_id": "question_approve_instructions", + "response_template": ( + "**Soru havuzu** (`/questions`) → soru detayında " + "**Onayla** ile bekleyen soruyu yayınla, gerekirse **Reddet**. Onaylanan " + "soru **Onaylandı** olur ve herkese görünür. Onaylama Öğretmen ve üstüne açıktır." + ), + "auth_required": True, + "min_role": "ogretmen", + "example_questions": [ + "Havuzdaki soruları nasıl onaylarım?", + "Bekleyen soruları onaylamak istiyorum", + "Öğrenci sorusunu reddetmek istiyorum", + "Soru onaylama nerede?", + "Havuzdaki soruları onaylamak istiyorum", + ], + "must_not_match": ["question_ask", "question_solve"], + }, + # --- Beyaz tahta (T1; frontend /whiteboards "Beyaz tahtalar"; Veli hariç) -- + { + "intent": "board_view", + "category": "boards", + "description": "Beyaz tahtaları görüntüleme/açma (Öğrenci+, Veli hariç).", + "response_id": "board_view_info", + "response_template": ( + "Beyaz tahtaları **Çalışma alanı** grubundaki **Beyaz tahtalar** " + "(`/whiteboards`) sayfasından görürsün. Bir tahtayı açmak için kartında " + "**Aç**'a bas (`/whiteboards/$id`); katılımcılar eşzamanlı çizer. Beyaz " + "tahtalar Öğrenci ve üstüne açıktır (Veli hariç)." + ), + "auth_required": True, + "min_role": "ogrenci", + "example_questions": [ + "Beyaz tahtalar nerede?", + "Var olan bir tahtayı nasıl açarım?", + "Beyaz tahta sayfası nerede?", + "Tahtaları nereden görürüm?", + "Ortak çalışma tahtaları nerede?", + ], + "must_not_match": ["board_create"], + }, + { + "intent": "board_create", + "category": "boards", + "description": "Yeni beyaz tahta oluşturma (Öğrenci+, Veli hariç).", + "response_id": "board_create_instructions", + "response_template": ( + "Yeni beyaz tahta için **Beyaz tahtalar** (`/whiteboards`) → **Yeni tahta** " + "ile **Başlık** gir, isteğe bağlı **Katılımcılar** ekle, oluştur. Tahta " + "içinde **Kilitle/Kilidi aç**, **Temizle** ve **Tahtayı kapat** kontrolleri " + "vardır; Öğretmen+ **Toplu davet** ile sınıf/etkinlik katılımcısı çağırabilir." + ), + "auth_required": True, + "min_role": "ogrenci", + "example_questions": [ + "Yeni beyaz tahta nasıl oluştururum?", + "Yeni tahta oluşturmak istiyorum", + "Beyaz tahta eklemek istiyorum", + "Tahta oluşturma nerede?", + "Yeni bir tahta oluşturmak istiyorum", + ], + "must_not_match": ["board_view"], + }, ] @@ -1609,6 +1856,12 @@ RULE_ONLY_INTENTS: Final[frozenset[str]] = frozenset({ "fees_info", "branches_info", "calendar_info", "today_info", "question_bank_info", "notification_settings_info", "nav_overview", "event_view", "exam_schedule_info", "course_materials_info", + # T1 özellikleri: kural-tetikli; örnek soruları similarity/domain havuzuna + # ALINMAZ (yeni intent'ler TF-IDF/OOS'u kirletmesin — coverage intent'leri gibi). + "appointment_book", "appointment_slot_open", "appointment_requests", + "meal_view", "meal_book", "meal_menu_manage", + "question_ask", "question_solve", "question_approve", + "board_view", "board_create", }) @@ -1697,6 +1950,18 @@ INTENT_ROUTES: Final[dict[str, str | None]] = { "event_view": "/events", "exam_schedule_info": "/exams", "course_materials_info": "/courses", + # T1 özellikleri (frontend rotalarıyla birebir) + "appointment_book": "/appointments", + "appointment_slot_open": "/appointments", + "appointment_requests": "/appointments", + "meal_view": "/meals", + "meal_book": "/meals", + "meal_menu_manage": "/meals", + "question_ask": "/questions", + "question_solve": "/questions", + "question_approve": "/questions", + "board_view": "/whiteboards", + "board_create": "/whiteboards", } # Yol -> arayüzde görünen sayfa adı (buton etiketi için). Rehber §4'teki TR etiketler. @@ -1708,6 +1973,10 @@ ROUTE_LABELS: Final[dict[str, str]] = { "/exams": "Sınavlar", "/homework": "Ödevler", "/events": "Etkinlikler", + "/appointments": "Randevular", + "/meals": "Yemekler", + "/questions": "Soru havuzu", + "/whiteboards": "Beyaz tahtalar", "/marks": "Karnem", "/attendance": "Yoklama", "/notes": "Defter", diff --git a/src/engine.py b/src/engine.py index edfdda5..eff0e58 100644 --- a/src/engine.py +++ b/src/engine.py @@ -346,32 +346,8 @@ def _unavailable_feature(query: str) -> str | None: return None -# Üründe MEVCUT olan (frontend'de tam sayfa) ama chatbot kataloğunda ayrı intent'i -# olmayan özellikler -> doğru bilgi + sayfa butonu (yanlış "aktif değil" demez). -# (folded_anahtar, path, Başlık, açıklama) -_FEATURE_INFO: tuple[tuple[str, str, str, str], ...] = ( - ("randevu", "/appointments", "Randevular", - "Randevular sayfasında öğretmenler görüşme saatleri (slot) açar; öğrenci/veli " - "uygun saate randevu alır. Randevular onaylanır, ertelenir ya da iptal edilir."), - ("yemek", "/meals", "Yemekler", - "Yemekler sayfasında günlük yemek menüsü görüntülenir ve yemek rezervasyonu yapılır."), - ("beyaz tahta", "/whiteboards", "Beyaz tahtalar", - "Beyaz tahtalar sayfasında ortak çalışma için beyaz tahta oluşturup üzerinde " - "çizim ve not paylaşabilirsin."), - ("tahta", "/whiteboards", "Beyaz tahtalar", - "Beyaz tahtalar sayfasında ortak çalışma için beyaz tahta oluşturup üzerinde " - "çizim ve not paylaşabilirsin."), -) - - -def _feature_info(query: str) -> tuple[str, dict[str, Any]] | None: - """Mevcut ama ayrı intent'i olmayan özellik -> (açıklama, sayfa butonu).""" - - low = query.casefold() - for keyword, path, label, desc in _FEATURE_INFO: - if keyword in low: - return desc, {"route": path, "label": label, "available": True} - return None +# (T1 özellikleri — randevu/yemek/beyaz tahta/soru havuzu — artık gerçek intent'lerdir; +# eski _FEATURE_INFO stopgap'i kaldırıldı, boru hattı bunları normal karşılar.) # --- Kapsam sınırı: canlı VERİ çekme isteği --------------------------------- @@ -493,8 +469,11 @@ _TOPIC_HELP: tuple[tuple[str, str], ...] = ( ("takvim", "takvim nerede"), ("defter", "defterlerim nerede"), ("pomodoro", "pomodoro nedir"), - ("soru", "soru bankası nedir"), ("mesaj", "mesaj nasıl gönderirim"), + # T1: 'randevu/yemek/tahta ne işe yarar' -> ilgili T1 intent'ine götür + ("randevu", "randevu nasıl alırım"), + ("yemek", "yemek menüsü nerede"), + ("tahta", "beyaz tahtalar nerede"), ("yoklama", "yoklamam nerede"), ("devamsiz", "devamsızlığımı nasıl görürüm"), ) @@ -1053,27 +1032,6 @@ class Engine: if not pure_negation and _neg_resolved != effective_query: effective_query = _neg_resolved - # 1.56) Üründe MEVCUT ama ayrı intent'i olmayan özellik (randevu/yemek/beyaz - # tahta) -> doğru bilgi + sayfa butonu (yanlış "aktif değil" DEMEZ). - _feat = _feature_info(effective_query) - if _feat is not None: - _feat_text, _feat_nav = _feat - return _attach_assistant_meta({ - "trace_id": trace_id, - "response_id": "feature_info", - "text": _with_brand_note(_feat_text, query), - "intent": None, - "confidence": 1.0, - "fallback": False, - "auth_action": None, - "required_role": None, - "navigation": _feat_nav, - "clarification": None, - "answers": None, - "suggestions": suggestions, - "safety": safety_info, - }, role) - # 1.57) Henüz canlı olmayan/bulunmayan özellik -> yanlış yönlendirme YOK, # dürüstçe "henüz kullanılamıyor" (intent None, nav yok). _unavail = _unavailable_feature(effective_query) diff --git a/src/role_spaces.py b/src/role_spaces.py index 3b71ad8..b0c51e2 100644 --- a/src/role_spaces.py +++ b/src/role_spaces.py @@ -87,6 +87,20 @@ _ACTION_RULES: Final[dict[str, dict[str, tuple[AccessOutcome, AccessScope | None "school.settings_manage": _matrix((D, None, None), (D, None, None), (D, None, None), (A, S, "school_settings"), (A, S, "school_settings")), "school.terms_manage": _matrix((D, None, None), (D, None, None), (D, None, None), (A, S, "school_terms"), (A, S, "school_terms")), "users.roles_manage": _matrix((D, None, None), (D, None, None), (D, None, None), (D, None, None), (A, S, "admin_users")), + # --- T1 özellikleri --- + # Randevu: alma yalnız Öğrenci+Veli (backend: Student|Parent); saat açma/talep + # onaylama Öğretmen+. + "appointments.book": _matrix((A, O, "appointments"), (A, O, "appointments"), (D, None, None), (D, None, None), (D, None, None)), + "appointments.manage": _matrix((D, None, None), (D, None, None), (A, O, "appointments"), (A, S, "appointments"), (A, S, "appointments")), + # Yemek: menü görüntüleme herkese; yer ayırma Öğrenci(self)+Veli; menü/kredi Yönetici+. + "meals.view": _matrix((A, O, "meals"), (A, O, "meals"), (A, O, "meals"), (A, S, "meals"), (A, S, "meals")), + "meals.book": _matrix((A, O, "meals"), (A, O, "meals"), (D, None, None), (D, None, None), (D, None, None)), + "meals.manage": _matrix((D, None, None), (D, None, None), (D, None, None), (A, S, "meals"), (A, S, "meals")), + # Soru havuzu: sorma/çözme Öğrenci+ (Veli hariç); onaylama Öğretmen+ (moderatör). + "qpool.participate": _matrix((D, None, None), (A, O, "questions"), (A, O, "questions"), (A, S, "questions"), (A, S, "questions")), + "qpool.moderate": _matrix((D, None, None), (D, None, None), (A, M, "questions"), (A, S, "questions"), (A, S, "questions")), + # Beyaz tahta: görüntüleme/oluşturma Öğrenci+ (Veli hariç). + "boards.use": _matrix((D, None, None), (A, O, "whiteboards"), (A, O, "whiteboards"), (A, S, "whiteboards"), (A, S, "whiteboards")), } _ACTION_BY_INTENT: Final[dict[str, str]] = { @@ -158,6 +172,18 @@ _ACTION_BY_INTENT: Final[dict[str, str]] = { "event_view": "platform.help", "exam_schedule_info": "platform.help", "course_materials_info": "platform.help", + # T1 özellikleri + "appointment_book": "appointments.book", + "appointment_slot_open": "appointments.manage", + "appointment_requests": "appointments.manage", + "meal_view": "meals.view", + "meal_book": "meals.book", + "meal_menu_manage": "meals.manage", + "question_ask": "qpool.participate", + "question_solve": "qpool.participate", + "question_approve": "qpool.moderate", + "board_view": "boards.use", + "board_create": "boards.use", } _OWN_REPORT_RESPONSES: Final[dict[str, str]] = { diff --git a/src/rules.py b/src/rules.py index 890529a..375325c 100644 --- a/src/rules.py +++ b/src/rules.py @@ -366,10 +366,9 @@ _RAW_RULES: Final[list[dict[str, Any]]] = [ {"all": ["bugün", "panel"]}, {"all": ["ana", "panel"]}, ]}, {"intent": "question_bank_info", "groups": [ + # Yalnız 'soru bankası' (sınav şablon deposu). 'Soru havuzu' AYRI bir özellik + # (/questions, question_ask) -> ona bırakılır (havuz burada YOK). {"all": ["soru", "banka"]}, - # 'soru havuzu' = soru bankası (halk dilinde); tek 'havuz' okul bağlamında da - # soru havuzunu ifade eder -> question_bank_info. - {"all": ["soru", "havuz"]}, {"all": ["havuz"]}, ]}, {"intent": "notification_settings_info", "groups": [ {"all": ["bildirim"]}, @@ -394,6 +393,72 @@ _RAW_RULES: Final[list[dict[str, Any]]] = [ {"all": ["ders", "not", "pdf"]}, {"all": ["ders", "not", "dosya"]}, {"all": ["öğretmen", "pdf"]}, {"all": ["ders", "dosya"], "none": ["defter"]}, ]}, + # --- T1: Randevu (al=öğrenci/veli, saat aç=öğretmen, onayla=öğretmen) --- + {"intent": "appointment_book", "groups": [ + {"all": ["randevu", "al"], "none": [ + "saat", "onayla", "talepleri", "kabul", "reddet", "istek"]}, + {"all": ["randevu", "talep", "oluştur"]}, + {"all": ["randevu", "talep", "et"], "none": ["kabul", "onayla", "reddet"]}, + # "Randevular nerede" = randevu sayfası (öğrenci/veli için randevu alma). + {"all": ["randevu", "nerede"], "none": ["saat", "onayla", "talepleri"]}, + ]}, + {"intent": "appointment_slot_open", "groups": [ + {"all": ["randevu", "saat"]}, + {"all": ["müsait", "saat"]}, + {"all": ["müsait", "yayınla"]}, + ]}, + {"intent": "appointment_requests", "groups": [ + {"all": ["randevu", "onayla"]}, {"all": ["randevu", "kabul"]}, + {"all": ["randevu", "reddet"]}, {"all": ["randevu", "istek"]}, + {"all": ["randevu", "talepleri"]}, + ]}, + # --- T1: Yemek (menü görüntüle=view, yer ayır=book, yayınla/kredi=manage) --- + {"intent": "meal_view", "groups": [ + {"all": ["yemek", "menü"], "none": [ + "yayınla", "ekle", "oluştur", "kredi", "ayır", "rezerv"]}, + {"all": ["öğün", "menü"]}, + {"all": ["yemek", "liste"]}, + {"all": ["yemek", "nerede"], "none": ["yer", "rezerv", "yayınla", "ekle", "kredi"]}, + ]}, + {"intent": "meal_book", "groups": [ + {"all": ["yer", "ayır"]}, + {"all": ["yemek", "rezerv"]}, + {"all": ["öğün", "rezerv"]}, + ]}, + {"intent": "meal_menu_manage", "groups": [ + {"all": ["menü", "yayınla"]}, + {"all": ["menü", "oluştur"]}, + {"all": ["yemek", "ekle"], "none": ["yer"]}, + {"all": ["yemek", "kredi"]}, {"all": ["kredi", "kaydet"]}, + ]}, + # --- T1: Soru havuzu (sor=ask, çöz=solve, onayla=approve; sınav soru ekle'den ayrı) --- + {"intent": "question_ask", "groups": [ + # 'onayla/reddet/çöz' varsa approve/solve'a bırak (soru+havuz onlarda da var). + {"all": ["soru", "havuz"], "none": ["onayla", "reddet", "çöz", "çözüm", "bekleyen"]}, + {"all": ["havuz", "soru"], "none": ["onayla", "reddet", "çöz", "çözüm", "bekleyen"]}, + ]}, + {"intent": "question_solve", "groups": [ + {"all": ["çözüm", "gönder"]}, {"all": ["çözüm", "öner"]}, + {"all": ["çözüm", "paylaş"]}, {"all": ["çözüm", "yaz"]}, + {"all": ["soru", "çöz"]}, + ]}, + {"intent": "question_approve", "groups": [ + {"all": ["soru", "onayla"], "none": ["banka"]}, + {"all": ["soru", "reddet"]}, + {"all": ["bekleyen", "soru"]}, {"all": ["havuz", "onayla"]}, + ]}, + # --- T1: Beyaz tahta (aç/nerede=view, oluştur/yeni=create) --- + {"intent": "board_view", "groups": [ + {"all": ["tahta", "aç"]}, + {"all": ["tahta", "nerede"], "none": ["oluştur", "yeni", "ekle"]}, + {"all": ["beyaz", "tahta"], "none": ["oluştur", "yeni", "ekle"]}, + {"all": ["tahta", "gör"]}, + ]}, + {"intent": "board_create", "groups": [ + {"all": ["tahta", "oluştur"]}, + {"all": ["yeni", "tahta"]}, + {"all": ["tahta", "ekle"]}, + ]}, ] diff --git a/tests/e2e/test_behavior_matrix.py b/tests/e2e/test_behavior_matrix.py index 1aa24be..f873bbb 100644 --- a/tests/e2e/test_behavior_matrix.py +++ b/tests/e2e/test_behavior_matrix.py @@ -112,6 +112,18 @@ INTENT_MATRIX: list[tuple[str, str, str]] = [ ("ogrenci", "etkinlikleri nerede görürüm", "event_view"), ("ogrenci", "sınav tarihleri nerede yazıyor", "exam_schedule_info"), ("ogrenci", "ders notları ve öğretmenin yüklediği pdf nerede", "course_materials_info"), + # --- T1 özellikleri --- + ("ogrenci", "öğretmenden randevu almak istiyorum", "appointment_book"), + ("ogretmen", "randevu saatlerimi açmak istiyorum", "appointment_slot_open"), + ("ogretmen", "gelen randevu taleplerini onaylamak istiyorum", "appointment_requests"), + ("ogrenci", "yemek menüsünü nereden görürüm", "meal_view"), + ("ogrenci", "öğün için yer ayırmak istiyorum", "meal_book"), + ("yonetici", "yeni yemek menüsü yayınlamak istiyorum", "meal_menu_manage"), + ("ogrenci", "soru havuzuna soru sormak istiyorum", "question_ask"), + ("ogrenci", "bir soruya çözüm göndermek istiyorum", "question_solve"), + ("ogretmen", "havuzdaki soruları onaylamak istiyorum", "question_approve"), + ("ogrenci", "beyaz tahtalar nerede", "board_view"), + ("ogrenci", "yeni beyaz tahta oluşturmak istiyorum", "board_create"), ] diff --git a/tests/integration/test_edge_cases.py b/tests/integration/test_edge_cases.py index 6df8733..99e3e01 100644 --- a/tests/integration/test_edge_cases.py +++ b/tests/integration/test_edge_cases.py @@ -179,19 +179,30 @@ class TopicHelpAndFeatureInfoTests(unittest.TestCase): def test_specific_howto_not_hijacked(self) -> None: self.assertEqual(ask("etkinlik nasıl oluştururum", "ogretmen")["intent"], "event_create") - def test_existing_features_not_marked_unavailable(self) -> None: - for q in ["randevular nerede", "yemek menüsü nasıl", "beyaz tahta ne işe yarar", - "soru havuzu ne işe yarar"]: + def test_t1_features_have_real_intents(self) -> None: + # T1 özellikleri artık gerçek intent (feature_info stopgap kalktı); doğru + # role'de intent + buton verir, ASLA "aktif değil" demez. + for q, role, intent in [ + ("randevu nasıl alırım", "ogrenci", "appointment_book"), + ("yemek menüsü nerede", "ogrenci", "meal_view"), + ("beyaz tahta nasıl oluştururum", "ogrenci", "board_create"), + ("soru havuzuna nasıl soru sorarım", "ogrenci", "question_ask"), + ]: with self.subTest(q=q): - r = ask(q, "ogretmen") + r = ask(q, role) + self.assertEqual(r["intent"], intent) self.assertNotIn("aktif değil", r["text"]) - self.assertNotIn("kullanılamıyor", r["text"]) self.assertIsNotNone(r["navigation"]) - def test_question_pool_is_question_bank(self) -> None: - r = ask("soru havuzu sayfasını açmak istiyorum", "ogretmen") - self.assertEqual(r["intent"], "question_bank_info") - self.assertEqual(r["navigation"]["route"], "/question-bank") + def test_question_pool_vs_question_bank_distinct(self) -> None: + # 'Soru havuzu' (/questions, topluluk) ile 'Soru bankası' (/question-bank, + # sınav) AYRI özelliklerdir — karışmaz. + pool = ask("soru havuzuna nasıl soru sorarım", "ogrenci") + self.assertEqual(pool["intent"], "question_ask") + self.assertEqual(pool["navigation"]["route"], "/questions") + bank = ask("soru bankası nedir", "ogretmen") + self.assertEqual(bank["intent"], "question_bank_info") + self.assertEqual(bank["navigation"]["route"], "/question-bank") class KnownLimitTests(unittest.TestCase):