mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
🔄 fix: o-Series Model Regex for System Messages (#7245)
* fix: no system message only for o1-preview and o1-mini * chore(OpenAIClient): linting * fix: update regex to include o1-preview and o1-mini in noSystemModelRegex * refactor: rename variable for consistency with AgentClient --------- Co-authored-by: Andres <9771158+andresgit@users.noreply.github.com>
This commit is contained in:
parent
fc6e14efe2
commit
4fbb81c774
2 changed files with 8 additions and 6 deletions
|
|
@ -475,7 +475,9 @@ class OpenAIClient extends BaseClient {
|
||||||
promptPrefix = this.augmentedPrompt + promptPrefix;
|
promptPrefix = this.augmentedPrompt + promptPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (promptPrefix && this.isOmni !== true) {
|
const noSystemModelRegex = /\b(o1-preview|o1-mini)\b/i.test(this.modelOptions.model);
|
||||||
|
|
||||||
|
if (promptPrefix && !noSystemModelRegex) {
|
||||||
promptPrefix = `Instructions:\n${promptPrefix.trim()}`;
|
promptPrefix = `Instructions:\n${promptPrefix.trim()}`;
|
||||||
instructions = {
|
instructions = {
|
||||||
role: 'system',
|
role: 'system',
|
||||||
|
|
@ -503,7 +505,7 @@ class OpenAIClient extends BaseClient {
|
||||||
};
|
};
|
||||||
|
|
||||||
/** EXPERIMENTAL */
|
/** EXPERIMENTAL */
|
||||||
if (promptPrefix && this.isOmni === true) {
|
if (promptPrefix && noSystemModelRegex) {
|
||||||
const lastUserMessageIndex = payload.findLastIndex((message) => message.role === 'user');
|
const lastUserMessageIndex = payload.findLastIndex((message) => message.role === 'user');
|
||||||
if (lastUserMessageIndex !== -1) {
|
if (lastUserMessageIndex !== -1) {
|
||||||
if (Array.isArray(payload[lastUserMessageIndex].content)) {
|
if (Array.isArray(payload[lastUserMessageIndex].content)) {
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ const payloadParser = ({ req, agent, endpoint }) => {
|
||||||
|
|
||||||
const legacyContentEndpoints = new Set([KnownEndpoints.groq, KnownEndpoints.deepseek]);
|
const legacyContentEndpoints = new Set([KnownEndpoints.groq, KnownEndpoints.deepseek]);
|
||||||
|
|
||||||
const noSystemModelRegex = [/\b(o1)\b/gi];
|
const noSystemModelRegex = [/\b(o1-preview|o1-mini)\b/gi];
|
||||||
|
|
||||||
// const { processMemory, memoryInstructions } = require('~/server/services/Endpoints/agents/memory');
|
// const { processMemory, memoryInstructions } = require('~/server/services/Endpoints/agents/memory');
|
||||||
// const { getFormattedMemories } = require('~/models/Memory');
|
// const { getFormattedMemories } = require('~/models/Memory');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue