googleapis / googleapis/java-genai

MaxHistorySize

Open
#231 1 comment 1 reaction 2 assignees Claimed by @hemasekhar-p View on GitHub
priority: p3 type: feature request
Dominant language
Java
Stars
397
Forks
125
Avg merge
2d 8h
Merged PRs (30d)
41

Description

Hi,
I need of new featured that se max History size.

In class Chat you can add :
private int maxHistorySize = -1;

and new method:
private void trimHistoryIfNeeded() {
if (maxHistorySize > 0) {
while (comprehensiveHistory.size() > maxHistorySize) {
comprehensiveHistory.remove(0); // Rimuovi il primo (il più vecchio)
}
while (curatedHistory.size() > maxHistorySize) {
curatedHistory.remove(0);
}
}
}

in protected void recordHistory(List currentHistory, GenerateContentResponse response) {
super.recordHistory(currentHistory, response);
trimHistoryIfNeeded();
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.