fix: resolve mypy type errors in anthropic transformation

This commit is contained in:
Navnit Shukla 2026-06-08 14:34:23 -07:00
parent d3894ebd4f
commit f9de88f930
No known key found for this signature in database
GPG key ID: 46D87897A91C215F

View file

@ -171,7 +171,7 @@ class SnowflakeCortexAnthropicConfig(SnowflakeBaseConfig):
for msg in messages:
if isinstance(msg, dict):
role = msg.get("role", "")
content = msg.get("content", "")
content: Any = msg.get("content", "")
else:
role = getattr(msg, "role", "")
content = getattr(msg, "content", "")
@ -184,11 +184,11 @@ class SnowflakeCortexAnthropicConfig(SnowflakeBaseConfig):
if isinstance(msg, dict)
else getattr(msg, "tool_calls", None)
)
if tool_calls:
if tool_calls: # type: ignore[truthy-bool]
content_blocks: List[Dict[str, Any]] = []
if content:
content_blocks.append({"type": "text", "text": content})
for tc in tool_calls:
for tc in tool_calls: # type: ignore[union-attr]
func = (
tc.get("function", {})
if isinstance(tc, dict)
@ -385,7 +385,7 @@ class SnowflakeCortexAnthropicConfig(SnowflakeBaseConfig):
)
model_response.choices = [choice]
model_response.usage = usage
model_response.usage = usage # type: ignore[assignment]
model_response.model = "snowflake/" + response_json.get("model", model)
model_response.id = response_json.get("id", "")