This commit is contained in:
lorenzejay
2026-03-23 11:42:15 -07:00
parent ee5b9bb479
commit c596a71b0a
3 changed files with 8 additions and 5 deletions

View File

@@ -94,7 +94,9 @@ def _serialize_llm_for_context(llm: Any) -> dict[str, Any] | str | None:
return f"{provider}/{model}" if provider and "/" not in model else model
def _deserialize_llm_from_context(llm_data: dict[str, Any] | str | None) -> BaseLLM | None:
def _deserialize_llm_from_context(
llm_data: dict[str, Any] | str | None,
) -> BaseLLM | None:
"""Reconstruct an LLM instance from serialized context data.
Handles both the new dict format (with full config) and the legacy
@@ -118,7 +120,6 @@ def _deserialize_llm_from_context(llm_data: dict[str, Any] | str | None) -> Base
return None
@dataclass
class HumanFeedbackResult:
"""Result from a @human_feedback decorated method.

View File

@@ -1897,7 +1897,9 @@ class BedrockCompletion(BaseLLM):
# Anthropic (Claude) models reject assistant-last messages when
# tools are in the request. Append a user message so the
# Converse API accepts the payload.
elif "anthropic" in self.model.lower() or "claude" in self.model.lower():
elif (
"anthropic" in self.model.lower() or "claude" in self.model.lower()
):
converse_messages.append(
{
"role": "user",

View File

@@ -197,8 +197,8 @@ class GeminiCompletion(BaseLLM):
else s
for s in self.safety_settings
]
except Exception:
pass
except Exception: # noqa: S110
pass # non-serializable safety_settings — omit from config
return config
def _initialize_client(self, use_vertexai: bool = False) -> genai.Client: