MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / responses_chat_response

Method responses_chat_response

crates/opencode-provider/src/openai.rs:684–716  ·  view source on GitHub ↗
(
        request: &ChatRequest,
        result: crate::responses::ResponsesGenerateResult,
    )

Source from the content-addressed store, hash-verified

682 }
683
684 fn responses_chat_response(
685 request: &ChatRequest,
686 result: crate::responses::ResponsesGenerateResult,
687 ) -> ChatResponse {
688 let usage = Usage {
689 prompt_tokens: result.usage.input_tokens,
690 completion_tokens: result.usage.output_tokens,
691 total_tokens: result.usage.input_tokens + result.usage.output_tokens,
692 cache_read_input_tokens: result
693 .usage
694 .input_tokens_details
695 .as_ref()
696 .and_then(|d| d.cached_tokens),
697 cache_creation_input_tokens: None,
698 };
699
700 ChatResponse {
701 id: result
702 .metadata
703 .response_id
704 .unwrap_or_else(|| uuid::Uuid::new_v4().to_string()),
705 model: result
706 .metadata
707 .model_id
708 .unwrap_or_else(|| request.model.clone()),
709 choices: vec![Choice {
710 index: 0,
711 message: result.message,
712 finish_reason: Some(Self::finish_reason_to_string(result.finish_reason)),
713 }],
714 usage: Some(usage),
715 }
716 }
717
718 async fn chat_legacy(&self, request: ChatRequest) -> Result<ChatResponse, ProviderError> {
719 let url = Self::chat_completions_url(self.config.base_url.as_deref());

Callers

nothing calls this directly

Calls 1

cloneMethod · 0.45

Tested by

no test coverage detected