mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-25 20:58:50 +01:00
feat: Implement Default Preset Selection for Conversations 📌 (#1275)
* fix: type issues with icons * refactor: use react query for presets, show toasts on preset crud, refactor mutations, remove presetsQuery from Root (breaking change) * refactor: change preset titling * refactor: update preset schemas and methods for necessary new properties `order` and `defaultPreset` * feat: add `defaultPreset` Recoil value * refactor(getPresetTitle): make logic cleaner and more concise * feat: complete UI portion of defaultPreset feature, with animations added to preset items * chore: remove console.logs() * feat: complete default preset handling * refactor: remove user sensitive values on logout * fix: allow endpoint selection without default preset overwriting
This commit is contained in:
parent
fdb65366d7
commit
ca64efec1b
32 changed files with 681 additions and 270 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import type { TPreset } from 'librechat-data-provider';
|
||||
import { EModelEndpoint, alternateName } from 'librechat-data-provider';
|
||||
import { EModelEndpoint } from 'librechat-data-provider';
|
||||
|
||||
export const getPresetIcon = (preset: TPreset, Icon) => {
|
||||
return Icon({
|
||||
|
|
@ -13,43 +13,34 @@ export const getPresetIcon = (preset: TPreset, Icon) => {
|
|||
};
|
||||
|
||||
export const getPresetTitle = (preset: TPreset) => {
|
||||
const { endpoint } = preset;
|
||||
let _title = `${alternateName[endpoint ?? '']}`;
|
||||
const { chatGptLabel, modelLabel, model, jailbreak, toneStyle } = preset;
|
||||
const {
|
||||
endpoint,
|
||||
title: presetTitle,
|
||||
model,
|
||||
chatGptLabel,
|
||||
modelLabel,
|
||||
jailbreak,
|
||||
toneStyle,
|
||||
} = preset;
|
||||
let title = '';
|
||||
let modelInfo = model || '';
|
||||
let label = '';
|
||||
|
||||
if (endpoint === EModelEndpoint.azureOpenAI || endpoint === EModelEndpoint.openAI) {
|
||||
if (chatGptLabel) {
|
||||
_title = chatGptLabel;
|
||||
}
|
||||
if (model) {
|
||||
_title += `: ${model}`;
|
||||
}
|
||||
} else if (endpoint === EModelEndpoint.google || endpoint === EModelEndpoint.anthropic) {
|
||||
if (modelLabel) {
|
||||
_title = modelLabel;
|
||||
}
|
||||
if (model) {
|
||||
_title += `: ${model}`;
|
||||
}
|
||||
if (endpoint && [EModelEndpoint.azureOpenAI, EModelEndpoint.openAI].includes(endpoint)) {
|
||||
label = chatGptLabel || '';
|
||||
} else if (endpoint && [EModelEndpoint.google, EModelEndpoint.anthropic].includes(endpoint)) {
|
||||
label = modelLabel || '';
|
||||
} else if (endpoint === EModelEndpoint.bingAI) {
|
||||
if (jailbreak) {
|
||||
_title = 'Sydney';
|
||||
}
|
||||
if (toneStyle) {
|
||||
_title += `: ${toneStyle}`;
|
||||
}
|
||||
} else if (endpoint === EModelEndpoint.chatGPTBrowser) {
|
||||
if (model) {
|
||||
_title += `: ${model}`;
|
||||
}
|
||||
} else if (endpoint === EModelEndpoint.gptPlugins) {
|
||||
if (model) {
|
||||
_title += `: ${model}`;
|
||||
}
|
||||
} else if (endpoint === null) {
|
||||
null;
|
||||
} else {
|
||||
null;
|
||||
modelInfo = jailbreak ? 'Sydney' : modelInfo;
|
||||
label = toneStyle ? `: ${toneStyle}` : '';
|
||||
}
|
||||
return _title;
|
||||
|
||||
if (label && presetTitle && label.toLowerCase().includes(presetTitle.toLowerCase())) {
|
||||
title = label + ': ';
|
||||
label = '';
|
||||
} else if (presetTitle && presetTitle.trim() !== 'New Chat') {
|
||||
title = presetTitle + ': ';
|
||||
}
|
||||
|
||||
return `${title}${modelInfo}${label ? ` (${label})` : ''}`.trim();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue