feat: Update AgentChatHistoryCodec to use JSON instead of gRPC for chat history management
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
#include "absl/time/clock.h"
|
#include "absl/time/clock.h"
|
||||||
#include "absl/time/time.h"
|
#include "absl/time/time.h"
|
||||||
|
|
||||||
#ifdef YAZE_WITH_GRPC
|
#if defined(YAZE_WITH_JSON)
|
||||||
#include "nlohmann/json.hpp"
|
#include "nlohmann/json.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ namespace editor {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
#ifdef YAZE_WITH_GRPC
|
#if defined(YAZE_WITH_JSON)
|
||||||
using Json = nlohmann::json;
|
using Json = nlohmann::json;
|
||||||
|
|
||||||
absl::Time ParseTimestamp(const Json& value) {
|
absl::Time ParseTimestamp(const Json& value) {
|
||||||
@@ -118,7 +118,7 @@ std::optional<cli::agent::ChatMessage::ProposalSummary> ParseProposal(
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool AgentChatHistoryCodec::Available() {
|
bool AgentChatHistoryCodec::Available() {
|
||||||
#ifdef YAZE_WITH_GRPC
|
#if defined(YAZE_WITH_JSON)
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
@@ -127,7 +127,7 @@ bool AgentChatHistoryCodec::Available() {
|
|||||||
|
|
||||||
absl::StatusOr<AgentChatHistoryCodec::Snapshot> AgentChatHistoryCodec::Load(
|
absl::StatusOr<AgentChatHistoryCodec::Snapshot> AgentChatHistoryCodec::Load(
|
||||||
const std::filesystem::path& path) {
|
const std::filesystem::path& path) {
|
||||||
#ifdef YAZE_WITH_GRPC
|
#if defined(YAZE_WITH_JSON)
|
||||||
Snapshot snapshot;
|
Snapshot snapshot;
|
||||||
|
|
||||||
std::ifstream file(path);
|
std::ifstream file(path);
|
||||||
@@ -239,7 +239,7 @@ absl::StatusOr<AgentChatHistoryCodec::Snapshot> AgentChatHistoryCodec::Load(
|
|||||||
|
|
||||||
absl::Status AgentChatHistoryCodec::Save(
|
absl::Status AgentChatHistoryCodec::Save(
|
||||||
const std::filesystem::path& path, const Snapshot& snapshot) {
|
const std::filesystem::path& path, const Snapshot& snapshot) {
|
||||||
#ifdef YAZE_WITH_GRPC
|
#if defined(YAZE_WITH_JSON)
|
||||||
Json json;
|
Json json;
|
||||||
json["version"] = 2;
|
json["version"] = 2;
|
||||||
json["messages"] = Json::array();
|
json["messages"] = Json::array();
|
||||||
|
|||||||
Reference in New Issue
Block a user