mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-24 03:06:12 +01:00
🚀 feat: Banner (#3952)
* feat: Add banner schema and model * feat: Add optional JwtAuth To handle the conditional logic with and without authentication within the model. * feat: Add an endpoint to retrieve a banner * feat: Add implementation for client to use banner and access API * feat: Display a banner on UI * feat: Script for updating and deleting banners * style: Update banner style * fix: Adjust the height when the banner is displayed * fix: failed specs
This commit is contained in:
parent
07e5531b5b
commit
aea01f0bc5
26 changed files with 453 additions and 4 deletions
|
|
@ -220,3 +220,4 @@ export const addTagToConversation = (conversationId: string) =>
|
|||
|
||||
export const userTerms = () => '/api/user/terms';
|
||||
export const acceptUserTerms = () => '/api/user/terms/accept';
|
||||
export const banner = () => '/api/banner';
|
||||
|
|
|
|||
|
|
@ -691,3 +691,7 @@ export function getUserTerms(): Promise<t.TUserTermsResponse> {
|
|||
export function acceptTerms(): Promise<t.TAcceptTermsResponse> {
|
||||
return request.post(endpoints.acceptUserTerms());
|
||||
}
|
||||
|
||||
export function getBanner(): Promise<t.TBannerResponse> {
|
||||
return request.get(endpoints.banner());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ export enum QueryKeys {
|
|||
conversationTags = 'conversationTags',
|
||||
health = 'health',
|
||||
userTerms = 'userTerms',
|
||||
banner = 'banner',
|
||||
}
|
||||
|
||||
export enum MutationKeys {
|
||||
|
|
|
|||
|
|
@ -451,3 +451,14 @@ export const useGetCustomConfigSpeechQuery = (
|
|||
},
|
||||
);
|
||||
};
|
||||
|
||||
export const useGetBannerQuery = (
|
||||
config?: UseQueryOptions<t.TBannerResponse>,
|
||||
): QueryObserverResult<t.TBannerResponse> => {
|
||||
return useQuery<t.TBannerResponse>([QueryKeys.banner], () => dataService.getBanner(), {
|
||||
refetchOnWindowFocus: false,
|
||||
refetchOnReconnect: false,
|
||||
refetchOnMount: false,
|
||||
...config,
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1212,6 +1212,17 @@ export const compactPluginsSchema = tConversationSchema
|
|||
})
|
||||
.catch(() => ({}));
|
||||
|
||||
const tBannerSchema = z.object({
|
||||
bannerId: z.string(),
|
||||
message: z.string(),
|
||||
displayFrom: z.string(),
|
||||
displayTo: z.string(),
|
||||
createdAt: z.string(),
|
||||
updatedAt: z.string(),
|
||||
isPublic: z.boolean(),
|
||||
});
|
||||
export type TBanner = z.infer<typeof tBannerSchema>;
|
||||
|
||||
export const compactAgentsSchema = tConversationSchema
|
||||
.pick({
|
||||
model: true,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import type {
|
|||
TConversation,
|
||||
EModelEndpoint,
|
||||
TConversationTag,
|
||||
TBanner,
|
||||
} from './schemas';
|
||||
import type { TSpecsConfig } from './models';
|
||||
export type TOpenAIMessage = OpenAI.Chat.ChatCompletionMessageParam;
|
||||
|
|
@ -518,3 +519,5 @@ export type TUserTermsResponse = {
|
|||
export type TAcceptTermsResponse = {
|
||||
success: boolean;
|
||||
};
|
||||
|
||||
export type TBannerResponse = TBanner | null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue