feat: Consolidate AI agent build flags and enhance JSON support handling
This commit is contained in:
@@ -7,26 +7,9 @@
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "cli/service/agent/conversational_agent_service.h"
|
||||
|
||||
// Check if we have httplib available (from vcpkg or bundled)
|
||||
#if __has_include("httplib.h")
|
||||
#define YAZE_HAS_HTTPLIB 1
|
||||
#ifdef YAZE_WITH_JSON
|
||||
#include "httplib.h"
|
||||
#elif __has_include("incl/httplib.h")
|
||||
#define YAZE_HAS_HTTPLIB 1
|
||||
#include "incl/httplib.h"
|
||||
#else
|
||||
#define YAZE_HAS_HTTPLIB 0
|
||||
#endif
|
||||
|
||||
// Check if we have JSON library available
|
||||
#if __has_include("third_party/json/src/json.hpp")
|
||||
#define YAZE_HAS_JSON 1
|
||||
#include "third_party/json/src/json.hpp"
|
||||
#elif __has_include("json.hpp")
|
||||
#define YAZE_HAS_JSON 1
|
||||
#include "json.hpp"
|
||||
#else
|
||||
#define YAZE_HAS_JSON 0
|
||||
#include "nlohmann/json.hpp"
|
||||
#endif
|
||||
|
||||
namespace yaze {
|
||||
@@ -60,10 +43,10 @@ void OllamaAIService::SetRomContext(Rom* rom) {
|
||||
}
|
||||
|
||||
absl::Status OllamaAIService::CheckAvailability() {
|
||||
#if !YAZE_HAS_HTTPLIB || !YAZE_HAS_JSON
|
||||
#ifndef YAZE_WITH_JSON
|
||||
return absl::UnimplementedError(
|
||||
"Ollama service requires httplib and JSON support. "
|
||||
"Install vcpkg dependencies or use bundled libraries.");
|
||||
"Ollama service requires JSON support. "
|
||||
"Build with -DZ3ED_AI=ON or -DYAZE_WITH_JSON=ON");
|
||||
#else
|
||||
try {
|
||||
httplib::Client cli(config_.base_url);
|
||||
|
||||
@@ -125,6 +125,13 @@ absl::StatusOr<std::string> PromptBuilder::ResolveCataloguePath(
|
||||
}
|
||||
|
||||
absl::Status PromptBuilder::LoadResourceCatalogue(const std::string& yaml_path) {
|
||||
#ifndef YAZE_WITH_JSON
|
||||
// Gracefully degrade if JSON support not available
|
||||
std::cerr << "⚠️ PromptBuilder requires JSON support for catalogue loading\n"
|
||||
<< " Build with -DZ3ED_AI=ON or -DYAZE_WITH_JSON=ON\n"
|
||||
<< " AI features will use basic prompts without tool definitions\n";
|
||||
return absl::OkStatus(); // Don't fail, just skip catalogue loading
|
||||
#else
|
||||
auto resolved_or = ResolveCataloguePath(yaml_path);
|
||||
if (!resolved_or.ok()) {
|
||||
ClearCatalogData();
|
||||
@@ -175,6 +182,7 @@ absl::Status PromptBuilder::LoadResourceCatalogue(const std::string& yaml_path)
|
||||
|
||||
catalogue_loaded_ = true;
|
||||
return absl::OkStatus();
|
||||
#endif // YAZE_WITH_JSON
|
||||
}
|
||||
|
||||
absl::Status PromptBuilder::ParseCommands(const nlohmann::json& commands) {
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
#ifndef YAZE_CLI_SERVICE_PROMPT_BUILDER_H_
|
||||
#define YAZE_CLI_SERVICE_PROMPT_BUILDER_H_
|
||||
|
||||
// PromptBuilder requires JSON and YAML support for catalogue loading
|
||||
// If you see linker errors, enable Z3ED_AI or YAZE_WITH_JSON in CMake
|
||||
#if !defined(YAZE_WITH_JSON)
|
||||
#warning "PromptBuilder requires JSON support. Build with -DZ3ED_AI=ON or -DYAZE_WITH_JSON=ON"
|
||||
#endif
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
Reference in New Issue
Block a user