2023-07-30 10:37:25 -04:00
|
|
|
import {
|
|
|
|
UseQueryOptions,
|
|
|
|
useQuery,
|
|
|
|
useMutation,
|
|
|
|
useQueryClient,
|
|
|
|
UseMutationResult,
|
|
|
|
QueryObserverResult,
|
|
|
|
} from '@tanstack/react-query';
|
|
|
|
import * as t from './types';
|
2023-08-05 12:10:36 -04:00
|
|
|
import * as s from './schemas';
|
2023-07-30 10:37:25 -04:00
|
|
|
import * as dataService from './data-service';
|
|
|
|
|
|
|
|
export enum QueryKeys {
|
|
|
|
messages = 'messsages',
|
|
|
|
allConversations = 'allConversations',
|
|
|
|
conversation = 'conversation',
|
|
|
|
searchEnabled = 'searchEnabled',
|
|
|
|
user = 'user',
|
refactor: Encrypt & Expire User Provided Keys, feat: Rate Limiting (#874)
* docs: make_your_own.md formatting fix for mkdocs
* feat: add express-mongo-sanitize
feat: add login/registration rate limiting
* chore: remove unnecessary console log
* wip: remove token handling from localStorage to encrypted DB solution
* refactor: minor change to UserService
* fix mongo query and add keys route to server
* fix backend controllers and simplify schema/crud
* refactor: rename token to key to separate from access/refresh tokens, setTokenDialog -> setKeyDialog
* refactor(schemas): TEndpointOption token -> key
* refactor(api): use new encrypted key retrieval system
* fix(SetKeyDialog): fix key prop error
* fix(abortMiddleware): pass random UUID if messageId is not generated yet for proper error display on frontend
* fix(getUserKey): wrong prop passed in arg, adds error handling
* fix: prevent message without conversationId from saving to DB, prevents branching on the frontend to a new top-level branch
* refactor: change wording of multiple display messages
* refactor(checkExpiry -> checkUserKeyExpiry): move to UserService file
* fix: type imports from common
* refactor(SubmitButton): convert to TS
* refactor(key.ts): change localStorage map key name
* refactor: add new custom tailwind classes to better match openAI colors
* chore: remove unnecessary warning and catch ScreenShot error
* refactor: move userKey frontend logic to hooks and remove use of localStorage and instead query the DB
* refactor: invalidate correct query key, memoize userKey hook, conditionally render SetKeyDialog to avoid unnecessary calls, refactor SubmitButton props and useEffect for showing 'provide key first'
* fix(SetKeyDialog): use enum-like object for expiry values
feat(Dropdown): add optionsClassName to dynamically change dropdown options container classes
* fix: handle edge case where user had provided a key but the server changes to env variable for keys
* refactor(OpenAI/titleConvo): move titling to client to retain authorized credentials in message lifecycle for titling
* fix(azure): handle user_provided keys correctly for azure
* feat: send user Id to OpenAI to differentiate users in completion requests
* refactor(OpenAI/titleConvo): adding tokens helps minimize LLM from using the language in title response
* feat: add delete endpoint for keys
* chore: remove throttling of title
* feat: add 'Data controls' to Settings, add 'Revoke' keys feature in Key Dialog and Data controls
* refactor: reorganize PluginsClient files in langchain format
* feat: use langchain for titling convos
* chore: cleanup titling convo, with fallback to original method, escape braces, use only snippet for language detection
* refactor: move helper functions to appropriate langchain folders for reusability
* fix: userProvidesKey handling for gptPlugins
* fix: frontend handling of plugins key
* chore: cleanup logging and ts-ignore SSE
* fix: forwardRef misuse in DangerButton
* fix(GoogleConfig/FileUpload): localize errors and simplify validation with zod
* fix: cleanup google logging and fix user provided key handling
* chore: remove titling from google
* chore: removing logging from browser endpoint
* wip: fix menu flicker
* feat: useLocalStorage hook
* feat: add Tooltip for UI
* refactor(EndpointMenu): utilize Tooltip and useLocalStorage, remove old 'New Chat' slide-over
* fix(e2e): use testId for endpoint menu trigger
* chore: final touches to EndpointMenu before future refactor to declutter component
* refactor(localization): change select endpoint to open menu and add translations
* chore: add final prop to error message response
* ci: minor edits to facilitate testing
* ci: new e2e test which tests for new key setting/revoking features
2023-09-06 10:46:27 -04:00
|
|
|
name = 'name', // user key name
|
2023-07-30 10:37:25 -04:00
|
|
|
endpoints = 'endpoints',
|
|
|
|
presets = 'presets',
|
|
|
|
searchResults = 'searchResults',
|
|
|
|
tokenCount = 'tokenCount',
|
|
|
|
availablePlugins = 'availablePlugins',
|
|
|
|
startupConfig = 'startupConfig',
|
|
|
|
}
|
|
|
|
|
|
|
|
export const useAbortRequestWithMessage = (): UseMutationResult<
|
|
|
|
void,
|
|
|
|
Error,
|
|
|
|
{ endpoint: string; abortKey: string; message: string }
|
|
|
|
> => {
|
|
|
|
return useMutation(({ endpoint, abortKey, message }) =>
|
|
|
|
dataService.abortRequestWithMessage(endpoint, abortKey, message),
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useGetUserQuery = (
|
|
|
|
config?: UseQueryOptions<t.TUser>,
|
|
|
|
): QueryObserverResult<t.TUser> => {
|
|
|
|
return useQuery<t.TUser>([QueryKeys.user], () => dataService.getUser(), {
|
|
|
|
refetchOnWindowFocus: false,
|
|
|
|
refetchOnReconnect: false,
|
|
|
|
refetchOnMount: false,
|
|
|
|
retry: false,
|
|
|
|
...config,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useGetMessagesByConvoId = (
|
|
|
|
id: string,
|
2023-08-05 12:10:36 -04:00
|
|
|
config?: UseQueryOptions<s.TMessage[]>,
|
|
|
|
): QueryObserverResult<s.TMessage[]> => {
|
|
|
|
return useQuery<s.TMessage[]>(
|
2023-07-30 10:37:25 -04:00
|
|
|
[QueryKeys.messages, id],
|
|
|
|
() => dataService.getMessagesByConvoId(id),
|
|
|
|
{
|
|
|
|
refetchOnWindowFocus: false,
|
|
|
|
refetchOnReconnect: false,
|
|
|
|
refetchOnMount: false,
|
|
|
|
...config,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useGetConversationByIdQuery = (
|
|
|
|
id: string,
|
2023-08-05 12:10:36 -04:00
|
|
|
config?: UseQueryOptions<s.TConversation>,
|
|
|
|
): QueryObserverResult<s.TConversation> => {
|
|
|
|
return useQuery<s.TConversation>(
|
2023-07-30 10:37:25 -04:00
|
|
|
[QueryKeys.conversation, id],
|
|
|
|
() => dataService.getConversationById(id),
|
|
|
|
{
|
|
|
|
refetchOnWindowFocus: false,
|
|
|
|
refetchOnReconnect: false,
|
|
|
|
refetchOnMount: false,
|
|
|
|
...config,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
//This isn't ideal because its just a query and we're using mutation, but it was the only way
|
|
|
|
//to make it work with how the Chat component is structured
|
2023-08-05 12:10:36 -04:00
|
|
|
export const useGetConversationByIdMutation = (id: string): UseMutationResult<s.TConversation> => {
|
2023-07-30 10:37:25 -04:00
|
|
|
const queryClient = useQueryClient();
|
|
|
|
return useMutation(() => dataService.getConversationById(id), {
|
2023-08-05 12:10:36 -04:00
|
|
|
// onSuccess: (res: s.TConversation) => {
|
2023-07-30 10:37:25 -04:00
|
|
|
onSuccess: () => {
|
|
|
|
queryClient.invalidateQueries([QueryKeys.conversation, id]);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useUpdateConversationMutation = (
|
|
|
|
id: string,
|
|
|
|
): UseMutationResult<
|
|
|
|
t.TUpdateConversationResponse,
|
|
|
|
unknown,
|
|
|
|
t.TUpdateConversationRequest,
|
|
|
|
unknown
|
|
|
|
> => {
|
|
|
|
const queryClient = useQueryClient();
|
|
|
|
return useMutation(
|
|
|
|
(payload: t.TUpdateConversationRequest) => dataService.updateConversation(payload),
|
|
|
|
{
|
|
|
|
onSuccess: () => {
|
|
|
|
queryClient.invalidateQueries([QueryKeys.conversation, id]);
|
|
|
|
queryClient.invalidateQueries([QueryKeys.allConversations]);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
feat: Edit AI Messages, Edit Messages in Place (#825)
* refactor: replace lodash import with specific function import
fix(api): esm imports to cjs
* refactor(Messages.tsx): convert to TS, out-source scrollToDiv logic to a custom hook
fix(ScreenshotContext.tsx): change Ref to RefObject in ScreenshotContextType
feat(useScrollToRef.ts): add useScrollToRef hook for scrolling to a ref with throttle
fix(Chat.tsx): update import path for Messages component
fix(Search.tsx): update import path for Messages component
* chore(types.ts): add TAskProps and TOptions types
refactor(useMessageHandler.ts): use TAskFunction type for ask function signature
* refactor(Message/Content): convert to TS, move Plugin component to Content dir
* feat(MessageContent.tsx): add MessageContent component for displaying and editing message content
feat(index.ts): export MessageContent component from Messages/Content directory
* wip(Message.jsx): conversion and use of new component in progress
* refactor: convert Message.jsx to TS and fix typing/imports based on changes
* refactor: add typed props and refactor MultiMessage to TS, fix typing issues resulting from the conversion
* edit message in progress
* feat: complete edit AI message logic, refactor continue logic
* feat(middleware): add validateMessageReq middleware
feat(routes): add validation for message requests using validateMessageReq middleware
feat(routes): add create, read, update, and delete routes for messages
* feat: complete frontend logic for editing messages in place
feat(messages.js): update route for updating a specific message
- Change the route for updating a message to include the messageId in the URL
- Update the request handler to use the messageId from the request parameters and the text from the request body
- Call the updateMessage function with the updated parameters
feat(MessageContent.tsx): add functionality to update a message
- Import the useUpdateMessageMutation hook from the data provider
- Destructure the conversationId, parentMessageId, and messageId from the message object
- Create a mutation function using the useUpdateMessageMutation hook
- Implement the updateMessage function to call the mutation function with the updated message parameters
- Update the messages state to reflect the updated message text
feat(api-endpoints.ts): update messages endpoint to include messageId
- Update the messages endpoint to include the messageId as an optional parameter
feat(data-service.ts): add updateMessage function
- Implement the updateMessage function to make a PUT request to
* fix(messages.js): make updateMessage function asynchronous and await its execution
* style(EditIcon): make icon active for AI message
* feat(gptPlugins/anthropic): add edit support
* fix(validateMessageReq.js): handle case when conversationId is 'new' and return empty array
feat(Message.tsx): pass message prop to SiblingSwitch component
refactor(SiblingSwitch.tsx): convert to TS
* fix(useMessageHandler.ts): remove message from currentMessages if isContinued is true
feat(useMessageHandler.ts): add support for submission messages in setMessages
fix(useServerStream.ts): remove unnecessary conditional in setMessages
fix(useServerStream.ts): remove isContinued variable from submission
* fix(continue): switch to continued message generation when continuing an earlier branch in conversation
* fix(abortMiddleware.js): fix condition to check partialText length
chore(abortMiddleware.js): add error logging when abortMessage fails
* refactor(MessageHeader.tsx): convert to TS
fix(Plugin.tsx): add default value for className prop in Plugin component
* refactor(MultiMessage.tsx): remove commented out code
docs(MultiMessage.tsx): update comment to clarify when siblingIdx is reset
* fix(GenerationButtons): optimistic state for continue button
* fix(MessageContent.tsx): add data-testid attribute to message text editor
fix(messages.spec.ts): update waitForServerStream function to include edit endpoint check
feat(messages.spec.ts): add test case for editing messages
* fix(HoverButtons & Message & useGenerations): Refactor edit functionality and related conditions
- Update enterEdit function signature and prop
- Create and utilize hideEditButton variable
- Enhance conditions for edit button visibility and active state
- Update button event handlers
- Introduce isEditableEndpoint in useGenerations and refine continueSupported condition.
* fix(useGenerations.ts): fix condition for hideEditButton to include error and searchResult
chore(data-provider): bump version to 0.1.6
fix(types.ts): add status property to TError type
* chore: bump @dqbd/tiktoken to 1.0.7
* fix(abortMiddleware.js): add required isCreatedByUser property to the error response object
* refactor(Message.tsx): remove unnecessary props from SiblingSwitch component, as setLatestMessage is firing on every switch already
refactor(SiblingSwitch.tsx): remove unused imports and code
* chore(BaseClient.js): move console.debug statements back inside if block
2023-08-22 18:44:59 -04:00
|
|
|
export const useUpdateMessageMutation = (
|
|
|
|
id: string,
|
|
|
|
): UseMutationResult<unknown, unknown, t.TUpdateMessageRequest, unknown> => {
|
|
|
|
const queryClient = useQueryClient();
|
|
|
|
return useMutation((payload: t.TUpdateMessageRequest) => dataService.updateMessage(payload), {
|
|
|
|
onSuccess: () => {
|
|
|
|
queryClient.invalidateQueries([QueryKeys.messages, id]);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
refactor: Encrypt & Expire User Provided Keys, feat: Rate Limiting (#874)
* docs: make_your_own.md formatting fix for mkdocs
* feat: add express-mongo-sanitize
feat: add login/registration rate limiting
* chore: remove unnecessary console log
* wip: remove token handling from localStorage to encrypted DB solution
* refactor: minor change to UserService
* fix mongo query and add keys route to server
* fix backend controllers and simplify schema/crud
* refactor: rename token to key to separate from access/refresh tokens, setTokenDialog -> setKeyDialog
* refactor(schemas): TEndpointOption token -> key
* refactor(api): use new encrypted key retrieval system
* fix(SetKeyDialog): fix key prop error
* fix(abortMiddleware): pass random UUID if messageId is not generated yet for proper error display on frontend
* fix(getUserKey): wrong prop passed in arg, adds error handling
* fix: prevent message without conversationId from saving to DB, prevents branching on the frontend to a new top-level branch
* refactor: change wording of multiple display messages
* refactor(checkExpiry -> checkUserKeyExpiry): move to UserService file
* fix: type imports from common
* refactor(SubmitButton): convert to TS
* refactor(key.ts): change localStorage map key name
* refactor: add new custom tailwind classes to better match openAI colors
* chore: remove unnecessary warning and catch ScreenShot error
* refactor: move userKey frontend logic to hooks and remove use of localStorage and instead query the DB
* refactor: invalidate correct query key, memoize userKey hook, conditionally render SetKeyDialog to avoid unnecessary calls, refactor SubmitButton props and useEffect for showing 'provide key first'
* fix(SetKeyDialog): use enum-like object for expiry values
feat(Dropdown): add optionsClassName to dynamically change dropdown options container classes
* fix: handle edge case where user had provided a key but the server changes to env variable for keys
* refactor(OpenAI/titleConvo): move titling to client to retain authorized credentials in message lifecycle for titling
* fix(azure): handle user_provided keys correctly for azure
* feat: send user Id to OpenAI to differentiate users in completion requests
* refactor(OpenAI/titleConvo): adding tokens helps minimize LLM from using the language in title response
* feat: add delete endpoint for keys
* chore: remove throttling of title
* feat: add 'Data controls' to Settings, add 'Revoke' keys feature in Key Dialog and Data controls
* refactor: reorganize PluginsClient files in langchain format
* feat: use langchain for titling convos
* chore: cleanup titling convo, with fallback to original method, escape braces, use only snippet for language detection
* refactor: move helper functions to appropriate langchain folders for reusability
* fix: userProvidesKey handling for gptPlugins
* fix: frontend handling of plugins key
* chore: cleanup logging and ts-ignore SSE
* fix: forwardRef misuse in DangerButton
* fix(GoogleConfig/FileUpload): localize errors and simplify validation with zod
* fix: cleanup google logging and fix user provided key handling
* chore: remove titling from google
* chore: removing logging from browser endpoint
* wip: fix menu flicker
* feat: useLocalStorage hook
* feat: add Tooltip for UI
* refactor(EndpointMenu): utilize Tooltip and useLocalStorage, remove old 'New Chat' slide-over
* fix(e2e): use testId for endpoint menu trigger
* chore: final touches to EndpointMenu before future refactor to declutter component
* refactor(localization): change select endpoint to open menu and add translations
* chore: add final prop to error message response
* ci: minor edits to facilitate testing
* ci: new e2e test which tests for new key setting/revoking features
2023-09-06 10:46:27 -04:00
|
|
|
export const useUpdateUserKeysMutation = (): UseMutationResult<
|
|
|
|
t.TUser,
|
|
|
|
unknown,
|
|
|
|
t.TUpdateUserKeyRequest,
|
|
|
|
unknown
|
|
|
|
> => {
|
|
|
|
const queryClient = useQueryClient();
|
|
|
|
return useMutation((payload: t.TUpdateUserKeyRequest) => dataService.updateUserKey(payload), {
|
|
|
|
onSuccess: () => {
|
|
|
|
queryClient.invalidateQueries([QueryKeys.name]);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2023-07-30 10:37:25 -04:00
|
|
|
export const useDeleteConversationMutation = (
|
|
|
|
id?: string,
|
|
|
|
): UseMutationResult<
|
|
|
|
t.TDeleteConversationResponse,
|
|
|
|
unknown,
|
|
|
|
t.TDeleteConversationRequest,
|
|
|
|
unknown
|
|
|
|
> => {
|
|
|
|
const queryClient = useQueryClient();
|
|
|
|
return useMutation(
|
|
|
|
(payload: t.TDeleteConversationRequest) => dataService.deleteConversation(payload),
|
|
|
|
{
|
|
|
|
onSuccess: () => {
|
|
|
|
queryClient.invalidateQueries([QueryKeys.conversation, id]);
|
|
|
|
queryClient.invalidateQueries([QueryKeys.allConversations]);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useClearConversationsMutation = (): UseMutationResult<unknown> => {
|
|
|
|
const queryClient = useQueryClient();
|
|
|
|
return useMutation(() => dataService.clearAllConversations(), {
|
|
|
|
onSuccess: () => {
|
|
|
|
queryClient.invalidateQueries([QueryKeys.allConversations]);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
refactor: Encrypt & Expire User Provided Keys, feat: Rate Limiting (#874)
* docs: make_your_own.md formatting fix for mkdocs
* feat: add express-mongo-sanitize
feat: add login/registration rate limiting
* chore: remove unnecessary console log
* wip: remove token handling from localStorage to encrypted DB solution
* refactor: minor change to UserService
* fix mongo query and add keys route to server
* fix backend controllers and simplify schema/crud
* refactor: rename token to key to separate from access/refresh tokens, setTokenDialog -> setKeyDialog
* refactor(schemas): TEndpointOption token -> key
* refactor(api): use new encrypted key retrieval system
* fix(SetKeyDialog): fix key prop error
* fix(abortMiddleware): pass random UUID if messageId is not generated yet for proper error display on frontend
* fix(getUserKey): wrong prop passed in arg, adds error handling
* fix: prevent message without conversationId from saving to DB, prevents branching on the frontend to a new top-level branch
* refactor: change wording of multiple display messages
* refactor(checkExpiry -> checkUserKeyExpiry): move to UserService file
* fix: type imports from common
* refactor(SubmitButton): convert to TS
* refactor(key.ts): change localStorage map key name
* refactor: add new custom tailwind classes to better match openAI colors
* chore: remove unnecessary warning and catch ScreenShot error
* refactor: move userKey frontend logic to hooks and remove use of localStorage and instead query the DB
* refactor: invalidate correct query key, memoize userKey hook, conditionally render SetKeyDialog to avoid unnecessary calls, refactor SubmitButton props and useEffect for showing 'provide key first'
* fix(SetKeyDialog): use enum-like object for expiry values
feat(Dropdown): add optionsClassName to dynamically change dropdown options container classes
* fix: handle edge case where user had provided a key but the server changes to env variable for keys
* refactor(OpenAI/titleConvo): move titling to client to retain authorized credentials in message lifecycle for titling
* fix(azure): handle user_provided keys correctly for azure
* feat: send user Id to OpenAI to differentiate users in completion requests
* refactor(OpenAI/titleConvo): adding tokens helps minimize LLM from using the language in title response
* feat: add delete endpoint for keys
* chore: remove throttling of title
* feat: add 'Data controls' to Settings, add 'Revoke' keys feature in Key Dialog and Data controls
* refactor: reorganize PluginsClient files in langchain format
* feat: use langchain for titling convos
* chore: cleanup titling convo, with fallback to original method, escape braces, use only snippet for language detection
* refactor: move helper functions to appropriate langchain folders for reusability
* fix: userProvidesKey handling for gptPlugins
* fix: frontend handling of plugins key
* chore: cleanup logging and ts-ignore SSE
* fix: forwardRef misuse in DangerButton
* fix(GoogleConfig/FileUpload): localize errors and simplify validation with zod
* fix: cleanup google logging and fix user provided key handling
* chore: remove titling from google
* chore: removing logging from browser endpoint
* wip: fix menu flicker
* feat: useLocalStorage hook
* feat: add Tooltip for UI
* refactor(EndpointMenu): utilize Tooltip and useLocalStorage, remove old 'New Chat' slide-over
* fix(e2e): use testId for endpoint menu trigger
* chore: final touches to EndpointMenu before future refactor to declutter component
* refactor(localization): change select endpoint to open menu and add translations
* chore: add final prop to error message response
* ci: minor edits to facilitate testing
* ci: new e2e test which tests for new key setting/revoking features
2023-09-06 10:46:27 -04:00
|
|
|
export const useRevokeUserKeyMutation = (name: string): UseMutationResult<unknown> => {
|
|
|
|
const queryClient = useQueryClient();
|
|
|
|
return useMutation(() => dataService.revokeUserKey(name), {
|
|
|
|
onSuccess: () => {
|
|
|
|
queryClient.invalidateQueries([QueryKeys.name]);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useRevokeAllUserKeysMutation = (): UseMutationResult<unknown> => {
|
|
|
|
const queryClient = useQueryClient();
|
|
|
|
return useMutation(() => dataService.revokeAllUserKeys(), {
|
|
|
|
onSuccess: () => {
|
|
|
|
queryClient.invalidateQueries([QueryKeys.name]);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2023-07-30 10:37:25 -04:00
|
|
|
export const useGetConversationsQuery = (
|
|
|
|
pageNumber: string,
|
|
|
|
config?: UseQueryOptions<t.TGetConversationsResponse>,
|
|
|
|
): QueryObserverResult<t.TGetConversationsResponse> => {
|
|
|
|
return useQuery<t.TGetConversationsResponse>(
|
|
|
|
[QueryKeys.allConversations, pageNumber],
|
|
|
|
() => dataService.getConversations(pageNumber),
|
|
|
|
{
|
|
|
|
refetchOnReconnect: false,
|
|
|
|
refetchOnMount: false,
|
|
|
|
retry: 1,
|
|
|
|
...config,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useGetSearchEnabledQuery = (
|
|
|
|
config?: UseQueryOptions<boolean>,
|
|
|
|
): QueryObserverResult<boolean> => {
|
|
|
|
return useQuery<boolean>([QueryKeys.searchEnabled], () => dataService.getSearchEnabled(), {
|
|
|
|
refetchOnWindowFocus: false,
|
|
|
|
refetchOnReconnect: false,
|
|
|
|
refetchOnMount: false,
|
|
|
|
...config,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
refactor: Settings/Presets UI Restructure, convert many files to TS (#740)
* progress on settings refactor
* fix(helpers.js): replace fs.rmdirSync with fs.rm to delete node_modules directory recursively
fix(packages.js): delete package-lock.json if it exists before running the script
* feat(CrossIcon.tsx): add CrossIcon component
* wip: refactor Options for modularity into higher order components, OptionsBar > ModelSelect/Settings
* refactor: import more from utils/index, including cardStyle used by model select/settings
* refactor(AnthropicOptions): refactor to new format, OpenAI: reduce format to name of endpoint
* refactor(AnthropicSettings): refactor to new format, match defaults to API docs
* fix: google and anthropic defaults
* refactor(conversation/submission atoms): add typing, remove unused code
* chore(types.ts): add missing type definitions for TMessages, TMessagesAtom, TConversationAtom, and ModelSelectProps
feat(types.ts): make endpoint property nullable in TSubmission, TEndpointOption, TConversation, and TPreset types
* refactor(ChatGPT): refactor to new format, add omit settings logic
* refactor(EndpointSettings/BingAI): new dir structure and format BingAI options/settings to new
* fix: update useUpdateTokenCountMutation to accept an object with a 'text' property instead of a string
* fix(endpoints): ensure expected behaviors for preset dialogs
* chore(index.ts): add defaultTextProps to utils/index.ts for use in settings components
* chore(index.ts): add optionText to utils/index.ts for use in settings components
* wip: refactor google settings
* wip: progress with Google refactor, needs AdditionalButtons handling and global state setters
* refactor(OptionsBar.tsx): The setOption function has been refactored to use the useSetOptions custom hook for setting conversation options.
* chore(Anthropic.tsx, BingAI.tsx, Google.tsx, OpenAI.tsx): adjust height of container div in Settings component; chore(Examples.tsx): adjust height in Examples component
* refactor(Google): complete google refactor
feat(client): add new component PopoverButtons for displaying popover buttons in EndpointPopover
feat(data-provider): add types for PopoverButton and EndpointOptionsPopoverProps
* fix(OptionsBar.tsx): add useEffect hook to handle opacity class based on messagesTree and advancedMode
fix(style.css): rename class from 'openAIOptions-simple-container' to 'options-bar' and update references
* refactor(Plugins/OptionsBar): complete refactor of Plugins Select options, consolidate logic from TextChat to OptionsBar
* fix(Plugins.tsx): filter lastSelectedTools to remove any tools that are not in the current tools list
fix(useSetOptions.ts): remove unnecessary empty line
* feat(useSetOptions.ts): add setAgentOption function to update agentOptions in conversation state
feat(types.ts): add setAgentOption function to UseSetOptions type
* refactor(Settings/Plugins): refactor to new format, refactor(OptionHover): use same component for all endpoints
* refactor(OptionHover.tsx): refactor types object to use nested objects for openAI and gptPlugins
feat(OptionHover.tsx): add openAI object with specific properties for openAI configuration
* refactor(AgentSettings): new format, feat(types.ts): add TAgentOptions type for defining agent options in a conversation
* feat(PopoverButtons.tsx): add support for GPT plugin settings button
feat(Plugins.tsx): create PluginsView component for displaying plugin settings
feat(optionSettings.ts): add showAgentSettings atom for controlling agent settings visibility
* feat(client): add support for PluginsSettings in Input/Settings component
fix(client): change import path for PluginsSettings in Input/Settings component
* refactor(Settings/Plugins): complete refactor, store: refactor to TS, refactor: import defaultTextPropsLabel from utils
* feat(EndpointSettings, AgentSettings, Anthropic, Google, types.ts): Add support for Recoil state management and useRecoilValue hook; Pass models from endpointsConfig to various components; Add TModels type and update ModelSelectProps type.
fix(AgentSettings, Anthropic, Google, GoogleView, Plugins, OpenAI, Settings.tsx): Change import statements for ModelSelectProps from librechat-data-provider; Add models as a parameter to various components; Add models prop to PluginsView, Settings, and other components.
* refactor(EditPresetDialog.jsx): update import statements for Examples and AgentSettings components
feat(Settings/index.ts): add export statements for Examples and AgentSettings components
* chore(package.json): update eslint-plugin-import to version 2.28.0
* fix(eslint): dependency cycle rule is now working
* fix: dependency cycle errors and type errors
* refactor(EditPresetDialog.jsx): update import path for DialogTemplate component
refactor(NewConversationMenu/index.jsx): update import path for DialogTemplate component
refactor(ExportModel.jsx): update import path for DialogTemplate component
* refactor: rename NewConversationMenu to EndpointMenu
* style: mobile and desktop optimizations
* chore: eslint changes
* chore(eslintrc.js): update eslint configuration to use 'prettier' plugin
chore(postcss.config.cjs): update postcss configuration to use single quotes for require statements
fix(helpers.js): fix fs.rmSync function call to delete node_modules directory recursively
feat(update.js): add support for skipping git commands with '-g' flag
* chore(ModelSelect.tsx): add support for azureOpenAI option component
chore(Settings.tsx): add support for azureOpenAI option component
chore(package.json): add rebuild:package-lock and update:branch scripts
* fix(OptionHover.tsx): fix accessing nested properties in types object
feat(OptionHover.tsx): add check for existence of text before rendering HoverCardContent
* chore(style.css): update transition duration for options-bar from 0.3s to 0.25s
* fix(ScrollToBottom.jsx): fix z-index value for scroll button
* style: improve dialogs
* fix(Nav.jsx): adjust width and max-width of nav component
* chore(Nav.jsx): update max-width class for nav component in different screen sizes
chore(Dialog.tsx): update class for DialogFooter component to use flex-row layout
* fix(client): fix node_module resolution with path mapping
* fix(AdjustToneButton.jsx): add z-index to adjust tone button for proper layering
fix(TextChat.jsx): change onClick function to use arrow function to avoid immediate execution
fix(mobile.css): update z-index for nav and nav-mask for proper layering
chore(package.json): rename update:branch script to reinstall for clarity and consistency
* fix(OptionsBar/Settings): add null checks for conversation in BingAI.tsx, ChatGPT.tsx, Plugins.tsx, Settings.tsx
* style(TextChat/OptionsBar): match official site styles, setup regen/continue/stop buttons div
* chore: Import and apply removeFocusOutlines utility across various components, and rename removeButtonOutline to removeFocusOutlines
chore(Settings): Remove unused import and conditionally return null if conversation is falsy
* feat(hooks): add useLocalize hook
The useLocalize hook is added to the hooks/index.ts file. This hook allows for localization of phrases using the localize function from the ~/localization/Translation module. The hook uses the lang value from the store to determine the current language and returns a function that takes a phraseKey and optional values array as arguments and returns the localized phrase.
* refactor(OptionHover.tsx): Update text keys for OptionHover component, use new hook: useLocalize
* refactor(useDocumentTitle.ts): refactor to TS
* fix(typescript): type issues and update typescript linting deps
* refactor: Update ThemeContext and useOnClickOutside to TypeScript
chore(useDidMountEffect.js): Remove useDidMountEffect hook
* feat: GenerationButtons for stop/continue/regen, remove AdjustToneButton in favor of alternate advanced mode/Settings in OptionsBar
* fix(EndpointOptionsPopover.tsx): change switchToSimpleMode function name to closePopover
fix(GenerationButtons.tsx): change advancedMode prop name to showPopover
fix(OptionsBar.tsx): change advancedMode state name to showPopover
feat(OptionsBar.tsx): add logic to show/hide popover based on showPopover state
fix(types.ts): change switchToSimpleMode function name to closePopover
* chore: remove template button
* chore(GenerationButtons.tsx): adjust positioning of the div element
chore(Plugins.tsx): adjust width of the MultiSelectDropDown component
chore(OptionsBar.tsx): adjust padding of the button element
* refactor(EditPresetDialog): use new modular higher order components
* chore(newoptionsbar.html): delete unused file newoptionsbar.html
* refactor(EditPresetDialog): convert to TS
* chore(babel.config.cjs): update babel configuration, linting
* chore(EditPresetDialog.tsx): update className for DialogTemplate to include pb-0
chore(EndpointOptionsDialog.jsx): update className for DialogTemplate to include pb-0
chore(PopoverButtons.tsx): add buttonClass prop to PopoverButtons component
chore(DialogTemplate.tsx): update className for the footer div to include h-auto
chore(Dropdown.jsx): remove id prop from Dropdown component
chore(mobile.css): update transition duration for .nav class from 0.2s to 0.15s
* refactor(EditPresetDialog.tsx): simplify localization usage with hook
* chore(EditPresetDialog.tsx): update containerClassName to include z-index value
* fix(endpoints.ts): change type of endpointsConfig atom to TEndpointsConfig
refactor(cleanupPreset.ts): convert to TS
fix(index.ts): export cleanupPreset utility function
fix(types.ts): add missing properties to TPreset type
* refactor(EndpointOptionsDialog): convert to TS
* fix(EditPresetDialog.tsx):
- import cleanupPreset from index
- add null check before submitting preset
- add null check before exporting preset
refactor(SaveAsPresetDialog.tsx): convert to TS
fix(usePresetOptions.ts): import cleanupPreset from index
fix(types.ts):
- make title prop optional in EditPresetProps
- change preset prop in CleanupPreset to be partial
* chore: reorganize imports in App, EndpointMenu, Messages, and ExportModel components
feat(ScreenshotContext.jsx): add ScreenshotContext to hooks/index
chore(index.ts): export ThemeContext, ScreenshotContext, ApiErrorBoundaryContext hooks, cleanupPreset, and getIcon functions from utils
* wip: add headerClassName for dialog template
* chore(EndpointOptionsDialog.tsx): remove unused headerClassName prop
chore(EndpointOptionsDialog.tsx): adjust height of main container in mobile and desktop view
* fix(react-query-service.ts): change return type of useGetEndpointsQuery to QueryObserverResult<t.TEndpointsConfig>
* refactor: imports from index and refactor to TS
* refactor: refactor all svg components to TS
* refactor: refactor all UI components to TS, remove unused component
* fix(SelectDropDown.tsx): remove file extension from import statement for CheckMark component
* fix: SaveAsPresetDialog typing issue
* fix(OptionsBar): close popover when an endpoint with no settings is selected
* chore(ChatGPT.tsx): update width of model select dropdown to 60px
refactor(types.ts): decouple ModelSelectProps from SettingsProps
* fix(popover Settings): space taken from the options menu for each endpoint
* fix:'Set token first' element alignment, add padding to endpointmenu icon in mobile
* style: match official site header
* refactor(EndpointOptionsDialog): make functionality explicitly saving current convos as presets
* fix(useLocalize.ts): change values parameter from an array to rest parameters
* refactor(EndpointSettings): Utilize useLocalize hook for all endpoint settings
* fix(Popover): correct spacing/center and remove focus outlines for close button
* chore: employ use of cn (clsx) in Popover styles
* chore(EditPresetDialog.tsx): update className to add padding bottom
chore(EndpointOptionsDialog.tsx): update className to add padding bottom
* style(EndpointMenu, TextChat): add better styling at diff. breakpoints
* refactor(EndpointSettings): consolidate container style to higher order component
* refactor(EditPresetDialog.tsx): pass custom style to Settings from here
* style: setting dialogs improved in all views
* style(EndpointMenu): improve UX for mobile
* style(PresetDialog): increase height so scrollbar isn't triggered
* chore(EditPresetDialog.tsx): update className to include xl height for DialogTemplate
chore(InputNumber.tsx): update className to include max height for InputNumber component
* fix: light mode styling
* fix(OptionsBar/ScrollToBottom/Popover): quick fix to rework in future: hide scrollToBottom when Popover is open
* style: remove bg-gradient around textarea in mobile view
* chore(ThemeContext.tsx): refactor ThemeContext to use default context value, also fixes type issue
* chore(EditPresetDialog.tsx): adjust grid layout in EditPresetDialog component
* style(TextChat): make gradient more opaque/smoother
* fix(TextChat.jsx): fix background gradient color based on theme and system preference
* test(layout-test-utils.tsx): add mock implementation for window.matchMedia in test setup
feat(layout-test-utils.tsx): add authConfig prop to AuthContextProvider in renderWithProvidersWrapper function
chore(tsconfig.json): include test directory in tsconfig include section
* chore(jest.config.cjs): update test file paths in jest configuration
chore(Login.spec.tsx): update test file path in import statement
chore(LoginForm.spec.tsx): update test file path in import statement
chore(Registration.spec.tsx): update test file path in import statement
chore(PluginAuthForm.spec.tsx): update test file path in import statement
chore(PluginStoreDialog.spec.tsx): update test file path in import statement
chore(layout-test-utils.tsx): move matchMedia mock to separate file
chore(tsconfig.json): add path mapping for test files in client directory
* test: add import for 'test/matchMedia.mock' in test files
The changes in this commit add an import statement for 'test/matchMedia.mock' in multiple test files. This import is necessary for mocking the behavior of the matchMedia function during testing.
* style(ClearConvosDialog): remove borders from button and modal, uniform button size
* fix(AgentSettings.tsx): overlapping issue
* fix(PresetDialogs): improve spacing of top row and dialog content
* style(Settings): 2nd column will now dynamically adjust better across all screen sizes
* style(ModelSelect): improve styling for mobile/desktop, add hover shadow
feat(ModelSelect/Plugins): hide ModelSelect when screen is small
* refactor(RowButton, buildTree): convert to TS
* style(ModelSelect): add transition effect to shadows on hover
2023-08-04 13:56:44 -04:00
|
|
|
export const useGetEndpointsQuery = (): QueryObserverResult<t.TEndpointsConfig> => {
|
2023-07-30 10:37:25 -04:00
|
|
|
return useQuery([QueryKeys.endpoints], () => dataService.getAIEndpoints(), {
|
|
|
|
refetchOnWindowFocus: false,
|
|
|
|
refetchOnReconnect: false,
|
|
|
|
refetchOnMount: false,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useCreatePresetMutation = (): UseMutationResult<
|
2023-08-05 12:10:36 -04:00
|
|
|
s.TPreset[],
|
2023-07-30 10:37:25 -04:00
|
|
|
unknown,
|
2023-08-05 12:10:36 -04:00
|
|
|
s.TPreset,
|
2023-07-30 10:37:25 -04:00
|
|
|
unknown
|
|
|
|
> => {
|
|
|
|
const queryClient = useQueryClient();
|
2023-08-05 12:10:36 -04:00
|
|
|
return useMutation((payload: s.TPreset) => dataService.createPreset(payload), {
|
2023-07-30 10:37:25 -04:00
|
|
|
onSuccess: () => {
|
|
|
|
queryClient.invalidateQueries([QueryKeys.presets]);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useUpdatePresetMutation = (): UseMutationResult<
|
2023-08-05 12:10:36 -04:00
|
|
|
s.TPreset[],
|
2023-07-30 10:37:25 -04:00
|
|
|
unknown,
|
2023-08-05 12:10:36 -04:00
|
|
|
s.TPreset,
|
2023-07-30 10:37:25 -04:00
|
|
|
unknown
|
|
|
|
> => {
|
|
|
|
const queryClient = useQueryClient();
|
2023-08-05 12:10:36 -04:00
|
|
|
return useMutation((payload: s.TPreset) => dataService.updatePreset(payload), {
|
2023-07-30 10:37:25 -04:00
|
|
|
onSuccess: () => {
|
|
|
|
queryClient.invalidateQueries([QueryKeys.presets]);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useGetPresetsQuery = (
|
2023-08-05 12:10:36 -04:00
|
|
|
config?: UseQueryOptions<s.TPreset[]>,
|
|
|
|
): QueryObserverResult<s.TPreset[], unknown> => {
|
|
|
|
return useQuery<s.TPreset[]>([QueryKeys.presets], () => dataService.getPresets(), {
|
2023-07-30 10:37:25 -04:00
|
|
|
refetchOnWindowFocus: false,
|
|
|
|
refetchOnReconnect: false,
|
|
|
|
refetchOnMount: false,
|
|
|
|
...config,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useDeletePresetMutation = (): UseMutationResult<
|
2023-08-05 12:10:36 -04:00
|
|
|
s.TPreset[],
|
2023-07-30 10:37:25 -04:00
|
|
|
unknown,
|
2023-08-05 12:10:36 -04:00
|
|
|
s.TPreset | object,
|
2023-07-30 10:37:25 -04:00
|
|
|
unknown
|
|
|
|
> => {
|
|
|
|
const queryClient = useQueryClient();
|
2023-08-05 12:10:36 -04:00
|
|
|
return useMutation((payload: s.TPreset | object) => dataService.deletePreset(payload), {
|
2023-07-30 10:37:25 -04:00
|
|
|
onSuccess: () => {
|
|
|
|
queryClient.invalidateQueries([QueryKeys.presets]);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useSearchQuery = (
|
|
|
|
searchQuery: string,
|
|
|
|
pageNumber: string,
|
|
|
|
config?: UseQueryOptions<t.TSearchResults>,
|
|
|
|
): QueryObserverResult<t.TSearchResults> => {
|
|
|
|
return useQuery<t.TSearchResults>(
|
|
|
|
[QueryKeys.searchResults, pageNumber, searchQuery],
|
|
|
|
() => dataService.searchConversations(searchQuery, pageNumber),
|
|
|
|
{
|
|
|
|
refetchOnWindowFocus: false,
|
|
|
|
refetchOnReconnect: false,
|
|
|
|
refetchOnMount: false,
|
|
|
|
...config,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useUpdateTokenCountMutation = (): UseMutationResult<
|
|
|
|
t.TUpdateTokenCountResponse,
|
|
|
|
unknown,
|
refactor: Settings/Presets UI Restructure, convert many files to TS (#740)
* progress on settings refactor
* fix(helpers.js): replace fs.rmdirSync with fs.rm to delete node_modules directory recursively
fix(packages.js): delete package-lock.json if it exists before running the script
* feat(CrossIcon.tsx): add CrossIcon component
* wip: refactor Options for modularity into higher order components, OptionsBar > ModelSelect/Settings
* refactor: import more from utils/index, including cardStyle used by model select/settings
* refactor(AnthropicOptions): refactor to new format, OpenAI: reduce format to name of endpoint
* refactor(AnthropicSettings): refactor to new format, match defaults to API docs
* fix: google and anthropic defaults
* refactor(conversation/submission atoms): add typing, remove unused code
* chore(types.ts): add missing type definitions for TMessages, TMessagesAtom, TConversationAtom, and ModelSelectProps
feat(types.ts): make endpoint property nullable in TSubmission, TEndpointOption, TConversation, and TPreset types
* refactor(ChatGPT): refactor to new format, add omit settings logic
* refactor(EndpointSettings/BingAI): new dir structure and format BingAI options/settings to new
* fix: update useUpdateTokenCountMutation to accept an object with a 'text' property instead of a string
* fix(endpoints): ensure expected behaviors for preset dialogs
* chore(index.ts): add defaultTextProps to utils/index.ts for use in settings components
* chore(index.ts): add optionText to utils/index.ts for use in settings components
* wip: refactor google settings
* wip: progress with Google refactor, needs AdditionalButtons handling and global state setters
* refactor(OptionsBar.tsx): The setOption function has been refactored to use the useSetOptions custom hook for setting conversation options.
* chore(Anthropic.tsx, BingAI.tsx, Google.tsx, OpenAI.tsx): adjust height of container div in Settings component; chore(Examples.tsx): adjust height in Examples component
* refactor(Google): complete google refactor
feat(client): add new component PopoverButtons for displaying popover buttons in EndpointPopover
feat(data-provider): add types for PopoverButton and EndpointOptionsPopoverProps
* fix(OptionsBar.tsx): add useEffect hook to handle opacity class based on messagesTree and advancedMode
fix(style.css): rename class from 'openAIOptions-simple-container' to 'options-bar' and update references
* refactor(Plugins/OptionsBar): complete refactor of Plugins Select options, consolidate logic from TextChat to OptionsBar
* fix(Plugins.tsx): filter lastSelectedTools to remove any tools that are not in the current tools list
fix(useSetOptions.ts): remove unnecessary empty line
* feat(useSetOptions.ts): add setAgentOption function to update agentOptions in conversation state
feat(types.ts): add setAgentOption function to UseSetOptions type
* refactor(Settings/Plugins): refactor to new format, refactor(OptionHover): use same component for all endpoints
* refactor(OptionHover.tsx): refactor types object to use nested objects for openAI and gptPlugins
feat(OptionHover.tsx): add openAI object with specific properties for openAI configuration
* refactor(AgentSettings): new format, feat(types.ts): add TAgentOptions type for defining agent options in a conversation
* feat(PopoverButtons.tsx): add support for GPT plugin settings button
feat(Plugins.tsx): create PluginsView component for displaying plugin settings
feat(optionSettings.ts): add showAgentSettings atom for controlling agent settings visibility
* feat(client): add support for PluginsSettings in Input/Settings component
fix(client): change import path for PluginsSettings in Input/Settings component
* refactor(Settings/Plugins): complete refactor, store: refactor to TS, refactor: import defaultTextPropsLabel from utils
* feat(EndpointSettings, AgentSettings, Anthropic, Google, types.ts): Add support for Recoil state management and useRecoilValue hook; Pass models from endpointsConfig to various components; Add TModels type and update ModelSelectProps type.
fix(AgentSettings, Anthropic, Google, GoogleView, Plugins, OpenAI, Settings.tsx): Change import statements for ModelSelectProps from librechat-data-provider; Add models as a parameter to various components; Add models prop to PluginsView, Settings, and other components.
* refactor(EditPresetDialog.jsx): update import statements for Examples and AgentSettings components
feat(Settings/index.ts): add export statements for Examples and AgentSettings components
* chore(package.json): update eslint-plugin-import to version 2.28.0
* fix(eslint): dependency cycle rule is now working
* fix: dependency cycle errors and type errors
* refactor(EditPresetDialog.jsx): update import path for DialogTemplate component
refactor(NewConversationMenu/index.jsx): update import path for DialogTemplate component
refactor(ExportModel.jsx): update import path for DialogTemplate component
* refactor: rename NewConversationMenu to EndpointMenu
* style: mobile and desktop optimizations
* chore: eslint changes
* chore(eslintrc.js): update eslint configuration to use 'prettier' plugin
chore(postcss.config.cjs): update postcss configuration to use single quotes for require statements
fix(helpers.js): fix fs.rmSync function call to delete node_modules directory recursively
feat(update.js): add support for skipping git commands with '-g' flag
* chore(ModelSelect.tsx): add support for azureOpenAI option component
chore(Settings.tsx): add support for azureOpenAI option component
chore(package.json): add rebuild:package-lock and update:branch scripts
* fix(OptionHover.tsx): fix accessing nested properties in types object
feat(OptionHover.tsx): add check for existence of text before rendering HoverCardContent
* chore(style.css): update transition duration for options-bar from 0.3s to 0.25s
* fix(ScrollToBottom.jsx): fix z-index value for scroll button
* style: improve dialogs
* fix(Nav.jsx): adjust width and max-width of nav component
* chore(Nav.jsx): update max-width class for nav component in different screen sizes
chore(Dialog.tsx): update class for DialogFooter component to use flex-row layout
* fix(client): fix node_module resolution with path mapping
* fix(AdjustToneButton.jsx): add z-index to adjust tone button for proper layering
fix(TextChat.jsx): change onClick function to use arrow function to avoid immediate execution
fix(mobile.css): update z-index for nav and nav-mask for proper layering
chore(package.json): rename update:branch script to reinstall for clarity and consistency
* fix(OptionsBar/Settings): add null checks for conversation in BingAI.tsx, ChatGPT.tsx, Plugins.tsx, Settings.tsx
* style(TextChat/OptionsBar): match official site styles, setup regen/continue/stop buttons div
* chore: Import and apply removeFocusOutlines utility across various components, and rename removeButtonOutline to removeFocusOutlines
chore(Settings): Remove unused import and conditionally return null if conversation is falsy
* feat(hooks): add useLocalize hook
The useLocalize hook is added to the hooks/index.ts file. This hook allows for localization of phrases using the localize function from the ~/localization/Translation module. The hook uses the lang value from the store to determine the current language and returns a function that takes a phraseKey and optional values array as arguments and returns the localized phrase.
* refactor(OptionHover.tsx): Update text keys for OptionHover component, use new hook: useLocalize
* refactor(useDocumentTitle.ts): refactor to TS
* fix(typescript): type issues and update typescript linting deps
* refactor: Update ThemeContext and useOnClickOutside to TypeScript
chore(useDidMountEffect.js): Remove useDidMountEffect hook
* feat: GenerationButtons for stop/continue/regen, remove AdjustToneButton in favor of alternate advanced mode/Settings in OptionsBar
* fix(EndpointOptionsPopover.tsx): change switchToSimpleMode function name to closePopover
fix(GenerationButtons.tsx): change advancedMode prop name to showPopover
fix(OptionsBar.tsx): change advancedMode state name to showPopover
feat(OptionsBar.tsx): add logic to show/hide popover based on showPopover state
fix(types.ts): change switchToSimpleMode function name to closePopover
* chore: remove template button
* chore(GenerationButtons.tsx): adjust positioning of the div element
chore(Plugins.tsx): adjust width of the MultiSelectDropDown component
chore(OptionsBar.tsx): adjust padding of the button element
* refactor(EditPresetDialog): use new modular higher order components
* chore(newoptionsbar.html): delete unused file newoptionsbar.html
* refactor(EditPresetDialog): convert to TS
* chore(babel.config.cjs): update babel configuration, linting
* chore(EditPresetDialog.tsx): update className for DialogTemplate to include pb-0
chore(EndpointOptionsDialog.jsx): update className for DialogTemplate to include pb-0
chore(PopoverButtons.tsx): add buttonClass prop to PopoverButtons component
chore(DialogTemplate.tsx): update className for the footer div to include h-auto
chore(Dropdown.jsx): remove id prop from Dropdown component
chore(mobile.css): update transition duration for .nav class from 0.2s to 0.15s
* refactor(EditPresetDialog.tsx): simplify localization usage with hook
* chore(EditPresetDialog.tsx): update containerClassName to include z-index value
* fix(endpoints.ts): change type of endpointsConfig atom to TEndpointsConfig
refactor(cleanupPreset.ts): convert to TS
fix(index.ts): export cleanupPreset utility function
fix(types.ts): add missing properties to TPreset type
* refactor(EndpointOptionsDialog): convert to TS
* fix(EditPresetDialog.tsx):
- import cleanupPreset from index
- add null check before submitting preset
- add null check before exporting preset
refactor(SaveAsPresetDialog.tsx): convert to TS
fix(usePresetOptions.ts): import cleanupPreset from index
fix(types.ts):
- make title prop optional in EditPresetProps
- change preset prop in CleanupPreset to be partial
* chore: reorganize imports in App, EndpointMenu, Messages, and ExportModel components
feat(ScreenshotContext.jsx): add ScreenshotContext to hooks/index
chore(index.ts): export ThemeContext, ScreenshotContext, ApiErrorBoundaryContext hooks, cleanupPreset, and getIcon functions from utils
* wip: add headerClassName for dialog template
* chore(EndpointOptionsDialog.tsx): remove unused headerClassName prop
chore(EndpointOptionsDialog.tsx): adjust height of main container in mobile and desktop view
* fix(react-query-service.ts): change return type of useGetEndpointsQuery to QueryObserverResult<t.TEndpointsConfig>
* refactor: imports from index and refactor to TS
* refactor: refactor all svg components to TS
* refactor: refactor all UI components to TS, remove unused component
* fix(SelectDropDown.tsx): remove file extension from import statement for CheckMark component
* fix: SaveAsPresetDialog typing issue
* fix(OptionsBar): close popover when an endpoint with no settings is selected
* chore(ChatGPT.tsx): update width of model select dropdown to 60px
refactor(types.ts): decouple ModelSelectProps from SettingsProps
* fix(popover Settings): space taken from the options menu for each endpoint
* fix:'Set token first' element alignment, add padding to endpointmenu icon in mobile
* style: match official site header
* refactor(EndpointOptionsDialog): make functionality explicitly saving current convos as presets
* fix(useLocalize.ts): change values parameter from an array to rest parameters
* refactor(EndpointSettings): Utilize useLocalize hook for all endpoint settings
* fix(Popover): correct spacing/center and remove focus outlines for close button
* chore: employ use of cn (clsx) in Popover styles
* chore(EditPresetDialog.tsx): update className to add padding bottom
chore(EndpointOptionsDialog.tsx): update className to add padding bottom
* style(EndpointMenu, TextChat): add better styling at diff. breakpoints
* refactor(EndpointSettings): consolidate container style to higher order component
* refactor(EditPresetDialog.tsx): pass custom style to Settings from here
* style: setting dialogs improved in all views
* style(EndpointMenu): improve UX for mobile
* style(PresetDialog): increase height so scrollbar isn't triggered
* chore(EditPresetDialog.tsx): update className to include xl height for DialogTemplate
chore(InputNumber.tsx): update className to include max height for InputNumber component
* fix: light mode styling
* fix(OptionsBar/ScrollToBottom/Popover): quick fix to rework in future: hide scrollToBottom when Popover is open
* style: remove bg-gradient around textarea in mobile view
* chore(ThemeContext.tsx): refactor ThemeContext to use default context value, also fixes type issue
* chore(EditPresetDialog.tsx): adjust grid layout in EditPresetDialog component
* style(TextChat): make gradient more opaque/smoother
* fix(TextChat.jsx): fix background gradient color based on theme and system preference
* test(layout-test-utils.tsx): add mock implementation for window.matchMedia in test setup
feat(layout-test-utils.tsx): add authConfig prop to AuthContextProvider in renderWithProvidersWrapper function
chore(tsconfig.json): include test directory in tsconfig include section
* chore(jest.config.cjs): update test file paths in jest configuration
chore(Login.spec.tsx): update test file path in import statement
chore(LoginForm.spec.tsx): update test file path in import statement
chore(Registration.spec.tsx): update test file path in import statement
chore(PluginAuthForm.spec.tsx): update test file path in import statement
chore(PluginStoreDialog.spec.tsx): update test file path in import statement
chore(layout-test-utils.tsx): move matchMedia mock to separate file
chore(tsconfig.json): add path mapping for test files in client directory
* test: add import for 'test/matchMedia.mock' in test files
The changes in this commit add an import statement for 'test/matchMedia.mock' in multiple test files. This import is necessary for mocking the behavior of the matchMedia function during testing.
* style(ClearConvosDialog): remove borders from button and modal, uniform button size
* fix(AgentSettings.tsx): overlapping issue
* fix(PresetDialogs): improve spacing of top row and dialog content
* style(Settings): 2nd column will now dynamically adjust better across all screen sizes
* style(ModelSelect): improve styling for mobile/desktop, add hover shadow
feat(ModelSelect/Plugins): hide ModelSelect when screen is small
* refactor(RowButton, buildTree): convert to TS
* style(ModelSelect): add transition effect to shadows on hover
2023-08-04 13:56:44 -04:00
|
|
|
{ text: string },
|
2023-07-30 10:37:25 -04:00
|
|
|
unknown
|
|
|
|
> => {
|
|
|
|
const queryClient = useQueryClient();
|
refactor: Settings/Presets UI Restructure, convert many files to TS (#740)
* progress on settings refactor
* fix(helpers.js): replace fs.rmdirSync with fs.rm to delete node_modules directory recursively
fix(packages.js): delete package-lock.json if it exists before running the script
* feat(CrossIcon.tsx): add CrossIcon component
* wip: refactor Options for modularity into higher order components, OptionsBar > ModelSelect/Settings
* refactor: import more from utils/index, including cardStyle used by model select/settings
* refactor(AnthropicOptions): refactor to new format, OpenAI: reduce format to name of endpoint
* refactor(AnthropicSettings): refactor to new format, match defaults to API docs
* fix: google and anthropic defaults
* refactor(conversation/submission atoms): add typing, remove unused code
* chore(types.ts): add missing type definitions for TMessages, TMessagesAtom, TConversationAtom, and ModelSelectProps
feat(types.ts): make endpoint property nullable in TSubmission, TEndpointOption, TConversation, and TPreset types
* refactor(ChatGPT): refactor to new format, add omit settings logic
* refactor(EndpointSettings/BingAI): new dir structure and format BingAI options/settings to new
* fix: update useUpdateTokenCountMutation to accept an object with a 'text' property instead of a string
* fix(endpoints): ensure expected behaviors for preset dialogs
* chore(index.ts): add defaultTextProps to utils/index.ts for use in settings components
* chore(index.ts): add optionText to utils/index.ts for use in settings components
* wip: refactor google settings
* wip: progress with Google refactor, needs AdditionalButtons handling and global state setters
* refactor(OptionsBar.tsx): The setOption function has been refactored to use the useSetOptions custom hook for setting conversation options.
* chore(Anthropic.tsx, BingAI.tsx, Google.tsx, OpenAI.tsx): adjust height of container div in Settings component; chore(Examples.tsx): adjust height in Examples component
* refactor(Google): complete google refactor
feat(client): add new component PopoverButtons for displaying popover buttons in EndpointPopover
feat(data-provider): add types for PopoverButton and EndpointOptionsPopoverProps
* fix(OptionsBar.tsx): add useEffect hook to handle opacity class based on messagesTree and advancedMode
fix(style.css): rename class from 'openAIOptions-simple-container' to 'options-bar' and update references
* refactor(Plugins/OptionsBar): complete refactor of Plugins Select options, consolidate logic from TextChat to OptionsBar
* fix(Plugins.tsx): filter lastSelectedTools to remove any tools that are not in the current tools list
fix(useSetOptions.ts): remove unnecessary empty line
* feat(useSetOptions.ts): add setAgentOption function to update agentOptions in conversation state
feat(types.ts): add setAgentOption function to UseSetOptions type
* refactor(Settings/Plugins): refactor to new format, refactor(OptionHover): use same component for all endpoints
* refactor(OptionHover.tsx): refactor types object to use nested objects for openAI and gptPlugins
feat(OptionHover.tsx): add openAI object with specific properties for openAI configuration
* refactor(AgentSettings): new format, feat(types.ts): add TAgentOptions type for defining agent options in a conversation
* feat(PopoverButtons.tsx): add support for GPT plugin settings button
feat(Plugins.tsx): create PluginsView component for displaying plugin settings
feat(optionSettings.ts): add showAgentSettings atom for controlling agent settings visibility
* feat(client): add support for PluginsSettings in Input/Settings component
fix(client): change import path for PluginsSettings in Input/Settings component
* refactor(Settings/Plugins): complete refactor, store: refactor to TS, refactor: import defaultTextPropsLabel from utils
* feat(EndpointSettings, AgentSettings, Anthropic, Google, types.ts): Add support for Recoil state management and useRecoilValue hook; Pass models from endpointsConfig to various components; Add TModels type and update ModelSelectProps type.
fix(AgentSettings, Anthropic, Google, GoogleView, Plugins, OpenAI, Settings.tsx): Change import statements for ModelSelectProps from librechat-data-provider; Add models as a parameter to various components; Add models prop to PluginsView, Settings, and other components.
* refactor(EditPresetDialog.jsx): update import statements for Examples and AgentSettings components
feat(Settings/index.ts): add export statements for Examples and AgentSettings components
* chore(package.json): update eslint-plugin-import to version 2.28.0
* fix(eslint): dependency cycle rule is now working
* fix: dependency cycle errors and type errors
* refactor(EditPresetDialog.jsx): update import path for DialogTemplate component
refactor(NewConversationMenu/index.jsx): update import path for DialogTemplate component
refactor(ExportModel.jsx): update import path for DialogTemplate component
* refactor: rename NewConversationMenu to EndpointMenu
* style: mobile and desktop optimizations
* chore: eslint changes
* chore(eslintrc.js): update eslint configuration to use 'prettier' plugin
chore(postcss.config.cjs): update postcss configuration to use single quotes for require statements
fix(helpers.js): fix fs.rmSync function call to delete node_modules directory recursively
feat(update.js): add support for skipping git commands with '-g' flag
* chore(ModelSelect.tsx): add support for azureOpenAI option component
chore(Settings.tsx): add support for azureOpenAI option component
chore(package.json): add rebuild:package-lock and update:branch scripts
* fix(OptionHover.tsx): fix accessing nested properties in types object
feat(OptionHover.tsx): add check for existence of text before rendering HoverCardContent
* chore(style.css): update transition duration for options-bar from 0.3s to 0.25s
* fix(ScrollToBottom.jsx): fix z-index value for scroll button
* style: improve dialogs
* fix(Nav.jsx): adjust width and max-width of nav component
* chore(Nav.jsx): update max-width class for nav component in different screen sizes
chore(Dialog.tsx): update class for DialogFooter component to use flex-row layout
* fix(client): fix node_module resolution with path mapping
* fix(AdjustToneButton.jsx): add z-index to adjust tone button for proper layering
fix(TextChat.jsx): change onClick function to use arrow function to avoid immediate execution
fix(mobile.css): update z-index for nav and nav-mask for proper layering
chore(package.json): rename update:branch script to reinstall for clarity and consistency
* fix(OptionsBar/Settings): add null checks for conversation in BingAI.tsx, ChatGPT.tsx, Plugins.tsx, Settings.tsx
* style(TextChat/OptionsBar): match official site styles, setup regen/continue/stop buttons div
* chore: Import and apply removeFocusOutlines utility across various components, and rename removeButtonOutline to removeFocusOutlines
chore(Settings): Remove unused import and conditionally return null if conversation is falsy
* feat(hooks): add useLocalize hook
The useLocalize hook is added to the hooks/index.ts file. This hook allows for localization of phrases using the localize function from the ~/localization/Translation module. The hook uses the lang value from the store to determine the current language and returns a function that takes a phraseKey and optional values array as arguments and returns the localized phrase.
* refactor(OptionHover.tsx): Update text keys for OptionHover component, use new hook: useLocalize
* refactor(useDocumentTitle.ts): refactor to TS
* fix(typescript): type issues and update typescript linting deps
* refactor: Update ThemeContext and useOnClickOutside to TypeScript
chore(useDidMountEffect.js): Remove useDidMountEffect hook
* feat: GenerationButtons for stop/continue/regen, remove AdjustToneButton in favor of alternate advanced mode/Settings in OptionsBar
* fix(EndpointOptionsPopover.tsx): change switchToSimpleMode function name to closePopover
fix(GenerationButtons.tsx): change advancedMode prop name to showPopover
fix(OptionsBar.tsx): change advancedMode state name to showPopover
feat(OptionsBar.tsx): add logic to show/hide popover based on showPopover state
fix(types.ts): change switchToSimpleMode function name to closePopover
* chore: remove template button
* chore(GenerationButtons.tsx): adjust positioning of the div element
chore(Plugins.tsx): adjust width of the MultiSelectDropDown component
chore(OptionsBar.tsx): adjust padding of the button element
* refactor(EditPresetDialog): use new modular higher order components
* chore(newoptionsbar.html): delete unused file newoptionsbar.html
* refactor(EditPresetDialog): convert to TS
* chore(babel.config.cjs): update babel configuration, linting
* chore(EditPresetDialog.tsx): update className for DialogTemplate to include pb-0
chore(EndpointOptionsDialog.jsx): update className for DialogTemplate to include pb-0
chore(PopoverButtons.tsx): add buttonClass prop to PopoverButtons component
chore(DialogTemplate.tsx): update className for the footer div to include h-auto
chore(Dropdown.jsx): remove id prop from Dropdown component
chore(mobile.css): update transition duration for .nav class from 0.2s to 0.15s
* refactor(EditPresetDialog.tsx): simplify localization usage with hook
* chore(EditPresetDialog.tsx): update containerClassName to include z-index value
* fix(endpoints.ts): change type of endpointsConfig atom to TEndpointsConfig
refactor(cleanupPreset.ts): convert to TS
fix(index.ts): export cleanupPreset utility function
fix(types.ts): add missing properties to TPreset type
* refactor(EndpointOptionsDialog): convert to TS
* fix(EditPresetDialog.tsx):
- import cleanupPreset from index
- add null check before submitting preset
- add null check before exporting preset
refactor(SaveAsPresetDialog.tsx): convert to TS
fix(usePresetOptions.ts): import cleanupPreset from index
fix(types.ts):
- make title prop optional in EditPresetProps
- change preset prop in CleanupPreset to be partial
* chore: reorganize imports in App, EndpointMenu, Messages, and ExportModel components
feat(ScreenshotContext.jsx): add ScreenshotContext to hooks/index
chore(index.ts): export ThemeContext, ScreenshotContext, ApiErrorBoundaryContext hooks, cleanupPreset, and getIcon functions from utils
* wip: add headerClassName for dialog template
* chore(EndpointOptionsDialog.tsx): remove unused headerClassName prop
chore(EndpointOptionsDialog.tsx): adjust height of main container in mobile and desktop view
* fix(react-query-service.ts): change return type of useGetEndpointsQuery to QueryObserverResult<t.TEndpointsConfig>
* refactor: imports from index and refactor to TS
* refactor: refactor all svg components to TS
* refactor: refactor all UI components to TS, remove unused component
* fix(SelectDropDown.tsx): remove file extension from import statement for CheckMark component
* fix: SaveAsPresetDialog typing issue
* fix(OptionsBar): close popover when an endpoint with no settings is selected
* chore(ChatGPT.tsx): update width of model select dropdown to 60px
refactor(types.ts): decouple ModelSelectProps from SettingsProps
* fix(popover Settings): space taken from the options menu for each endpoint
* fix:'Set token first' element alignment, add padding to endpointmenu icon in mobile
* style: match official site header
* refactor(EndpointOptionsDialog): make functionality explicitly saving current convos as presets
* fix(useLocalize.ts): change values parameter from an array to rest parameters
* refactor(EndpointSettings): Utilize useLocalize hook for all endpoint settings
* fix(Popover): correct spacing/center and remove focus outlines for close button
* chore: employ use of cn (clsx) in Popover styles
* chore(EditPresetDialog.tsx): update className to add padding bottom
chore(EndpointOptionsDialog.tsx): update className to add padding bottom
* style(EndpointMenu, TextChat): add better styling at diff. breakpoints
* refactor(EndpointSettings): consolidate container style to higher order component
* refactor(EditPresetDialog.tsx): pass custom style to Settings from here
* style: setting dialogs improved in all views
* style(EndpointMenu): improve UX for mobile
* style(PresetDialog): increase height so scrollbar isn't triggered
* chore(EditPresetDialog.tsx): update className to include xl height for DialogTemplate
chore(InputNumber.tsx): update className to include max height for InputNumber component
* fix: light mode styling
* fix(OptionsBar/ScrollToBottom/Popover): quick fix to rework in future: hide scrollToBottom when Popover is open
* style: remove bg-gradient around textarea in mobile view
* chore(ThemeContext.tsx): refactor ThemeContext to use default context value, also fixes type issue
* chore(EditPresetDialog.tsx): adjust grid layout in EditPresetDialog component
* style(TextChat): make gradient more opaque/smoother
* fix(TextChat.jsx): fix background gradient color based on theme and system preference
* test(layout-test-utils.tsx): add mock implementation for window.matchMedia in test setup
feat(layout-test-utils.tsx): add authConfig prop to AuthContextProvider in renderWithProvidersWrapper function
chore(tsconfig.json): include test directory in tsconfig include section
* chore(jest.config.cjs): update test file paths in jest configuration
chore(Login.spec.tsx): update test file path in import statement
chore(LoginForm.spec.tsx): update test file path in import statement
chore(Registration.spec.tsx): update test file path in import statement
chore(PluginAuthForm.spec.tsx): update test file path in import statement
chore(PluginStoreDialog.spec.tsx): update test file path in import statement
chore(layout-test-utils.tsx): move matchMedia mock to separate file
chore(tsconfig.json): add path mapping for test files in client directory
* test: add import for 'test/matchMedia.mock' in test files
The changes in this commit add an import statement for 'test/matchMedia.mock' in multiple test files. This import is necessary for mocking the behavior of the matchMedia function during testing.
* style(ClearConvosDialog): remove borders from button and modal, uniform button size
* fix(AgentSettings.tsx): overlapping issue
* fix(PresetDialogs): improve spacing of top row and dialog content
* style(Settings): 2nd column will now dynamically adjust better across all screen sizes
* style(ModelSelect): improve styling for mobile/desktop, add hover shadow
feat(ModelSelect/Plugins): hide ModelSelect when screen is small
* refactor(RowButton, buildTree): convert to TS
* style(ModelSelect): add transition effect to shadows on hover
2023-08-04 13:56:44 -04:00
|
|
|
return useMutation(({ text }: { text: string }) => dataService.updateTokenCount(text), {
|
2023-07-30 10:37:25 -04:00
|
|
|
onSuccess: () => {
|
|
|
|
queryClient.invalidateQueries([QueryKeys.tokenCount]);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useLoginUserMutation = (): UseMutationResult<
|
|
|
|
t.TLoginResponse,
|
|
|
|
unknown,
|
|
|
|
t.TLoginUser,
|
|
|
|
unknown
|
|
|
|
> => {
|
|
|
|
const queryClient = useQueryClient();
|
|
|
|
return useMutation((payload: t.TLoginUser) => dataService.login(payload), {
|
|
|
|
onSuccess: () => {
|
|
|
|
queryClient.invalidateQueries([QueryKeys.user]);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useRegisterUserMutation = (): UseMutationResult<
|
|
|
|
unknown,
|
|
|
|
unknown,
|
|
|
|
t.TRegisterUser,
|
|
|
|
unknown
|
|
|
|
> => {
|
|
|
|
const queryClient = useQueryClient();
|
|
|
|
return useMutation((payload: t.TRegisterUser) => dataService.register(payload), {
|
|
|
|
onSuccess: () => {
|
|
|
|
queryClient.invalidateQueries([QueryKeys.user]);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useLogoutUserMutation = (): UseMutationResult<unknown> => {
|
|
|
|
const queryClient = useQueryClient();
|
|
|
|
return useMutation(() => dataService.logout(), {
|
|
|
|
onSuccess: () => {
|
|
|
|
queryClient.invalidateQueries([QueryKeys.user]);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useRefreshTokenMutation = (): UseMutationResult<
|
|
|
|
t.TRefreshTokenResponse,
|
|
|
|
unknown,
|
|
|
|
unknown,
|
|
|
|
unknown
|
|
|
|
> => {
|
|
|
|
return useMutation(() => dataService.refreshToken(), {});
|
|
|
|
};
|
|
|
|
|
refactor: Encrypt & Expire User Provided Keys, feat: Rate Limiting (#874)
* docs: make_your_own.md formatting fix for mkdocs
* feat: add express-mongo-sanitize
feat: add login/registration rate limiting
* chore: remove unnecessary console log
* wip: remove token handling from localStorage to encrypted DB solution
* refactor: minor change to UserService
* fix mongo query and add keys route to server
* fix backend controllers and simplify schema/crud
* refactor: rename token to key to separate from access/refresh tokens, setTokenDialog -> setKeyDialog
* refactor(schemas): TEndpointOption token -> key
* refactor(api): use new encrypted key retrieval system
* fix(SetKeyDialog): fix key prop error
* fix(abortMiddleware): pass random UUID if messageId is not generated yet for proper error display on frontend
* fix(getUserKey): wrong prop passed in arg, adds error handling
* fix: prevent message without conversationId from saving to DB, prevents branching on the frontend to a new top-level branch
* refactor: change wording of multiple display messages
* refactor(checkExpiry -> checkUserKeyExpiry): move to UserService file
* fix: type imports from common
* refactor(SubmitButton): convert to TS
* refactor(key.ts): change localStorage map key name
* refactor: add new custom tailwind classes to better match openAI colors
* chore: remove unnecessary warning and catch ScreenShot error
* refactor: move userKey frontend logic to hooks and remove use of localStorage and instead query the DB
* refactor: invalidate correct query key, memoize userKey hook, conditionally render SetKeyDialog to avoid unnecessary calls, refactor SubmitButton props and useEffect for showing 'provide key first'
* fix(SetKeyDialog): use enum-like object for expiry values
feat(Dropdown): add optionsClassName to dynamically change dropdown options container classes
* fix: handle edge case where user had provided a key but the server changes to env variable for keys
* refactor(OpenAI/titleConvo): move titling to client to retain authorized credentials in message lifecycle for titling
* fix(azure): handle user_provided keys correctly for azure
* feat: send user Id to OpenAI to differentiate users in completion requests
* refactor(OpenAI/titleConvo): adding tokens helps minimize LLM from using the language in title response
* feat: add delete endpoint for keys
* chore: remove throttling of title
* feat: add 'Data controls' to Settings, add 'Revoke' keys feature in Key Dialog and Data controls
* refactor: reorganize PluginsClient files in langchain format
* feat: use langchain for titling convos
* chore: cleanup titling convo, with fallback to original method, escape braces, use only snippet for language detection
* refactor: move helper functions to appropriate langchain folders for reusability
* fix: userProvidesKey handling for gptPlugins
* fix: frontend handling of plugins key
* chore: cleanup logging and ts-ignore SSE
* fix: forwardRef misuse in DangerButton
* fix(GoogleConfig/FileUpload): localize errors and simplify validation with zod
* fix: cleanup google logging and fix user provided key handling
* chore: remove titling from google
* chore: removing logging from browser endpoint
* wip: fix menu flicker
* feat: useLocalStorage hook
* feat: add Tooltip for UI
* refactor(EndpointMenu): utilize Tooltip and useLocalStorage, remove old 'New Chat' slide-over
* fix(e2e): use testId for endpoint menu trigger
* chore: final touches to EndpointMenu before future refactor to declutter component
* refactor(localization): change select endpoint to open menu and add translations
* chore: add final prop to error message response
* ci: minor edits to facilitate testing
* ci: new e2e test which tests for new key setting/revoking features
2023-09-06 10:46:27 -04:00
|
|
|
export const useUserKeyQuery = (
|
|
|
|
name: string,
|
|
|
|
config?: UseQueryOptions<t.TCheckUserKeyResponse>,
|
|
|
|
): QueryObserverResult<t.TCheckUserKeyResponse> => {
|
|
|
|
return useQuery<t.TCheckUserKeyResponse>(
|
|
|
|
[QueryKeys.name, name],
|
|
|
|
() => {
|
|
|
|
if (!name) {
|
|
|
|
return Promise.resolve({ expiresAt: '' });
|
|
|
|
}
|
|
|
|
return dataService.userKeyQuery(name);
|
|
|
|
},
|
|
|
|
{
|
|
|
|
refetchOnWindowFocus: false,
|
|
|
|
refetchOnReconnect: false,
|
|
|
|
refetchOnMount: false,
|
|
|
|
retry: false,
|
|
|
|
...config,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-07-30 10:37:25 -04:00
|
|
|
export const useRequestPasswordResetMutation = (): UseMutationResult<
|
|
|
|
t.TRequestPasswordResetResponse,
|
|
|
|
unknown,
|
|
|
|
t.TRequestPasswordReset,
|
|
|
|
unknown
|
|
|
|
> => {
|
|
|
|
return useMutation((payload: t.TRequestPasswordReset) =>
|
|
|
|
dataService.requestPasswordReset(payload),
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useResetPasswordMutation = (): UseMutationResult<
|
|
|
|
unknown,
|
|
|
|
unknown,
|
|
|
|
t.TResetPassword,
|
|
|
|
unknown
|
|
|
|
> => {
|
|
|
|
return useMutation((payload: t.TResetPassword) => dataService.resetPassword(payload));
|
|
|
|
};
|
|
|
|
|
2023-08-05 12:10:36 -04:00
|
|
|
export const useAvailablePluginsQuery = (): QueryObserverResult<s.TPlugin[]> => {
|
|
|
|
return useQuery<s.TPlugin[]>(
|
2023-07-30 10:37:25 -04:00
|
|
|
[QueryKeys.availablePlugins],
|
|
|
|
() => dataService.getAvailablePlugins(),
|
|
|
|
{
|
|
|
|
refetchOnWindowFocus: false,
|
|
|
|
refetchOnReconnect: false,
|
|
|
|
refetchOnMount: false,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useUpdateUserPluginsMutation = (): UseMutationResult<
|
|
|
|
t.TUser,
|
|
|
|
unknown,
|
|
|
|
t.TUpdateUserPlugins,
|
|
|
|
unknown
|
|
|
|
> => {
|
|
|
|
const queryClient = useQueryClient();
|
|
|
|
return useMutation((payload: t.TUpdateUserPlugins) => dataService.updateUserPlugins(payload), {
|
|
|
|
onSuccess: () => {
|
|
|
|
queryClient.invalidateQueries([QueryKeys.user]);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const useGetStartupConfig = (): QueryObserverResult<t.TStartupConfig> => {
|
|
|
|
return useQuery<t.TStartupConfig>(
|
|
|
|
[QueryKeys.startupConfig],
|
|
|
|
() => dataService.getStartupConfig(),
|
|
|
|
{
|
|
|
|
refetchOnWindowFocus: false,
|
|
|
|
refetchOnReconnect: false,
|
|
|
|
refetchOnMount: false,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
};
|