mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 18:30:15 +01:00
refactor(client): Refactors recent typescript changes for best practices (#763)
* create common types in client * remove unnecessary rules from eslint config * cleanup types * put back eslintrc rules
This commit is contained in:
parent
5828200197
commit
96d29f7390
32 changed files with 233 additions and 245 deletions
|
|
@ -1,16 +1,12 @@
|
|||
import {
|
||||
UseSetOptions,
|
||||
TConversation,
|
||||
SetOption,
|
||||
SetExample,
|
||||
TPlugin,
|
||||
tConversationSchema,
|
||||
} from 'librechat-data-provider';
|
||||
import { TConversation, TPreset, TPlugin, tConversationSchema } from 'librechat-data-provider';
|
||||
import type { TSetExample, TSetOption, TSetOptionsPayload } from '~/common';
|
||||
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
|
||||
import usePresetOptions from './usePresetOptions';
|
||||
import store from '~/store';
|
||||
|
||||
const useSetOptions: UseSetOptions = (preset = false) => {
|
||||
type TUseSetOptions = (preset?: TPreset | boolean | null) => TSetOptionsPayload;
|
||||
|
||||
const useSetOptions: TUseSetOptions = (preset = false) => {
|
||||
const setShowPluginStoreDialog = useSetRecoilState(store.showPluginStoreDialog);
|
||||
const [conversation, setConversation] = useRecoilState(store.conversation);
|
||||
const availableTools = useRecoilValue(store.availableTools);
|
||||
|
|
@ -21,7 +17,7 @@ const useSetOptions: UseSetOptions = (preset = false) => {
|
|||
return result;
|
||||
}
|
||||
|
||||
const setOption: SetOption = (param) => (newValue) => {
|
||||
const setOption: TSetOption = (param) => (newValue) => {
|
||||
const update = {};
|
||||
update[param] = newValue;
|
||||
setConversation((prevState) =>
|
||||
|
|
@ -32,7 +28,7 @@ const useSetOptions: UseSetOptions = (preset = false) => {
|
|||
);
|
||||
};
|
||||
|
||||
const setExample: SetExample = (i, type, newValue = null) => {
|
||||
const setExample: TSetExample = (i, type, newValue = null) => {
|
||||
const update = {};
|
||||
const current = conversation?.examples?.slice() || [];
|
||||
const currentExample = { ...current[i] } || {};
|
||||
|
|
@ -92,7 +88,7 @@ const useSetOptions: UseSetOptions = (preset = false) => {
|
|||
return conversation.tools.find((el) => el.pluginKey === value) ? true : false;
|
||||
}
|
||||
|
||||
const setAgentOption: SetOption = (param) => (newValue) => {
|
||||
const setAgentOption: TSetOption = (param) => (newValue) => {
|
||||
const editableConvo = JSON.stringify(conversation);
|
||||
const convo = JSON.parse(editableConvo);
|
||||
const { agentOptions } = convo;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue