forked from React-Group/interstellar_ai
Merge branch 'main' into main
This commit is contained in:
commit
7b25153361
6 changed files with 59 additions and 27 deletions
27
app/backend/ChatHistory.ts
Normal file
27
app/backend/ChatHistory.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
type ChatMessage = {
|
||||
name: string;
|
||||
message: any;
|
||||
timestamp: number;
|
||||
};
|
||||
|
||||
let chatHistory: ChatMessage[] = [];
|
||||
|
||||
function addMessage(name: string, message: any): void {
|
||||
const newMessage: ChatMessage = {
|
||||
name: name,
|
||||
message: message,
|
||||
timestamp: Date.now()
|
||||
};
|
||||
chatHistory.push(newMessage);
|
||||
console.log(`Added message from ${name}: ${message}`);
|
||||
}
|
||||
|
||||
function removeMessage(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}`);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
"use client"
|
||||
import React, { use, useEffect, useRef, useState } from "react";
|
||||
import ConversationFrontend from "../components/ConversationFrontend";
|
||||
import ConversationFrontend from '../components/ConversationFrontend';
|
||||
import InputFrontend from "../components/InputFrontend";
|
||||
import { sendToVoiceRecognition } from "./voice_backend"
|
||||
import axios from "axios";
|
||||
|
@ -55,6 +55,7 @@ const InputOutputBackend: React.FC = () => {
|
|||
}, [preferredCurrency, preferredLanguage, timeFormat, dateFormat, preferredMeasurement, timeZone]);
|
||||
|
||||
|
||||
const conversationRef = useRef<HTMLDivElement>(null)
|
||||
const [copyClicked, setCopyClicked] = useState(false)
|
||||
const [accessToken, setAccessToken] = useState("")
|
||||
const postWorkerRef = useRef<Worker | null>(null)
|
||||
|
@ -269,6 +270,7 @@ const InputOutputBackend: React.FC = () => {
|
|||
return (
|
||||
<>
|
||||
<ConversationFrontend
|
||||
ref={conversationRef}
|
||||
messages={messages}
|
||||
onResendClick={handleResendClick}
|
||||
onEditClick={handleEditClick}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue