MCPcopy Create free account
hub / github.com/AI45Lab/Code / request_headers

Method request_headers

core/src/llm/openai.rs:145–163  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

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

Calls 2

lenMethod · 0.45
cloneMethod · 0.45