2023-03-31 00:20:45 +08:00
|
|
|
import { atom, selector } from 'recoil';
|
|
|
|
|
|
2023-04-01 14:33:07 +08:00
|
|
|
const endpointsConfig = atom({
|
|
|
|
|
key: 'endpointsConfig',
|
2023-03-31 00:20:45 +08:00
|
|
|
default: {
|
2023-04-01 14:33:07 +08:00
|
|
|
azureOpenAI: null,
|
|
|
|
|
openAI: null,
|
|
|
|
|
bingAI: null,
|
2023-05-13 16:29:06 -04:00
|
|
|
chatGPTBrowser: null,
|
2023-05-18 11:09:31 -07:00
|
|
|
google: null
|
2023-04-01 14:33:07 +08:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const endpointsFilter = selector({
|
|
|
|
|
key: 'endpointsFilter',
|
|
|
|
|
get: ({ get }) => {
|
|
|
|
|
const config = get(endpointsConfig) || {};
|
|
|
|
|
|
|
|
|
|
let filter = {};
|
|
|
|
|
for (const key of Object.keys(config)) filter[key] = !!config[key];
|
|
|
|
|
return filter;
|
2023-03-31 00:20:45 +08:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const availableEndpoints = selector({
|
|
|
|
|
key: 'availableEndpoints',
|
|
|
|
|
get: ({ get }) => {
|
2023-05-13 16:29:06 -04:00
|
|
|
const endpoints = ['azureOpenAI', 'openAI', 'chatGPTBrowser', 'bingAI', 'google'];
|
2023-03-31 00:20:45 +08:00
|
|
|
const f = get(endpointsFilter);
|
|
|
|
|
return endpoints.filter(endpoint => f[endpoint]);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// const modelAvailable
|
|
|
|
|
|
|
|
|
|
export default {
|
2023-04-01 14:33:07 +08:00
|
|
|
endpointsConfig,
|
2023-03-31 00:20:45 +08:00
|
|
|
endpointsFilter,
|
|
|
|
|
availableEndpoints
|
|
|
|
|
};
|