Merge pull request #1724 from NousResearch/fix/model-metadata-fuzzy-match
fix(metadata): fuzzy context length match can return wrong model's value
This commit is contained in:
commit
0878e5f4a8
1 changed files with 4 additions and 2 deletions
|
|
@ -266,8 +266,10 @@ def get_model_context_length(model: str, base_url: str = "") -> int:
|
||||||
if model in metadata:
|
if model in metadata:
|
||||||
return metadata[model].get("context_length", 128000)
|
return metadata[model].get("context_length", 128000)
|
||||||
|
|
||||||
# 3. Hardcoded defaults (fuzzy match)
|
# 3. Hardcoded defaults (fuzzy match — longest key first for specificity)
|
||||||
for default_model, length in DEFAULT_CONTEXT_LENGTHS.items():
|
for default_model, length in sorted(
|
||||||
|
DEFAULT_CONTEXT_LENGTHS.items(), key=lambda x: len(x[0]), reverse=True
|
||||||
|
):
|
||||||
if default_model in model or model in default_model:
|
if default_model in model or model in default_model:
|
||||||
return length
|
return length
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue