googleapis / googleapis/java-genai
MaxHistorySize
- 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
Assessment
This issue has not been assessed yet.