-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcompact_checkpoint.hpp
More file actions
47 lines (35 loc) · 1.34 KB
/
Copy pathcompact_checkpoint.hpp
File metadata and controls
47 lines (35 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
#include "../provider/llm_provider.hpp"
#include "session_history_recovery.hpp"
#include <cstdint>
#include <optional>
#include <string>
#include <vector>
namespace acecode {
constexpr const char* kCompactCheckpointSubtype = "compact_checkpoint";
constexpr int kCompactCheckpointVersion = 2;
struct CompactCheckpoint {
int version = kCompactCheckpointVersion;
std::string id;
std::string timestamp;
std::string trigger;
std::string summary;
int messages_compressed = 0;
int estimated_tokens_saved = 0;
int pre_tokens = 0;
int post_tokens = 0;
std::uint64_t window_number = 0;
std::string first_window_id;
std::string previous_window_id;
std::string window_id;
std::vector<ChatMessage> replacement_history;
};
bool is_compact_checkpoint_message(const ChatMessage& msg);
ChatMessage encode_compact_checkpoint(const CompactCheckpoint& checkpoint);
std::optional<CompactCheckpoint> decode_compact_checkpoint(const ChatMessage& msg);
std::vector<ChatMessage> provider_relevant_messages(const std::vector<ChatMessage>& messages);
std::vector<ChatMessage> reconstruct_effective_model_history(
const std::vector<ChatMessage>& raw_messages);
ProviderHistoryRecoveryResult reconstruct_effective_model_history_with_recovery(
const std::vector<ChatMessage>& raw_messages);
} // namespace acecode