|
3 | 3 | use crate::{ |
4 | 4 | config::Config, |
5 | 5 | error::{ApiError, OpenAIError}, |
6 | | - http_client::{HttpClient, HttpResponse}, |
| 6 | + http_client::HttpResponse, |
7 | 7 | types::{ |
8 | 8 | CreateChatCompletionRequest, CreateChatCompletionResponse, |
9 | 9 | CreateChatCompletionStreamResponse, |
@@ -35,7 +35,7 @@ impl<'c, C: Config> ChatWithTrait<'c, C> { |
35 | 35 |
|
36 | 36 | // Serialize request body |
37 | 37 | let body = serde_json::to_vec(&request) |
38 | | - .map_err(|e| OpenAIError::JSONSerialize(e))?; |
| 38 | + .map_err(|e| OpenAIError::InvalidArgument(format!("Failed to serialize request: {}", e)))?; |
39 | 39 |
|
40 | 40 | // Prepare headers |
41 | 41 | let mut headers = self.client.config.headers(); |
@@ -117,12 +117,10 @@ impl<'c, C: Config> ChatWithTrait<'c, C> { |
117 | 117 | } |
118 | 118 | } |
119 | 119 | Err(e) => { |
120 | | - // Network error, retry |
121 | | - Err(backoff::Error::transient(OpenAIError::Reqwest( |
122 | | - reqwest::Error::from(std::io::Error::new( |
123 | | - std::io::ErrorKind::Other, |
124 | | - e.message |
125 | | - )) |
| 120 | + // Network error, retry |
| 121 | + // Convert to a string-based error since we can't create reqwest::Error directly |
| 122 | + Err(backoff::Error::transient(OpenAIError::InvalidArgument( |
| 123 | + format!("HTTP client error: {}", e.message) |
126 | 124 | ))) |
127 | 125 | } |
128 | 126 | } |
|
0 commit comments