Streaming tool calls (#29179)
https://github.com/user-attachments/assets/7854a737-ef83-414c-b397-45122e4f32e8 Release Notes: - Create file and edit file tools now stream their tool descriptions, so you can see what they're doing sooner. --------- Co-authored-by: Marshall Bowers <git@maxdeviant.com>
This commit is contained in:
parent
7aa0fa1543
commit
4f2f9ff762
17 changed files with 358 additions and 47 deletions
|
@ -1293,12 +1293,27 @@ impl Thread {
|
|||
thread.insert_message(Role::Assistant, vec![], cx)
|
||||
});
|
||||
|
||||
thread.tool_use.request_tool_use(
|
||||
let tool_use_id = tool_use.id.clone();
|
||||
let streamed_input = if tool_use.is_input_complete {
|
||||
None
|
||||
} else {
|
||||
Some((&tool_use.input).clone())
|
||||
};
|
||||
|
||||
let ui_text = thread.tool_use.request_tool_use(
|
||||
last_assistant_message_id,
|
||||
tool_use,
|
||||
tool_use_metadata.clone(),
|
||||
cx,
|
||||
);
|
||||
|
||||
if let Some(input) = streamed_input {
|
||||
cx.emit(ThreadEvent::StreamedToolUse {
|
||||
tool_use_id,
|
||||
ui_text,
|
||||
input,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2189,6 +2204,11 @@ pub enum ThreadEvent {
|
|||
StreamedCompletion,
|
||||
StreamedAssistantText(MessageId, String),
|
||||
StreamedAssistantThinking(MessageId, String),
|
||||
StreamedToolUse {
|
||||
tool_use_id: LanguageModelToolUseId,
|
||||
ui_text: Arc<str>,
|
||||
input: serde_json::Value,
|
||||
},
|
||||
Stopped(Result<StopReason, Arc<anyhow::Error>>),
|
||||
MessageAdded(MessageId),
|
||||
MessageEdited(MessageId),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue