From ccf0c8899888e9f299b40bf686c83d522a803666 Mon Sep 17 00:00:00 2001 From: Linghong Date: Mon, 27 Jul 2026 04:06:26 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20platform-llm=20Rust=20?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 按仓库 rustfmt 配置整理流式工具调用实现。 格式化 live stream 工具调用验收测试。 --- server-rs/crates/platform-llm/src/lib.rs | 13 ++++--------- .../platform-llm/tests/live_stream_tool_calls.rs | 9 +++++++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/server-rs/crates/platform-llm/src/lib.rs b/server-rs/crates/platform-llm/src/lib.rs index 3d705a99a..c1e471020 100644 --- a/server-rs/crates/platform-llm/src/lib.rs +++ b/server-rs/crates/platform-llm/src/lib.rs @@ -683,10 +683,7 @@ impl StreamAccumulation { .iter() .map(|pending| { let id = pending.id.clone().ok_or_else(|| { - LlmError::Deserialize(format!( - "LLM 流式工具调用缺少 id:slot={}", - pending.slot - )) + LlmError::Deserialize(format!("LLM 流式工具调用缺少 id:slot={}", pending.slot)) })?; let name = pending.name.clone().ok_or_else(|| { LlmError::Deserialize(format!( @@ -1966,11 +1963,9 @@ fn build_anthropic_messages_request_body( system: (!system.is_empty()).then_some(system), messages, tools, - tool_choice: request - .tool_choice - .map(|choice| AnthropicToolChoice { - choice_type: choice.as_anthropic_type(), - }), + tool_choice: request.tool_choice.map(|choice| AnthropicToolChoice { + choice_type: choice.as_anthropic_type(), + }), } } diff --git a/server-rs/crates/platform-llm/tests/live_stream_tool_calls.rs b/server-rs/crates/platform-llm/tests/live_stream_tool_calls.rs index 2f9c2a847..8307815e8 100644 --- a/server-rs/crates/platform-llm/tests/live_stream_tool_calls.rs +++ b/server-rs/crates/platform-llm/tests/live_stream_tool_calls.rs @@ -21,7 +21,9 @@ use platform_llm::{ }; fn env_var(name: &str) -> Option { - std::env::var(name).ok().filter(|value| !value.trim().is_empty()) + std::env::var(name) + .ok() + .filter(|value| !value.trim().is_empty()) } fn parse_api_kind(value: &str) -> LlmApiKind { @@ -86,7 +88,10 @@ async fn live_stream_run_returns_native_tool_calls() { response.finish_reason, response.text ); for call in &response.tool_calls { - println!("tool_call id={} name={} args={}", call.id, call.name, call.arguments); + println!( + "tool_call id={} name={} args={}", + call.id, call.name, call.arguments + ); } assert!(