pub trait ChatbotTool: ChatbotToolDeclaration {
type Arguments: DeserializeOwned;
// Required methods
fn call_requirements(
arguments: &Self::Arguments,
user_context: &ChatbotTurnContext,
) -> Vec<ToolRequirement>;
fn from_db_and_arguments(
conn: &mut PgConnection,
app_config: &ApplicationConfiguration,
arguments: Self::Arguments,
user_context: &ChatbotTurnContext,
) -> impl Future<Output = ChatbotResult<Self>> + Send
where Self: Sized;
fn output(&self) -> String;
fn output_description_instructions(&self) -> Option<String>;
// Provided methods
fn parse_arguments(args_string: String) -> ChatbotResult<Self::Arguments> { ... }
fn citations(&self) -> Vec<ToolCitation> { ... }
fn get_tool_output(&self) -> String { ... }
}Required Associated Types§
Required Methods§
Sourcefn call_requirements(
arguments: &Self::Arguments,
user_context: &ChatbotTurnContext,
) -> Vec<ToolRequirement>
fn call_requirements( arguments: &Self::Arguments, user_context: &ChatbotTurnContext, ) -> Vec<ToolRequirement>
What the caller must be allowed to do against what this call actually targets.
The model picks the target, so this is the check that binds; the tool must name every
resource the call touches, since all of them are required. user_context is here for the
tools whose arguments name a target only by omission, leaving it to default to the
chatbot’s own course.
Sourcefn from_db_and_arguments(
conn: &mut PgConnection,
app_config: &ApplicationConfiguration,
arguments: Self::Arguments,
user_context: &ChatbotTurnContext,
) -> impl Future<Output = ChatbotResult<Self>> + Sendwhere
Self: Sized,
fn from_db_and_arguments(
conn: &mut PgConnection,
app_config: &ApplicationConfiguration,
arguments: Self::Arguments,
user_context: &ChatbotTurnContext,
) -> impl Future<Output = ChatbotResult<Self>> + Sendwhere
Self: Sized,
Create a new instance after parsing arguments
Sourcefn output_description_instructions(&self) -> Option<String>
fn output_description_instructions(&self) -> Option<String>
Additional instructions for the LLM on how to describe and communicate the tool output. Just-in-time prompt.
Provided Methods§
Sourcefn parse_arguments(args_string: String) -> ChatbotResult<Self::Arguments>
fn parse_arguments(args_string: String) -> ChatbotResult<Self::Arguments>
Parses and validates the arguments the LLM called the tool with.
The LLM is free to emit values the schema forbids, so every constraint the tool body relies on has to be rejected here rather than assumed; the derived deserialization the default body does is only as strict as the argument type. Fails with ChatbotErrorType::InvalidToolArguments, which is reported to the LLM.
Sourcefn citations(&self) -> Vec<ToolCitation>
fn citations(&self) -> Vec<ToolCitation>
Page references this call’s output cites, numbered as the tool told the model to cite them. Empty for a tool whose output is not quotable material.
Sourcefn get_tool_output(&self) -> String
fn get_tool_output(&self) -> String
Get and format tool output and instructions for LLM
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
Source§impl ChatbotTool for CourseFinderTool
impl ChatbotTool for CourseFinderTool
Source§impl ChatbotTool for DocumentLookupTool
Look up a document (page) from the course the chatbot is on.
impl ChatbotTool for DocumentLookupTool
Look up a document (page) from the course the chatbot is on.