pub struct OpenAIClientState {
pub prompt: VecDeque<Message>,
pub client: OpenAIClient,
pub entry_limit: Option<u64>,
}Expand description
Represents a client state with a prompt history.
Fields§
§prompt: VecDeque<Message>Conversation history messages.
client: OpenAIClientReference to the OpenAIClient.
entry_limit: Option<u64>Implementations§
Source§impl<'a> OpenAIClientState
impl<'a> OpenAIClientState
pub async fn add_last(&mut self, messages: Vec<Message>) -> &mut Self
Sourcepub async fn set_entry_limit(&mut self, limit: u64) -> &mut Self
pub async fn set_entry_limit(&mut self, limit: u64) -> &mut Self
Sourcepub async fn last(&mut self) -> Option<&Message>
pub async fn last(&mut self) -> Option<&Message>
Retrieve the last message in the prompt.
§Returns
An Option containing a reference to the last Message.
Sourcepub async fn generate(
&mut self,
model: Option<&ModelConfig>,
) -> Result<GenerateResponse, ClientError>
pub async fn generate( &mut self, model: Option<&ModelConfig>, ) -> Result<GenerateResponse, ClientError>
Sourcepub async fn generate_can_use_tool<F>(
&mut self,
model: Option<&ModelConfig>,
show_call: Option<F>,
) -> Result<GenerateResponse, ClientError>
pub async fn generate_can_use_tool<F>( &mut self, model: Option<&ModelConfig>, show_call: Option<F>, ) -> Result<GenerateResponse, ClientError>
Generate an AI response, possibly calling a tool.
If the API response includes a function call, it will run the corresponding tool.
§Arguments
model- The model configuration.show_call- Optional callback function to show the tool call.(eg,show_call("tool_name", "args"))
§Returns
An APIResult with the API response or a ClientError.
Sourcepub async fn generate_use_tool<F>(
&mut self,
model: Option<&ModelConfig>,
show_call: Option<F>,
) -> Result<GenerateResponse, ClientError>
pub async fn generate_use_tool<F>( &mut self, model: Option<&ModelConfig>, show_call: Option<F>, ) -> Result<GenerateResponse, ClientError>
Generate an AI response while forcing the use of a specific tool.
If the response includes a function call, the specified tool will be executed
§Arguments
model- The model configuration.tool_name- The name of the tool to use.show_call- Optional callback function to show the tool call.(eg,show_call("tool_name", "args"))
§Returns
An APIResult with the API response or a ClientError.
Sourcepub async fn generate_with_tool<F>(
&mut self,
model: Option<&ModelConfig>,
tool_name: &str,
show_call: Option<F>,
) -> Result<GenerateResponse, ClientError>
pub async fn generate_with_tool<F>( &mut self, model: Option<&ModelConfig>, tool_name: &str, show_call: Option<F>, ) -> Result<GenerateResponse, ClientError>
Generate an AI response while forcing the use of a specific tool.
If the response includes a function call, the specified tool will be executed.
§Arguments
model- The model configuration.tool_name- The name of the tool to use.show_call- Optional callback function to show the tool call.(eg,show_call("tool_name", "args"))
§Returns
An APIResult with the API response or a ClientError.
Source§impl<'a> OpenAIClientState
new api after v.1.4.0
impl<'a> OpenAIClientState
new api after v.1.4.0
pub async fn reasoning( &'a mut self, model: Option<&ModelConfig>, mode: &ToolMode, ) -> Result<ReasoningState<'a>, ClientError>
Trait Implementations§
Source§impl Clone for OpenAIClientState
impl Clone for OpenAIClientState
Source§fn clone(&self) -> OpenAIClientState
fn clone(&self) -> OpenAIClientState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more