Fix/supported llm params (#3290)

This commit is contained in:
Parshva Daftari
2025-08-08 14:39:42 -07:00
committed by GitHub
parent 4c748423fc
commit 2307dc8613
8 changed files with 73 additions and 39 deletions
+2
View File
@@ -6,6 +6,8 @@ title: OpenAI
To use OpenAI LLM models, you have to set the `OPENAI_API_KEY` environment variable. You can obtain the OpenAI API key from the [OpenAI Platform](https://platform.openai.com/account/api-keys).
> **Note**: The following are currently unsupported with reasoning models `Parallel tool calling`,`temperature`, `top_p`, `presence_penalty`, `frequency_penalty`, `logprobs`, `top_logprobs`, `logit_bias`, `max_tokens`
## Usage
<CodeGroup>
+1 -2
View File
@@ -70,8 +70,7 @@ class AnthropicLLM(LLMBase):
else:
filtered_messages.append(message)
# Get common parameters
params = self._get_common_params(**kwargs)
params = self._get_supported_params(messages=messages, **kwargs)
params.update(
{
"model": self.config.model,
+7 -21
View File
@@ -110,27 +110,13 @@ class AzureOpenAILLM(LLMBase):
messages[-1]["content"] = user_prompt
# Get common parameters
params = self._get_common_params(**kwargs)
params.update(
{
"model": self.config.model,
"messages": messages,
}
)
if self.config.model in {"o3-mini", "o1-preview", "o1"}:
# Use common params for these models
pass
else:
# Add additional parameters for other models
params.update(
{
"temperature": self.config.temperature,
"max_tokens": self.config.max_tokens,
"top_p": self.config.top_p,
}
)
params = self._get_supported_params(messages=messages, **kwargs)
# Add model and messages
params.update({
"model": self.config.model,
"messages": messages,
})
if tools:
params["tools"] = tools
+54
View File
@@ -40,6 +40,60 @@ class LLMBase(ABC):
# This will be handled by individual providers
pass
def _is_reasoning_model(self, model: str) -> bool:
"""
Check if the model is a reasoning model or GPT-5 series that doesn't support certain parameters.
Args:
model: The model name to check
Returns:
bool: True if the model is a reasoning model or GPT-5 series
"""
reasoning_models = {
"o1", "o1-preview", "o3-mini", "o3",
"gpt-5", "gpt-5o", "gpt-5o-mini", "gpt-5o-micro",
}
if model.lower() in reasoning_models:
return True
model_lower = model.lower()
if any(reasoning_model in model_lower for reasoning_model in ["gpt-5", "o1", "o3"]):
return True
return False
def _get_supported_params(self, **kwargs) -> Dict:
"""
Get parameters that are supported by the current model.
Filters out unsupported parameters for reasoning models and GPT-5 series.
Args:
**kwargs: Additional parameters to include
Returns:
Dict: Filtered parameters dictionary
"""
model = getattr(self.config, 'model', '')
if self._is_reasoning_model(model):
supported_params = {}
if "messages" in kwargs:
supported_params["messages"] = kwargs["messages"]
if "response_format" in kwargs:
supported_params["response_format"] = kwargs["response_format"]
if "tools" in kwargs:
supported_params["tools"] = kwargs["tools"]
if "tool_choice" in kwargs:
supported_params["tool_choice"] = kwargs["tool_choice"]
return supported_params
else:
# For regular models, include all common parameters
return self._get_common_params(**kwargs)
@abstractmethod
def generate_response(
self, messages: List[Dict[str, str]], tools: Optional[List[Dict]] = None, tool_choice: str = "auto", **kwargs
+1 -2
View File
@@ -91,8 +91,7 @@ class DeepSeekLLM(LLMBase):
Returns:
str: The generated response.
"""
# Get common parameters
params = self._get_common_params(**kwargs)
params = self._get_supported_params(messages=messages, **kwargs)
params.update(
{
"model": self.config.model,
+1 -4
View File
@@ -91,8 +91,7 @@ class LMStudioLLM(LLMBase):
Returns:
str: The generated response.
"""
# Get common parameters
params = self._get_common_params(**kwargs)
params = self._get_supported_params(messages=messages, **kwargs)
params.update(
{
"model": self.config.model,
@@ -100,13 +99,11 @@ class LMStudioLLM(LLMBase):
}
)
# Handle response format - LM Studio defaults to json_object
if self.config.lmstudio_response_format:
params["response_format"] = self.config.lmstudio_response_format
elif response_format:
params["response_format"] = response_format
else:
# Default to json_object for LM Studio
params["response_format"] = {"type": "json_object"}
if tools:
+6 -8
View File
@@ -101,14 +101,12 @@ class OpenAILLM(LLMBase):
Returns:
json: The generated response.
"""
# Get common parameters
params = self._get_common_params(**kwargs)
params.update(
{
"model": self.config.model,
"messages": messages,
}
)
params = self._get_supported_params(messages=messages, **kwargs)
params.update({
"model": self.config.model,
"messages": messages,
})
if os.getenv("OPENROUTER_API_KEY"):
openrouter_params = {}
+1 -2
View File
@@ -91,8 +91,7 @@ class VllmLLM(LLMBase):
Returns:
str: The generated response.
"""
# Get common parameters
params = self._get_common_params(**kwargs)
params = self._get_supported_params(messages=messages, **kwargs)
params.update(
{
"model": self.config.model,