assistant2: Add helper methods to Thread
for dealing with tool use (#26310)
This PR adds two new helper methods to the `Thread` for dealing with tool use: - `use_pending_tools` - This uses all of the tools that are pending - The reason we aren't calling this directly in `stream_completion` is that we still might need to have a way for users to confirm that they want tools to be run, which would need to happen at the UI layer in the `ActiveThread`. - `send_tool_results_to_model` - This encapsulates inserting a new user message that contains the tool results and sending them up to the model. Release Notes: - N/A
This commit is contained in:
parent
18f3f8097f
commit
921c24e274
4 changed files with 61 additions and 52 deletions
|
@ -26,7 +26,6 @@ pub fn init(cx: &mut App) {
|
|||
}
|
||||
|
||||
pub struct ThreadStore {
|
||||
#[allow(unused)]
|
||||
project: Entity<Project>,
|
||||
tools: Arc<ToolWorkingSet>,
|
||||
context_server_manager: Entity<ContextServerManager>,
|
||||
|
@ -78,7 +77,7 @@ impl ThreadStore {
|
|||
}
|
||||
|
||||
pub fn create_thread(&mut self, cx: &mut Context<Self>) -> Entity<Thread> {
|
||||
cx.new(|cx| Thread::new(self.tools.clone(), cx))
|
||||
cx.new(|cx| Thread::new(self.project.clone(), self.tools.clone(), cx))
|
||||
}
|
||||
|
||||
pub fn open_thread(
|
||||
|
@ -96,7 +95,15 @@ impl ThreadStore {
|
|||
.ok_or_else(|| anyhow!("no thread found with ID: {id:?}"))?;
|
||||
|
||||
this.update(&mut cx, |this, cx| {
|
||||
cx.new(|cx| Thread::from_saved(id.clone(), thread, this.tools.clone(), cx))
|
||||
cx.new(|cx| {
|
||||
Thread::from_saved(
|
||||
id.clone(),
|
||||
thread,
|
||||
this.project.clone(),
|
||||
this.tools.clone(),
|
||||
cx,
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue