pub struct ToolConversation { /* private fields */ }Expand description
High-level tool conversation manager.
This provides a simplified interface for conducting conversations with Claude that involve tool use, automatically handling tool execution and conversation flow.
Implementations§
Source§impl ToolConversation
impl ToolConversation
Sourcepub fn new(client: Arc<Anthropic>, registry: Arc<ToolRegistry>) -> Self
pub fn new(client: Arc<Anthropic>, registry: Arc<ToolRegistry>) -> Self
Create a new tool conversation.
Sourcepub fn with_config(
client: Arc<Anthropic>,
registry: Arc<ToolRegistry>,
config: ConversationConfig,
) -> Self
pub fn with_config( client: Arc<Anthropic>, registry: Arc<ToolRegistry>, config: ConversationConfig, ) -> Self
Create a new tool conversation with custom configuration.
Sourcepub async fn start(
&self,
user_message: impl Into<String>,
) -> ToolOperationResult<Message>
pub async fn start( &self, user_message: impl Into<String>, ) -> ToolOperationResult<Message>
Start a conversation with an initial user message.
This method initiates a conversation and returns the first response from Claude.
If Claude uses tools, they will be automatically executed if auto_execute_tools is enabled.
Sourcepub async fn continue_with_tools(
&self,
message: &Message,
) -> ToolOperationResult<Option<Message>>
pub async fn continue_with_tools( &self, message: &Message, ) -> ToolOperationResult<Option<Message>>
Continue a conversation by processing tool uses and getting the next response.
This method takes a message that may contain tool use requests, executes the tools, and returns Claude’s response incorporating the tool results.
Sourcepub async fn execute_until_complete(
&self,
initial_message: impl Into<String>,
) -> ToolOperationResult<Message>
pub async fn execute_until_complete( &self, initial_message: impl Into<String>, ) -> ToolOperationResult<Message>
Execute a complete conversation until completion or max turns reached.
This method manages the entire conversation flow, automatically executing tools and continuing the conversation until Claude provides a final response.
Sourcepub fn registry(&self) -> &Arc<ToolRegistry> ⓘ
pub fn registry(&self) -> &Arc<ToolRegistry> ⓘ
Get the tool registry.
Sourcepub fn executor(&self) -> &ToolExecutor
pub fn executor(&self) -> &ToolExecutor
Get the tool executor.
Sourcepub fn config(&self) -> &ConversationConfig
pub fn config(&self) -> &ConversationConfig
Get the conversation configuration.
Sourcepub fn set_config(&mut self, config: ConversationConfig)
pub fn set_config(&mut self, config: ConversationConfig)
Update the conversation configuration.