Agents 0.0.2
Edge AI Agents SDK
Loading...
Searching...
No Matches
anthropic_llm.h
1
10#pragma once
11
12#include <agents-cpp/llm_interface.h>
13
14namespace agents {
19namespace llms {
20
24class AnthropicLLM : public LLMInterface {
25public:
31 AnthropicLLM(const String& api_key = "", const String& model = "claude-3-5-sonnet-20240620");
35 ~AnthropicLLM() override = default;
36
41 std::vector<String> getAvailableModels() override;
42
47 void setModel(const String& model) override;
48
53 String getModel() const override;
54
59 void setApiKey(const String& api_key) override;
60
65 void setApiBase(const String& api_base) override;
66
71 void setOptions(const LLMOptions& options) override;
72
77 LLMOptions getOptions() const override;
78
84 LLMResponse complete(const String& prompt) override;
85
91 LLMResponse chat(const std::vector<Message>& messages) override;
92
100 const std::vector<Message>& messages,
101 const std::vector<std::shared_ptr<Tool>>& tools
102 ) override;
103
110 const std::vector<Message>& messages,
111 std::function<void(const String&, bool)> callback
112 ) override;
113
114private:
115 String api_key_;
116 String api_base_ = "https://api.anthropic.com";
117 String model_;
118 LLMOptions options_;
119
125 JsonObject messagesToAnthropicFormat(const std::vector<Message>& messages);
126
132 JsonObject toolsToAnthropicFormat(const std::vector<std::shared_ptr<Tool>>& tools);
133
139 LLMResponse parseAnthropicResponse(const JsonObject& response);
140
147 JsonObject makeApiCall(const JsonObject& request_body, bool stream = false);
148};
149
150} // namespace llms
151} // namespace agents
Interface for language model providers (OpenAI, Anthropic, Google, Ollama)
Definition llm_interface.h:68
void streamChat(const std::vector< Message > &messages, std::function< void(const String &, bool)> callback) override
Stream results with callback.
void setApiKey(const String &api_key) override
Set API key.
String getModel() const override
Get current model.
AnthropicLLM(const String &api_key="", const String &model="claude-3-5-sonnet-20240620")
Constructor.
~AnthropicLLM() override=default
Destructor.
void setApiBase(const String &api_base) override
Set API base URL (for self-hosted or proxied endpoints)
LLMResponse chatWithTools(const std::vector< Message > &messages, const std::vector< std::shared_ptr< Tool > > &tools) override
Generate completion with available tools.
std::vector< String > getAvailableModels() override
Get available models from Anthropic.
void setModel(const String &model) override
Set the model to use.
LLMResponse complete(const String &prompt) override
Generate completion from a prompt.
LLMOptions getOptions() const override
Get current options.
void setOptions(const LLMOptions &options) override
Set options for API calls.
LLMResponse chat(const std::vector< Message > &messages) override
Generate completion from a list of messages.
Large Language Models Namespace.
Definition anthropic_llm.h:19
Tools Namespace.
Definition file_tool.h:15
Framework Namespace.
Definition agent.h:18
nlohmann::json JsonObject
JSON object type.
Definition types.h:39
std::string String
String type.
Definition types.h:27
Options for LLM API calls.
Definition llm_interface.h:25
Response from an LLM.
Definition types.h:85