feat: Enhance conversation testing with ROM loading and verbose output options

This commit is contained in:
scawful
2025-10-03 22:49:52 -04:00
parent 57c8434ee1
commit ad7c5f72b2
5 changed files with 105 additions and 15 deletions

View File

@@ -157,6 +157,10 @@ void ConversationalAgentService::SetRomContext(Rom* rom) {
}
}
void ConversationalAgentService::ResetConversation() {
history_.clear();
}
absl::StatusOr<ChatMessage> ConversationalAgentService::SendMessage(
const std::string& message) {
if (message.empty() && history_.empty()) {

View File

@@ -42,6 +42,9 @@ class ConversationalAgentService {
// Provide the service with a ROM context for tool execution.
void SetRomContext(Rom* rom);
// Clear the current conversation history, preserving ROM/tool context.
void ResetConversation();
private:
std::vector<ChatMessage> history_;
std::unique_ptr<AIService> ai_service_;

View File

@@ -7,6 +7,7 @@
#include <iostream>
#include <sstream>
#include "absl/strings/ascii.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h"
#include "nlohmann/json.hpp"
@@ -19,14 +20,31 @@ namespace {
namespace fs = std::filesystem;
bool IsYamlBool(const std::string& value) {
const std::string lower = absl::AsciiStrToLower(value);
return lower == "true" || lower == "false" || lower == "yes" ||
lower == "no" || lower == "on" || lower == "off";
}
nlohmann::json YamlToJson(const YAML::Node& node) {
if (!node) {
return nlohmann::json();
}
switch (node.Type()) {
case YAML::NodeType::Scalar:
return node.as<std::string>("");
case YAML::NodeType::Scalar: {
const std::string scalar = node.as<std::string>("");
if (IsYamlBool(scalar)) {
return node.as<bool>();
}
if (scalar == "~" || absl::AsciiStrToLower(scalar) == "null") {
return nlohmann::json();
}
return scalar;
}
case YAML::NodeType::Sequence: {
nlohmann::json array = nlohmann::json::array();
for (const auto& item : node) {