Integrate AI Agent Services and Chat Interface
- Added support for AI agent services, including `ConversationalAgentService`, to facilitate user interactions through a chat interface. - Implemented `ChatTUI` for a terminal-based chat experience, allowing users to send messages and receive responses from the AI agent. - Updated `EditorManager` to include options for displaying the agent chat widget and performance dashboard. - Enhanced CMake configurations to include new source files for AI services and chat interface components. This commit significantly expands the functionality of the z3ed system, paving the way for a more interactive and user-friendly experience in ROM hacking.
This commit is contained in:
@@ -93,6 +93,7 @@ target_include_directories(
|
||||
${CMAKE_SOURCE_DIR}/incl/
|
||||
${CMAKE_SOURCE_DIR}/src/
|
||||
${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine
|
||||
${CMAKE_SOURCE_DIR}/third_party/httplib
|
||||
${SDL2_INCLUDE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${PROJECT_BINARY_DIR}
|
||||
@@ -273,6 +274,19 @@ if(YAZE_WITH_GRPC)
|
||||
${CMAKE_SOURCE_DIR}/src/app/core/testing/test_script_parser.cc
|
||||
${CMAKE_SOURCE_DIR}/src/app/core/testing/test_script_parser.h)
|
||||
|
||||
# Add AI agent sources
|
||||
target_sources(yaze PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/src/cli/service/agent/conversational_agent_service.cc
|
||||
${CMAKE_SOURCE_DIR}/src/cli/service/ai/service_factory.cc
|
||||
${CMAKE_SOURCE_DIR}/src/cli/service/ai/ai_service.cc
|
||||
${CMAKE_SOURCE_DIR}/src/cli/service/ai/ollama_ai_service.cc
|
||||
${CMAKE_SOURCE_DIR}/src/cli/service/ai/gemini_ai_service.cc
|
||||
${CMAKE_SOURCE_DIR}/src/cli/service/ai/prompt_builder.cc
|
||||
${CMAKE_SOURCE_DIR}/src/cli/service/planning/tile16_proposal_generator.cc
|
||||
${CMAKE_SOURCE_DIR}/src/cli/service/resources/resource_context_builder.cc
|
||||
${CMAKE_SOURCE_DIR}/src/cli/service/resources/resource_catalog.cc
|
||||
)
|
||||
|
||||
# Link gRPC libraries
|
||||
target_link_libraries(yaze PRIVATE
|
||||
grpc++
|
||||
@@ -280,4 +294,5 @@ if(YAZE_WITH_GRPC)
|
||||
libprotobuf)
|
||||
|
||||
message(STATUS "✓ gRPC ImGuiTestHarness integrated")
|
||||
message(STATUS "✓ AI Agent services integrated into yaze GUI")
|
||||
endif()
|
||||
|
||||
@@ -37,3 +37,7 @@ set(
|
||||
app/test/unit_test_suite.h
|
||||
app/editor/system/proposal_drawer.cc
|
||||
)
|
||||
|
||||
if(YAZE_WITH_GRPC)
|
||||
list(APPEND YAZE_APP_EDITOR_SRC app/editor/system/agent_chat_widget.cc)
|
||||
endif()
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "absl/strings/match.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "app/core/features.h"
|
||||
#include "app/gfx/performance_profiler.h"
|
||||
#include "app/core/platform/file_dialog.h"
|
||||
#include "app/core/project.h"
|
||||
#include "app/editor/code/assembly_editor.h"
|
||||
@@ -21,6 +20,7 @@
|
||||
#include "app/editor/sprite/sprite_editor.h"
|
||||
#include "app/emu/emulator.h"
|
||||
#include "app/gfx/arena.h"
|
||||
#include "app/gfx/performance_profiler.h"
|
||||
#include "app/gui/background_renderer.h"
|
||||
#include "app/gui/icons.h"
|
||||
#include "app/gui/input.h"
|
||||
@@ -38,11 +38,16 @@
|
||||
#ifdef YAZE_ENABLE_GTEST
|
||||
#include "app/test/unit_test_suite.h"
|
||||
#endif
|
||||
#include "app/editor/system/settings_editor.h"
|
||||
#include "app/editor/system/toast_manager.h"
|
||||
#include "app/emu/emulator.h"
|
||||
#include "app/gfx/performance_dashboard.h"
|
||||
#include "editor/editor.h"
|
||||
#include "imgui/imgui.h"
|
||||
#include "imgui/misc/cpp/imgui_stdlib.h"
|
||||
#include "util/log.h"
|
||||
#include "util/macro.h"
|
||||
#include "yaze_config.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
@@ -706,6 +711,10 @@ void EditorManager::Initialize(const std::string& filename) {
|
||||
// Agent Proposals
|
||||
{absl::StrCat(ICON_MD_PREVIEW, " Agent Proposals"), "",
|
||||
[&]() { proposal_drawer_.Toggle(); }},
|
||||
#ifdef YAZE_WITH_GRPC
|
||||
{absl::StrCat(ICON_MD_CHAT, " Agent Chat"), "",
|
||||
[&]() { show_agent_chat_widget_ = !show_agent_chat_widget_; }},
|
||||
#endif
|
||||
|
||||
{gui::kSeparator, "", nullptr, []() { return true; }},
|
||||
|
||||
@@ -915,6 +924,19 @@ absl::Status EditorManager::Update() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (show_performance_dashboard_) {
|
||||
gfx::PerformanceDashboard::Get().Render();
|
||||
}
|
||||
if (show_proposal_drawer_) {
|
||||
proposal_drawer_.Draw();
|
||||
}
|
||||
#ifdef YAZE_WITH_GRPC
|
||||
if (show_agent_chat_widget_) {
|
||||
agent_chat_widget_.Draw();
|
||||
}
|
||||
#endif
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#include "app/editor/sprite/sprite_editor.h"
|
||||
#include "app/editor/system/popup_manager.h"
|
||||
#include "app/editor/system/proposal_drawer.h"
|
||||
#ifdef YAZE_WITH_GRPC
|
||||
#include "app/editor/system/agent_chat_widget.h"
|
||||
#endif
|
||||
#include "app/editor/system/settings_editor.h"
|
||||
#include "app/editor/system/toast_manager.h"
|
||||
#include "app/emu/emulator.h"
|
||||
@@ -174,11 +177,17 @@ class EditorManager {
|
||||
// Testing interface
|
||||
bool show_test_dashboard_ = false;
|
||||
bool show_performance_dashboard_ = false;
|
||||
|
||||
|
||||
// Agent proposal drawer
|
||||
ProposalDrawer proposal_drawer_;
|
||||
bool show_proposal_drawer_ = false;
|
||||
|
||||
#ifdef YAZE_WITH_GRPC
|
||||
// Agent chat widget
|
||||
AgentChatWidget agent_chat_widget_;
|
||||
bool show_agent_chat_widget_ = false;
|
||||
#endif
|
||||
|
||||
std::string version_ = "";
|
||||
std::string settings_filename_ = "settings.ini";
|
||||
float font_global_scale_ = 1.0f;
|
||||
|
||||
42
src/app/editor/system/agent_chat_widget.cc
Normal file
42
src/app/editor/system/agent_chat_widget.cc
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "app/editor/system/agent_chat_widget.h"
|
||||
#include "imgui.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
|
||||
AgentChatWidget::AgentChatWidget() {
|
||||
title_ = "Agent Chat";
|
||||
memset(input_buffer_, 0, sizeof(input_buffer_));
|
||||
}
|
||||
|
||||
void AgentChatWidget::Draw() {
|
||||
if (!active_) {
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui::Begin(title_.c_str(), &active_);
|
||||
|
||||
// Display message history
|
||||
ImGui::BeginChild("History", ImVec2(0, -ImGui::GetFrameHeightWithSpacing()));
|
||||
for (const auto& msg : agent_service_.GetHistory()) {
|
||||
std::string prefix =
|
||||
msg.sender == cli::agent::ChatMessage::Sender::kUser ? "You: " : "Agent: ";
|
||||
ImGui::TextWrapped((prefix + msg.message).c_str());
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
// Display input text box
|
||||
if (ImGui::InputText("Input", input_buffer_, sizeof(input_buffer_),
|
||||
ImGuiInputTextFlags_EnterReturnsTrue)) {
|
||||
if (strlen(input_buffer_) > 0) {
|
||||
(void)agent_service_.SendMessage(input_buffer_);
|
||||
memset(input_buffer_, 0, sizeof(input_buffer_));
|
||||
}
|
||||
ImGui::SetKeyboardFocusHere(-1); // Refocus input
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
} // namespace editor
|
||||
} // namespace yaze
|
||||
30
src/app/editor/system/agent_chat_widget.h
Normal file
30
src/app/editor/system/agent_chat_widget.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef YAZE_SRC_APP_EDITOR_SYSTEM_AGENT_CHAT_WIDGET_H_
|
||||
#define YAZE_SRC_APP_EDITOR_SYSTEM_AGENT_CHAT_WIDGET_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "cli/service/agent/conversational_agent_service.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
|
||||
class AgentChatWidget {
|
||||
public:
|
||||
AgentChatWidget();
|
||||
|
||||
void Draw();
|
||||
|
||||
bool* active() { return &active_; }
|
||||
void set_active(bool active) { active_ = active; }
|
||||
|
||||
private:
|
||||
cli::agent::ConversationalAgentService agent_service_;
|
||||
char input_buffer_[1024];
|
||||
bool active_ = false;
|
||||
std::string title_;
|
||||
};
|
||||
|
||||
} // namespace editor
|
||||
} // namespace yaze
|
||||
|
||||
#endif // YAZE_SRC_APP_EDITOR_SYSTEM_AGENT_CHAT_WIDGET_H_
|
||||
Reference in New Issue
Block a user