mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-17 23:51:30 +00:00
fix(anthropic): satisfy lint on staging re-raise
This commit is contained in:
parent
e5c1daf3d2
commit
9ec472bb97
2 changed files with 9 additions and 4 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue