mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 09:20:15 +01:00
persist models in localStorage, minor changes
This commit is contained in:
parent
e2a3ecbf88
commit
1a6cddb8bb
6 changed files with 27 additions and 14 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Messages from './components/main/Messages';
|
import Messages from './components/Main/Messages';
|
||||||
import Landing from './components/main/Landing';
|
import Landing from './components/Main/Landing';
|
||||||
import TextChat from './components/main/TextChat';
|
import TextChat from './components/Main/TextChat';
|
||||||
import Nav from './components/Nav';
|
import Nav from './components/Nav';
|
||||||
import MobileNav from './components/Nav/MobileNav';
|
import MobileNav from './components/Nav/MobileNav';
|
||||||
import useDocumentTitle from '~/hooks/useDocumentTitle';
|
import useDocumentTitle from '~/hooks/useDocumentTitle';
|
||||||
|
|
|
||||||
|
|
@ -42,19 +42,19 @@ export default function Landing({ title }) {
|
||||||
onClick={clickHandler}
|
onClick={clickHandler}
|
||||||
className="w-full rounded-md bg-gray-50 p-3 hover:bg-gray-200 dark:bg-white/5 dark:hover:bg-gray-900"
|
className="w-full rounded-md bg-gray-50 p-3 hover:bg-gray-200 dark:bg-white/5 dark:hover:bg-gray-900"
|
||||||
>
|
>
|
||||||
"Explain quantum computing in simple terms" →
|
"Explain quantum computing in simple terms" →
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={clickHandler}
|
onClick={clickHandler}
|
||||||
className="w-full rounded-md bg-gray-50 p-3 hover:bg-gray-200 dark:bg-white/5 dark:hover:bg-gray-900"
|
className="w-full rounded-md bg-gray-50 p-3 hover:bg-gray-200 dark:bg-white/5 dark:hover:bg-gray-900"
|
||||||
>
|
>
|
||||||
"Got any creative ideas for a 10 year old's birthday?" →
|
"Got any creative ideas for a 10 year old's birthday?" →
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={clickHandler}
|
onClick={clickHandler}
|
||||||
className="w-full rounded-md bg-gray-50 p-3 hover:bg-gray-200 dark:bg-white/5 dark:hover:bg-gray-900"
|
className="w-full rounded-md bg-gray-50 p-3 hover:bg-gray-200 dark:bg-white/5 dark:hover:bg-gray-900"
|
||||||
>
|
>
|
||||||
"How do I make an HTTP request in Javascript?" →
|
"How do I make an HTTP request in Javascript?" →
|
||||||
</button>
|
</button>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { useSelector, useDispatch } from 'react-redux';
|
import { useSelector, useDispatch } from 'react-redux';
|
||||||
import { setModel } from '~/store/submitSlice';
|
import { setModel } from '~/store/submitSlice';
|
||||||
import GPTIcon from '../svg/GPTIcon';
|
import GPTIcon from '../svg/GPTIcon';
|
||||||
|
|
@ -22,6 +22,18 @@ export default function ModelMenu() {
|
||||||
dispatch(setModel(value));
|
dispatch(setModel(value));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const lastSelectedModel = JSON.parse(localStorage.getItem('model'));
|
||||||
|
if (lastSelectedModel) {
|
||||||
|
dispatch(setModel(lastSelectedModel));
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
localStorage.setItem('model', JSON.stringify(model));
|
||||||
|
}, [model]);
|
||||||
|
|
||||||
const defaultColorProps = [
|
const defaultColorProps = [
|
||||||
'text-gray-500',
|
'text-gray-500',
|
||||||
'hover:bg-gray-100',
|
'hover:bg-gray-100',
|
||||||
|
|
|
||||||
|
|
@ -112,14 +112,14 @@ export default function TextChat({ messages }) {
|
||||||
|
|
||||||
const handleKeyUp = (e) => {
|
const handleKeyUp = (e) => {
|
||||||
if (e.key === 'Enter' && e.shiftKey) {
|
if (e.key === 'Enter' && e.shiftKey) {
|
||||||
console.log('Enter + Shift');
|
return console.log('Enter + Shift');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSubmitting) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.key === 'Enter' && !e.shiftKey) {
|
if (e.key === 'Enter' && !e.shiftKey) {
|
||||||
if (isSubmitting) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
submitMessage();
|
submitMessage();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -160,7 +160,7 @@ export default function TextChat({ messages }) {
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
onChange={changeHandler}
|
onChange={changeHandler}
|
||||||
placeholder=""
|
placeholder=""
|
||||||
className="m-0 h-auto max-h-52 resize-none overflow-auto border-0 bg-transparent p-0 pl-9 pr-7 leading-6 focus:outline-none focus:ring-0 focus-visible:ring-0 dark:bg-transparent md:pl-8"
|
className="m-0 h-auto max-h-52 resize-none overflow-auto border-0 bg-transparent p-0 pl-9 pr-9 leading-6 focus:outline-none focus:ring-0 focus-visible:ring-0 dark:bg-transparent md:pl-8"
|
||||||
/>
|
/>
|
||||||
<SubmitButton submitMessage={submitMessage} />
|
<SubmitButton submitMessage={submitMessage} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable react-hooks/rules-of-hooks */
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
import useSWRMutation from 'swr/mutation';
|
import useSWRMutation from 'swr/mutation';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { ClassValue, clsx } from 'clsx';
|
import { clsx } from 'clsx';
|
||||||
import { twMerge } from 'tailwind-merge';
|
import { twMerge } from 'tailwind-merge';
|
||||||
|
|
||||||
export function cn(...inputs) {
|
export function cn(...inputs) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue