mirror of
https://github.com/anthropics/claude-code-sdk-python.git
synced 2025-07-07 14:45:00 +00:00
Merge 82ac5df92e
into 343ec4812c
This commit is contained in:
commit
01d033e32e
3 changed files with 31 additions and 1 deletions
|
@ -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(
|
||||
|
|
|
@ -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."""
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue