Merge branch 'main' into respect-provider-choice

This commit is contained in:
Cole Medin
2024-11-09 07:44:40 -06:00
committed by GitHub
11 changed files with 196 additions and 27 deletions

View File

@@ -15,6 +15,7 @@ import { DEFAULT_MODEL, DEFAULT_PROVIDER } from '~/utils/constants';
import { cubicEasingFn } from '~/utils/easings';
import { createScopedLogger, renderLogger } from '~/utils/logger';
import { BaseChat } from './BaseChat';
import Cookies from 'js-cookie';
const toastAnimation = cssTransition({
enter: 'animated fadeInRight',
@@ -80,8 +81,13 @@ export const ChatImpl = memo(({ initialMessages, storeMessageHistory }: ChatProp
const [animationScope, animate] = useAnimate();
const [apiKeys, setApiKeys] = useState<Record<string, string>>({});
const { messages, isLoading, input, handleInputChange, setInput, stop, append } = useChat({
api: '/api/chat',
body: {
apiKeys
},
onError: (error) => {
logger.error('Request failed\n\n', error);
toast.error('There was an error processing your request');
@@ -203,6 +209,13 @@ export const ChatImpl = memo(({ initialMessages, storeMessageHistory }: ChatProp
const [messageRef, scrollRef] = useSnapScroll();
useEffect(() => {
const storedApiKeys = Cookies.get('apiKeys');
if (storedApiKeys) {
setApiKeys(JSON.parse(storedApiKeys));
}
}, []);
return (
<BaseChat
ref={animationScope}