pub struct OutputMapper { /* private fields */ }Expand description
Maps response parts to content and builds provider metadata.
Implementations§
Source§impl OutputMapper
impl OutputMapper
Sourcepub fn new(config: SharedConfig, mapping: ToolNameMapping) -> Self
pub fn new(config: SharedConfig, mapping: ToolNameMapping) -> Self
Creates a mapper.
Sourcepub fn metadata(&self, object: JsonObject) -> ProviderMetadata
pub fn metadata(&self, object: JsonObject) -> ProviderMetadata
Wraps object under the google key (and the configured name when it
differs).
Sourcepub fn metadata_opt(&self, object: JsonObject) -> Option<ProviderMetadata>
pub fn metadata_opt(&self, object: JsonObject) -> Option<ProviderMetadata>
Like Self::metadata, None for an empty object.
Sourcepub fn signature_metadata(
&self,
signature: Option<&str>,
) -> Option<ProviderMetadata>
pub fn signature_metadata( &self, signature: Option<&str>, ) -> Option<ProviderMetadata>
Metadata carrying only a thought signature.
Sourcepub fn code_execution_name(&self) -> String
pub fn code_execution_name(&self) -> String
Custom name of the code execution tool.
Sourcepub fn custom_tool_name(&self, provider_name: &str) -> String
pub fn custom_tool_name(&self, provider_name: &str) -> String
Custom name of a function.
Sourcepub fn generate_id(&self) -> String
pub fn generate_id(&self) -> String
Generates an id.
Sourcepub fn code_execution_call(
&mut self,
language: Option<&str>,
code: Option<&str>,
) -> ToolCall
pub fn code_execution_call( &mut self, language: Option<&str>, code: Option<&str>, ) -> ToolCall
Maps a code execution part to a provider-executed tool call.
Sourcepub fn code_execution_result(
&mut self,
outcome: Option<&str>,
output: Option<&str>,
) -> ProviderToolResult
pub fn code_execution_result( &mut self, outcome: Option<&str>, output: Option<&str>, ) -> ProviderToolResult
Maps a code execution result.
Sourcepub fn function_call(
&self,
id: Option<&str>,
name: &str,
args: Option<&JsonValue>,
signature: Option<&str>,
) -> ToolCall
pub fn function_call( &self, id: Option<&str>, name: &str, args: Option<&JsonValue>, signature: Option<&str>, ) -> ToolCall
Maps a function call part.
Sourcepub fn server_tool_call(
&mut self,
tool_type: Option<&str>,
args: Option<&JsonValue>,
id: Option<&str>,
signature: Option<&str>,
) -> ToolCall
pub fn server_tool_call( &mut self, tool_type: Option<&str>, args: Option<&JsonValue>, id: Option<&str>, signature: Option<&str>, ) -> ToolCall
Maps a server-side tool call part.
Sourcepub fn server_tool_response(
&mut self,
response: &JsonValue,
) -> ProviderToolResult
pub fn server_tool_response( &mut self, response: &JsonValue, ) -> ProviderToolResult
Maps a server-side tool response part.
Sourcepub fn inline_file(
&self,
mime_type: &str,
data: &str,
thought: bool,
signature: Option<&str>,
) -> Result<Content, ProviderError>
pub fn inline_file( &self, mime_type: &str, data: &str, thought: bool, signature: Option<&str>, ) -> Result<Content, ProviderError>
Decodes an inline data part into a file or reasoning file.
§Errors
Returns ProviderError::InvalidResponseData for invalid base64.
Sourcepub fn map_parts(
&mut self,
parts: &[Part],
) -> Result<Vec<Content>, ProviderError>
pub fn map_parts( &mut self, parts: &[Part], ) -> Result<Vec<Content>, ProviderError>
Maps the parts of a non-streaming candidate.
§Errors
Returns ProviderError::InvalidResponseData for invalid inline data.
Sourcepub fn sources(&self, chunks: &[GroundingChunk]) -> Vec<Source>
pub fn sources(&self, chunks: &[GroundingChunk]) -> Vec<Source>
Maps grounding chunks to sources.
Sourcepub fn response_metadata(
&self,
response: &GenerateContentResponse,
candidate: Option<&Candidate>,
raw_usage: Option<&JsonValue>,
) -> ProviderMetadata
pub fn response_metadata( &self, response: &GenerateContentResponse, candidate: Option<&Candidate>, raw_usage: Option<&JsonValue>, ) -> ProviderMetadata
Result-level provider metadata.
Trait Implementations§
Source§impl Clone for OutputMapper
impl Clone for OutputMapper
Source§fn clone(&self) -> OutputMapper
fn clone(&self) -> OutputMapper
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more