feat(gateway): 이미지 붙은 요청만 vision 모델(Gemma4)로 — 텍스트는 기본 339

Gemma4 가 '안녕' 한 단어에 94s(580 은 188s) 라 텍스트 기본으로는 못 씀.
AAF_FABRIX_VISION_MODEL_ID 가 있으면 messages 에 image_url 파트가 있을 때만 그 모델로 x-llm-model-id 를 바꿈.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
lee-hyeon-cheol
2026-09-18 10:34:55 +09:00
co-authored by Claude Fable 5.1
parent 2b8c2d7742
commit 7ad48732ae
5 changed files with 51 additions and 3 deletions
+13
View File
@@ -38,6 +38,19 @@ def test_prepare_picks_model_by_header_not_body():
assert headers["x-llm-model-id"] == "339"
def test_vision_model_only_when_image_attached():
cfg = FabrixConfig.from_env({**FULL_ENV, "AAF_FABRIX_VISION_MODEL_ID": "605"})
text = {"model": "339", "messages": [{"role": "user", "content": "hi"}]}
img = {"model": "339", "messages": [{"role": "user", "content": [
{"type": "text", "text": "what is this"},
{"type": "image_url", "image_url": {"url": "data:image/png;base64,AAAA"}},
]}]}
assert cfg.prepare(text)[1]["x-llm-model-id"] == "339"
assert cfg.prepare(img)[1]["x-llm-model-id"] == "605"
# 설정 없으면 분기 안 함
assert FabrixConfig.from_env(FULL_ENV).prepare(img)[1]["x-llm-model-id"] == "339"
def test_missing_config_names():
assert FabrixConfig.from_env({}).missing() == [
"AAF_FABRIX_BASE_URL", "AAF_FABRIX_MODEL_ID", "AAF_FABRIX_CLIENT_KEY", "AAF_FABRIX_OPENAPI_TOKEN",