mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-09 12:08:50 +01:00
feat: support user-provided token to bingAI and chatgptBrowser
This commit is contained in:
parent
a953fc9f2b
commit
bbf2f8a6ca
22 changed files with 309 additions and 86 deletions
21
client/src/store/token.js
Normal file
21
client/src/store/token.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { atom, useRecoilState } from 'recoil';
|
||||
|
||||
const tokenRefreshHints = atom({
|
||||
key: 'tokenRefreshHints',
|
||||
default: 1
|
||||
});
|
||||
|
||||
const useToken = endpoint => {
|
||||
const [hints, setHints] = useRecoilState(tokenRefreshHints);
|
||||
const getToken = () => localStorage.getItem(`${endpoint}_token`);
|
||||
const saveToken = value => {
|
||||
localStorage.setItem(`${endpoint}_token`, value);
|
||||
setHints(prev => prev + 1);
|
||||
};
|
||||
|
||||
return { token: getToken(), getToken, saveToken };
|
||||
};
|
||||
|
||||
export default {
|
||||
useToken
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue