This commit is contained in:
yokomotod 2025-07-06 00:45:18 +03:00 committed by GitHub
commit 01d033e32e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 1 deletions

View file

@ -11,6 +11,7 @@ from ..types import (
ResultMessage,
SystemMessage,
TextBlock,
ThinkingBlock,
ToolResultBlock,
ToolUseBlock,
UserMessage,
@ -55,6 +56,13 @@ class InternalClient:
match block["type"]:
case "text":
content_blocks.append(TextBlock(text=block["text"]))
case "thinking":
content_blocks.append(
ThinkingBlock(
thinking=block["thinking"],
signature=block["signature"],
)
)
case "tool_use":
content_blocks.append(
ToolUseBlock(

View file

@ -47,6 +47,14 @@ class TextBlock:
text: str
@dataclass
class ThinkingBlock:
"""Thinking content block."""
thinking: str
signature: str
@dataclass
class ToolUseBlock:
"""Tool use content block."""

View file

@ -5,7 +5,13 @@ from claude_code_sdk import (
ClaudeCodeOptions,
ResultMessage,
)
from claude_code_sdk.types import TextBlock, ToolResultBlock, ToolUseBlock, UserMessage
from claude_code_sdk.types import (
TextBlock,
ThinkingBlock,
ToolResultBlock,
ToolUseBlock,
UserMessage,
)
class TestMessageTypes:
@ -23,6 +29,14 @@ class TestMessageTypes:
assert len(msg.content) == 1
assert msg.content[0].text == "Hello, human!"
def test_assistant_message_with_thinking(self):
"""Test creating an AssistantMessage with thinking content."""
thinking_block = ThinkingBlock(thinking="I'm thinking...", signature="sig-123")
msg = AssistantMessage(content=[thinking_block])
assert len(msg.content) == 1
assert msg.content[0].thinking == "I'm thinking..."
assert msg.content[0].signature == "sig-123"
def test_tool_use_block(self):
"""Test creating a ToolUseBlock."""
block = ToolUseBlock(