feat(backend): 이미지 요청만 vision 모델로 — OPENCODE_VISION_MODEL

로컬(OpenRouter)은 게이트웨이를 안 거쳐서 백엔드가 OpenCode prompt 에 model{providerID,modelID} 를 실어 분기.
기본 openrouter/google/gemma-4-31b-it(고객사 605 와 같은 모델). 텍스트는 기본 GLM 5.2.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
lee-hyeon-cheol
2026-09-21 14:54:04 +09:00
co-authored by Claude Fable 5.1
parent 6d7723a533
commit 113d97c77c
6 changed files with 28 additions and 2 deletions
+14
View File
@@ -357,3 +357,17 @@ async def test_stream_title_arriving_after_idle_is_mirrored(fake, django_user_mo
await asyncio.sleep(0.3)
session = await ChatSession.objects.aget(id="s1")
assert session.title_llm == "늦게 온 제목"
# ── 이미지 있으면 vision 모델 ─────────────────────────────────────
def test_prompt_payload_switches_model_only_with_images(settings):
settings.OPENCODE_VISION_MODEL = "openrouter/google/gemma-4-31b-it"
text_only = stream_mod._prompt_payload({"content": "hi", "explain": False, "images": []})
assert "model" not in text_only
with_img = stream_mod._prompt_payload(
{"content": "", "explain": False, "images": [{"mediaType": "image/png", "data": "data:image/png;base64,AA"}]}
)
assert with_img["model"] == {"providerID": "openrouter", "modelID": "google/gemma-4-31b-it"}
settings.OPENCODE_VISION_MODEL = ""
assert "model" not in stream_mod._prompt_payload({"content": "", "explain": False, "images": with_img["parts"] and [{"mediaType": "image/png", "data": "x"}]})