Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ pub struct ChatCompletionMessageDelta {
pub role: Option<ChatCompletionMessageRole>,
/// The contents of the message
pub content: Option<String>,
/// The contents of the reasoning message
pub reasoning_content:Option<String>,
/// The name of the user in a multi-user chat
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
Expand Down Expand Up @@ -440,6 +442,27 @@ impl ChatCompletionChoiceDelta {
}
}
};
// Merge reasonging contents.
match self.delta.reasoning_content.as_mut() {
Some(content) => {
match &other.delta.reasoning_content {
Some(other_content) => {
// Push other content into this one.
content.push_str(other_content)
}
None => {}
}
}
None => {
match &other.delta.reasoning_content {
Some(other_content) => {
// Set this content to other content.
self.delta.reasoning_content = Some(other_content.clone());
}
None => {}
}
}
};

// merge function calls
// function call names are concatenated
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use reqwest::header::USER_AGENT;
use reqwest::multipart::Form;
use reqwest::{header::AUTHORIZATION, Client, Method, RequestBuilder, Response};
use reqwest_eventsource::{CannotCloneRequestError, EventSource, RequestBuilderExt};
Expand Down Expand Up @@ -205,6 +206,7 @@ where
request = builder(request);
let stream = request
.header(AUTHORIZATION, format!("Bearer {}", credentials.api_key))
.header(USER_AGENT, format!("claude-code/1.0"))
.eventsource()?;
Ok(stream)
}
Expand Down
Loading