From 7e267b95f8a151412141a2cce049ffb62474ee3c Mon Sep 17 00:00:00 2001 From: Daniel Chalef <131175+danielchalef@users.noreply.github.com> Date: Thu, 30 Oct 2025 16:22:06 -0700 Subject: [PATCH] Fix Anthropic client temperature type error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed pyright type error where temperature parameter (float | None) was being passed directly to Anthropic's messages.create() method which expects (float | Omit). Changes: - Build message creation parameters as a dictionary - Conditionally include temperature only when not None - Use dictionary unpacking to pass parameters This allows temperature to be properly omitted when None, rather than passing None as a value. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- graphiti_core/llm_client/anthropic_client.py | 25 +++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/graphiti_core/llm_client/anthropic_client.py b/graphiti_core/llm_client/anthropic_client.py index 1f2916b3..179e035a 100644 --- a/graphiti_core/llm_client/anthropic_client.py +++ b/graphiti_core/llm_client/anthropic_client.py @@ -214,15 +214,22 @@ class AnthropicClient(LLMClient): try: # Create the appropriate tool based on whether response_model is provided tools, tool_choice = self._create_tool(response_model) - result = await self.client.messages.create( - system=system_message.content, - max_tokens=max_creation_tokens, - temperature=self.temperature, - messages=user_messages_cast, - model=self.model, - tools=tools, - tool_choice=tool_choice, - ) + + # Build the message creation parameters + create_params: dict[str, typing.Any] = { + 'system': system_message.content, + 'max_tokens': max_creation_tokens, + 'messages': user_messages_cast, + 'model': self.model, + 'tools': tools, + 'tool_choice': tool_choice, + } + + # Only include temperature if it's not None + if self.temperature is not None: + create_params['temperature'] = self.temperature + + result = await self.client.messages.create(**create_params) # Extract the tool output from the response for content_item in result.content: