yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
ollama_ai_service.h
Go to the documentation of this file.
1#ifndef YAZE_SRC_CLI_OLLAMA_AI_SERVICE_H_
2#define YAZE_SRC_CLI_OLLAMA_AI_SERVICE_H_
3
4#include <cstdint>
5#include <string>
6#include <vector>
7
8#include "absl/status/status.h"
9#include "absl/status/statusor.h"
10#include "absl/time/time.h"
12
13#ifdef YAZE_AI_RUNTIME_AVAILABLE
15#endif
16
17namespace yaze {
18namespace cli {
19
20// Ollama configuration for local LLM inference
22 std::string base_url = "http://localhost:11434"; // Default Ollama endpoint
23 std::string model =
24 "qwen2.5-coder:0.5b"; // Lightweight default with tool-calling
25 float temperature = 0.1; // Low temp for deterministic commands
26 int max_tokens = 2048; // Sufficient for command lists
27 std::string system_prompt; // Injected from resource catalogue
28 bool use_enhanced_prompting = true; // Enable few-shot examples
29 float top_p = 0.92f;
30 int top_k = 40;
31 int num_ctx = 4096;
32 bool stream = false;
34 std::vector<std::string> favorite_models;
35};
36
37#ifdef YAZE_AI_RUNTIME_AVAILABLE
38
39class OllamaAIService : public AIService {
40 public:
41 explicit OllamaAIService(const OllamaConfig& config);
42
43 struct OllamaModelDetails {
44 std::string name;
45 std::string digest;
46 std::string family;
47 std::string parameter_size;
48 std::string quantization_level;
49 uint64_t size_bytes = 0;
50 absl::Time modified_at = absl::InfinitePast();
51 };
52
53 void SetRomContext(Rom* rom) override;
54
55 // Generate z3ed commands from natural language prompt
56 absl::StatusOr<AgentResponse> GenerateResponse(
57 const std::string& prompt) override;
58 absl::StatusOr<AgentResponse> GenerateResponse(
59 const std::vector<agent::ChatMessage>& history) override;
60
61 // Health check: verify Ollama server is running and model is available
62 absl::Status CheckAvailability();
63
64 // List available models on Ollama server
65 absl::StatusOr<std::vector<ModelInfo>> ListAvailableModels() override;
66
67 std::string GetProviderName() const override { return "ollama"; }
68
69 private:
70 OllamaConfig config_;
71 PromptBuilder prompt_builder_;
72
73 // Build system prompt from resource catalogue
74 std::string BuildSystemPrompt();
75
76 // Parse JSON response from Ollama API
77 absl::StatusOr<std::string> ParseOllamaResponse(
78 const std::string& json_response);
79};
80
81#else // !YAZE_AI_RUNTIME_AVAILABLE
82
83class OllamaAIService : public AIService {
84 public:
86 std::string name;
87 std::string digest;
88 std::string family;
89 std::string parameter_size;
90 std::string quantization_level;
91 uint64_t size_bytes = 0;
92 absl::Time modified_at = absl::InfinitePast();
93 };
94
95 explicit OllamaAIService(const OllamaConfig&) {}
96 void SetRomContext(Rom*) override {}
97 absl::StatusOr<AgentResponse> GenerateResponse(const std::string&) override {
98 return absl::FailedPreconditionError("Ollama AI runtime is disabled");
99 }
100 absl::StatusOr<AgentResponse> GenerateResponse(
101 const std::vector<agent::ChatMessage>&) override {
102 return absl::FailedPreconditionError("Ollama AI runtime is disabled");
103 }
104 absl::Status CheckAvailability() {
105 return absl::FailedPreconditionError("Ollama AI runtime is disabled");
106 }
107 absl::StatusOr<std::vector<ModelInfo>> ListAvailableModels() override {
108 return absl::FailedPreconditionError("Ollama AI runtime is disabled");
109 }
110 std::string GetProviderName() const override { return "ollama"; }
111};
112
113#endif // YAZE_AI_RUNTIME_AVAILABLE
114
115} // namespace cli
116} // namespace yaze
117
118#endif // YAZE_SRC_CLI_OLLAMA_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:24
absl::StatusOr< std::vector< ModelInfo > > ListAvailableModels() override
std::string GetProviderName() const override
OllamaAIService(const OllamaConfig &)
absl::StatusOr< AgentResponse > GenerateResponse(const std::vector< agent::ChatMessage > &) override
void SetRomContext(Rom *) override
absl::StatusOr< AgentResponse > GenerateResponse(const std::string &) override
std::vector< std::string > favorite_models