pub struct FunctionResult { /* private fields */ }Expand description
Validated caller-supplied result for a client function call.
§Examples
use providers_kit::generation::{FunctionResult, ContentPart};
let result = FunctionResult::new(
Some("call-1".into()),
"lookup",
vec![ContentPart::Json {
value: serde_json::json!({"value":2}),
}],
false,
)?;
assert_eq!(result.call_id(), Some("call-1"));
assert_eq!(result.name(), "lookup");
assert_eq!(result.content().len(), 1);
assert!(!result.is_error());
Implementations§
Source§impl FunctionResult
impl FunctionResult
Sourcepub fn new(
call_id: Option<String>,
name: impl Into<String>,
content: Vec<ContentPart>,
is_error: bool,
) -> Result<Self, KitError>
pub fn new( call_id: Option<String>, name: impl Into<String>, content: Vec<ContentPart>, is_error: bool, ) -> Result<Self, KitError>
Creates a validated function result.
§Errors
Returns an input error for an invalid name/id, empty or invalid content, or provider thinking content. Accepted function failures use is_error = true with nonempty model-visible content.
See crate::generation::FunctionResult for a complete example.
Sourcepub fn call_id(&self) -> Option<&str>
pub fn call_id(&self) -> Option<&str>
Returns the originating call id, when available.
See crate::generation::FunctionResult for a complete example.
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Returns the function name.
See crate::generation::FunctionResult for a complete example.
Sourcepub fn content(&self) -> &[ContentPart]
pub fn content(&self) -> &[ContentPart]
Returns ordered model-visible result content.
See crate::generation::FunctionResult for a complete example.
Sourcepub const fn is_error(&self) -> bool
pub const fn is_error(&self) -> bool
Reports whether the completed function execution failed.
See crate::generation::FunctionResult for a complete example.