Merge pull request 'main' (#127) from YasinOnm08/interstellar_ai:main into main
Reviewed-on: https://interstellardevelopment.org/code/code/React-Group/interstellar_ai/pulls/127
This commit is contained in:
commit
d7040e8a5d
4 changed files with 9 additions and 28 deletions
|
@ -4,7 +4,6 @@ import ConversationFrontend from '../components/ConversationFrontend';
|
||||||
import InputFrontend from "../components/InputFrontend";
|
import InputFrontend from "../components/InputFrontend";
|
||||||
import { sendToVoiceRecognition } from "./voice_backend"
|
import { sendToVoiceRecognition } from "./voice_backend"
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { changeHistory, checkCredentials, getHistory } from './database';
|
|
||||||
import { useChatHistory } from '../hooks/useChatHistory';
|
import { useChatHistory } from '../hooks/useChatHistory';
|
||||||
|
|
||||||
const InputOutputBackend: React.FC = () => {
|
const InputOutputBackend: React.FC = () => {
|
||||||
|
@ -80,13 +79,9 @@ const InputOutputBackend: React.FC = () => {
|
||||||
}, [preferredCurrency, preferredLanguage, timeFormat, preferredMeasurement, timeZone, dateFormat, myBoolean]);
|
}, [preferredCurrency, preferredLanguage, timeFormat, preferredMeasurement, timeZone, dateFormat, myBoolean]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const updateSystemprompt = (prompt: string) => {
|
const messageIndex = 0 // system prompt is the first so index 0
|
||||||
setMessages(prevMessages => {
|
updateMessage(messageIndex, systemMessage)
|
||||||
const newMessage = { role: "system", content: prompt }
|
console.log(messages)
|
||||||
return [newMessage, ...prevMessages]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
updateSystemprompt
|
|
||||||
},[systemMessage])
|
},[systemMessage])
|
||||||
|
|
||||||
|
|
||||||
|
@ -188,17 +183,6 @@ const InputOutputBackend: React.FC = () => {
|
||||||
}
|
}
|
||||||
const messageIndex = chatHistory.chats[chatHistory.selectedIndex].messages.length-1
|
const messageIndex = chatHistory.chats[chatHistory.selectedIndex].messages.length-1
|
||||||
updateMessage(messageIndex,newContent)
|
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) => {
|
const addMessage = (role: string, content: string) => {
|
||||||
|
|
|
@ -2,14 +2,10 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import InputOutputBackend from '../backend/InputOutputHandler';
|
import InputOutputBackend from '../backend/InputOutputHandler';
|
||||||
|
|
||||||
interface AIProps{
|
const AI: React.FC = () => {
|
||||||
selectedIndex:number
|
|
||||||
}
|
|
||||||
|
|
||||||
const AI: React.FC<AIProps> = ({selectedIndex}) => {
|
|
||||||
return (
|
return (
|
||||||
<div className="ai-container">
|
<div className="ai-container">
|
||||||
<InputOutputBackend selectedIndex={selectedIndex}/>
|
<InputOutputBackend />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,8 @@ const History: React.FC = () => {
|
||||||
const [isEditing, setIsEditing] = useState(false);
|
const [isEditing, setIsEditing] = useState(false);
|
||||||
const [inputValue, setInputValue] = useState<string>('');
|
const [inputValue, setInputValue] = useState<string>('');
|
||||||
|
|
||||||
|
setChatHistory(chatHistory)
|
||||||
|
|
||||||
const handleEditButtonClick = () => {
|
const handleEditButtonClick = () => {
|
||||||
setIsEditing(true);
|
setIsEditing(true);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ const LandingPage: React.FC = () => {
|
||||||
const [showDivs, setShowDivs] = useState(true);
|
const [showDivs, setShowDivs] = useState(true);
|
||||||
const [view, setView] = useState<'AI' | 'FAQ' | 'Documentation' | 'Credits'>('AI');
|
const [view, setView] = useState<'AI' | 'FAQ' | 'Documentation' | 'Credits'>('AI');
|
||||||
const conversationRef = useRef<HTMLDivElement>(null);
|
const conversationRef = useRef<HTMLDivElement>(null);
|
||||||
const [selectedHistoryIndex, setSelectedHistoryIndex] = useState<number>(0)
|
|
||||||
|
|
||||||
const [primaryColor, setPrimaryColor] = useState("#fefefe");
|
const [primaryColor, setPrimaryColor] = useState("#fefefe");
|
||||||
const [secondaryColor, setSecondaryColor] = useState("#fefefe");
|
const [secondaryColor, setSecondaryColor] = useState("#fefefe");
|
||||||
|
@ -92,13 +91,13 @@ const LandingPage: React.FC = () => {
|
||||||
<div className={`left-panel ${showDivs ? 'visible' : 'hidden'}`}>
|
<div className={`left-panel ${showDivs ? 'visible' : 'hidden'}`}>
|
||||||
{showDivs && (
|
{showDivs && (
|
||||||
<div className="history-models">
|
<div className="history-models">
|
||||||
<History selectedIndex={selectedHistoryIndex} setSelectedIndex={setSelectedHistoryIndex}/>
|
<History />
|
||||||
<Models />
|
<Models />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className={`conversation-container ${showDivs ? 'collapsed' : 'expanded'}`} ref={conversationRef}>
|
<div className={`conversation-container ${showDivs ? 'collapsed' : 'expanded'}`} ref={conversationRef}>
|
||||||
{view === 'AI' && <AI selectedIndex={selectedHistoryIndex} />}
|
{view === 'AI' && <AI />}
|
||||||
{view === 'FAQ' && <FAQ />}
|
{view === 'FAQ' && <FAQ />}
|
||||||
{view === 'Documentation' && <Documentation />}
|
{view === 'Documentation' && <Documentation />}
|
||||||
{view === 'Credits' && <Credits />}
|
{view === 'Credits' && <Credits />}
|
||||||
|
|
Loading…
Reference in a new issue