pub struct Assistant<LLM: LanguageModel> { /* private fields */ }Expand description
A struct representing an Assistant that interacts with a language model (LLM), manages a collection of messages, and provides access to various tools.
§Type Parameters
LLM: A type that implements theLanguageModeltrait, representing the underlying language model used by the Assistant.
§Fields
messages: A vector ofMessageinstances representing the conversation history or context.tools: A collection of tools available to the Assistant for performing various tasks.llm: The language model instance used by the Assistant for generating responses or performing language-related tasks.
Implementations§
Source§impl<LLM: LanguageModel> Assistant<LLM>
impl<LLM: LanguageModel> Assistant<LLM>
Sourcepub fn tool(self, tool: impl Tool + 'static) -> Result<Self, RegisterError>
pub fn tool(self, tool: impl Tool + 'static) -> Result<Self, RegisterError>
Registers a tool with the assistant, making it available for use in interactions.
§Parameters
tool: The tool to register with the assistant.
§Errors
Returns RegisterError if a tool of that name is already registered,
or the tool has no description for the model to read.
Sourcepub async fn send(&mut self, message: impl Into<String>) -> Result<()>
pub async fn send(&mut self, message: impl Into<String>) -> Result<()>
Sends a user message to the assistant, processes it with the language model, and appends the response to the conversation history.
§Parameters
message: The user message to send to the assistant.
§Errors
Returns an error if the language model fails to generate a response or if message processing fails.
Trait Implementations§
Auto Trait Implementations§
impl<LLM> !RefUnwindSafe for Assistant<LLM>
impl<LLM> !UnwindSafe for Assistant<LLM>
impl<LLM> Freeze for Assistant<LLM>where
LLM: Freeze,
impl<LLM> Send for Assistant<LLM>
impl<LLM> Sync for Assistant<LLM>
impl<LLM> Unpin for Assistant<LLM>where
LLM: Unpin,
impl<LLM> UnsafeUnpin for Assistant<LLM>where
LLM: UnsafeUnpin,
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