From 54fdebfc3a774c8b0d5cf6a00fa02c4ac9913ac0 Mon Sep 17 00:00:00 2001 From: AI Christianson Date: Fri, 24 Jan 2025 10:37:30 -0500 Subject: [PATCH] Do not incorrectly give temp parameter to expert model. --- ra_aid/llm.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ra_aid/llm.py b/ra_aid/llm.py index 2821578..549a811 100644 --- a/ra_aid/llm.py +++ b/ra_aid/llm.py @@ -122,9 +122,10 @@ def create_llm_client( if not config: raise ValueError(f"Unsupported provider: {provider}") - # Handle temperature for expert mode - if is_expert: - temperature = 0 + # Only pass temperature if it's explicitly set and not in expert mode + temp_kwargs = {} + if not is_expert and temperature is not None: + temp_kwargs = {"temperature": temperature} if provider == "deepseek": return create_deepseek_client( @@ -145,26 +146,26 @@ def create_llm_client( return ChatOpenAI( api_key=config["api_key"], model=model_name, - **({"temperature": temperature} if temperature is not None else {}), + **temp_kwargs, ) elif provider == "anthropic": return ChatAnthropic( api_key=config["api_key"], model_name=model_name, - **({"temperature": temperature} if temperature is not None else {}), + **temp_kwargs, ) elif provider == "openai-compatible": return ChatOpenAI( api_key=config["api_key"], base_url=config["base_url"], - temperature=temperature if temperature is not None else 0.3, + **temp_kwargs if temp_kwargs else {"temperature": 0.3}, model=model_name, ) elif provider == "gemini": return ChatGoogleGenerativeAI( api_key=config["api_key"], model=model_name, - **({"temperature": temperature} if temperature is not None else {}), + **temp_kwargs, ) else: raise ValueError(f"Unsupported provider: {provider}")