mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
✋ feat: Stop Sequences for Conversations & Presets (#2536)
* feat: `stop` conversation parameter * feat: Tag primitive * feat: dynamic tags * refactor: update tag styling * feat: add stop sequences to OpenAI settings * fix(Presentation): prevent `SidePanel` re-renders that flicker side panel * refactor: use stop placeholder * feat: type and schema update for `stop` and `TPreset` in generation param related types * refactor: pass conversation to dynamic settings * refactor(OpenAIClient): remove default handling for `modelOptions.stop` * docs: fix Google AI Setup formatting * feat: current_model * docs: WIP update * fix(ChatRoute): prevent default preset override before `hasSetConversation.current` becomes true by including latest conversation state as template * docs: update docs with more info on `stop` * chore: bump config_version * refactor: CURRENT_MODEL handling
This commit is contained in:
parent
4121818124
commit
099aa9dead
29 changed files with 690 additions and 93 deletions
|
|
@ -283,6 +283,7 @@ export const tConversationSchema = z.object({
|
|||
instructions: z.string().optional(),
|
||||
/** Used to overwrite active conversation settings when saving a Preset */
|
||||
presetOverride: z.record(z.unknown()).optional(),
|
||||
stop: z.array(z.string()).optional(),
|
||||
});
|
||||
|
||||
export const tPresetSchema = tConversationSchema
|
||||
|
|
@ -319,7 +320,7 @@ export type TPreset = z.infer<typeof tPresetSchema>;
|
|||
|
||||
export type TSetOption = (
|
||||
param: number | string,
|
||||
) => (newValue: number | string | boolean | Partial<TPreset>) => void;
|
||||
) => (newValue: number | string | boolean | string[] | Partial<TPreset>) => void;
|
||||
|
||||
export type TConversation = z.infer<typeof tConversationSchema> & {
|
||||
presetOverride?: Partial<TPreset>;
|
||||
|
|
@ -336,6 +337,7 @@ export const openAISchema = tConversationSchema
|
|||
frequency_penalty: true,
|
||||
resendFiles: true,
|
||||
imageDetail: true,
|
||||
stop: true,
|
||||
})
|
||||
.transform((obj) => ({
|
||||
...obj,
|
||||
|
|
@ -349,6 +351,7 @@ export const openAISchema = tConversationSchema
|
|||
resendFiles:
|
||||
typeof obj.resendFiles === 'boolean' ? obj.resendFiles : openAISettings.resendFiles.default,
|
||||
imageDetail: obj.imageDetail ?? openAISettings.imageDetail.default,
|
||||
stop: obj.stop ?? undefined,
|
||||
}))
|
||||
.catch(() => ({
|
||||
model: openAISettings.model.default,
|
||||
|
|
@ -360,6 +363,7 @@ export const openAISchema = tConversationSchema
|
|||
frequency_penalty: openAISettings.frequency_penalty.default,
|
||||
resendFiles: openAISettings.resendFiles.default,
|
||||
imageDetail: openAISettings.imageDetail.default,
|
||||
stop: undefined,
|
||||
}));
|
||||
|
||||
export const googleSchema = tConversationSchema
|
||||
|
|
@ -568,6 +572,7 @@ export const compactOpenAISchema = tConversationSchema
|
|||
frequency_penalty: true,
|
||||
resendFiles: true,
|
||||
imageDetail: true,
|
||||
stop: true,
|
||||
})
|
||||
.transform((obj: Partial<TConversation>) => {
|
||||
const newObj: Partial<TConversation> = { ...obj };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue