DeepSeek-VL varsayılan captioner (mevcut key, yeni key yok) — Refs #23
Browse files at this commita4ea060a6e87fa346dc923fdad7c70997c77813aParent: d6fb062- feat
- DeepSeek-VL varsayılan captioner (mevcut key, yeni key yok) — Refs #23
2 changed files +21 -2
- src/ingest/canonical.py +2 -2
- src/providers/vlm.py +19 -0
src/ingest/canonical.pymodified+2 -2
| @@ -118,8 +118,8 @@ def build_canonical(path: str, sinif: str, ders: str, *, | |||
| 118 | if vlm: | 118 | if vlm: |
| 119 | from .visual_caption import caption_visual_units, merge_visual_units | 119 | from .visual_caption import caption_visual_units, merge_visual_units |
| 120 | if captioner is None: | 120 | if captioner is None: |
| 121 | - from ..providers.vlm import VLMCaptioner | 121 | + from ..providers.vlm import default_captioner |
| 122 | - captioner = VLMCaptioner() | 122 | + captioner = default_captioner() |
| 123 | vunits = caption_visual_units(path, doc_id=doc_id, sinif=sinif, ders=ders, | 123 | vunits = caption_visual_units(path, doc_id=doc_id, sinif=sinif, ders=ders, |
| 124 | kaynak_turu=kaynak_turu, page_visual=page_visual, | 124 | kaynak_turu=kaynak_turu, page_visual=page_visual, |
| 125 | captioner=captioner) | 125 | captioner=captioner) |
src/providers/vlm.pymodified+19 -0
| @@ -94,3 +94,22 @@ class VLMCaptioner: | |||
| 94 | def caption(self, image_png: bytes, **kw) -> str: | 94 | def caption(self, image_png: bytes, **kw) -> str: |
| 95 | """Yalnız betim metni (maliyet gerekmezse).""" | 95 | """Yalnız betim metni (maliyet gerekmezse).""" |
| 96 | return self.caption_with_usage(image_png, **kw).text | 96 | return self.caption_with_usage(image_png, **kw).text |
| 97 | + | ||
| 98 | + | ||
| 99 | +# DeepSeek API'nin görsel modeli (canlı /models ile doğrulandı 2026-09-06); mevcut | ||
| 100 | +# DEEPSEEK_API_KEY ile çalışır — ayrı vision key gerekmez. | ||
| 101 | +DEEPSEEK_VISION_MODEL = "deepseek-v4-flash-vision-exp" | ||
| 102 | +DEEPSEEK_BASE = "https://api.deepseek.com" | ||
| 103 | + | ||
| 104 | + | ||
| 105 | +def default_captioner(timeout: float = 120.0) -> VLMCaptioner: | ||
| 106 | + """Sağlayıcı seçimi: VLM_* env verilmişse ONU kullanır (herhangi OpenAI-uyumlu | ||
| 107 | + VLM); yoksa mevcut `DEEPSEEK_API_KEY` ile DeepSeek-VL'e düşer (yeni key yok). | ||
| 108 | + İkisi de yoksa kullanılamaz captioner (zarif degradasyon).""" | ||
| 109 | + if os.environ.get("VLM_API_KEY") and os.environ.get("VLM_BASE_URL") and os.environ.get("VLM_MODEL"): | ||
| 110 | + return VLMCaptioner(timeout=timeout) | ||
| 111 | + dk = os.environ.get("DEEPSEEK_API_KEY") | ||
| 112 | + if dk: | ||
| 113 | + return VLMCaptioner(model=DEEPSEEK_VISION_MODEL, base_url=DEEPSEEK_BASE, | ||
| 114 | + api_key=dk, timeout=timeout) | ||
| 115 | + return VLMCaptioner() | ||