feat(settings): Use selected system prompt in current chat model temp system fallback
Adds support for using the currently selected system prompt in the current model settings. This allows users to fine-tune their chat experience based on their preferred prompt.
This commit is contained in:
parent
88d0cb68ae
commit
8fbdfc35d3
@ -1,3 +1,5 @@
|
|||||||
|
import { getPromptById } from "@/db"
|
||||||
|
import { useMessageOption } from "@/hooks/useMessageOption"
|
||||||
import { getAllModelSettings } from "@/services/model-settings"
|
import { getAllModelSettings } from "@/services/model-settings"
|
||||||
import { useStoreChatModelSettings } from "@/store/model"
|
import { useStoreChatModelSettings } from "@/store/model"
|
||||||
import { useQuery } from "@tanstack/react-query"
|
import { useQuery } from "@tanstack/react-query"
|
||||||
@ -27,10 +29,20 @@ export const CurrentChatModelSettings = ({
|
|||||||
const { t } = useTranslation("common")
|
const { t } = useTranslation("common")
|
||||||
const [form] = Form.useForm()
|
const [form] = Form.useForm()
|
||||||
const cUserSettings = useStoreChatModelSettings()
|
const cUserSettings = useStoreChatModelSettings()
|
||||||
|
const { selectedSystemPrompt } = useMessageOption()
|
||||||
const { isPending: isLoading } = useQuery({
|
const { isPending: isLoading } = useQuery({
|
||||||
queryKey: ["fetchModelConfig2", open],
|
queryKey: ["fetchModelConfig2", open],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const data = await getAllModelSettings()
|
const data = await getAllModelSettings()
|
||||||
|
|
||||||
|
let tempSystemPrompt = "";
|
||||||
|
|
||||||
|
// i hate this method but i need this feature so badly that i need to do this
|
||||||
|
if (selectedSystemPrompt) {
|
||||||
|
const prompt = await getPromptById(selectedSystemPrompt)
|
||||||
|
tempSystemPrompt = prompt?.content ?? ""
|
||||||
|
}
|
||||||
|
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
temperature: cUserSettings.temperature ?? data.temperature,
|
temperature: cUserSettings.temperature ?? data.temperature,
|
||||||
topK: cUserSettings.topK ?? data.topK,
|
topK: cUserSettings.topK ?? data.topK,
|
||||||
@ -40,7 +52,7 @@ export const CurrentChatModelSettings = ({
|
|||||||
seed: cUserSettings.seed,
|
seed: cUserSettings.seed,
|
||||||
numGpu: cUserSettings.numGpu ?? data.numGpu,
|
numGpu: cUserSettings.numGpu ?? data.numGpu,
|
||||||
numPredict: cUserSettings.numPredict ?? data.numPredict,
|
numPredict: cUserSettings.numPredict ?? data.numPredict,
|
||||||
systemPrompt: cUserSettings.systemPrompt ?? ""
|
systemPrompt: cUserSettings.systemPrompt ?? tempSystemPrompt
|
||||||
})
|
})
|
||||||
return data
|
return data
|
||||||
},
|
},
|
||||||
@ -49,6 +61,7 @@ export const CurrentChatModelSettings = ({
|
|||||||
refetchOnWindowFocus: false
|
refetchOnWindowFocus: false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
const renderBody = () => {
|
const renderBody = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user