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

Method chat

crates/opencode-provider/src/gitlab.rs:140–169  ·  view source on GitHub ↗
(&self, request: ChatRequest)

Source from the content-addressed store, hash-verified

138 }
139
140 async fn chat(&self, request: ChatRequest) -> Result<ChatResponse, ProviderError> {
141 let url = self.get_api_url();
142 let gitlab_request = self.convert_request(request);
143
144 let response = self
145 .client
146 .post(&url)
147 .header("Content-Type", "application/json")
148 .header("PRIVATE-TOKEN", &self.config.api_key)
149 .json(&gitlab_request)
150 .send()
151 .await
152 .map_err(|e| ProviderError::NetworkError(e.to_string()))?;
153
154 if !response.status().is_success() {
155 let status = response.status();
156 let body = response.text().await.unwrap_or_default();
157 return Err(ProviderError::api_error_with_status(
158 format!("{}: {}", status, body),
159 status.as_u16(),
160 ));
161 }
162
163 let gitlab_response: GitLabResponse = response
164 .json()
165 .await
166 .map_err(|e| ProviderError::ApiError(e.to_string()))?;
167
168 Ok(convert_gitlab_response(gitlab_response))
169 }
170
171 async fn chat_stream(&self, request: ChatRequest) -> Result<StreamResult, ProviderError> {
172 let url = self.get_api_url();

Callers

nothing calls this directly

Calls 7

convert_gitlab_responseFunction · 0.85
get_api_urlMethod · 0.80
ApiErrorEnum · 0.50
convert_requestMethod · 0.45
sendMethod · 0.45
statusMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected