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

Method chat

crates/opencode-provider/src/deepseek.rs:66–87  ·  view source on GitHub ↗
(&self, request: ChatRequest)

Source from the content-addressed store, hash-verified

64 }
65
66 async fn chat(&self, request: ChatRequest) -> Result<ChatResponse, ProviderError> {
67 let response = self
68 .client
69 .post(DEEPSEEK_API_URL)
70 .header("Authorization", format!("Bearer {}", self.api_key))
71 .header("Content-Type", "application/json")
72 .json(&request)
73 .send()
74 .await
75 .map_err(|e| ProviderError::NetworkError(e.to_string()))?;
76
77 if !response.status().is_success() {
78 let status = response.status();
79 let body = response.text().await.unwrap_or_default();
80 return Err(ProviderError::ApiError(format!("{}: {}", status, body)));
81 }
82
83 response
84 .json()
85 .await
86 .map_err(|e| ProviderError::ApiError(e.to_string()))
87 }
88
89 async fn chat_stream(&self, request: ChatRequest) -> Result<StreamResult, ProviderError> {
90 let mut stream_request = request;

Callers

nothing calls this directly

Calls 4

ApiErrorEnum · 0.50
sendMethod · 0.45
statusMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected