pub struct ChatResponseUpdate {Show 13 fields
pub contents: Vec<Content>,
pub role: Option<Role>,
pub author_name: Option<String>,
pub response_id: Option<String>,
pub message_id: Option<String>,
pub conversation_id: Option<String>,
pub model: Option<String>,
pub created_at: Option<String>,
pub finish_reason: Option<FinishReason>,
pub continuation_token: Option<ContinuationToken>,
pub operation_state: Option<OperationState>,
pub additional_properties: HashMap<String, Value>,
pub raw_representation: Option<Value>,
}Expand description
A single streaming chunk from a chat client.
Fields§
§contents: Vec<Content>§role: Option<Role>§response_id: Option<String>§message_id: Option<String>§conversation_id: Option<String>§model: Option<String>§created_at: Option<String>§finish_reason: Option<FinishReason>§continuation_token: Option<ContinuationToken>The handle for resuming a long-running operation, when the service issues one.
On a streamed response this used to be lost: ChatResponse has the
field but the update type did not, so the token never survived
aggregation and a streamed background run could not be resumed — the
blocked response a policy check produces most of all, since that is
the one a caller needs to pick back up. Carried on the update that
knows it (in practice the last) and taken by
absorb_update the way finish_reason
is.
operation_state: Option<OperationState>Where the resumable operation this update belongs to stands, when the
provider knows. See OperationState: a
Terminal update clears the aggregated
continuation_token.
additional_properties: HashMap<String, Value>Provider-specific metadata for this update. Merged onto
ChatResponse::additional_properties during aggregation.
raw_representation: Option<Value>The raw provider payload this update was decoded from, if retained.
Implementations§
Source§impl ChatResponseUpdate
impl ChatResponseUpdate
Sourcepub fn text(text: impl Into<String>) -> ChatResponseUpdate
pub fn text(text: impl Into<String>) -> ChatResponseUpdate
A text-only update from the assistant.
Sourcepub fn text_content(&self) -> String
pub fn text_content(&self) -> String
The concatenated text of this update.
Empty when the update carries a refusal fragment — see
ChatResponse::text for why refusals are withheld rather than
surfaced as text.
Sourcepub fn has_refusal(&self) -> bool
pub fn has_refusal(&self) -> bool
Whether this update carries a provider refusal fragment.
Sourcepub fn refusal_text(&self) -> Option<String>
pub fn refusal_text(&self) -> Option<String>
This update’s refusal text, or None.
Trait Implementations§
Source§impl Clone for ChatResponseUpdate
impl Clone for ChatResponseUpdate
Source§fn clone(&self) -> ChatResponseUpdate
fn clone(&self) -> ChatResponseUpdate
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more