Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 5473a75

Browse files
committed
feat: anthropic
1 parent 3f9f451 commit 5473a75

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

engine/extensions/remote-engine/remote_engine.cc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
#include <iostream>
44
#include <sstream>
55
#include <string>
6+
#include "utils/logging_utils.h"
67
namespace remote_engine {
7-
8+
namespace {
89
constexpr const int k200OK = 200;
910
constexpr const int k400BadRequest = 400;
1011
constexpr const int k409Conflict = 409;
1112
constexpr const int k500InternalServerError = 500;
1213
constexpr const int kFileLoggerOption = 0;
14+
bool is_anthropic(const std::string& model) {
15+
return model.find("claude") != std::string::npos;
16+
}
17+
} // namespace
1318

1419
CurlResponse RemoteEngine::MakeStreamingChatCompletionRequest(
1520
const ModelConfig& config, const std::string& body,
@@ -166,6 +171,11 @@ CurlResponse RemoteEngine::MakeChatCompletionRequest(
166171

167172
headers = curl_slist_append(headers, api_key_template_.c_str());
168173
}
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+
}
169179
headers = curl_slist_append(headers, "Content-Type: application/json");
170180

171181
curl_easy_setopt(curl, CURLOPT_URL, full_url.c_str());
@@ -200,6 +210,13 @@ bool RemoteEngine::LoadModelConfig(const std::string& model,
200210

201211
ModelConfig model_config;
202212
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+
}
203220

204221
// Required fields
205222
if (!config["api_key_template"]) {

engine/extensions/remote-engine/remote_engine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class RemoteEngine : public EngineI {
8080
// Model configuration
8181
struct ModelConfig {
8282
std::string model;
83+
std::string version;
8384
std::string api_key;
8485
std::string url;
8586
YAML::Node transform_req;

0 commit comments

Comments
 (0)