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

Method chat_legacy

crates/opencode-provider/src/github_copilot.rs:366–399  ·  view source on GitHub ↗
(&self, request: ChatRequest)

Source from the content-addressed store, hash-verified

364 }
365
366 async fn chat_legacy(&self, request: ChatRequest) -> Result<ChatResponse, ProviderError> {
367 let url = self.config.base_url.as_deref().unwrap_or(COPILOT_API_URL);
368 let copilot_request = self.convert_request(request);
369
370 let response = self
371 .client
372 .post(url)
373 .header("Content-Type", "application/json")
374 .header(
375 "Authorization",
376 format!("Bearer {}", self.config.oauth_token),
377 )
378 .header("Copilot-Integration-Id", "vscode-chat")
379 .json(&copilot_request)
380 .send()
381 .await
382 .map_err(|e| ProviderError::NetworkError(e.to_string()))?;
383
384 if !response.status().is_success() {
385 let status = response.status();
386 let body = response.text().await.unwrap_or_default();
387 return Err(ProviderError::api_error_with_status(
388 format!("{}: {}", status, body),
389 status.as_u16(),
390 ));
391 }
392
393 let copilot_response: CopilotResponse = response
394 .json()
395 .await
396 .map_err(|e| ProviderError::ApiError(e.to_string()))?;
397
398 Ok(convert_copilot_response(copilot_response))
399 }
400
401 async fn chat_stream_legacy(
402 &self,

Callers 1

chatMethod · 0.45

Calls 6

convert_copilot_responseFunction · 0.85
ApiErrorEnum · 0.50
convert_requestMethod · 0.45
sendMethod · 0.45
statusMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected