Skip to content

Commit 13e178a

Browse files
committed
Fix _get_model_type to dynamically fetch models from API with preset fallback, adding QWEN2 and other missing models to MODEL_MAP
1 parent 7e6ad97 commit 13e178a

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

vecto/schema.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ class VectoNewTokenResponse(NamedTuple):
8787
MODEL_MAP = {
8888
1: "CLIP",
8989
2: "SBERT",
90-
3: "OPENAI"
90+
3: "OPENAI",
91+
4: "OPENAI_V3_SMALL",
92+
5: "OPENAI_V3_LARGE",
93+
6: "QWEN2"
9194
}
9295

9396

vecto/vecto_requests.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,18 +659,26 @@ def ingest_all_text(self, text_list:list, attribute_list:list, batch_size=64) ->
659659
##################
660660

661661
def _get_model_type(self, input_value):
662+
# Try dynamic lookup from API first, fall back to hardcoded MODEL_MAP
663+
try:
664+
models = self.list_models()
665+
dynamic_map = {m.id: m.name.upper() for m in models}
666+
except Exception:
667+
dynamic_map = None
668+
669+
model_map = dynamic_map if dynamic_map else MODEL_MAP
670+
662671
if isinstance(input_value, int):
663-
if input_value in MODEL_MAP:
672+
if input_value in model_map:
664673
return input_value
665674
else:
666675
raise ModelNotFoundException(f"Model not found for integer value: {input_value}")
667676
elif isinstance(input_value, str):
668677
input_value = input_value.upper()
669-
for model_int, model_str in MODEL_MAP.items():
678+
for model_int, model_str in model_map.items():
670679
if model_str == input_value:
671680
return model_int
672-
else:
673-
raise ModelNotFoundException(f"Model not found for string value: {input_value}")
681+
raise ModelNotFoundException(f"Model not found for string value: {input_value}")
674682
else:
675683
raise TypeError(f"Invalid input type: {type(input_value)}.")
676684

0 commit comments

Comments
 (0)