mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-21 19:00:13 +01:00
refactor: basic message and send message. as well as model
THIS IS NOT FINISHED. DONT USE THIS
This commit is contained in:
parent
de8f519742
commit
c7c30d8bb5
24 changed files with 1057 additions and 1035 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
import { createBrowserRouter, RouterProvider, Navigate } from 'react-router-dom';
|
||||
import Root from './routes/Root';
|
||||
// import Chat from './routes/Chat';
|
||||
import Chat from './routes/Chat';
|
||||
import store from './store';
|
||||
import userAuth from './utils/userAuth';
|
||||
import { useRecoilState, useSetRecoilState } from 'recoil';
|
||||
|
|
@ -24,7 +24,7 @@ const router = createBrowserRouter([
|
|||
},
|
||||
{
|
||||
path: 'chat/:conversationId',
|
||||
element: null //<Chat />
|
||||
element: <Chat />
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -33,14 +33,45 @@ const router = createBrowserRouter([
|
|||
const App = () => {
|
||||
const [user, setUser] = useRecoilState(store.user);
|
||||
const setIsSearchEnabled = useSetRecoilState(store.isSearchEnabled);
|
||||
const setModelsFilter = useSetRecoilState(store.modelsFilter);
|
||||
|
||||
useEffect(() => {
|
||||
axios.get('/api/search/enable').then(res => {
|
||||
setIsSearchEnabled(res.data);
|
||||
});
|
||||
// fetch if seatch enabled
|
||||
axios
|
||||
.get('/api/search/enable', {
|
||||
timeout: 1000,
|
||||
withCredentials: true
|
||||
})
|
||||
.then(res => {
|
||||
setIsSearchEnabled(res.data);
|
||||
});
|
||||
|
||||
// fetch user
|
||||
userAuth()
|
||||
.then(user => setUser(user))
|
||||
.catch(err => console.log(err));
|
||||
|
||||
// fetch models
|
||||
axios
|
||||
.get('/api/models', {
|
||||
timeout: 1000,
|
||||
withCredentials: true
|
||||
})
|
||||
.then(({ data }) => {
|
||||
const filter = {
|
||||
chatgpt: data?.hasOpenAI,
|
||||
chatgptCustom: data?.hasOpenAI,
|
||||
bingai: data?.hasBing,
|
||||
sydney: data?.hasBing,
|
||||
chatgptBrowser: data?.hasChatGpt
|
||||
};
|
||||
setModelsFilter(filter);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
console.log('Not login!');
|
||||
window.location.href = '/auth/login';
|
||||
});
|
||||
}, []);
|
||||
|
||||
if (user)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue