yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
anthropic_ai_service.h
Go to the documentation of this file.
1#ifndef YAZE_SRC_CLI_ANTHROPIC_AI_SERVICE_H_
2#define YAZE_SRC_CLI_ANTHROPIC_AI_SERVICE_H_
3
4#include <string>
5#include <vector>
6
7#include "absl/status/status.h"
8#include "absl/status/statusor.h"
11
12#ifdef YAZE_AI_RUNTIME_AVAILABLE
14#endif
15
16namespace yaze {
17namespace cli {
18
20 std::string api_key;
21 std::string model = "claude-3-5-sonnet-20241022"; // Default to 3.5 Sonnet
22 float temperature = 0.7f;
23 int max_output_tokens = 4096; // Anthropic supports larger output context
24 std::string system_instruction;
26 std::string prompt_version = "v3";
27 bool verbose = false;
28
29 AnthropicConfig() = default;
30 explicit AnthropicConfig(const std::string& key) : api_key(key) {}
31};
32
33#ifdef YAZE_AI_RUNTIME_AVAILABLE
34
35class AnthropicAIService : public AIService {
36 public:
37 explicit AnthropicAIService(const AnthropicConfig& config);
38 void SetRomContext(Rom* rom) override;
39
40 // Primary interface
41 absl::StatusOr<AgentResponse> GenerateResponse(
42 const std::string& prompt) override;
43 absl::StatusOr<AgentResponse> GenerateResponse(
44 const std::vector<agent::ChatMessage>& history) override;
45
46 // Health check
47 absl::Status CheckAvailability();
48
49 // List available models from Anthropic API (simulated, as list endpoint is sparse)
50 absl::StatusOr<std::vector<ModelInfo>> ListAvailableModels() override;
51
52 std::string GetProviderName() const override { return kProviderAnthropic; }
53
54 // Function calling support
55 void EnableFunctionCalling(bool enable = true);
56 std::vector<std::string> GetAvailableTools() const;
57
58 private:
59 std::string BuildSystemInstruction();
60 absl::StatusOr<AgentResponse> ParseAnthropicResponse(
61 const std::string& response_body);
62
63 bool function_calling_enabled_ = true;
64
65 AnthropicConfig config_;
66 PromptBuilder prompt_builder_;
67};
68
69#else // !YAZE_AI_RUNTIME_AVAILABLE
70
71// Stub implementation when AI runtime is disabled
73 public:
75 void SetRomContext(Rom*) override {}
76 absl::StatusOr<AgentResponse> GenerateResponse(
77 const std::string& prompt) override {
78 return absl::FailedPreconditionError(
79 "Anthropic AI runtime is disabled (prompt: " + prompt + ")");
80 }
81 absl::StatusOr<AgentResponse> GenerateResponse(
82 const std::vector<agent::ChatMessage>&) override {
83 return absl::FailedPreconditionError("Anthropic AI runtime is disabled");
84 }
85 absl::Status CheckAvailability() {
86 return absl::FailedPreconditionError("Anthropic AI runtime is disabled");
87 }
89 std::vector<std::string> GetAvailableTools() const { return {}; }
90 absl::StatusOr<std::vector<ModelInfo>> ListAvailableModels() override {
91 return absl::FailedPreconditionError("Anthropic AI runtime is disabled");
92 }
93 std::string GetProviderName() const override { return kProviderAnthropic; }
94};
95
96#endif // YAZE_AI_RUNTIME_AVAILABLE
97
98} // namespace cli
99} // namespace yaze
100
101#endif // YAZE_SRC_CLI_ANTHROPIC_AI_SERVICE_H_
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
absl::StatusOr< AgentResponse > GenerateResponse(const std::string &prompt) override
absl::StatusOr< std::vector< ModelInfo > > ListAvailableModels() override
absl::StatusOr< AgentResponse > GenerateResponse(const std::vector< agent::ChatMessage > &) override
std::vector< std::string > GetAvailableTools() const
std::string GetProviderName() const override
AnthropicAIService(const AnthropicConfig &)
constexpr char kProviderAnthropic[]
AnthropicConfig(const std::string &key)