Skip to content

Commit 8db97fe

Browse files
committed
fix: handle missing content field in tool call responses
OpenAI-compatible APIs (e.g. GLM-4-flash) may omit the 'content' field in assistant messages that contain tool_calls. Adding #[serde(default)] makes it default to empty string instead of failing deserialization. Error was: 'missing field content at line 1 column 270'
1 parent c928351 commit 8db97fe

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

src/llm/api_types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize};
44
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
55
pub struct Message {
66
pub role: String,
7+
#[serde(default)]
78
pub content: String,
89
/// Tool calls requested by the assistant (only present when role=assistant).
910
#[serde(skip_serializing_if = "Option::is_none", default)]

0 commit comments

Comments
 (0)