| 143 | } |
| 144 | |
| 145 | pub(crate) fn request_headers(&self) -> Vec<(String, String)> { |
| 146 | let mut headers = Vec::with_capacity(self.headers.len() + 1); |
| 147 | let has_authorization = self |
| 148 | .headers |
| 149 | .keys() |
| 150 | .any(|key| key.eq_ignore_ascii_case("authorization")); |
| 151 | if !has_authorization { |
| 152 | headers.push(( |
| 153 | "Authorization".to_string(), |
| 154 | format!("Bearer {}", self.api_key.expose()), |
| 155 | )); |
| 156 | } |
| 157 | headers.extend( |
| 158 | self.headers |
| 159 | .iter() |
| 160 | .map(|(key, value)| (key.clone(), value.clone())), |
| 161 | ); |
| 162 | headers |
| 163 | } |
| 164 | |
| 165 | pub(crate) fn convert_messages(&self, messages: &[Message]) -> Vec<serde_json::Value> { |
| 166 | messages |