forked from React-Group/interstellar_ai
28 lines
No EOL
773 B
TypeScript
28 lines
No EOL
773 B
TypeScript
/* type ChatMessage = {
|
|
name: string;
|
|
messages: any;
|
|
timestamp: number;
|
|
};
|
|
|
|
let chatHistory: ChatMessage[] = [];
|
|
|
|
function addMessageToHistory(name: string, message: any): void {
|
|
const newMessage: ChatMessage = {
|
|
name: name,
|
|
messages: message,
|
|
timestamp: Date.now()
|
|
};
|
|
chatHistory.push(newMessage);
|
|
console.log(`Added message from ${name}: ${message}`);
|
|
}
|
|
|
|
function removeMessageFromHistory(timestamp: number): void {
|
|
const index = chatHistory.findIndex((msg) => msg.timestamp === timestamp);
|
|
if (index > -1) {
|
|
chatHistory.splice(index, 1);
|
|
console.log(`Removed message with timestamp: ${timestamp}`);
|
|
} else {
|
|
console.log(`Message not found with timestamp: ${timestamp}`);
|
|
}
|
|
}
|
|
*/ |