pub struct FunctionToolBuilder { /* private fields */ }Expand description
Builds a FunctionTool; finish with callback or
stream_callback.
Implementations§
Source§impl FunctionToolBuilder
impl FunctionToolBuilder
Sourcepub fn input_schema(self, schema: JsonSchema) -> Self
pub fn input_schema(self, schema: JsonSchema) -> Self
Sets the input JSON Schema. Without one the tool takes an empty object
({"type":"object","properties":{},"additionalProperties":false}). The input is passed to
the callback as given, unvalidated.
Sourcepub fn input_schema_for<T: SchemarsJsonSchema>(self) -> Self
pub fn input_schema_for<T: SchemarsJsonSchema>(self) -> Self
Uses the normalized schema of T as the input schema and validates the input against it
before calling the callback; invalid input becomes an error result listing the violations.
Sourcepub fn callback<F, Fut>(self, callback: F) -> FunctionTool
pub fn callback<F, Fut>(self, callback: F) -> FunctionTool
Finishes the tool with an async callback that returns the result value.
Sourcepub fn stream_callback<F, S>(self, callback: F) -> FunctionToolwhere
F: Fn(JsonValue, ToolContext) -> S + Send + Sync + 'static,
S: Stream<Item = Result<FunctionToolItem, ToolError>> + Send + 'static,
pub fn stream_callback<F, S>(self, callback: F) -> FunctionToolwhere
F: Fn(JsonValue, ToolContext) -> S + Send + Sync + 'static,
S: Stream<Item = Result<FunctionToolItem, ToolError>> + Send + 'static,
Finishes the tool with a streaming callback: each FunctionToolItem::Update becomes a
progress event and FunctionToolItem::Return the result. A stream that ends without a
return value returns null.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for FunctionToolBuilder
impl !UnwindSafe for FunctionToolBuilder
impl Freeze for FunctionToolBuilder
impl Send for FunctionToolBuilder
impl Sync for FunctionToolBuilder
impl Unpin for FunctionToolBuilder
impl UnsafeUnpin for FunctionToolBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.