Files
moloapp/src/google/models/claude_models.h
T
retoorandClaude Sonnet 5.5 6b731643bf feat(clients): models: Gemini on Vertex, Model Garden, Claude, endpoint models, media, VertexModel
One call table verified against Discovery (29 calls), live-verified read-only
with an express key and a service account token, /agent/models example routes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 04:40:00 +02:00

64 lines
2.0 KiB
C++

#pragma once
// Partner models: Claude on Vertex AI through publishers/anthropic
// rawPredict and streamRawPredict. Project scoped only (Discovery has no
// express form for the raw predict methods).
#include <functional>
#include <optional>
#include <string>
#include <vector>
#include "google/models/vertex_service.h"
namespace molo::google::models {
struct ClaudeMessage {
std::string role; // "user" | "assistant"
std::string text;
};
struct ClaudeRequest {
std::string model; // e.g. claude-sonnet-4-6
std::string system;
std::vector<ClaudeMessage> messages;
int max_tokens = 1024;
std::optional<double> temperature;
int thinking_budget = 0; // 0: off; else >= 1024 and < max_tokens
clients::body::Json tools; // Anthropic tools array; null: none
clients::body::Json to_json(bool stream) const;
};
struct ClaudeResponse {
std::string id;
std::string model;
std::string stop_reason;
std::string text; // concatenated text blocks
int input_tokens = 0;
int output_tokens = 0;
clients::body::Json content; // raw content blocks (tool_use included)
static ClaudeResponse from_json(const clients::body::Json& doc);
};
class ClaudeModels : public VertexService {
public:
static constexpr const char* kAnthropicVersion = "vertex-2023-10-16";
ClaudeModels(std::shared_ptr<GoogleClient> client, VertexTarget target);
ClaudeResponse generate(const ClaudeRequest& request) const;
// Calls sink per Anthropic stream event (message_start, content_block_delta,
// ...); return false to stop.
void stream(const ClaudeRequest& request,
const std::function<bool(const clients::body::Json&)>& sink) const;
PlannedCall plan_generate(const ClaudeRequest& request) const;
PlannedCall plan_stream(const ClaudeRequest& request) const;
// Text of a content_block_delta / text_delta event, else "".
static std::string text_delta(const clients::body::Json& event);
static void validate(const ClaudeRequest& request);
};
} // namespace molo::google::models