mirror of
https://github.com/anthropics/claude-code-sdk-python.git
synced 2025-07-07 22:55:01 +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,
|
ResultMessage,
|
||||||
SystemMessage,
|
SystemMessage,
|
||||||
TextBlock,
|
TextBlock,
|
||||||
|
ThinkingBlock,
|
||||||
ToolResultBlock,
|
ToolResultBlock,
|
||||||
ToolUseBlock,
|
ToolUseBlock,
|
||||||
UserMessage,
|
UserMessage,
|
||||||
|
@ -55,6 +56,13 @@ class InternalClient:
|
||||||
match block["type"]:
|
match block["type"]:
|
||||||
case "text":
|
case "text":
|
||||||
content_blocks.append(TextBlock(text=block["text"]))
|
content_blocks.append(TextBlock(text=block["text"]))
|
||||||
|
case "thinking":
|
||||||
|
content_blocks.append(
|
||||||
|
ThinkingBlock(
|
||||||
|
thinking=block["thinking"],
|
||||||
|
signature=block["signature"],
|
||||||
|
)
|
||||||
|
)
|
||||||
case "tool_use":
|
case "tool_use":
|
||||||
content_blocks.append(
|
content_blocks.append(
|
||||||
ToolUseBlock(
|
ToolUseBlock(
|
||||||
|
|
|
@ -47,6 +47,14 @@ class TextBlock:
|
||||||
text: str
|
text: str
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class ThinkingBlock:
|
||||||
|
"""Thinking content block."""
|
||||||
|
|
||||||
|
thinking: str
|
||||||
|
signature: str
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class ToolUseBlock:
|
class ToolUseBlock:
|
||||||
"""Tool use content block."""
|
"""Tool use content block."""
|
||||||
|
|
|
@ -5,7 +5,13 @@ from claude_code_sdk import (
|
||||||
ClaudeCodeOptions,
|
ClaudeCodeOptions,
|
||||||
ResultMessage,
|
ResultMessage,
|
||||||
)
|
)
|
||||||
from claude_code_sdk.types import TextBlock, ToolResultBlock, ToolUseBlock, UserMessage
|
from claude_code_sdk.types import (
|
||||||
|
TextBlock,
|
||||||
|
ThinkingBlock,
|
||||||
|
ToolResultBlock,
|
||||||
|
ToolUseBlock,
|
||||||
|
UserMessage,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestMessageTypes:
|
class TestMessageTypes:
|
||||||
|
@ -23,6 +29,14 @@ class TestMessageTypes:
|
||||||
assert len(msg.content) == 1
|
assert len(msg.content) == 1
|
||||||
assert msg.content[0].text == "Hello, human!"
|
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):
|
def test_tool_use_block(self):
|
||||||
"""Test creating a ToolUseBlock."""
|
"""Test creating a ToolUseBlock."""
|
||||||
block = ToolUseBlock(
|
block = ToolUseBlock(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue