|
3 | 3 | #include <iostream> |
4 | 4 | #include <sstream> |
5 | 5 | #include <string> |
| 6 | +#include "utils/logging_utils.h" |
6 | 7 | namespace remote_engine { |
7 | | - |
| 8 | +namespace { |
8 | 9 | constexpr const int k200OK = 200; |
9 | 10 | constexpr const int k400BadRequest = 400; |
10 | 11 | constexpr const int k409Conflict = 409; |
11 | 12 | constexpr const int k500InternalServerError = 500; |
12 | 13 | constexpr const int kFileLoggerOption = 0; |
| 14 | +bool is_anthropic(const std::string& model) { |
| 15 | + return model.find("claude") != std::string::npos; |
| 16 | +} |
| 17 | +} // namespace |
13 | 18 |
|
14 | 19 | CurlResponse RemoteEngine::MakeStreamingChatCompletionRequest( |
15 | 20 | const ModelConfig& config, const std::string& body, |
@@ -166,6 +171,11 @@ CurlResponse RemoteEngine::MakeChatCompletionRequest( |
166 | 171 |
|
167 | 172 | headers = curl_slist_append(headers, api_key_template_.c_str()); |
168 | 173 | } |
| 174 | + |
| 175 | + if (is_anthropic(config.model)) { |
| 176 | + std::string v = "anthropic-version: " + config.version; |
| 177 | + headers = curl_slist_append(headers, v.c_str()); |
| 178 | + } |
169 | 179 | headers = curl_slist_append(headers, "Content-Type: application/json"); |
170 | 180 |
|
171 | 181 | curl_easy_setopt(curl, CURLOPT_URL, full_url.c_str()); |
@@ -200,6 +210,13 @@ bool RemoteEngine::LoadModelConfig(const std::string& model, |
200 | 210 |
|
201 | 211 | ModelConfig model_config; |
202 | 212 | model_config.model = model; |
| 213 | + if (is_anthropic(model)) { |
| 214 | + if (!config["version"]) { |
| 215 | + CTL_ERR("Missing version for model: " << model); |
| 216 | + return false; |
| 217 | + } |
| 218 | + model_config.version = config["version"].as<std::string>(); |
| 219 | + } |
203 | 220 |
|
204 | 221 | // Required fields |
205 | 222 | if (!config["api_key_template"]) { |
|
0 commit comments