chore: Bump version to 0.1.3
- Fix: Skip empty/whitespace-only text content blocks in chat completions - This resolves Anthropic API errors: - "messages: text content blocks must contain non-whitespace text" - "messages: text content blocks must be non-empty" - Updated version strings in all test files and snapshots 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -175,7 +175,10 @@ pub(crate) async fn stream_chat_completions(
|
||||
ContentItem::InputText { text: t }
|
||||
| ContentItem::OutputText { text: t } => {
|
||||
text.push_str(t);
|
||||
items.push(json!({"type":"text","text": t}));
|
||||
// Only add text content blocks that are non-empty
|
||||
if !t.trim().is_empty() {
|
||||
items.push(json!({"type":"text","text": t}));
|
||||
}
|
||||
}
|
||||
ContentItem::InputImage { image_url } => {
|
||||
saw_image = true;
|
||||
@@ -184,6 +187,11 @@ pub(crate) async fn stream_chat_completions(
|
||||
}
|
||||
}
|
||||
|
||||
// Skip messages with empty or whitespace-only text content (unless they contain images)
|
||||
if text.trim().is_empty() && !saw_image {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip exact-duplicate assistant messages.
|
||||
if role == "assistant" {
|
||||
if let Some(prev) = &last_assistant_text
|
||||
|
||||
Reference in New Issue
Block a user