ChatbotTool

Trait ChatbotTool 

Source
pub trait ChatbotTool {
    type State;
    type Arguments: Serialize;

    // Required methods
    fn parse_arguments(args_string: String) -> ChatbotResult<Self::Arguments>;
    fn from_db_and_arguments(
        conn: &mut PgConnection,
        arguments: Self::Arguments,
        user_context: &ChatbotUserContext,
    ) -> impl Future<Output = ChatbotResult<Self>> + Send
       where Self: Sized;
    fn output(&self) -> String;
    fn output_description_instructions(&self) -> Option<String>;
    fn get_arguments(&self) -> &Self::Arguments;
    fn get_tool_definition() -> AzureLLMToolDefinition;

    // Provided methods
    fn get_tool_output(&self) -> String { ... }
    fn new(
        conn: &mut PgConnection,
        args_string: String,
        user_context: &ChatbotUserContext,
    ) -> impl Future<Output = ChatbotResult<Self>> + Send
       where Self: Sized { ... }
}

Required Associated Types§

Required Methods§

Source

fn parse_arguments(args_string: String) -> ChatbotResult<Self::Arguments>

Parse the LLM-generated function arguments and clean them

Source

fn from_db_and_arguments( conn: &mut PgConnection, arguments: Self::Arguments, user_context: &ChatbotUserContext, ) -> impl Future<Output = ChatbotResult<Self>> + Send
where Self: Sized,

Create a new instance after parsing arguments

Source

fn output(&self) -> String

Output the result of the tool call in LLM-readable form

Source

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.

Source

fn get_arguments(&self) -> &Self::Arguments

Get parsed arguments

Source

fn get_tool_definition() -> AzureLLMToolDefinition

Get a AzureLLMToolDefinition struct that represents this tool. The definition is sent to the LLM as part of a chat request.

Provided Methods§

Source

fn get_tool_output(&self) -> String

Get and format tool output and instructions for LLM

Source

fn new( conn: &mut PgConnection, args_string: String, user_context: &ChatbotUserContext, ) -> impl Future<Output = ChatbotResult<Self>> + Send
where Self: Sized,

Create a new instance from connection, args and context

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§