diff --git a/src/chat.rs b/src/chat.rs index aeba4ca..784d001 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -88,6 +88,8 @@ pub struct ChatCompletionMessageDelta { pub role: Option, /// The contents of the message pub content: Option, + /// The contents of the reasoning message + pub reasoning_content:Option, /// The name of the user in a multi-user chat #[serde(skip_serializing_if = "Option::is_none")] pub name: Option, @@ -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 diff --git a/src/lib.rs b/src/lib.rs index 8a0339c..914a785 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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}; @@ -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) }