diff --git a/app/backend/InputOutputHandler.tsx b/app/backend/InputOutputHandler.tsx index 68e552a..d40f9fb 100644 --- a/app/backend/InputOutputHandler.tsx +++ b/app/backend/InputOutputHandler.tsx @@ -4,7 +4,6 @@ import ConversationFrontend from '../components/ConversationFrontend'; import InputFrontend from "../components/InputFrontend"; import { sendToVoiceRecognition } from "./voice_backend" import axios from "axios"; -import { changeHistory, checkCredentials, getHistory } from './database'; import { useChatHistory } from '../hooks/useChatHistory'; const InputOutputBackend: React.FC = () => { @@ -80,13 +79,9 @@ const InputOutputBackend: React.FC = () => { }, [preferredCurrency, preferredLanguage, timeFormat, preferredMeasurement, timeZone, dateFormat, myBoolean]); useEffect(() => { - const updateSystemprompt = (prompt: string) => { - setMessages(prevMessages => { - const newMessage = { role: "system", content: prompt } - return [newMessage, ...prevMessages] - }) - } - updateSystemprompt + const messageIndex = 0 // system prompt is the first so index 0 + updateMessage(messageIndex, systemMessage) + console.log(messages) },[systemMessage]) @@ -188,17 +183,6 @@ const InputOutputBackend: React.FC = () => { } const messageIndex = chatHistory.chats[chatHistory.selectedIndex].messages.length-1 updateMessage(messageIndex,newContent) - // setMessages((prevMessages) => { - // const updatedMessages = prevMessages.slice(); // Create a shallow copy of the current messages - // if (updatedMessages.length > 0) { - // const lastMessage = updatedMessages[updatedMessages.length - 1]; - // updatedMessages[updatedMessages.length - 1] = { - // ...lastMessage, // Keep the existing role and other properties - // content: newContent, // Update only the content - // }; - // } - // return updatedMessages; // Return the updated array - // }); }; const addMessage = (role: string, content: string) => { diff --git a/app/components/AI.tsx b/app/components/AI.tsx index a4db7fa..824f6d6 100644 --- a/app/components/AI.tsx +++ b/app/components/AI.tsx @@ -2,14 +2,10 @@ import React from 'react'; import InputOutputBackend from '../backend/InputOutputHandler'; -interface AIProps{ - selectedIndex:number -} - -const AI: React.FC = ({selectedIndex}) => { +const AI: React.FC = () => { return (
- +
); }; diff --git a/app/components/History.tsx b/app/components/History.tsx index 92b86e8..b3cf197 100644 --- a/app/components/History.tsx +++ b/app/components/History.tsx @@ -6,6 +6,8 @@ const History: React.FC = () => { const [isEditing, setIsEditing] = useState(false); const [inputValue, setInputValue] = useState(''); + setChatHistory(chatHistory) + const handleEditButtonClick = () => { setIsEditing(true); diff --git a/app/page.tsx b/app/page.tsx index 832fbb7..3c77911 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -14,7 +14,6 @@ const LandingPage: React.FC = () => { const [showDivs, setShowDivs] = useState(true); const [view, setView] = useState<'AI' | 'FAQ' | 'Documentation' | 'Credits'>('AI'); const conversationRef = useRef(null); - const [selectedHistoryIndex, setSelectedHistoryIndex] = useState(0) const [primaryColor, setPrimaryColor] = useState("#fefefe"); const [secondaryColor, setSecondaryColor] = useState("#fefefe"); @@ -92,13 +91,13 @@ const LandingPage: React.FC = () => {
{showDivs && (
- +
)}
- {view === 'AI' && } + {view === 'AI' && } {view === 'FAQ' && } {view === 'Documentation' && } {view === 'Credits' && }