mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-10 20:48:54 +01:00
* feat: add zod schemas for better type safety * refactor(useSetOptions): remove 'as Type' in favor of zod schema * fix: descendant console error, change <p> tag to <div> tag for content in PluginTooltip component * style(MessagesView): instant/snappier scroll behavior matching official site * fix(Messages): add null check for scrollableRef before accessing its properties in handleScroll and useEffect * fix(messageSchema.js): change type of invocationId from string to number fix(schemas.ts): make authenticated property in tPluginSchema optional fix(schemas.ts): make isButton property in tPluginSchema optional fix(schemas.ts): make messages property in tConversationSchema optional and change its type to array of strings fix(schemas.ts): make systemMessage property in tConversationSchema nullable and optional fix(schemas.ts): make modelLabel property in tConversationSchema nullable and optional fix(schemas.ts): make chatGptLabel property in tConversationSchema nullable and optional fix(schemas.ts): make promptPrefix property in tConversationSchema nullable and optional fix(schemas.ts): make context property in tConversationSchema nullable and optional fix(schemas.ts): make jailbreakConversationId property in tConversationSchema nullable and optional fix(schemas.ts): make conversationSignature property in tConversationSchema nullable and optional fix(schemas.ts): make clientId property * refactor(types): replace main types with zod schemas and inferred types * refactor(types/schemas): use schemas for better type safety of main types * style(ModelSelect/Buttons): remove shadow and transition * style(ModelSelect): button changes to closer match OpenAI * style(ModelSelect): remove green rings which flicker * style(scrollToBottom): add two separate scrolling functions * fix(OptionsBar.tsx): handle onFocus and onBlur events to update opacityClass fix(Messages/index.jsx): increase debounce time for scrollIntoView function
120 lines
3.4 KiB
TypeScript
120 lines
3.4 KiB
TypeScript
import * as t from './types';
|
|
import * as s from './schemas';
|
|
import request from './request';
|
|
import * as endpoints from './api-endpoints';
|
|
|
|
export function getConversations(pageNumber: string): Promise<t.TGetConversationsResponse> {
|
|
return request.get(endpoints.conversations(pageNumber));
|
|
}
|
|
|
|
export function abortRequestWithMessage(
|
|
endpoint: string,
|
|
abortKey: string,
|
|
message: string,
|
|
): Promise<void> {
|
|
return request.post(endpoints.abortRequest(endpoint), { arg: { abortKey, message } });
|
|
}
|
|
|
|
export function deleteConversation(payload: t.TDeleteConversationRequest) {
|
|
//todo: this should be a DELETE request
|
|
return request.post(endpoints.deleteConversation(), { arg: payload });
|
|
}
|
|
|
|
export function clearAllConversations(): Promise<unknown> {
|
|
return request.post(endpoints.deleteConversation(), { arg: {} });
|
|
}
|
|
|
|
export function getMessagesByConvoId(id: string): Promise<s.TMessage[]> {
|
|
return request.get(endpoints.messages(id));
|
|
}
|
|
|
|
export function getConversationById(id: string): Promise<s.TConversation> {
|
|
return request.get(endpoints.conversationById(id));
|
|
}
|
|
|
|
export function updateConversation(
|
|
payload: t.TUpdateConversationRequest,
|
|
): Promise<t.TUpdateConversationResponse> {
|
|
return request.post(endpoints.updateConversation(), { arg: payload });
|
|
}
|
|
|
|
export function getPresets(): Promise<s.TPreset[]> {
|
|
return request.get(endpoints.presets());
|
|
}
|
|
|
|
export function createPreset(payload: s.TPreset): Promise<s.TPreset[]> {
|
|
return request.post(endpoints.presets(), payload);
|
|
}
|
|
|
|
export function updatePreset(payload: s.TPreset): Promise<s.TPreset[]> {
|
|
return request.post(endpoints.presets(), payload);
|
|
}
|
|
|
|
export function deletePreset(arg: s.TPreset | object): Promise<s.TPreset[]> {
|
|
return request.post(endpoints.deletePreset(), arg);
|
|
}
|
|
|
|
export function getSearchEnabled(): Promise<boolean> {
|
|
return request.get(endpoints.searchEnabled());
|
|
}
|
|
|
|
export function getUser(): Promise<t.TUser> {
|
|
return request.get(endpoints.user());
|
|
}
|
|
|
|
export const searchConversations = async (
|
|
q: string,
|
|
pageNumber: string,
|
|
): Promise<t.TSearchResults> => {
|
|
return request.get(endpoints.search(q, pageNumber));
|
|
};
|
|
|
|
export const getAIEndpoints = () => {
|
|
return request.get(endpoints.aiEndpoints());
|
|
};
|
|
|
|
export const updateTokenCount = (text: string) => {
|
|
return request.post(endpoints.tokenizer(), { arg: text });
|
|
};
|
|
|
|
export const login = (payload: t.TLoginUser) => {
|
|
return request.post(endpoints.login(), payload);
|
|
};
|
|
|
|
export const logout = () => {
|
|
return request.post(endpoints.logout());
|
|
};
|
|
|
|
export const register = (payload: t.TRegisterUser) => {
|
|
return request.post(endpoints.register(), payload);
|
|
};
|
|
|
|
export const refreshToken = () => {
|
|
return request.post(endpoints.refreshToken());
|
|
};
|
|
|
|
export const getLoginGoogle = () => {
|
|
return request.get(endpoints.loginGoogle());
|
|
};
|
|
|
|
export const requestPasswordReset = (
|
|
payload: t.TRequestPasswordReset,
|
|
): Promise<t.TRequestPasswordResetResponse> => {
|
|
return request.post(endpoints.requestPasswordReset(), payload);
|
|
};
|
|
|
|
export const resetPassword = (payload: t.TResetPassword) => {
|
|
return request.post(endpoints.resetPassword(), payload);
|
|
};
|
|
|
|
export const getAvailablePlugins = (): Promise<s.TPlugin[]> => {
|
|
return request.get(endpoints.plugins());
|
|
};
|
|
|
|
export const updateUserPlugins = (payload: t.TUpdateUserPlugins) => {
|
|
return request.post(endpoints.userPlugins(), payload);
|
|
};
|
|
|
|
export const getStartupConfig = (): Promise<t.TStartupConfig> => {
|
|
return request.get(endpoints.config());
|
|
};
|