NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
history.h
Go to the documentation of this file.
1
19#pragma once
20
21#include <neograph/api.h>
22#include <neograph/provider.h>
23#include <neograph/types.h>
24
25#include <asio/awaitable.hpp>
26
27#include <string>
28#include <vector>
29
30namespace neograph::history {
31
43NEOGRAPH_API int estimate_tokens(const std::vector<ChatMessage>& messages);
44
62NEOGRAPH_API void sanitize_tool_calls(std::vector<ChatMessage>& messages);
63
66 std::string summary;
67 std::vector<ChatMessage> recent;
68 bool compacted = false;
69};
70
98NEOGRAPH_API asio::awaitable<CompactedHistory> compact_history(
99 std::vector<ChatMessage> messages,
100 Provider& provider,
101 std::string model,
102 int max_tokens = 12000,
103 int recent_keep = 6);
104
105} // namespace neograph::history
NEOGRAPH_API export/import macro for shared-library builds.
Abstract base class for LLM providers.
Definition provider.h:127
NEOGRAPH_API asio::awaitable< CompactedHistory > compact_history(std::vector< ChatMessage > messages, Provider &provider, std::string model, int max_tokens=12000, int recent_keep=6)
Summarize old turns when the history exceeds a token budget.
NEOGRAPH_API int estimate_tokens(const std::vector< ChatMessage > &messages)
Rough token estimate for a message list.
NEOGRAPH_API void sanitize_tool_calls(std::vector< ChatMessage > &messages)
Repair OpenAI-invalid tool pairings in place.
Abstract LLM provider interface.
Result of compact_history.
Definition history.h:65
std::string summary
LLM summary of the compacted span ("" if none).
Definition history.h:66
bool compacted
true iff a summary was produced.
Definition history.h:68
std::vector< ChatMessage > recent
Leading system (if any) + summary-as-system + last N.
Definition history.h:67
Foundation types for NeoGraph: messages, tool calls, and LLM completions.