@nomyx/assistant
Version:
A powerful assistant library and cli for your AI projects. works with Vertex AI (Claude and Gemini)
34 lines (33 loc) • 1.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RequestHistory = void 0;
class RequestHistory {
constructor(maxLength = 5, logger) {
this.logger = logger;
this.history = [];
this.maxLength = maxLength;
}
addEntry(request, response) {
const entry = {
request,
response,
timestamp: Date.now(),
};
this.history.unshift(entry);
if (this.history.length > this.maxLength) {
this.history.pop();
}
this.logger?.debug(`Added new entry to request history. Current history length: ${this.history.length}`);
}
getHistory() {
return [...this.history];
}
clear() {
this.history = [];
this.logger?.info('Request history cleared');
}
getFormattedHistory() {
return this.history.map(entry => `User: ${entry.request}\nAI: ${entry.response}\n`).join('\n');
}
}
exports.RequestHistory = RequestHistory;