|
6 | 6 | from litellm import acompletion
|
7 | 7 | from tenacity import retry, retry_if_exception_type, stop_after_attempt
|
8 | 8 |
|
9 |
| -from pr_agent.algo import NO_SUPPORT_TEMPERATURE_MODELS, USER_MESSAGE_ONLY_MODELS |
| 9 | +from pr_agent.algo import NO_SUPPORT_TEMPERATURE_MODELS, SUPPORT_REASONING_EFFORT_MODELS, USER_MESSAGE_ONLY_MODELS |
10 | 10 | from pr_agent.algo.ai_handlers.base_ai_handler import BaseAiHandler
|
11 |
| -from pr_agent.algo.utils import get_version |
| 11 | +from pr_agent.algo.utils import ReasoningEffort, get_version |
12 | 12 | from pr_agent.config_loader import get_settings
|
13 | 13 | from pr_agent.log import get_logger
|
14 | 14 |
|
@@ -101,6 +101,9 @@ def __init__(self):
|
101 | 101 | # Model that doesn't support temperature argument
|
102 | 102 | self.no_support_temperature_models = NO_SUPPORT_TEMPERATURE_MODELS
|
103 | 103 |
|
| 104 | + # Models that support reasoning effort |
| 105 | + self.support_reasoning_models = SUPPORT_REASONING_EFFORT_MODELS |
| 106 | + |
104 | 107 | def prepare_logs(self, response, system, user, resp, finish_reason):
|
105 | 108 | response_log = response.dict().copy()
|
106 | 109 | response_log['system'] = system
|
@@ -228,8 +231,16 @@ async def chat_completion(self, model: str, system: str, user: str, temperature:
|
228 | 231 |
|
229 | 232 | # Add temperature only if model supports it
|
230 | 233 | if model not in self.no_support_temperature_models and not get_settings().config.custom_reasoning_model:
|
| 234 | + get_logger().info(f"Adding temperature with value {temperature} to model {model}.") |
231 | 235 | kwargs["temperature"] = temperature
|
232 | 236 |
|
| 237 | + # Add reasoning_effort if model supports it |
| 238 | + if (model in self.support_reasoning_models): |
| 239 | + supported_reasoning_efforts = [ReasoningEffort.HIGH.value, ReasoningEffort.MEDIUM.value, ReasoningEffort.LOW.value] |
| 240 | + reasoning_effort = get_settings().config.reasoning_effort if (get_settings().config.reasoning_effort in supported_reasoning_efforts) else ReasoningEffort.MEDIUM.value |
| 241 | + get_logger().info(f"Adding reasoning_effort with value {reasoning_effort} to model {model}.") |
| 242 | + kwargs["reasoning_effort"] = reasoning_effort |
| 243 | + |
233 | 244 | if get_settings().litellm.get("enable_callbacks", False):
|
234 | 245 | kwargs = self.add_litellm_callbacks(kwargs)
|
235 | 246 |
|
|
0 commit comments