main #3

Merged
YasinOnm08 merged 8 commits from React-Group/interstellar_ai:main into main 2024-09-18 16:30:44 +02:00
5 changed files with 76 additions and 11 deletions

View file

@ -26,39 +26,44 @@ const handleCopyClick = () => {
// Handle copy action
};
const InputBackend:React.FC = () => {
const InputBackend: React.FC = () => {
async function prompt_mistral(model: string, prompt: string, system: string) {
const apiKey = "m3kZRjN8DRSIo88r8Iti9hmKGWIklrLY";
const client = new Mistral({ apiKey: apiKey });
var chatResponse = await client.chat.complete({
model: model,
messages: [{ role: 'user', content: prompt }, { role: 'system', content: system, }],
});
if (chatResponse && chatResponse.choices && chatResponse.choices.length > 0) {
if (chatResponse.choices[0].message.content) {
addMessage('AI: ' + chatResponse.choices[0].message.content);
console.error('Error: Brain Not Found');
console.log(messages)
}
} else {
console.error('Error: Unexpected API response:', chatResponse);
}
}
const handleSendClick = (message: string) => {
var system = "You are a helpful assistant. The following is the chat history."
for (let index = 0; index < messages.length; index++) {
system += messages[index] + " ";
};
addMessage('User: ' + message);
prompt_mistral("mistral-large-latest", message, "You are a helpful assistant.")
prompt_mistral("mistral-large-latest", message, system)
};
const [messages, setMessages] = useState([
'User: Hello!',
'AI: Hi there!',
'User: How are you?',
'AI: Im good, thank you!'
]);
const addMessage = (message: string) => {
setMessages((prevMessages) => [...prevMessages, message]);
};
@ -69,12 +74,12 @@ const InputBackend:React.FC = () => {
onResendClick={handleResendClick}
onEditClick={handleEditClick}
onCopyClick={handleCopyClick}
/>
/>
<InputFrontend
message=""
onSendClick={handleSendClick}
onMicClick={handleMicClick}
/>
/>
</div>
);
};

View file

@ -10,6 +10,7 @@ header {
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
z-index: 1000;
font-family: var(--font-family);
height: 5vh;
}
header li {

View file

@ -5,8 +5,9 @@
overflow: hidden;
background-color: var(--history-background-color);
padding: 1em;
border-radius: 2em;
margin: 1em;
margin-right: 0;
border-radius: 2em;
}
.history {

View file

@ -11,3 +11,4 @@
@import './input.css';
@import './faq.css';
@import './scrollbar.css';
@import './responsive.css';

57
app/styles/responsive.css Normal file
View file

@ -0,0 +1,57 @@
/* responsive.css */
/* Responsive behavior - applies only on smaller screens */
@media (max-width: 1200px) {
/* Left panel as an overlay */
.left-panel {
margin: 0 auto;
min-width: 100vw;
max-width: 100vw;
padding: 1em;
}
.left-panel.hidden {
width: 0;
/* Set width to 0 when hidden */
visibility: hidden;
/* Fully hide the panel */
margin: 0;
padding: 0;
overflow: hidden;
}
header {
height: 125px;
}
header li {
flex-direction: column;
display: block;
padding: 2px;
}
body {
margin-top: 100px;
}
.conversation-container.expanded {
width: 0;
/* Set width to 0 when hidden */
visibility: hidden;
/* Fully hide the panel */
margin: 0;
padding: 0;
overflow: hidden;
}
.conversation-container.collapsed {
margin: 0 auto;
min-width: 100vw;
max-width: 100vw;
padding: 1em;
margin-left: 0;
}
}