fix(anthropic): satisfy lint on staging re-raise

This commit is contained in:
Gennaro Malafronte 2026-04-27 18:48:58 +02:00
parent e5c1daf3d2
commit 9ec472bb97
2 changed files with 9 additions and 4 deletions

View file

@ -1573,6 +1573,12 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):
)
return _message
@staticmethod
def _strip_leaked_think_prefix(text_content: str) -> str:
if "</think>" not in text_content:
return text_content
return text_content.split("</think>", 1)[1].lstrip()
def extract_response_content(self, completion_response: dict) -> Tuple[
str,
Optional[List[Any]],
@ -1667,8 +1673,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):
if thinking_content is not None:
reasoning_content += thinking_content
if "</think>" in text_content:
text_content = text_content.split("</think>", 1)[1].lstrip()
text_content = self._strip_leaked_think_prefix(text_content)
return (
text_content,

View file

@ -1385,12 +1385,12 @@ class LiteLLMAnthropicMessagesAdapter:
raw_id = choice.delta.tool_calls[0].id or str(uuid.uuid4())
tool_name = choice.delta.tool_calls[0].function.name or ""
base_id = raw_id
thought_sig: Optional[str] = None
thought_sig: str | None = None
if THOUGHT_SIGNATURE_SEPARATOR in raw_id:
parts = raw_id.split(THOUGHT_SIGNATURE_SEPARATOR, 1)
base_id = parts[0]
thought_sig = parts[1] if len(parts) > 1 else None
tool_block: Dict[str, Any] = {
tool_block: dict[str, Any] = {
"type": "tool_use",
"id": base_id,
"name": tool_name,