GPT-4.1-support (#2159)

This commit is contained in:
Suchintan 2025-04-16 02:12:33 -04:00 committed by GitHub
parent 0d24fe3981
commit c829966936
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 70 additions and 10 deletions

View file

@ -37,7 +37,17 @@ class LLMConfigRegistry:
@classmethod
def get_config(cls, llm_key: str) -> LLMRouterConfig | LLMConfig:
if llm_key not in cls._configs:
raise InvalidLLMConfigError(llm_key)
# If the key is not found in registered configs, treat it as a general model
LOG.info("Using general model configuration for unknown LLM key", llm_key=llm_key)
if not llm_key:
raise InvalidLLMConfigError(f"LLM_KEY not set for {llm_key}")
return LLMConfig(
llm_key, # Use the LLM_KEY as the model name
["LLM_API_KEY"],
supports_vision=settings.LLM_CONFIG_SUPPORT_VISION,
add_assistant_prefix=settings.LLM_CONFIG_ADD_ASSISTANT_PREFIX,
max_completion_tokens=settings.LLM_CONFIG_MAX_TOKENS,
)
return cls._configs[llm_key]
@ -52,6 +62,36 @@ if settings.ENABLE_OPENAI:
add_assistant_prefix=False,
),
)
LLMConfigRegistry.register_config(
"OPENAI_GPT4_1",
LLMConfig(
"gpt-4.1",
["OPENAI_API_KEY"],
supports_vision=True,
add_assistant_prefix=False,
max_completion_tokens=16384,
),
)
LLMConfigRegistry.register_config(
"OPENAI_GPT4_1_MINI",
LLMConfig(
"gpt-4.1-mini",
["OPENAI_API_KEY"],
supports_vision=True,
add_assistant_prefix=False,
max_completion_tokens=16384,
),
)
LLMConfigRegistry.register_config(
"OPENAI_GPT4_1_NANO",
LLMConfig(
"gpt-4.1-nano",
["OPENAI_API_KEY"],
supports_vision=True,
add_assistant_prefix=False,
max_completion_tokens=16384,
),
)
LLMConfigRegistry.register_config(
"OPENAI_GPT4_5",
LLMConfig(