story-kit: merge 86_story_show_live_activity_status_instead_of_static_thinking_indicator_in_chat
This commit is contained in:
@@ -176,13 +176,15 @@ pub fn set_anthropic_api_key(store: &dyn StoreOps, api_key: String) -> Result<()
|
||||
set_anthropic_api_key_impl(store, &api_key)
|
||||
}
|
||||
|
||||
pub async fn chat<F, U>(
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn chat<F, U, A>(
|
||||
messages: Vec<Message>,
|
||||
config: ProviderConfig,
|
||||
state: &SessionState,
|
||||
store: &dyn StoreOps,
|
||||
mut on_update: F,
|
||||
mut on_token: U,
|
||||
mut on_activity: A,
|
||||
permission_tx: Option<
|
||||
tokio::sync::mpsc::UnboundedSender<
|
||||
crate::llm::providers::claude_code::PermissionReqMsg,
|
||||
@@ -192,6 +194,7 @@ pub async fn chat<F, U>(
|
||||
where
|
||||
F: FnMut(&[Message]) + Send,
|
||||
U: FnMut(&str) + Send,
|
||||
A: FnMut(&str) + Send,
|
||||
{
|
||||
use crate::llm::providers::anthropic::AnthropicProvider;
|
||||
use crate::llm::providers::ollama::OllamaProvider;
|
||||
@@ -322,6 +325,7 @@ where
|
||||
tools,
|
||||
&mut cancel_rx,
|
||||
|token| on_token(token),
|
||||
|tool_name| on_activity(tool_name),
|
||||
)
|
||||
.await
|
||||
.map_err(|e| format!("Anthropic Error: {e}"))?
|
||||
|
||||
@@ -156,16 +156,18 @@ impl AnthropicProvider {
|
||||
.join("\n\n")
|
||||
}
|
||||
|
||||
pub async fn chat_stream<F>(
|
||||
pub async fn chat_stream<F, A>(
|
||||
&self,
|
||||
model: &str,
|
||||
messages: &[Message],
|
||||
tools: &[ToolDefinition],
|
||||
cancel_rx: &mut Receiver<bool>,
|
||||
mut on_token: F,
|
||||
mut on_activity: A,
|
||||
) -> Result<CompletionResponse, String>
|
||||
where
|
||||
F: FnMut(&str),
|
||||
A: FnMut(&str),
|
||||
{
|
||||
let anthropic_messages = Self::convert_messages(messages);
|
||||
let anthropic_tools = Self::convert_tools(tools);
|
||||
@@ -257,6 +259,7 @@ impl AnthropicProvider {
|
||||
{
|
||||
let id = content_block["id"].as_str().unwrap_or("").to_string();
|
||||
let name = content_block["name"].as_str().unwrap_or("").to_string();
|
||||
on_activity(&name);
|
||||
current_tool_use = Some((id, name, String::new()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user