Merge pull request 'main' (#52) from React-Group/interstellar_ai:main into main

Reviewed-on: https://interstellardevelopment.org/code/code/sageTheDm/interstellar_ai/pulls/52
This commit is contained in:
sageTheDm 2024-10-10 10:39:32 +02:00
commit 1c82fc87d6
5 changed files with 99 additions and 40 deletions

View file

@ -1,28 +0,0 @@
// type Message = {
// role: string;
// content:string
// }
// type Chat = {
// name: string;
// messages: Message[];
// timestamp: number;
// };
// export function addMessageToHistory(index: number, chat: Chat): void {
// if (index >= 0 && index < chatHistory.length) {
// chatHistory[index] = chat;
// chatHistory.sort((a, b) => b.timestamp - a.timestamp)
// }
// }
// export 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}`);
// }
// }

View file

@ -23,7 +23,7 @@ const InputOutputBackend: React.FC = () => {
const [preferredMeasurement, setPreferredMeasurement] = useState<string>("metric");
const [timeZone, setTimeZone] = useState<string>("GMT");
const [dateFormat, setDateFormat] = useState<string>("DD-MM-YYYY");
const [messages, setMessages] = useState<Message[]>(chatHistory.chats[chatHistory.selectedIndex].messages || []);
const [messages, setMessages] = useState<Message[]>([]);
const [myBoolean, setMyBoolean] = useState<boolean>(false);
const [systemMessage, setSystemMessage] = useState<string>("You are a helpful assistant")
const [weatherData, setWeatherData] = useState<string>("")
@ -38,11 +38,16 @@ const InputOutputBackend: React.FC = () => {
console.log(setSelectedIndex)
useEffect(() => {
setMessages(chatHistory.chats[chatHistory.selectedIndex].messages)
}, [chatHistory.selectedIndex])
useEffect(() => {
console.log("History", chatHistory);
console.log("Messages", messages);
// Get the current chat's messages
const currentMessages = chatHistory.chats[chatHistory.selectedIndex].messages || [];