Cok-korpus yonlendirme + cok-turlu rewrite baglandi + sozlesme siniri
Browse files at this commit7ed0a396c38843751c317d2a59391936d363aafbParent: 08e44ec- feat
- cok-korpus yonlendirme + cok-turlu rewrite baglandi + sozlesme siniri
7 changed files +593 -3
- .env.example +6 -0
- docs/API-CONTRACT.md +28 -0
- outputs/deployment/suite.log +183 -0
- src/service/http_app.py +14 -1
- src/service/registry.py +153 -0
- tests/unit/test_registry.py +193 -0
- tests/unit/test_service.py +16 -2
.env.examplemodified+6 -0
| @@ -129,3 +129,9 @@ HEZARFEN_DELETION_LOG= | |||
| 129 | # ornekleme oraninden BAGIMSIZ olarak HER ZAMAN yazilir. | 129 | # ornekleme oraninden BAGIMSIZ olarak HER ZAMAN yazilir. |
| 130 | HEZARFEN_TRACE_PATH= | 130 | HEZARFEN_TRACE_PATH= |
| 131 | HEZARFEN_TRACE_SAMPLE=1.0 | 131 | HEZARFEN_TRACE_SAMPLE=1.0 |
| 132 | + | ||
| 133 | +# --- Cok-turlu rewrite (#87, EXP-010/OPS-14) --- | ||
| 134 | +# API-CONTRACT `history` alanini vaat ediyordu ama kod onu SESSIZCE ATIYORDU | ||
| 135 | +# (build_service hic rewriter gecirmiyordu). Artik bagli. | ||
| 136 | +# Maliyet: gecmisli her soruda BIR EK LLM cagrisi (~$0.0002). | ||
| 137 | +RAG_REWRITE_HISTORY=1 | ||
docs/API-CONTRACT.mdmodified+28 -0
| @@ -12,6 +12,34 @@ header/body'sinden körü körüne alınmaz** (RES-002 §2, RES-003 §7: RagArt' | |||
| 12 | buydu). Kasa izolasyonu (öğrenci yalnız kendi sınıf/dersini görür) bu role'e dayanır; | 12 | buydu). Kasa izolasyonu (öğrenci yalnız kendi sınıf/dersini görür) bu role'e dayanır; |
| 13 | yanlış role = veri sızıntısı. RAG `role`'ü olduğu gibi uygular, doğrulamaz. | 13 | yanlış role = veri sızıntısı. RAG `role`'ü olduğu gibi uygular, doğrulamaz. |
| 14 | 14 | ||
| 15 | +## 0. Sorumluluk sınırı — kim neyi yapar (#87, 2026-09-12) | ||
| 16 | + | ||
| 17 | +Denetimde (OPS-16) şu tespit edildi: bu sözleşme backend'e *"kaynak yükleme/ | ||
| 18 | +indeksleme tetikleme"*, *"kalıcılık"*, *"rate limit / maliyet tavanı"* diyordu | ||
| 19 | +ama **RAG deposu bunları yapacak arayüzü sunmuyordu** → iki ekip birbirini | ||
| 20 | +bekliyordu. Sınır şöyle netleştirildi: | ||
| 21 | + | ||
| 22 | +| iş | kim | bu depoda durum | | ||
| 23 | +|---|---|---| | ||
| 24 | +| Kaynağın sahipliği, yetkisi, yaşam döngüsü (oluştur/sil) | **backend** | — | | ||
| 25 | +| Chunk + vektör + sparse indeksin kurulması | **RAG** | var (`build_service`) | | ||
| 26 | +| **Kaynak silme → chunk/vektör/cache kaskadı** | **RAG** | var (`src/corpus/deletion.py`, #76) | | ||
| 27 | +| Kaynak sürümü → cache geçersizleştirme | **RAG** | var (`corpus_version`, #77) | | ||
| 28 | +| Oran sınırı (kullanıcı bazlı) | **backend** | RAG'da ikinci katman var (#50) | | ||
| 29 | +| Maliyet tavanı (kullanıcı/kurum) | **her ikisi** | RAG'da var (#79) | | ||
| 30 | +| Atıf tıklanınca ACL yeniden kontrolü | **backend** | RAG kaynak kimliğini döndürür | | ||
| 31 | +| Çok-turlu rewrite | **RAG** | **artık bağlı** (#87/OPS-14) | | ||
| 32 | + | ||
| 33 | +**Not (OPS-14):** `history` alanı sözleşmede duruyordu ama `build_service` hiç | ||
| 34 | +`rewriter` geçirmediği için üretimde **sessizce atılıyordu**. Bağlandı; | ||
| 35 | +`RAG_REWRITE_HISTORY=0` ile kapatılabilir (geçmişli her soruda bir ek LLM | ||
| 36 | +çağrısı, ~$0,0002). | ||
| 37 | + | ||
| 38 | +**Henüz yok:** `POST /rag/ingest` ve `DELETE /rag/sources/{id}` HTTP uçları. | ||
| 39 | +Silme/indeksleme mantığı hazır (`src/corpus/deletion.py`) ama HTTP yüzeyi | ||
| 40 | +köprü sözleşmesine bağlı (#95) — backend RAG'ı QUIC köprüsüyle çağırıyor, | ||
| 41 | +HTTP ile değil. Köprü yeteneği tanımlanınca eklenecek. | ||
| 42 | + | ||
| 15 | ## 1. POST /rag/chat — kaynakla konuşma (soru-cevap) | 43 | ## 1. POST /rag/chat — kaynakla konuşma (soru-cevap) |
| 16 | 44 | ||
| 17 | **İstek:** | 45 | **İstek:** |
outputs/deployment/suite.logadded+183 -0
| @@ -0,0 +1,183 @@ | |||
| 1 | +warning: The `fitz` API is deprecated and will be removed in future. Use `import pymupdf` instead. | ||
| 2 | + Loading weights: 0%| | 0/391 [00:00<?, ?it/s] Loading weights: 1%|▏ | 5/391 [00:00<01:13, 5.24it/s] Loading weights: 75%|███████▍ | 293/391 [00:01<00:00, 360.15it/s] Loading weights: 100%|██████████| 391/391 [00:01<00:00, 356.09it/s] | ||
| 3 | + pre tokenize: 0%| | 0/21 [00:00<?, ?it/s] pre tokenize: 100%|██████████| 21/21 [00:00<00:00, 421.49it/s] | ||
| 4 | + Inference Embeddings: 0%| | 0/21 [00:00<?, ?it/s] Inference Embeddings: 5%|▍ | 1/21 [00:00<00:15, 1.33it/s] Inference Embeddings: 10%|▉ | 2/21 [00:00<00:08, 2.27it/s] Inference Embeddings: 14%|█▍ | 3/21 [00:01<00:06, 2.94it/s] Inference Embeddings: 19%|█▉ | 4/21 [00:01<00:04, 3.49it/s] Inference Embeddings: 24%|██▍ | 5/21 [00:01<00:03, 4.00it/s] Inference Embeddings: 29%|██▊ | 6/21 [00:01<00:03, 4.40it/s] Inference Embeddings: 33%|███▎ | 7/21 [00:01<00:02, 4.75it/s] Inference Embeddings: 38%|███▊ | 8/21 [00:02<00:02, 5.02it/s] Inference Embeddings: 43%|████▎ | 9/21 [00:02<00:02, 5.31it/s] Inference Embeddings: 48%|████▊ | 10/21 [00:02<00:01, 5.63it/s] Inference Embeddings: 52%|█████▏ | 11/21 [00:02<00:01, 6.00it/s] Inference Embeddings: 57%|█████▋ | 12/21 [00:02<00:01, 6.49it/s] Inference Embeddings: 62%|██████▏ | 13/21 [00:02<00:01, 7.16it/s] Inference Embeddings: 67%|██████▋ | 14/21 [00:02<00:00, 7.81it/s] Inference Embeddings: 76%|███████▌ | 16/21 [00:03<00:00, 9.30it/s] Inference Embeddings: 86%|████████▌ | 18/21 [00:03<00:00, 11.61it/s] Inference Embeddings: 100%|██████████| 21/21 [00:03<00:00, 6.45it/s] | ||
| 5 | + pre tokenize: 0%| | 0/21 [00:00<?, ?it/s] pre tokenize: 100%|██████████| 21/21 [00:00<00:00, 647.49it/s] | ||
| 6 | + Inference Embeddings: 0%| | 0/21 [00:00<?, ?it/s] Inference Embeddings: 5%|▍ | 1/21 [00:00<00:14, 1.36it/s] Inference Embeddings: 10%|▉ | 2/21 [00:00<00:08, 2.30it/s] Inference Embeddings: 14%|█▍ | 3/21 [00:01<00:06, 2.98it/s] Inference Embeddings: 19%|█▉ | 4/21 [00:01<00:04, 3.55it/s] Inference Embeddings: 24%|██▍ | 5/21 [00:01<00:03, 4.05it/s] Inference Embeddings: 29%|██▊ | 6/21 [00:01<00:03, 4.44it/s] Inference Embeddings: 33%|███▎ | 7/21 [00:01<00:02, 4.75it/s] Inference Embeddings: 38%|███▊ | 8/21 [00:02<00:02, 5.02it/s] Inference Embeddings: 43%|████▎ | 9/21 [00:02<00:02, 5.32it/s] Inference Embeddings: 48%|████▊ | 10/21 [00:02<00:01, 5.61it/s] Inference Embeddings: 52%|█████▏ | 11/21 [00:02<00:01, 5.94it/s] Inference Embeddings: 57%|█████▋ | 12/21 [00:02<00:01, 6.41it/s] Inference Embeddings: 62%|██████▏ | 13/21 [00:02<00:01, 7.05it/s] Inference Embeddings: 67%|██████▋ | 14/21 [00:02<00:00, 7.67it/s] Inference Embeddings: 76%|███████▌ | 16/21 [00:03<00:00, 9.12it/s] Inference Embeddings: 86%|████████▌ | 18/21 [00:03<00:00, 11.39it/s] Inference Embeddings: 100%|██████████| 21/21 [00:03<00:00, 6.46it/s] | ||
| 7 | + Loading weights: 0%| | 0/393 [00:00<?, ?it/s] Loading weights: 30%|██▉ | 116/393 [00:00<00:00, 1138.15it/s] Loading weights: 59%|█████▊ | 230/393 [00:00<00:00, 1049.09it/s] Loading weights: 91%|█████████ | 358/393 [00:00<00:00, 1137.42it/s] Loading weights: 100%|██████████| 393/393 [00:00<00:00, 1167.47it/s] | ||
| 8 | + pre tokenize: 0%| | 0/21 [00:00<?, ?it/s] pre tokenize: 100%|██████████| 21/21 [00:00<00:00, 662.61it/s] | ||
| 9 | + Inference Embeddings: 0%| | 0/21 [00:00<?, ?it/s] Inference Embeddings: 5%|▍ | 1/21 [00:00<00:14, 1.34it/s] Inference Embeddings: 10%|▉ | 2/21 [00:00<00:08, 2.30it/s] Inference Embeddings: 14%|█▍ | 3/21 [00:01<00:06, 2.99it/s] Inference Embeddings: 19%|█▉ | 4/21 [00:01<00:04, 3.56it/s] Inference Embeddings: 24%|██▍ | 5/21 [00:01<00:03, 4.08it/s] Inference Embeddings: 29%|██▊ | 6/21 [00:01<00:03, 4.48it/s] Inference Embeddings: 33%|███▎ | 7/21 [00:01<00:02, 4.82it/s] Inference Embeddings: 38%|███▊ | 8/21 [00:02<00:02, 5.11it/s] Inference Embeddings: 43%|████▎ | 9/21 [00:02<00:02, 5.40it/s] Inference Embeddings: 48%|████▊ | 10/21 [00:02<00:01, 5.68it/s] Inference Embeddings: 52%|█████▏ | 11/21 [00:02<00:01, 6.03it/s] Inference Embeddings: 57%|█████▋ | 12/21 [00:02<00:01, 6.51it/s] Inference Embeddings: 62%|██████▏ | 13/21 [00:02<00:01, 7.17it/s] Inference Embeddings: 67%|██████▋ | 14/21 [00:02<00:00, 7.82it/s] Inference Embeddings: 76%|███████▌ | 16/21 [00:03<00:00, 9.27it/s] Inference Embeddings: 86%|████████▌ | 18/21 [00:03<00:00, 11.61it/s] Inference Embeddings: 100%|██████████| 21/21 [00:03<00:00, 6.53it/s] | ||
| 10 | + pre tokenize: 0%| | 0/21 [00:00<?, ?it/s] pre tokenize: 100%|██████████| 21/21 [00:00<00:00, 599.60it/s] | ||
| 11 | + Inference Embeddings: 0%| | 0/21 [00:00<?, ?it/s] Inference Embeddings: 5%|▍ | 1/21 [00:00<00:15, 1.32it/s] Inference Embeddings: 10%|▉ | 2/21 [00:00<00:08, 2.26it/s] Inference Embeddings: 14%|█▍ | 3/21 [00:01<00:06, 2.96it/s] Inference Embeddings: 19%|█▉ | 4/21 [00:01<00:04, 3.51it/s] Inference Embeddings: 24%|██▍ | 5/21 [00:01<00:03, 4.02it/s] Inference Embeddings: 29%|██▊ | 6/21 [00:01<00:03, 4.43it/s] Inference Embeddings: 33%|███▎ | 7/21 [00:01<00:02, 4.78it/s] Inference Embeddings: 38%|███▊ | 8/21 [00:02<00:02, 5.07it/s] Inference Embeddings: 43%|████▎ | 9/21 [00:02<00:02, 5.34it/s] Inference Embeddings: 48%|████▊ | 10/21 [00:02<00:01, 5.60it/s] Inference Embeddings: 52%|█████▏ | 11/21 [00:02<00:01, 5.94it/s] Inference Embeddings: 57%|█████▋ | 12/21 [00:02<00:01, 6.41it/s] Inference Embeddings: 62%|██████▏ | 13/21 [00:02<00:01, 7.06it/s] Inference Embeddings: 67%|██████▋ | 14/21 [00:02<00:00, 7.72it/s] Inference Embeddings: 76%|███████▌ | 16/21 [00:03<00:00, 9.19it/s] Inference Embeddings: 86%|████████▌ | 18/21 [00:03<00:00, 11.48it/s] Inference Embeddings: 100%|██████████| 21/21 [00:03<00:00, 6.44it/s] | ||
| 12 | + pre tokenize: 0%| | 0/21 [00:00<?, ?it/s] pre tokenize: 100%|██████████| 21/21 [00:00<00:00, 661.01it/s] | ||
| 13 | + Inference Embeddings: 0%| | 0/21 [00:00<?, ?it/s] Inference Embeddings: 5%|▍ | 1/21 [00:00<00:14, 1.34it/s] Inference Embeddings: 10%|▉ | 2/21 [00:00<00:08, 2.26it/s] Inference Embeddings: 14%|█▍ | 3/21 [00:01<00:06, 2.95it/s] Inference Embeddings: 19%|█▉ | 4/21 [00:01<00:04, 3.52it/s] Inference Embeddings: 24%|██▍ | 5/21 [00:01<00:03, 4.02it/s] Inference Embeddings: 29%|██▊ | 6/21 [00:01<00:03, 4.41it/s] Inference Embeddings: 33%|███▎ | 7/21 [00:01<00:02, 4.73it/s] Inference Embeddings: 38%|███▊ | 8/21 [00:02<00:02, 5.00it/s] Inference Embeddings: 43%|████▎ | 9/21 [00:02<00:02, 5.32it/s] Inference Embeddings: 48%|████▊ | 10/21 [00:02<00:01, 5.61it/s] Inference Embeddings: 52%|█████▏ | 11/21 [00:02<00:01, 5.95it/s] Inference Embeddings: 57%|█████▋ | 12/21 [00:02<00:01, 6.40it/s] Inference Embeddings: 62%|██████▏ | 13/21 [00:02<00:01, 7.04it/s] Inference Embeddings: 67%|██████▋ | 14/21 [00:02<00:00, 7.64it/s] Inference Embeddings: 76%|███████▌ | 16/21 [00:03<00:00, 9.07it/s] Inference Embeddings: 86%|████████▌ | 18/21 [00:03<00:00, 11.37it/s] Inference Embeddings: 100%|██████████| 21/21 [00:03<00:00, 6.42it/s] | ||
| 14 | + pre tokenize: 0%| | 0/21 [00:00<?, ?it/s] pre tokenize: 100%|██████████| 21/21 [00:00<00:00, 589.65it/s] | ||
| 15 | + Inference Embeddings: 0%| | 0/21 [00:00<?, ?it/s] Inference Embeddings: 5%|▍ | 1/21 [00:00<00:14, 1.33it/s] Inference Embeddings: 10%|▉ | 2/21 [00:00<00:08, 2.28it/s] Inference Embeddings: 14%|█▍ | 3/21 [00:01<00:06, 2.98it/s] Inference Embeddings: 19%|█▉ | 4/21 [00:01<00:04, 3.52it/s] Inference Embeddings: 24%|██▍ | 5/21 [00:01<00:03, 4.03it/s] Inference Embeddings: 29%|██▊ | 6/21 [00:01<00:03, 4.43it/s] Inference Embeddings: 33%|███▎ | 7/21 [00:01<00:02, 4.78it/s] Inference Embeddings: 38%|███▊ | 8/21 [00:02<00:02, 5.07it/s] Inference Embeddings: 43%|████▎ | 9/21 [00:02<00:02, 5.34it/s] Inference Embeddings: 48%|████▊ | 10/21 [00:02<00:01, 5.63it/s] Inference Embeddings: 52%|█████▏ | 11/21 [00:02<00:01, 5.97it/s] Inference Embeddings: 57%|█████▋ | 12/21 [00:02<00:01, 6.45it/s] Inference Embeddings: 62%|██████▏ | 13/21 [00:02<00:01, 7.10it/s] Inference Embeddings: 67%|██████▋ | 14/21 [00:02<00:00, 7.77it/s] Inference Embeddings: 76%|███████▌ | 16/21 [00:03<00:00, 9.25it/s] Inference Embeddings: 86%|████████▌ | 18/21 [00:03<00:00, 11.56it/s] Inference Embeddings: 100%|██████████| 21/21 [00:03<00:00, 6.48it/s] | ||
| 16 | + pre tokenize: 0%| | 0/21 [00:00<?, ?it/s] pre tokenize: 100%|██████████| 21/21 [00:00<00:00, 679.56it/s] | ||
| 17 | + Inference Embeddings: 0%| | 0/21 [00:00<?, ?it/s] Inference Embeddings: 5%|▍ | 1/21 [00:00<00:14, 1.35it/s] Inference Embeddings: 10%|▉ | 2/21 [00:00<00:08, 2.28it/s] Inference Embeddings: 14%|█▍ | 3/21 [00:01<00:06, 2.96it/s] Inference Embeddings: 19%|█▉ | 4/21 [00:01<00:04, 3.52it/s] Inference Embeddings: 24%|██▍ | 5/21 [00:01<00:03, 4.02it/s] Inference Embeddings: 29%|██▊ | 6/21 [00:01<00:03, 4.41it/s] Inference Embeddings: 33%|███▎ | 7/21 [00:01<00:02, 4.73it/s] Inference Embeddings: 38%|███▊ | 8/21 [00:02<00:02, 5.01it/s] Inference Embeddings: 43%|████▎ | 9/21 [00:02<00:02, 5.29it/s] Inference Embeddings: 48%|████▊ | 10/21 [00:02<00:01, 5.58it/s] Inference Embeddings: 52%|█████▏ | 11/21 [00:02<00:01, 5.93it/s] Inference Embeddings: 57%|█████▋ | 12/21 [00:02<00:01, 6.38it/s] Inference Embeddings: 62%|██████▏ | 13/21 [00:02<00:01, 7.03it/s] Inference Embeddings: 67%|██████▋ | 14/21 [00:02<00:00, 7.65it/s] Inference Embeddings: 76%|███████▌ | 16/21 [00:03<00:00, 9.06it/s] Inference Embeddings: 86%|████████▌ | 18/21 [00:03<00:00, 11.34it/s] Inference Embeddings: 100%|██████████| 21/21 [00:03<00:00, 6.42it/s] | ||
| 18 | + pre tokenize: 0%| | 0/11 [00:00<?, ?it/s] pre tokenize: 100%|██████████| 11/11 [00:00<00:00, 367.09it/s] | ||
| 19 | + Inference Embeddings: 0%| | 0/11 [00:00<?, ?it/s] Inference Embeddings: 9%|▉ | 1/11 [00:01<00:15, 1.52s/it] Inference Embeddings: 18%|█▊ | 2/11 [00:01<00:07, 1.14it/s] Inference Embeddings: 27%|██▋ | 3/11 [00:02<00:05, 1.55it/s] Inference Embeddings: 36%|███▋ | 4/11 [00:02<00:03, 1.87it/s] Inference Embeddings: 45%|████▌ | 5/11 [00:03<00:02, 2.16it/s] Inference Embeddings: 55%|█████▍ | 6/11 [00:03<00:02, 2.47it/s] Inference Embeddings: 64%|██████▎ | 7/11 [00:03<00:01, 2.91it/s] Inference Embeddings: 73%|███████▎ | 8/11 [00:03<00:00, 3.42it/s] Inference Embeddings: 82%|████████▏ | 9/11 [00:03<00:00, 4.24it/s] Inference Embeddings: 100%|██████████| 11/11 [00:03<00:00, 2.82it/s] | ||
| 20 | + pre tokenize: 0%| | 0/11 [00:00<?, ?it/s] pre tokenize: 100%|██████████| 11/11 [00:00<00:00, 399.38it/s] | ||
| 21 | + Inference Embeddings: 0%| | 0/11 [00:00<?, ?it/s] Inference Embeddings: 9%|▉ | 1/11 [00:01<00:15, 1.52s/it] Inference Embeddings: 18%|█▊ | 2/11 [00:01<00:07, 1.14it/s] Inference Embeddings: 27%|██▋ | 3/11 [00:02<00:05, 1.55it/s] Inference Embeddings: 36%|███▋ | 4/11 [00:02<00:03, 1.87it/s] Inference Embeddings: 45%|████▌ | 5/11 [00:03<00:02, 2.16it/s] Inference Embeddings: 55%|█████▍ | 6/11 [00:03<00:02, 2.47it/s] Inference Embeddings: 64%|██████▎ | 7/11 [00:03<00:01, 2.90it/s] Inference Embeddings: 73%|███████▎ | 8/11 [00:03<00:00, 3.41it/s] Inference Embeddings: 82%|████████▏ | 9/11 [00:03<00:00, 4.24it/s] Inference Embeddings: 100%|██████████| 11/11 [00:03<00:00, 6.74it/s] Inference Embeddings: 100%|██████████| 11/11 [00:03<00:00, 2.80it/s] | ||
| 22 | +. pre tokenize: 0%| | 0/11 [00:00<?, ?it/s] pre tokenize: 100%|██████████| 11/11 [00:00<00:00, 403.44it/s] | ||
| 23 | + Inference Embeddings: 0%| | 0/11 [00:00<?, ?it/s] Inference Embeddings: 9%|▉ | 1/11 [00:01<00:15, 1.52s/it] Inference Embeddings: 18%|█▊ | 2/11 [00:01<00:07, 1.14it/s] Inference Embeddings: 27%|██▋ | 3/11 [00:02<00:05, 1.55it/s] Inference Embeddings: 36%|███▋ | 4/11 [00:02<00:03, 1.87it/s] Inference Embeddings: 45%|████▌ | 5/11 [00:03<00:02, 2.16it/s] Inference Embeddings: 55%|█████▍ | 6/11 [00:03<00:02, 2.47it/s] Inference Embeddings: 64%|██████▎ | 7/11 [00:03<00:01, 2.91it/s] Inference Embeddings: 73%|███████▎ | 8/11 [00:03<00:00, 3.42it/s] Inference Embeddings: 82%|████████▏ | 9/11 [00:03<00:00, 4.25it/s] Inference Embeddings: 100%|██████████| 11/11 [00:03<00:00, 2.83it/s] | ||
| 24 | +....ss... pre tokenize: 0%| | 0/11 [00:00<?, ?it/s] pre tokenize: 100%|██████████| 11/11 [00:00<00:00, 358.27it/s] | ||
| 25 | + Inference Embeddings: 0%| | 0/11 [00:00<?, ?it/s] Inference Embeddings: 9%|▉ | 1/11 [00:01<00:15, 1.52s/it] Inference Embeddings: 18%|█▊ | 2/11 [00:01<00:07, 1.14it/s] Inference Embeddings: 27%|██▋ | 3/11 [00:02<00:05, 1.54it/s] Inference Embeddings: 36%|███▋ | 4/11 [00:02<00:03, 1.86it/s] Inference Embeddings: 45%|████▌ | 5/11 [00:03<00:02, 2.15it/s] Inference Embeddings: 55%|█████▍ | 6/11 [00:03<00:02, 2.45it/s] Inference Embeddings: 64%|██████▎ | 7/11 [00:03<00:01, 2.89it/s] Inference Embeddings: 73%|███████▎ | 8/11 [00:03<00:00, 3.40it/s] Inference Embeddings: 82%|████████▏ | 9/11 [00:03<00:00, 4.23it/s] Inference Embeddings: 100%|██████████| 11/11 [00:03<00:00, 2.81it/s] | ||
| 26 | +.....................................................................................Cannot set non-stroke color: 2 components specified, but only 1 (grayscale), 3 (RGB), and 4 (CMYK) are supported | ||
| 27 | +Cannot set non-stroke color: 2 components specified, but only 1 (grayscale), 3 (RGB), and 4 (CMYK) are supported | ||
| 28 | +Cannot set non-stroke color: 2 components specified, but only 1 (grayscale), 3 (RGB), and 4 (CMYK) are supported | ||
| 29 | +Cannot set non-stroke color: 2 components specified, but only 1 (grayscale), 3 (RGB), and 4 (CMYK) are supported | ||
| 30 | +Cannot set non-stroke color: 2 components specified, but only 1 (grayscale), 3 (RGB), and 4 (CMYK) are supported | ||
| 31 | +Cannot set non-stroke color: 2 components specified, but only 1 (grayscale), 3 (RGB), and 4 (CMYK) are supported | ||
| 32 | +................................................................................................................................./home/kadiryonak/Masaüstü/Kodlama/HelloWorld/Hezarfen/hezarfen_rag/src/generate/generator.py:521: UserWarning: pricing: bilinmeyen model 'stub' (çözülen 'stub') → maliyet 0.0 sayıldı; pricing.PRICING'e ekle. | ||
| 33 | + usd = pricing_cost_usd(result.model, result.usage) | ||
| 34 | +......../home/kadiryonak/Masaüstü/Kodlama/HelloWorld/Hezarfen/hezarfen_rag/src/generate/generator.py:521: UserWarning: pricing: bilinmeyen model 'stub' (çözülen 'stub') → maliyet 0.0 sayıldı; pricing.PRICING'e ekle. | ||
| 35 | + usd = pricing_cost_usd(result.model, result.usage) | ||
| 36 | +.........................................<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc068f834c0> | ||
| 37 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 38 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc068f835b0> | ||
| 39 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 40 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00c4d16c0> | ||
| 41 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 42 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc068f836a0> | ||
| 43 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 44 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006901a80> | ||
| 45 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 46 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006901b70> | ||
| 47 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 48 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006901c60> | ||
| 49 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 50 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006901d50> | ||
| 51 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 52 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006901e40> | ||
| 53 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 54 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006901f30> | ||
| 55 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 56 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006902110> | ||
| 57 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 58 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006902200> | ||
| 59 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 60 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006902020> | ||
| 61 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 62 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc0069022f0> | ||
| 63 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 64 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc0069023e0> | ||
| 65 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 66 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc0069024d0> | ||
| 67 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 68 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc0069025c0> | ||
| 69 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 70 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc0069026b0> | ||
| 71 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 72 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc0069027a0> | ||
| 73 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 74 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006902890> | ||
| 75 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 76 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006902980> | ||
| 77 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 78 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006902a70> | ||
| 79 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 80 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006902b60> | ||
| 81 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 82 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006902c50> | ||
| 83 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 84 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006902d40> | ||
| 85 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 86 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006902e30> | ||
| 87 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 88 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006902f20> | ||
| 89 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 90 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006903010> | ||
| 91 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 92 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da894e0> | ||
| 93 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 94 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da895d0> | ||
| 95 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 96 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da896c0> | ||
| 97 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 98 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da897b0> | ||
| 99 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 100 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da898a0> | ||
| 101 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 102 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da89a80> | ||
| 103 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 104 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da89990> | ||
| 105 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 106 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da89c60> | ||
| 107 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 108 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da89b70> | ||
| 109 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 110 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da89d50> | ||
| 111 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 112 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da8a4d0> | ||
| 113 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 114 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da89e40> | ||
| 115 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 116 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da89f30> | ||
| 117 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 118 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da8a020> | ||
| 119 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 120 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da8a5c0> | ||
| 121 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 122 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da8a6b0> | ||
| 123 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 124 | +<frozen importlib._bootstrap_external>:781: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da8a7a0> | ||
| 125 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 126 | +....................................................................................................................................................................[eval] UYARI: dondurulmus judge kumesindeki 2 id bu golden set'te YOK: ['yok1', 'yok2']... | ||
| 127 | +./home/kadiryonak/Masaüstü/Kodlama/HelloWorld/Hezarfen/hezarfen_rag/tests/unit/test_eval_judge_sampling.py:150: ResourceWarning: unclosed file <_io.TextIOWrapper name='tests/golden/golden_12bio_v1.json' mode='r' encoding='utf-8'> | ||
| 128 | + return json.load(open(path, encoding="utf-8"))["items"] | ||
| 129 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 130 | +./home/kadiryonak/Masaüstü/Kodlama/HelloWorld/Hezarfen/hezarfen_rag/tests/unit/test_eval_judge_sampling.py:150: ResourceWarning: unclosed file <_io.TextIOWrapper name='tests/golden/golden_12kimya_v1.json' mode='r' encoding='utf-8'> | ||
| 131 | + return json.load(open(path, encoding="utf-8"))["items"] | ||
| 132 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 133 | +/home/kadiryonak/Masaüstü/Kodlama/HelloWorld/Hezarfen/hezarfen_rag/tests/unit/test_eval_judge_sampling.py:150: ResourceWarning: unclosed file <_io.TextIOWrapper name='tests/golden/golden_12fizik_v1.json' mode='r' encoding='utf-8'> | ||
| 134 | + return json.load(open(path, encoding="utf-8"))["items"] | ||
| 135 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 136 | +................................................../home/kadiryonak/Masaüstü/Kodlama/HelloWorld/Hezarfen/hezarfen_rag/src/generate/generator.py:521: UserWarning: pricing: bilinmeyen model 'stub' (çözülen 'stub') → maliyet 0.0 sayıldı; pricing.PRICING'e ekle. | ||
| 137 | + usd = pricing_cost_usd(result.model, result.usage) | ||
| 138 | +./home/kadiryonak/Masaüstü/Kodlama/HelloWorld/Hezarfen/hezarfen_rag/src/costlog.py:184: UserWarning: pricing: bilinmeyen model 'stub' (çözülen 'stub') → maliyet 0.0 sayıldı; pricing.PRICING'e ekle. | ||
| 139 | + usd = cost_usd(model, usage, tier) # saf hesap — kilidin DIŞINDA | ||
| 140 | +..................................s............................................................................................................./home/kadiryonak/Masaüstü/Kodlama/HelloWorld/Hezarfen/hezarfen_rag/tests/unit/test_generate.py:994: RuntimeWarning: ResponseCache verildi ama `corpus_version` BOS -- cache DEVRE DISI birakildi. Surumsuz anahtar, korpus degisince eski (hatta silinmis) kaynaklara atif donmesine yol acar (#77). | ||
| 141 | + gen.answer("DNA nedir?") | ||
| 142 | +/home/kadiryonak/Masaüstü/Kodlama/HelloWorld/Hezarfen/hezarfen_rag/tests/unit/test_generate.py:995: RuntimeWarning: ResponseCache verildi ama `corpus_version` BOS -- cache DEVRE DISI birakildi. Surumsuz anahtar, korpus degisince eski (hatta silinmis) kaynaklara atif donmesine yol acar (#77). | ||
| 143 | + gen.answer("DNA nedir?") | ||
| 144 | +.................................................................................../home/kadiryonak/Masaüstü/Kodlama/HelloWorld/Hezarfen/hezarfen_rag/.venv/lib/python3.13/site-packages/filelock/_api.py:1785: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc007dbb100> | ||
| 145 | + def _audit_fork_safety( # pragma: no cover - CPython disables tracing while Python audit hooks run | ||
| 146 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 147 | +/home/kadiryonak/Masaüstü/Kodlama/HelloWorld/Hezarfen/hezarfen_rag/.venv/lib/python3.13/site-packages/filelock/_api.py:1785: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da896c0> | ||
| 148 | + def _audit_fork_safety( # pragma: no cover - CPython disables tracing while Python audit hooks run | ||
| 149 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 150 | +/home/kadiryonak/Masaüstü/Kodlama/HelloWorld/Hezarfen/hezarfen_rag/.venv/lib/python3.13/site-packages/filelock/_api.py:1785: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00c4d3c40> | ||
| 151 | + def _audit_fork_safety( # pragma: no cover - CPython disables tracing while Python audit hooks run | ||
| 152 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 153 | +/home/kadiryonak/Masaüstü/Kodlama/HelloWorld/Hezarfen/hezarfen_rag/.venv/lib/python3.13/site-packages/filelock/_api.py:1785: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da8be20> | ||
| 154 | + def _audit_fork_safety( # pragma: no cover - CPython disables tracing while Python audit hooks run | ||
| 155 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 156 | +/home/kadiryonak/Masaüstü/Kodlama/HelloWorld/Hezarfen/hezarfen_rag/.venv/lib/python3.13/site-packages/filelock/_api.py:1785: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc00da895d0> | ||
| 157 | + def _audit_fork_safety( # pragma: no cover - CPython disables tracing while Python audit hooks run | ||
| 158 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 159 | +/home/kadiryonak/Masaüstü/Kodlama/HelloWorld/Hezarfen/hezarfen_rag/.venv/lib/python3.13/site-packages/filelock/_api.py:1785: ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7fc006902890> | ||
| 160 | + def _audit_fork_safety( # pragma: no cover - CPython disables tracing while Python audit hooks run | ||
| 161 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 162 | +......................................................../home/kadiryonak/Masaüstü/Kodlama/HelloWorld/Hezarfen/hezarfen_rag/src/generate/question_gen.py:131: UserWarning: pricing: bilinmeyen model 'stub' (çözülen 'stub') → maliyet 0.0 sayıldı; pricing.PRICING'e ekle. | ||
| 163 | + usd = pricing_cost_usd(result.model, result.usage) | ||
| 164 | +............/home/kadiryonak/Masaüstü/Kodlama/HelloWorld/Hezarfen/hezarfen_rag/src/summarize/summarizer.py:178: UserWarning: pricing: bilinmeyen model 'stub' (çözülen 'stub') → maliyet 0.0 sayıldı; pricing.PRICING'e ekle. | ||
| 165 | + usd = pricing_cost_usd(result.model, result.usage) | ||
| 166 | +.............................................................................................s................................................................................................................................................................................................/home/kadiryonak/Masaüstü/Kodlama/HelloWorld/Hezarfen/hezarfen_rag/tests/unit/test_trace.py:190: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/tmpz6zqbrjj/t.jsonl' mode='r' encoding='utf-8'> | ||
| 167 | + ham = open(yol, encoding="utf-8").read() | ||
| 168 | +ResourceWarning: Enable tracemalloc to get the object allocation traceback | ||
| 169 | +.............................. | ||
| 170 | +---------------------------------------------------------------------- | ||
| 171 | +Ran 1101 tests in 426.043s | ||
| 172 | + | ||
| 173 | +OK (skipped=4) | ||
| 174 | + | ||
| 175 | +[test_generate] soru='Kemosentez Ototrof olarak beslenen canlılar, inorg' | ||
| 176 | + cevap: Ototrof canlılar, inorganik maddelerden organik madde sentezlerken kullandıkları enerji kaynağına göre iki ana grupta incelenir [1]. Bunlardan fotosentetik ototroflarda gerekli enerji ışıktan sağlanır [1]. Kemosentetik ototroflarda ise inorganik maddeler oksitlenerek açığa çıkan enerjiyle organik madde sentezlenir [1]. | ||
| 177 | + atıflar: [{'n': 1, 'chunk_id': '534db77d8289:c54', 'span_ids': ['534db77d8289#39.2', '534db77d8289#39.3', '534db77d8289#39.4', '534db77d8289#39.5'], 'pages': [39], 'ders': 'biyoloji'}] | ||
| 178 | + maliyet: $0.000467 · gecikme: 1.49s | ||
| 179 | + | ||
| 180 | +[test_generate] kapsam-disi soru - abstained=True, reason=insufficient_data, llm_calls_delta=0 | ||
| 181 | + | ||
| 182 | +[test_generate] temp ledger: /tmp/hezarfen_test_generate_ledger_066vy0gu/runs.jsonl (1 run) · gerçek ledger değişmedi: /home/kadiryonak/Masaüstü/Obsidian Vault/Hezarfen-Vault/Hezarfen/rag/runs.jsonl | ||
| 183 | +Maliyet.md render edildi (20 run) -> /tmp/tmpipo7fw5z/Maliyet.md | ||
src/service/http_app.pymodified+14 -1
| @@ -364,6 +364,14 @@ CACHE_PATH = os.environ.get("RAG_CACHE_PATH") or "" | |||
| 364 | CACHE_MAX_BYTES = int(os.environ.get("RAG_CACHE_MAX_BYTES", str(512 * 1024 * 1024))) | 364 | CACHE_MAX_BYTES = int(os.environ.get("RAG_CACHE_MAX_BYTES", str(512 * 1024 * 1024))) |
| 365 | CACHE_TTL_S = float(os.environ.get("RAG_CACHE_TTL_S", "3600")) | 365 | CACHE_TTL_S = float(os.environ.get("RAG_CACHE_TTL_S", "3600")) |
| 366 | 366 | ||
| 367 | +# M4-13 (#87, EXP-010/OPS-14) — SOZLESME COK-TURLU REWRITE VAAT EDIYOR, | ||
| 368 | +# KOD YOK SAYIYOR. `build_service` hic `rewriter` gecirmiyordu; yani | ||
| 369 | +# `history` alani API-CONTRACT'ta duruyor ama uretimde SESSIZCE ATILIYORDU. | ||
| 370 | +# Kullanici "peki devami?" diye soruyor, sistem onceki turu hic gormuyor. | ||
| 371 | +# Maliyet: gecmisli her soruda BIR EK LLM cagrisi (~$0.0002). Kapatilabilir. | ||
| 372 | +REWRITE_HISTORY = os.environ.get("RAG_REWRITE_HISTORY", "1") not in ( | ||
| 373 | + "0", "", "false", "False") | ||
| 374 | + | ||
| 367 | 375 | ||
| 368 | def build_service(book_path: str, *, sinif: str, ders: str, corpus_version: str = "", | 376 | def build_service(book_path: str, *, sinif: str, ders: str, corpus_version: str = "", |
| 369 | ocr: bool = False, vlm: bool = False, | 377 | ocr: bool = False, vlm: bool = False, |
| @@ -430,10 +438,15 @@ def build_service(book_path: str, *, sinif: str, ders: str, corpus_version: str | |||
| 430 | # `reason="timeout"` donuyordu. Yani hazirlik sinyali YALAN soyluyordu. | 438 | # `reason="timeout"` donuyordu. Yani hazirlik sinyali YALAN soyluyordu. |
| 431 | reranker = BGEReranker() | 439 | reranker = BGEReranker() |
| 432 | reranker.warmup() | 440 | reranker.warmup() |
| 441 | + # #87/OPS-14: cok-turlu rewrite BAGLANDI (sozlesme zaten vaat ediyordu). | ||
| 442 | + rewriter = None | ||
| 443 | + if REWRITE_HISTORY: | ||
| 444 | + from ..memory.history_rewrite import HistoryAwareRewriter | ||
| 445 | + rewriter = HistoryAwareRewriter() | ||
| 433 | gen = Generator(retr, reranker, by_id, span_meta, ders=ders, | 446 | gen = Generator(retr, reranker, by_id, span_meta, ders=ders, |
| 434 | safety_classifier=LLMSafetyClassifier(), context_packing=True, | 447 | safety_classifier=LLMSafetyClassifier(), context_packing=True, |
| 435 | corpus_version=cv, require_role=True, # STRICT: rolsüz istek fail-closed | 448 | corpus_version=cv, require_role=True, # STRICT: rolsüz istek fail-closed |
| 436 | - response_cache=response_cache) | 449 | + response_cache=response_cache, rewriter=rewriter) |
| 437 | return RagService(gen, doc=doc, summarizer=Summarizer(), | 450 | return RagService(gen, doc=doc, summarizer=Summarizer(), |
| 438 | question_gen=QuestionGenerator(), ders=ders) | 451 | question_gen=QuestionGenerator(), ders=ders) |
| 439 | 452 | ||
src/service/registry.pyadded+153 -0
| @@ -0,0 +1,153 @@ | |||
| 1 | +"""Çok-korpus yönlendirme (#86, EXP-010/OPS-08+09+18). | ||
| 2 | + | ||
| 3 | +ÖLÇÜLEN DURUM: süreç = **1 kitap = 1 ders**. `build_service(book_path, sinif=, | ||
| 4 | +ders=)`, tek `BOOK_PATH` env, tek `doc`, tek indeks üçlüsü, tek `Generator`. | ||
| 5 | +Kaynak kataloğu, yönlendirme, indeks kataloğu **yoktu**. | ||
| 6 | + | ||
| 7 | +ÜRÜN AÇISINDAN NE DEMEK: öğrencinin 19 dersi var; servis yalnız birini | ||
| 8 | +cevaplayabiliyor. Bir okul demosunda öğrenci fiziğe geçtiği anda ürün | ||
| 9 | +"kaynaklarda bulunamadı" diyor — bu bir RAG hatası gibi görünüyor ama aslında | ||
| 10 | +**yanlış korpusa soruluyor**. | ||
| 11 | + | ||
| 12 | +BU MODÜL NE YAPAR: birden çok (sınıf, ders) korpusunu tutar ve isteği | ||
| 13 | +**rolün/kapsamın** gösterdiği korpusa yönlendirir. Yetki kararı yine | ||
| 14 | +`guard/roles.can_access` ile verilir — yönlendirme bir yetkilendirme DEĞİLDİR | ||
| 15 | +ve onun yerine geçmez. | ||
| 16 | + | ||
| 17 | +BU MODÜL NE YAPMAZ (dürüst sınır): ölçek duvarını kaldırmaz. Ölçüldü | ||
| 18 | +(bu makine, CPU): | ||
| 19 | + | ||
| 20 | +| | 10k chunk | 50k chunk | 100k chunk | | ||
| 21 | +|---|---|---|---| | ||
| 22 | +| dense arama (top-40) | 176 ms | 234 ms | — | | ||
| 23 | +| dense RSS artışı | +529 MB | **+2.139 MB** | — | | ||
| 24 | +| BM25 arama | 12,3 ms | 59,4 ms | **131,5 ms** | | ||
| 25 | +| sparse arama (saf Python) | 80,8 ms | **419,1 ms** | — | | ||
| 26 | + | ||
| 27 | +50 okul × 10 ders ≈ 129k chunk → RSS ~5,7 GB, tek sorgu ~1,8 s ve GIL altında | ||
| 28 | +**seri**. Bu ancak **kalıcı vektör store** ile çözülür (#75). Buradaki kayıt | ||
| 29 | +defteri, o gelene kadar birkaç korpusu (bir okulun dersleri) tek süreçte | ||
| 30 | +servis etmeyi mümkün kılar ve sınırı **görünür** tutar. | ||
| 31 | +""" | ||
| 32 | +from __future__ import annotations | ||
| 33 | + | ||
| 34 | +import threading | ||
| 35 | +from dataclasses import dataclass, field | ||
| 36 | + | ||
| 37 | + | ||
| 38 | +@dataclass(frozen=True) | ||
| 39 | +class CorpusKey: | ||
| 40 | + sinif: str | ||
| 41 | + ders: str | ||
| 42 | + | ||
| 43 | + def __str__(self) -> str: | ||
| 44 | + return f"{self.sinif}/{self.ders}" | ||
| 45 | + | ||
| 46 | + | ||
| 47 | +@dataclass | ||
| 48 | +class RegistryStats: | ||
| 49 | + corpora: int = 0 | ||
| 50 | + chunks: int = 0 | ||
| 51 | + detail: dict = field(default_factory=dict) | ||
| 52 | + | ||
| 53 | + | ||
| 54 | +class CorpusRegistry: | ||
| 55 | + """(sınıf, ders) → `RagService` kayıt defteri ve yönlendirici. | ||
| 56 | + | ||
| 57 | + Thread-güvenlidir: kayıt/silme kilit altında, okuma kilitsiz (sözlük | ||
| 58 | + okuması atomik). Servisin kendisi zaten eşzamanlı isteklere açık. | ||
| 59 | + """ | ||
| 60 | + | ||
| 61 | + def __init__(self, *, max_corpora: int = 0): | ||
| 62 | + """`max_corpora`: 0 = sınırsız. Sınır **bilinçli** bir güvenlik valfi: | ||
| 63 | + ölçek duvarı ölçüldü (#75 çözülene kadar RSS lineer büyüyor), sessizce | ||
| 64 | + belleği tüketmektense açıkça reddetmek yeğdir.""" | ||
| 65 | + self._services: dict[CorpusKey, object] = {} | ||
| 66 | + self._lock = threading.Lock() | ||
| 67 | + self.max_corpora = int(max_corpora or 0) | ||
| 68 | + | ||
| 69 | + # -- kayıt ----------------------------------------------------------- | ||
| 70 | + def register(self, service, *, sinif: str | None = None, | ||
| 71 | + ders: str | None = None): | ||
| 72 | + """Bir korpusu deftere ekler. Sınıf/ders verilmezse servisten okunur.""" | ||
| 73 | + s = sinif if sinif is not None else getattr( | ||
| 74 | + getattr(service, "doc", None), "sinif", None) | ||
| 75 | + d = ders if ders is not None else ( | ||
| 76 | + getattr(service, "ders", None) | ||
| 77 | + or getattr(getattr(service, "doc", None), "ders", None)) | ||
| 78 | + if not s or not d: | ||
| 79 | + raise ValueError("korpus sinif/ders bilgisi olmadan kaydedilemez") | ||
| 80 | + anahtar = CorpusKey(str(s), str(d)) | ||
| 81 | + with self._lock: | ||
| 82 | + if (self.max_corpora and anahtar not in self._services | ||
| 83 | + and len(self._services) >= self.max_corpora): | ||
| 84 | + raise ValueError( | ||
| 85 | + f"korpus siniri asildi ({self.max_corpora}) — " | ||
| 86 | + "kalici vektor store olmadan bellek lineer buyur (#75)") | ||
| 87 | + self._services[anahtar] = service | ||
| 88 | + return anahtar | ||
| 89 | + | ||
| 90 | + def unregister(self, sinif: str, ders: str) -> bool: | ||
| 91 | + with self._lock: | ||
| 92 | + return self._services.pop(CorpusKey(str(sinif), str(ders)), | ||
| 93 | + None) is not None | ||
| 94 | + | ||
| 95 | + # -- yönlendirme ----------------------------------------------------- | ||
| 96 | + def get(self, sinif: str | None, ders: str | None): | ||
| 97 | + if not sinif or not ders: | ||
| 98 | + return None | ||
| 99 | + return self._services.get(CorpusKey(str(sinif), str(ders))) | ||
| 100 | + | ||
| 101 | + def resolve(self, req: dict): | ||
| 102 | + """İsteği bir korpusa yönlendirir. Döner: `(service, reason)`. | ||
| 103 | + | ||
| 104 | + `service` None ise `reason` neden bulunamadığını söyler: | ||
| 105 | + `no_corpus` — o sınıf/ders için korpus yüklü değil | ||
| 106 | + `corpus_ambiguous` — hedef belirlenemedi (rol tek ders taşımıyor) | ||
| 107 | + | ||
| 108 | + **YÖNLENDİRME YETKİLENDİRME DEĞİLDİR.** Burada yalnız "hangi kitap" | ||
| 109 | + sorusu cevaplanır; "bu öğrenci o kitabı görebilir mi" sorusunu | ||
| 110 | + `guard/roles.can_access` cevaplar ve servis onu ayrıca uygular. İkisini | ||
| 111 | + karıştırmak, rolün istediği dersi seçmesine izin vermek demek olurdu — | ||
| 112 | + SEC-01'in tam olarak bu şekli ölçülmüştü. | ||
| 113 | + """ | ||
| 114 | + rol = req.get("role") or {} | ||
| 115 | + scope = req.get("scope") or {} | ||
| 116 | + sinif = scope.get("sinif") or rol.get("sinif") | ||
| 117 | + ders = scope.get("ders") or (req.get("options") or {}).get("ders") | ||
| 118 | + | ||
| 119 | + if not ders: | ||
| 120 | + dersler = list(rol.get("ders_list") or []) | ||
| 121 | + if len(dersler) == 1: | ||
| 122 | + ders = dersler[0] | ||
| 123 | + elif len(dersler) > 1: | ||
| 124 | + # Birden çok ders: hedef belirsiz. Tahmin etmek yanlış kitaptan | ||
| 125 | + # cevap üretmek demek olurdu. | ||
| 126 | + mevcut = [d for d in dersler if self.get(sinif, d) is not None] | ||
| 127 | + if len(mevcut) == 1: | ||
| 128 | + ders = mevcut[0] | ||
| 129 | + else: | ||
| 130 | + return None, "corpus_ambiguous" | ||
| 131 | + | ||
| 132 | + svc = self.get(sinif, ders) | ||
| 133 | + return (svc, "") if svc is not None else (None, "no_corpus") | ||
| 134 | + | ||
| 135 | + # -- gözlem ---------------------------------------------------------- | ||
| 136 | + def keys(self) -> list[CorpusKey]: | ||
| 137 | + return sorted(self._services, key=str) | ||
| 138 | + | ||
| 139 | + def stats(self) -> RegistryStats: | ||
| 140 | + detay, toplam = {}, 0 | ||
| 141 | + for k, svc in list(self._services.items()): | ||
| 142 | + n = len(getattr(getattr(svc, "generator", None), "chunks_by_id", {}) or {}) | ||
| 143 | + detay[str(k)] = n | ||
| 144 | + toplam += n | ||
| 145 | + return RegistryStats(corpora=len(detay), chunks=toplam, detail=detay) | ||
| 146 | + | ||
| 147 | + def __len__(self) -> int: | ||
| 148 | + return len(self._services) | ||
| 149 | + | ||
| 150 | + def __contains__(self, item) -> bool: | ||
| 151 | + if isinstance(item, CorpusKey): | ||
| 152 | + return item in self._services | ||
| 153 | + return False | ||
tests/unit/test_registry.pyadded+193 -0
| @@ -0,0 +1,193 @@ | |||
| 1 | +"""#86 (EXP-010/OPS-08+09) — çok-korpus yönlendirme. | ||
| 2 | + | ||
| 3 | +ÖLÇÜLEN DURUM: süreç = **1 kitap = 1 ders**. Kaynak kataloğu, yönlendirme, | ||
| 4 | +indeks kataloğu yoktu. | ||
| 5 | + | ||
| 6 | +ÜRÜN AÇISINDAN: öğrencinin 19 dersi var; servis yalnız birini cevaplayabiliyor. | ||
| 7 | +Demoda öğrenci fiziğe geçince ürün "kaynaklarda bulunamadı" diyor — bu bir RAG | ||
| 8 | +hatası gibi görünüyor ama aslında **yanlış korpusa soruluyor**. | ||
| 9 | + | ||
| 10 | +KRİTİK AYRIM: yönlendirme **yetkilendirme değildir**. Burada yalnız "hangi | ||
| 11 | +kitap" sorusu cevaplanır; "bu öğrenci onu görebilir mi" sorusunu | ||
| 12 | +`guard/roles.can_access` cevaplar. İkisini karıştırmak, rolün istediği dersi | ||
| 13 | +seçmesine izin vermek olurdu — SEC-01'in tam olarak bu şekli ölçülmüştü. | ||
| 14 | +""" | ||
| 15 | +import unittest | ||
| 16 | + | ||
| 17 | +from src.service.registry import CorpusKey, CorpusRegistry | ||
| 18 | + | ||
| 19 | + | ||
| 20 | +class _Doc: | ||
| 21 | + def __init__(self, sinif, ders): | ||
| 22 | + self.sinif = sinif | ||
| 23 | + self.ders = ders | ||
| 24 | + | ||
| 25 | + | ||
| 26 | +class _Gen: | ||
| 27 | + def __init__(self, n=0): | ||
| 28 | + self.chunks_by_id = {f"c{i}": i for i in range(n)} | ||
| 29 | + | ||
| 30 | + | ||
| 31 | +class _Svc: | ||
| 32 | + def __init__(self, sinif, ders, n=0): | ||
| 33 | + self.doc = _Doc(sinif, ders) | ||
| 34 | + self.ders = ders | ||
| 35 | + self.generator = _Gen(n) | ||
| 36 | + | ||
| 37 | + | ||
| 38 | +class RegistrationTests(unittest.TestCase): | ||
| 39 | + def setUp(self): | ||
| 40 | + self.r = CorpusRegistry() | ||
| 41 | + | ||
| 42 | + def test_register_reads_scope_from_the_service(self): | ||
| 43 | + k = self.r.register(_Svc("10", "biyoloji")) | ||
| 44 | + self.assertEqual(k, CorpusKey("10", "biyoloji")) | ||
| 45 | + self.assertEqual(len(self.r), 1) | ||
| 46 | + | ||
| 47 | + def test_explicit_scope_wins(self): | ||
| 48 | + k = self.r.register(_Svc("10", "biyoloji"), sinif="11", ders="fizik") | ||
| 49 | + self.assertEqual(str(k), "11/fizik") | ||
| 50 | + | ||
| 51 | + def test_scopeless_service_is_refused(self): | ||
| 52 | + """Sınıf/ders bilinmeden kayıt, sessizce yanlış yönlendirme demektir.""" | ||
| 53 | + class _Bos: | ||
| 54 | + doc = None | ||
| 55 | + ders = "" | ||
| 56 | + with self.assertRaises(ValueError): | ||
| 57 | + self.r.register(_Bos()) | ||
| 58 | + | ||
| 59 | + def test_re_register_replaces(self): | ||
| 60 | + self.r.register(_Svc("10", "biyoloji", n=5)) | ||
| 61 | + self.r.register(_Svc("10", "biyoloji", n=9)) | ||
| 62 | + self.assertEqual(len(self.r), 1) | ||
| 63 | + self.assertEqual(self.r.stats().chunks, 9) | ||
| 64 | + | ||
| 65 | + def test_unregister(self): | ||
| 66 | + self.r.register(_Svc("10", "biyoloji")) | ||
| 67 | + self.assertTrue(self.r.unregister("10", "biyoloji")) | ||
| 68 | + self.assertFalse(self.r.unregister("10", "biyoloji")) | ||
| 69 | + self.assertEqual(len(self.r), 0) | ||
| 70 | + | ||
| 71 | + def test_corpus_limit_is_a_deliberate_valve(self): | ||
| 72 | + """Ölçek duvarı ölçüldü (#75 yokken RSS lineer büyüyor): sessizce | ||
| 73 | + belleği tüketmektense açıkça reddetmek yeğdir.""" | ||
| 74 | + r = CorpusRegistry(max_corpora=2) | ||
| 75 | + r.register(_Svc("10", "biyoloji")) | ||
| 76 | + r.register(_Svc("10", "fizik")) | ||
| 77 | + with self.assertRaises(ValueError): | ||
| 78 | + r.register(_Svc("10", "kimya")) | ||
| 79 | + | ||
| 80 | + def test_limit_does_not_block_replacing_an_existing_corpus(self): | ||
| 81 | + r = CorpusRegistry(max_corpora=1) | ||
| 82 | + r.register(_Svc("10", "biyoloji", n=1)) | ||
| 83 | + r.register(_Svc("10", "biyoloji", n=2)) # aynı anahtar → yer açmaz | ||
| 84 | + self.assertEqual(r.stats().chunks, 2) | ||
| 85 | + | ||
| 86 | + | ||
| 87 | +class RoutingTests(unittest.TestCase): | ||
| 88 | + def setUp(self): | ||
| 89 | + self.r = CorpusRegistry() | ||
| 90 | + self.bio = _Svc("10", "biyoloji", n=3) | ||
| 91 | + self.fiz = _Svc("10", "fizik", n=4) | ||
| 92 | + self.r.register(self.bio) | ||
| 93 | + self.r.register(self.fiz) | ||
| 94 | + | ||
| 95 | + def test_scope_selects_the_corpus(self): | ||
| 96 | + svc, _ = self.r.resolve({"scope": {"sinif": "10", "ders": "fizik"}}) | ||
| 97 | + self.assertIs(svc, self.fiz) | ||
| 98 | + | ||
| 99 | + def test_single_subject_role_is_unambiguous(self): | ||
| 100 | + svc, _ = self.r.resolve( | ||
| 101 | + {"role": {"role": "student", "sinif": "10", "ders_list": ["biyoloji"]}}) | ||
| 102 | + self.assertIs(svc, self.bio) | ||
| 103 | + | ||
| 104 | + def test_options_ders_is_honoured(self): | ||
| 105 | + svc, _ = self.r.resolve( | ||
| 106 | + {"role": {"sinif": "10", "ders_list": ["biyoloji", "fizik"]}, | ||
| 107 | + "options": {"ders": "fizik"}}) | ||
| 108 | + self.assertIs(svc, self.fiz) | ||
| 109 | + | ||
| 110 | + def test_multi_subject_role_without_a_target_is_ambiguous(self): | ||
| 111 | + """Tahmin etmek yanlış kitaptan cevap üretmek demek olurdu.""" | ||
| 112 | + svc, sebep = self.r.resolve( | ||
| 113 | + {"role": {"sinif": "10", "ders_list": ["biyoloji", "fizik"]}}) | ||
| 114 | + self.assertIsNone(svc) | ||
| 115 | + self.assertEqual(sebep, "corpus_ambiguous") | ||
| 116 | + | ||
| 117 | + def test_multi_subject_role_resolves_when_only_one_is_loaded(self): | ||
| 118 | + """Öğrencinin 19 dersi olabilir ama süreçte tek korpus yüklüyse | ||
| 119 | + belirsizlik yoktur.""" | ||
| 120 | + r = CorpusRegistry() | ||
| 121 | + r.register(self.bio) | ||
| 122 | + svc, _ = r.resolve({"role": {"sinif": "10", | ||
| 123 | + "ders_list": ["biyoloji", "fizik", "kimya"]}}) | ||
| 124 | + self.assertIs(svc, self.bio) | ||
| 125 | + | ||
| 126 | + def test_unknown_corpus_is_reported_not_guessed(self): | ||
| 127 | + svc, sebep = self.r.resolve({"scope": {"sinif": "12", "ders": "biyoloji"}}) | ||
| 128 | + self.assertIsNone(svc) | ||
| 129 | + self.assertEqual(sebep, "no_corpus") | ||
| 130 | + | ||
| 131 | + def test_missing_scope_is_not_a_crash(self): | ||
| 132 | + for istek in ({}, {"role": {}}, {"scope": {}}, | ||
| 133 | + {"role": {"sinif": "10"}}): | ||
| 134 | + with self.subTest(istek=sorted(istek)): | ||
| 135 | + svc, sebep = self.r.resolve(istek) | ||
| 136 | + self.assertIsNone(svc) | ||
| 137 | + self.assertTrue(sebep) | ||
| 138 | + | ||
| 139 | + def test_routing_is_not_authorization(self): | ||
| 140 | + """Kapsam istemciden gelir; yönlendirme onu KABUL EDER ama yetki | ||
| 141 | + kararı ayrıdır. Bu test sınırı kayda geçirir: kayıt defteri rol | ||
| 142 | + kontrolü YAPMAZ, servis yapar (SEC-01).""" | ||
| 143 | + svc, _ = self.r.resolve({"scope": {"sinif": "10", "ders": "fizik"}, | ||
| 144 | + "role": {"role": "student", "sinif": "10", | ||
| 145 | + "ders_list": ["biyoloji"]}}) | ||
| 146 | + self.assertIs(svc, self.fiz, "yönlendirme kapsamı izlemeli") | ||
| 147 | + from src.guard.roles import Role, RoleContext, can_access | ||
| 148 | + ctx = RoleContext(role=Role.STUDENT, sinif="10", ders_list=["biyoloji"]) | ||
| 149 | + self.assertFalse(can_access(ctx, sinif="10", ders="fizik"), | ||
| 150 | + "yetki katmanı bu erişimi REDDETMELİ") | ||
| 151 | + | ||
| 152 | + | ||
| 153 | +class StatsTests(unittest.TestCase): | ||
| 154 | + def test_stats_report_scale(self): | ||
| 155 | + r = CorpusRegistry() | ||
| 156 | + r.register(_Svc("10", "biyoloji", n=100)) | ||
| 157 | + r.register(_Svc("10", "fizik", n=250)) | ||
| 158 | + s = r.stats() | ||
| 159 | + self.assertEqual(s.corpora, 2) | ||
| 160 | + self.assertEqual(s.chunks, 350) | ||
| 161 | + self.assertEqual(s.detail["10/fizik"], 250) | ||
| 162 | + | ||
| 163 | + def test_keys_are_sorted_and_stable(self): | ||
| 164 | + r = CorpusRegistry() | ||
| 165 | + for d in ("fizik", "biyoloji", "kimya"): | ||
| 166 | + r.register(_Svc("10", d)) | ||
| 167 | + self.assertEqual([str(k) for k in r.keys()], | ||
| 168 | + ["10/biyoloji", "10/fizik", "10/kimya"]) | ||
| 169 | + | ||
| 170 | + | ||
| 171 | +class ThreadSafetyTests(unittest.TestCase): | ||
| 172 | + def test_concurrent_registration(self): | ||
| 173 | + import threading | ||
| 174 | + r = CorpusRegistry() | ||
| 175 | + hatalar = [] | ||
| 176 | + | ||
| 177 | + def kaydet(i): | ||
| 178 | + try: | ||
| 179 | + r.register(_Svc("10", f"ders{i}")) | ||
| 180 | + except Exception as e: # noqa: BLE001 | ||
| 181 | + hatalar.append(repr(e)) | ||
| 182 | + | ||
| 183 | + ths = [threading.Thread(target=kaydet, args=(i,)) for i in range(20)] | ||
| 184 | + for t in ths: | ||
| 185 | + t.start() | ||
| 186 | + for t in ths: | ||
| 187 | + t.join() | ||
| 188 | + self.assertEqual(hatalar, []) | ||
| 189 | + self.assertEqual(len(r), 20) | ||
| 190 | + | ||
| 191 | + | ||
| 192 | +if __name__ == "__main__": | ||
| 193 | + unittest.main() | ||
tests/unit/test_service.pymodified+16 -2
| @@ -10,9 +10,23 @@ from src.guard.roles import Role | |||
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | class _GenStub: | 12 | class _GenStub: |
| 13 | - def __init__(self, ans): self.ans = ans; self.last_role = "UNSET" | 13 | + """Generator taklidi. |
| 14 | - def answer(self, query, *, history=None, top_n=6, candidate_n=40, role_ctx="UNSET"): | 14 | + |
| 15 | + `**kw` ŞART: bu stub gerçek imzadan geri kaldığında test, ürün kodundaki | ||
| 16 | + yeni bir parametreyi (örn. #85'te eklenen `trace=`) `TypeError` ile | ||
| 17 | + yakalamak yerine kırılıyor. Stub'ın esnek olması, testin ölçmek istediği | ||
| 18 | + şeyi (rol eşlemesi) ölçmeye devam etmesini sağlar; gerçek imza uyumu | ||
| 19 | + entegrasyon/e2e testlerinin işidir.""" | ||
| 20 | + | ||
| 21 | + def __init__(self, ans): | ||
| 22 | + self.ans = ans | ||
| 23 | + self.last_role = "UNSET" | ||
| 24 | + self.last_trace = None | ||
| 25 | + | ||
| 26 | + def answer(self, query, *, history=None, top_n=6, candidate_n=40, | ||
| 27 | + role_ctx="UNSET", trace=None, **kw): | ||
| 15 | self.last_role = role_ctx | 28 | self.last_role = role_ctx |
| 29 | + self.last_trace = trace | ||
| 16 | return self.ans | 30 | return self.ans |
| 17 | 31 | ||
| 18 | 32 | ||