Public declaration syntax from forge-rs/crates/forge-core/src/output.rs Original source SHA-256: 210229767995931afb9ca7c2ef32e38174f274750260eadec1ce3b7b3f8946e3 Function bodies and constant values are omitted. This is not the complete implementation. Source line 28 #[derive(Debug, Clone, Serialize, Deserialize)] pub struct GenerateResult { /// The model's response message. pub message: ModelMessage, /// Why generation stopped. pub finish_reason: FinishReason, /// Token usage statistics. pub usage: Usage } Source line 39 pub fn text(&self) -> String; Source line 44 pub fn has_tool_calls(&self) -> bool; Source line 52 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum FinishReason { /// The model produced a natural stop. Stop, /// The maximum token limit was reached. MaxTokens, /// The model requested tool calls. ToolCalls, /// A stop sequence was matched. StopSequence, /// A content filter blocked the output. ContentFilter, /// An error occurred during generation. Error, } Source line 69 pub fn is_complete(&self) -> bool; Source line 74 pub fn is_tool_call(&self) -> bool; Source line 95 #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub struct Usage { /// Tokens consumed by the input prompt. pub prompt_tokens: u64, /// Tokens generated in the response. pub completion_tokens: u64, /// Total tokens (prompt + completion). pub total_tokens: u64 } Source line 106 pub fn zero() -> Self; Source line 115 pub fn add(&self, other: &Usage) -> Usage; Source line 138 #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(tag = "type", rename_all = "snake_case")] pub enum StreamChunk { /// A text content delta. TextDelta { /// The text fragment. text: String, }, /// A tool call delta (streaming tool arguments). ToolCallDelta { /// The tool call index (for parallel tool calls). index: u32, /// The tool call ID (may be empty until fully received). id: String, /// The tool name (may be empty until fully received). name: String, /// Partial JSON arguments. arguments_delta: String, }, /// Signals the start of a tool call. /// /// Emitted when the model begins a tool invocation. The `id` uniquely /// identifies the tool call, and `name` is the tool being invoked. ToolCallStart { /// The tool call ID. id: String, /// The tool name being called. name: String, }, /// Signals the end of a tool call. /// /// Emitted when a tool invocation completes. The `id` matches the /// corresponding `ToolCallStart`. ToolCallEnd { /// The tool call ID. id: String, }, /// Metadata chunk with usage information. /// /// Emitted at any point during streaming to provide intermediate or /// final token usage statistics. Metadata { /// Token usage statistics. usage: Usage, }, /// An error occurred during streaming. /// /// The stream may continue after an error or terminate, depending on /// the provider implementation. Error { /// The error message. message: String, }, /// The stream has finished. Done { /// Why generation stopped. finish_reason: FinishReason, /// Final usage statistics. usage: Usage, }, } Source line 206 pub fn text_delta(text: impl Into) -> Self; Source line 211 pub fn done(finish_reason: FinishReason, usage: Usage) -> Self; Source line 219 pub fn tool_call_start(id: impl Into, name: impl Into) -> Self; Source line 227 pub fn tool_call_end(id: impl Into) -> Self; Source line 232 pub fn metadata(usage: Usage) -> Self; Source line 237 pub fn error(message: impl Into) -> Self; Source line 244 pub fn is_text_delta(&self) -> bool; Source line 249 pub fn is_done(&self) -> bool; Source line 254 pub fn is_tool_call_start(&self) -> bool; Source line 259 pub fn is_tool_call_end(&self) -> bool; Source line 264 pub fn is_metadata(&self) -> bool; Source line 269 pub fn is_error(&self) -> bool; Source line 274 pub fn as_text(&self) -> Option<&str>;