Get a response for a chat request
(
request: CreateChatCompletionRequest,
)
| 178 | |
| 179 | /// Get a response for a chat request |
| 180 | async fn get_chat_response( |
| 181 | request: CreateChatCompletionRequest, |
| 182 | ) -> Result<CreateChatCompletionResponse> { |
| 183 | let client: &Client<OpenAIConfig> = get_client().unwrap(); |
| 184 | for _retry in 0..config::RETRY_N { |
| 185 | let response = client |
| 186 | .chat() |
| 187 | .create(request.clone()) |
| 188 | .await |
| 189 | .map_err(eyre::Report::new); |
| 190 | match is_critical_err(&response) { |
| 191 | crate::Critical::Normal => { |
| 192 | let response = response?; |
| 193 | return Ok(response); |
| 194 | } |
| 195 | crate::Critical::NonCritical => { |
| 196 | continue; |
| 197 | } |
| 198 | crate::Critical::Critical => return Err(response.err().unwrap()), |
| 199 | } |
| 200 | } |
| 201 | Err(FuzzerError::RetryError(format!("{request:?}"), config::RETRY_N).into()) |
| 202 | } |
| 203 | |
| 204 | |
| 205 |
no test coverage detected