refactor into getBaseSystemMessage
This commit is contained in:
parent
ce213a9c1b
commit
924147c928
4 changed files with 20 additions and 18 deletions
|
|
@ -18,6 +18,7 @@ import {
|
|||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../../../../redux/slices/uiSlice";
|
||||
import { getBaseSystemMessage } from "../../../../util";
|
||||
import HeaderButtonWithToolTip from "../../../gui/HeaderButtonWithToolTip";
|
||||
import { useFontSize } from "../../../ui/font";
|
||||
import { ExploreBlocksButton } from "./ExploreBlocksButton";
|
||||
|
|
@ -182,12 +183,7 @@ export function RulesSection() {
|
|||
}
|
||||
// Add a displayed rule for the base system chat message when in chat mode
|
||||
if (mode === "chat" || mode === "agent") {
|
||||
let baseMessage:string | undefined;
|
||||
if(mode === 'agent') {
|
||||
baseMessage = config.selectedModelByRole.chat?.baseAgentSystemMessage ?? config.selectedModelByRole.chat?.baseChatSystemMessage
|
||||
} else {
|
||||
baseMessage = config.selectedModelByRole.chat?.baseChatSystemMessage
|
||||
}
|
||||
const baseMessage = getBaseSystemMessage(config.selectedModelByRole.chat, mode)
|
||||
if (baseMessage) {
|
||||
rules.unshift({
|
||||
rule: baseMessage,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { InputModifiers } from "core";
|
|||
import { constructMessages } from "core/llm/constructMessages";
|
||||
import posthog from "posthog-js";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { getBaseSystemMessage } from "../../util";
|
||||
import { selectSelectedChatModel } from "../slices/configSlice";
|
||||
import {
|
||||
submitEditorAndInitAtIndex,
|
||||
|
|
@ -87,12 +88,7 @@ export const streamResponseThunk = createAsyncThunk<
|
|||
const updatedHistory = getState().session.history;
|
||||
const messageMode = getState().session.mode
|
||||
|
||||
let baseChatOrAgentSystemMessage: string|undefined
|
||||
if(messageMode === 'agent') {
|
||||
baseChatOrAgentSystemMessage = selectedChatModel?.baseAgentSystemMessage ?? selectedChatModel?.baseChatSystemMessage // fallback to chat system message if agent system message is unavailable
|
||||
} else {
|
||||
baseChatOrAgentSystemMessage = selectedChatModel.baseChatSystemMessage
|
||||
}
|
||||
const baseChatOrAgentSystemMessage = getBaseSystemMessage(selectedChatModel, messageMode)
|
||||
|
||||
const messages = constructMessages(
|
||||
[...updatedHistory],
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { createAsyncThunk, unwrapResult } from "@reduxjs/toolkit";
|
|||
import { ChatMessage } from "core";
|
||||
import { constructMessages } from "core/llm/constructMessages";
|
||||
import { renderContextItems } from "core/util/messageContent";
|
||||
import { getBaseSystemMessage } from "../../util";
|
||||
import { selectSelectedChatModel } from "../slices/configSlice";
|
||||
import {
|
||||
addContextItemsAtIndex,
|
||||
|
|
@ -68,12 +69,7 @@ export const streamResponseAfterToolCall = createAsyncThunk<
|
|||
const updatedHistory = getState().session.history;
|
||||
const messageMode = getState().session.mode
|
||||
|
||||
let baseChatOrAgentSystemMessage: string|undefined
|
||||
if(messageMode === 'agent') {
|
||||
baseChatOrAgentSystemMessage = selectedChatModel?.baseAgentSystemMessage ?? selectedChatModel?.baseChatSystemMessage // fallback to chat system message if agent system message is unavailable
|
||||
} else {
|
||||
baseChatOrAgentSystemMessage = selectedChatModel.baseChatSystemMessage
|
||||
}
|
||||
const baseChatOrAgentSystemMessage = getBaseSystemMessage(selectedChatModel, messageMode)
|
||||
|
||||
const messages = constructMessages(
|
||||
[...updatedHistory],
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { MessageModes, ModelDescription } from "core";
|
||||
import { ProfileDescription } from "core/config/ProfileLifecycleManager";
|
||||
import _ from "lodash";
|
||||
import { KeyboardEvent } from "react";
|
||||
|
|
@ -114,3 +115,16 @@ export function updatedObj(old: any, pathToValue: { [key: string]: any }) {
|
|||
export function isLocalProfile(profile: ProfileDescription): boolean {
|
||||
return profile.profileType === "local";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the base system message for the agent or chat mode from the model description.
|
||||
*/
|
||||
export function getBaseSystemMessage(modelDetails: ModelDescription | null, mode: MessageModes) {
|
||||
let baseChatOrAgentSystemMessage: string|undefined
|
||||
if(mode === 'agent') {
|
||||
baseChatOrAgentSystemMessage = modelDetails?.baseAgentSystemMessage ?? modelDetails?.baseChatSystemMessage // fallback to chat system message if agent system message is unavailable
|
||||
} else {
|
||||
baseChatOrAgentSystemMessage = modelDetails?.baseChatSystemMessage
|
||||
}
|
||||
return baseChatOrAgentSystemMessage
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue