pub trait Chat: WasmCompatSend + WasmCompatSync {
// Required method
fn chat(
&self,
prompt: impl Into<Message> + WasmCompatSend,
chat_history: &mut Vec<Message>,
) -> impl Future<Output = Result<String, PromptError>> + WasmCompatSend;
}Expand description
Trait defining a high-level LLM chat interface (i.e.: prompt and chat history in, response out).
Required Methods§
Sourcefn chat(
&self,
prompt: impl Into<Message> + WasmCompatSend,
chat_history: &mut Vec<Message>,
) -> impl Future<Output = Result<String, PromptError>> + WasmCompatSend
fn chat( &self, prompt: impl Into<Message> + WasmCompatSend, chat_history: &mut Vec<Message>, ) -> impl Future<Output = Result<String, PromptError>> + WasmCompatSend
Send a prompt with optional chat history to the underlying completion model.
If the completion model’s response is a message, then it is returned as a string.
If the completion model’s response is a tool call, then the tool is called and the result is returned as a string.
If the tool does not exist, or the tool call fails, then an error is returned.
The prompt and any assistant or tool messages produced during the turn
are appended to chat_history. Callers should pass the current
conversation history and should not push the user prompt themselves
before calling this method.
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.