MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / convert_response

Function convert_response

crates/opencode-provider/src/anthropic.rs:319–343  ·  view source on GitHub ↗
(response: AnthropicResponse)

Source from the content-addressed store, hash-verified

317}
318
319fn convert_response(response: AnthropicResponse) -> ChatResponse {
320 let content = response
321 .content
322 .iter()
323 .filter_map(|c| c.text.clone())
324 .collect::<Vec<_>>()
325 .join("");
326
327 ChatResponse {
328 id: response.id,
329 model: response.model,
330 choices: vec![Choice {
331 index: 0,
332 message: Message::assistant(&content),
333 finish_reason: Some("stop".to_string()),
334 }],
335 usage: Some(Usage {
336 prompt_tokens: response.usage.input_tokens,
337 completion_tokens: response.usage.output_tokens,
338 total_tokens: response.usage.input_tokens + response.usage.output_tokens,
339 cache_read_input_tokens: None,
340 cache_creation_input_tokens: None,
341 }),
342 }
343}

Callers 1

chatMethod · 0.85

Calls 1

cloneMethod · 0.45

Tested by

no test coverage detected