修正 platform-llm Rust 格式
按仓库 rustfmt 配置整理流式工具调用实现。 格式化 live stream 工具调用验收测试。
This commit is contained in:
@@ -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(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,9 @@ use platform_llm::{
|
||||
};
|
||||
|
||||
fn env_var(name: &str) -> Option<String> {
|
||||
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!(
|
||||
|
||||
Reference in New Issue
Block a user