agent2: Port read_file tool (#35840)
Ports the read_file tool from `assistant_tools` to `agent2`. Note: Image support not implemented. Release Notes: - N/A
This commit is contained in:
parent
7d4d8b8398
commit
3d662ee282
6 changed files with 1011 additions and 4 deletions
|
@ -125,7 +125,7 @@ pub struct Thread {
|
|||
project_context: Rc<RefCell<ProjectContext>>,
|
||||
templates: Arc<Templates>,
|
||||
pub selected_model: Arc<dyn LanguageModel>,
|
||||
_action_log: Entity<ActionLog>,
|
||||
action_log: Entity<ActionLog>,
|
||||
}
|
||||
|
||||
impl Thread {
|
||||
|
@ -145,7 +145,7 @@ impl Thread {
|
|||
project_context,
|
||||
templates,
|
||||
selected_model: default_model,
|
||||
_action_log: action_log,
|
||||
action_log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,6 +315,10 @@ impl Thread {
|
|||
events_rx
|
||||
}
|
||||
|
||||
pub fn action_log(&self) -> &Entity<ActionLog> {
|
||||
&self.action_log
|
||||
}
|
||||
|
||||
pub fn build_system_message(&self) -> AgentMessage {
|
||||
log::debug!("Building system message");
|
||||
let prompt = SystemPromptTemplate {
|
||||
|
@ -924,3 +928,28 @@ impl ToolCallEventStream {
|
|||
.authorize_tool_call(&self.tool_use_id, title, kind, input)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub struct TestToolCallEventStream {
|
||||
stream: ToolCallEventStream,
|
||||
_events_rx: mpsc::UnboundedReceiver<Result<AgentResponseEvent, LanguageModelCompletionError>>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl TestToolCallEventStream {
|
||||
pub fn new() -> Self {
|
||||
let (events_tx, events_rx) =
|
||||
mpsc::unbounded::<Result<AgentResponseEvent, LanguageModelCompletionError>>();
|
||||
|
||||
let stream = ToolCallEventStream::new("test".into(), AgentResponseEventStream(events_tx));
|
||||
|
||||
Self {
|
||||
stream,
|
||||
_events_rx: events_rx,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn stream(&self) -> ToolCallEventStream {
|
||||
self.stream.clone()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue