fumito-ito / AnthropicSwiftSDK

Yet another Anthropic API client for Swift.
3 stars 1 forks source link

Streaming returns no content #44

Open misbell opened 21 hours ago

misbell commented 21 hours ago

Calling the streaming example, sending two messages, returns an empty content array.

Screenshot 2024-09-29 at 8 46 10 AM
fumito-ito commented 15 hours ago

@misbell Yes. The message_start event contains a message object with empty content. For more details, please refer to https://docs.anthropic.com/en/api/messages-streaming#event-types.

If you want to handle content within the message stream, please use the content_block_delta event as shown below.

https://github.com/fumito-ito/AnthropicSwiftSDK/blob/e06503a170602762aa0f5fde220122a1c13e1dc3/Example.swiftpm/ViewModel/StreamViewModel.swift#L57-L66