🗨️ feat: Prompt Slash Commands (#3219)

* chore: Update prompt description placeholder text

* fix: promptsPathPattern to not include new

* feat: command input and styling change for prompt views

* fix: intended validation

* feat: prompts slash command

* chore: localizations and fix add command during creation

* refactor(PromptsCommand): better label

* feat: update `allPrompGroups` cache on all promptGroups mutations

* refactor: ensure assistants builder is first within sidepanel

* refactor: allow defining emailVerified via create-user script
This commit is contained in:
Danny Avila 2024-06-27 17:34:48 -04:00 committed by GitHub
parent b8f2bee3fc
commit 83619de158
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 764 additions and 80 deletions

View file

@ -5,9 +5,12 @@ import type { UseMutationResult } from '@tanstack/react-query';
import type t from 'librechat-data-provider';
import {
/* Prompts */
addGroupToAll,
addPromptGroup,
updateGroupInAll,
updateGroupFields,
deletePromptGroup,
removeGroupFromAll,
} from '~/utils';
import store from '~/store';
@ -83,7 +86,12 @@ export const useUpdatePromptGroup = (
onError(err, variables, context);
}
},
onSuccess,
onSuccess: (response, variables, context) => {
updateGroupInAll(queryClient, { _id: variables.id, ...response });
if (onSuccess) {
onSuccess(response, variables, context);
}
},
});
};
@ -118,6 +126,8 @@ export const useCreatePrompt = (
return addPromptGroup(data, group);
},
);
addGroupToAll(queryClient, group);
}
if (onSuccess) {
@ -151,6 +161,8 @@ export const useDeletePrompt = (
return deletePromptGroup(data, promptGroupId);
},
);
removeGroupFromAll(queryClient, promptGroupId);
} else {
queryClient.setQueryData<t.TPrompt[]>(
[QueryKeys.prompts, variables.groupId],
@ -208,6 +220,8 @@ export const useDeletePromptGroup = (
return deletePromptGroup(data, variables.id);
},
);
removeGroupFromAll(queryClient, variables.id);
if (onSuccess) {
onSuccess(response, variables, context);
}
@ -299,6 +313,15 @@ export const useMakePromptProduction = (options?: t.MakePromptProductionOptions)
onError(err, variables, context);
}
},
onSuccess,
onSuccess: (response, variables, context) => {
updateGroupInAll(queryClient, {
_id: variables.groupId,
productionId: variables.id,
productionPrompt: variables.productionPrompt,
});
if (onSuccess) {
onSuccess(response, variables, context);
}
},
});
};

View file

@ -488,6 +488,23 @@ export const useGetPrompts = (
);
};
export const useGetAllPromptGroups = <TData = t.AllPromptGroupsResponse>(
filter?: t.AllPromptGroupsFilterRequest,
config?: UseQueryOptions<t.AllPromptGroupsResponse, unknown, TData>,
): QueryObserverResult<TData> => {
return useQuery<t.AllPromptGroupsResponse, unknown, TData>(
[QueryKeys.allPromptGroups],
() => dataService.getAllPromptGroups(),
{
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
retry: false,
...config,
},
);
};
export const useGetCategories = <TData = t.TGetCategoriesResponse>(
config?: UseQueryOptions<t.TGetCategoriesResponse, unknown, TData>,
): QueryObserverResult<TData> => {