yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
conversational_agent_service.h
Go to the documentation of this file.
1#ifndef YAZE_SRC_CLI_SERVICE_AGENT_CONVERSATIONAL_AGENT_SERVICE_H_
2#define YAZE_SRC_CLI_SERVICE_AGENT_CONVERSATIONAL_AGENT_SERVICE_H_
3
4#include <filesystem>
5#include <optional>
6#include <string>
7#include <vector>
8
9#include "absl/status/status.h"
10#include "absl/status/statusor.h"
11#include "absl/time/time.h"
15
16namespace yaze {
17
18class Rom;
19
20namespace cli {
21namespace agent {
22
24 enum class Sender { kUser, kAgent };
25 struct TableData {
26 std::vector<std::string> headers;
27 std::vector<std::vector<std::string>> rows;
28 };
30 std::string id;
31 int change_count = 0;
33 std::filesystem::path sandbox_rom_path;
34 std::filesystem::path proposal_json_path;
35 };
37 std::string message;
38 absl::Time timestamp;
39 std::optional<std::string> json_pretty;
40 std::optional<TableData> table_data;
41 bool is_internal = false; // True for tool results and other messages not meant for user display
52 std::optional<SessionMetrics> metrics;
53 std::optional<ProposalSummary> proposal;
54};
55
60 kJson
61};
62
64 int max_tool_iterations = 4; // Maximum number of tool calling iterations
65 int max_retry_attempts = 3; // Maximum retries on errors
66 bool verbose = false; // Enable verbose diagnostic output
67 bool show_reasoning = true; // Show LLM reasoning in output
68 size_t max_history_messages = 50; // Maximum stored history messages per session
69 bool trim_history = true; // Whether to trim history beyond the limit
70 bool enable_vim_mode = false; // Enable vim-style line editing in simple-chat
72};
73
75 public:
77 explicit ConversationalAgentService(const AgentConfig& config);
78
79 // Send a message from the user and get the agent's response.
80 absl::StatusOr<ChatMessage> SendMessage(const std::string& message);
81
82 // Get the full chat history.
83 const std::vector<ChatMessage>& GetHistory() const;
84
85 // Provide the service with a ROM context for tool execution.
86 void SetRomContext(Rom* rom);
87
88 // Clear the current conversation history, preserving ROM/tool context.
89 void ResetConversation();
90
91 // Configuration
92 void SetConfig(const AgentConfig& config) { config_ = config; }
93 const AgentConfig& GetConfig() const { return config_; }
94
96
97 void ReplaceHistory(std::vector<ChatMessage> history);
98
99 private:
103 int tool_calls = 0;
107 absl::Duration total_latency = absl::ZeroDuration();
108 };
109
110 void TrimHistoryIfNeeded();
113
114 std::vector<ChatMessage> history_;
115 std::unique_ptr<AIService> ai_service_;
117 Rom* rom_context_ = nullptr;
120};
121
122} // namespace agent
123} // namespace cli
124} // namespace yaze
125
126#endif // YAZE_SRC_CLI_SERVICE_AGENT_CONVERSATIONAL_AGENT_SERVICE_H_
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:71
absl::StatusOr< ChatMessage > SendMessage(const std::string &message)
const std::vector< ChatMessage > & GetHistory() const
void ReplaceHistory(std::vector< ChatMessage > history)
Main namespace for the application.
std::vector< std::vector< std::string > > rows
std::optional< std::string > json_pretty
std::optional< ProposalSummary > proposal
std::optional< SessionMetrics > metrics