feat: Add Ollama model settings for tfsZ, numKeep, numThread, and useMlock
This commit is contained in:
parent
0af69a3be8
commit
9674b842ef
@ -90,6 +90,21 @@
|
||||
"useMMap": {
|
||||
"label": "useMmap"
|
||||
},
|
||||
"tfsZ": {
|
||||
"label": "TFS-Z",
|
||||
"placeholder": "e.g. 1.0, 1.1"
|
||||
},
|
||||
"numKeep": {
|
||||
"label": "Num Keep",
|
||||
"placeholder": "e.g. 256, 512"
|
||||
},
|
||||
"numThread": {
|
||||
"label": "Num Thread",
|
||||
"placeholder": "e.g. 8, 16"
|
||||
},
|
||||
"useMlock": {
|
||||
"label": "useMlock"
|
||||
},
|
||||
"minP": {
|
||||
"label": "Min P",
|
||||
"placeholder": "e.g. 0.05"
|
||||
|
@ -13,9 +13,8 @@ import {
|
||||
Modal,
|
||||
Skeleton,
|
||||
Switch,
|
||||
Button
|
||||
} from "antd"
|
||||
import React, { useState, useCallback } from "react"
|
||||
import React, { useCallback } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { SaveButton } from "../SaveButton"
|
||||
|
||||
@ -79,7 +78,11 @@ export const CurrentChatModelSettings = ({
|
||||
useMMap: cUserSettings.useMMap ?? data.useMMap,
|
||||
minP: cUserSettings.minP ?? data.minP,
|
||||
repeatLastN: cUserSettings.repeatLastN ?? data.repeatLastN,
|
||||
repeatPenalty: cUserSettings.repeatPenalty ?? data.repeatPenalty
|
||||
repeatPenalty: cUserSettings.repeatPenalty ?? data.repeatPenalty,
|
||||
useMlock: cUserSettings.useMlock ?? data.useMlock,
|
||||
tfsZ: cUserSettings.tfsZ ?? data.tfsZ,
|
||||
numKeep: cUserSettings.numKeep ?? data.numKeep,
|
||||
numThread: cUserSettings.numThread ?? data.numThread
|
||||
})
|
||||
return data
|
||||
},
|
||||
@ -230,11 +233,44 @@ export const CurrentChatModelSettings = ({
|
||||
)}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="tfsZ"
|
||||
label={t("modelSettings.form.tfsZ.label")}>
|
||||
<InputNumber
|
||||
style={{ width: "100%" }}
|
||||
placeholder={t("modelSettings.form.tfsZ.placeholder")}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="numKeep"
|
||||
label={t("modelSettings.form.numKeep.label")}>
|
||||
<InputNumber
|
||||
style={{ width: "100%" }}
|
||||
placeholder={t(
|
||||
"modelSettings.form.numKeep.placeholder"
|
||||
)}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="numThread"
|
||||
label={t("modelSettings.form.numThread.label")}>
|
||||
<InputNumber
|
||||
style={{ width: "100%" }}
|
||||
placeholder={t(
|
||||
"modelSettings.form.numThread.placeholder"
|
||||
)}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="useMMap"
|
||||
label={t("modelSettings.form.useMMap.label")}>
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="useMlock"
|
||||
label={t("modelSettings.form.useMlock.label")}>
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
</React.Fragment>
|
||||
)
|
||||
}
|
||||
|
@ -150,11 +150,44 @@ export const ModelSettings = () => {
|
||||
)}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="tfsZ"
|
||||
label={t("modelSettings.form.tfsZ.label")}>
|
||||
<InputNumber
|
||||
style={{ width: "100%" }}
|
||||
placeholder={t("modelSettings.form.tfsZ.placeholder")}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="numKeep"
|
||||
label={t("modelSettings.form.numKeep.label")}>
|
||||
<InputNumber
|
||||
style={{ width: "100%" }}
|
||||
placeholder={t(
|
||||
"modelSettings.form.numKeep.placeholder"
|
||||
)}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="numThread"
|
||||
label={t("modelSettings.form.numThread.label")}>
|
||||
<InputNumber
|
||||
style={{ width: "100%" }}
|
||||
placeholder={t(
|
||||
"modelSettings.form.numThread.placeholder"
|
||||
)}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="useMMap"
|
||||
label={t("modelSettings.form.useMMap.label")}>
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="useMlock"
|
||||
label={t("modelSettings.form.useMlock.label")}>
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
</React.Fragment>
|
||||
)
|
||||
}
|
||||
|
@ -150,7 +150,15 @@ export const useMessage = () => {
|
||||
userDefaultModelSettings?.repeatLastN,
|
||||
repeatPenalty:
|
||||
currentChatModelSettings?.repeatPenalty ??
|
||||
userDefaultModelSettings?.repeatPenalty
|
||||
userDefaultModelSettings?.repeatPenalty,
|
||||
tfsZ: currentChatModelSettings?.tfsZ ?? userDefaultModelSettings?.tfsZ,
|
||||
numKeep:
|
||||
currentChatModelSettings?.numKeep ?? userDefaultModelSettings?.numKeep,
|
||||
numThread:
|
||||
currentChatModelSettings?.numThread ??
|
||||
userDefaultModelSettings?.numThread,
|
||||
useMlock:
|
||||
currentChatModelSettings?.useMlock ?? userDefaultModelSettings?.useMlock
|
||||
})
|
||||
|
||||
let newMessage: Message[] = []
|
||||
@ -293,7 +301,18 @@ export const useMessage = () => {
|
||||
userDefaultModelSettings?.repeatLastN,
|
||||
repeatPenalty:
|
||||
currentChatModelSettings?.repeatPenalty ??
|
||||
userDefaultModelSettings?.repeatPenalty
|
||||
userDefaultModelSettings?.repeatPenalty,
|
||||
tfsZ:
|
||||
currentChatModelSettings?.tfsZ ?? userDefaultModelSettings?.tfsZ,
|
||||
numKeep:
|
||||
currentChatModelSettings?.numKeep ??
|
||||
userDefaultModelSettings?.numKeep,
|
||||
numThread:
|
||||
currentChatModelSettings?.numThread ??
|
||||
userDefaultModelSettings?.numThread,
|
||||
useMlock:
|
||||
currentChatModelSettings?.useMlock ??
|
||||
userDefaultModelSettings?.useMlock
|
||||
})
|
||||
const response = await questionOllama.invoke(promptForQuestion)
|
||||
query = response.content.toString()
|
||||
@ -514,7 +533,15 @@ export const useMessage = () => {
|
||||
userDefaultModelSettings?.repeatLastN,
|
||||
repeatPenalty:
|
||||
currentChatModelSettings?.repeatPenalty ??
|
||||
userDefaultModelSettings?.repeatPenalty
|
||||
userDefaultModelSettings?.repeatPenalty,
|
||||
tfsZ: currentChatModelSettings?.tfsZ ?? userDefaultModelSettings?.tfsZ,
|
||||
numKeep:
|
||||
currentChatModelSettings?.numKeep ?? userDefaultModelSettings?.numKeep,
|
||||
numThread:
|
||||
currentChatModelSettings?.numThread ??
|
||||
userDefaultModelSettings?.numThread,
|
||||
useMlock:
|
||||
currentChatModelSettings?.useMlock ?? userDefaultModelSettings?.useMlock
|
||||
})
|
||||
|
||||
let newMessage: Message[] = []
|
||||
@ -758,7 +785,15 @@ export const useMessage = () => {
|
||||
userDefaultModelSettings?.repeatLastN,
|
||||
repeatPenalty:
|
||||
currentChatModelSettings?.repeatPenalty ??
|
||||
userDefaultModelSettings?.repeatPenalty
|
||||
userDefaultModelSettings?.repeatPenalty,
|
||||
tfsZ: currentChatModelSettings?.tfsZ ?? userDefaultModelSettings?.tfsZ,
|
||||
numKeep:
|
||||
currentChatModelSettings?.numKeep ?? userDefaultModelSettings?.numKeep,
|
||||
numThread:
|
||||
currentChatModelSettings?.numThread ??
|
||||
userDefaultModelSettings?.numThread,
|
||||
useMlock:
|
||||
currentChatModelSettings?.useMlock ?? userDefaultModelSettings?.useMlock
|
||||
})
|
||||
|
||||
let newMessage: Message[] = []
|
||||
@ -997,7 +1032,15 @@ export const useMessage = () => {
|
||||
userDefaultModelSettings?.repeatLastN,
|
||||
repeatPenalty:
|
||||
currentChatModelSettings?.repeatPenalty ??
|
||||
userDefaultModelSettings?.repeatPenalty
|
||||
userDefaultModelSettings?.repeatPenalty,
|
||||
tfsZ: currentChatModelSettings?.tfsZ ?? userDefaultModelSettings?.tfsZ,
|
||||
numKeep:
|
||||
currentChatModelSettings?.numKeep ?? userDefaultModelSettings?.numKeep,
|
||||
numThread:
|
||||
currentChatModelSettings?.numThread ??
|
||||
userDefaultModelSettings?.numThread,
|
||||
useMlock:
|
||||
currentChatModelSettings?.useMlock ?? userDefaultModelSettings?.useMlock
|
||||
})
|
||||
|
||||
let newMessage: Message[] = []
|
||||
@ -1087,7 +1130,18 @@ export const useMessage = () => {
|
||||
userDefaultModelSettings?.repeatLastN,
|
||||
repeatPenalty:
|
||||
currentChatModelSettings?.repeatPenalty ??
|
||||
userDefaultModelSettings?.repeatPenalty
|
||||
userDefaultModelSettings?.repeatPenalty,
|
||||
tfsZ:
|
||||
currentChatModelSettings?.tfsZ ?? userDefaultModelSettings?.tfsZ,
|
||||
numKeep:
|
||||
currentChatModelSettings?.numKeep ??
|
||||
userDefaultModelSettings?.numKeep,
|
||||
numThread:
|
||||
currentChatModelSettings?.numThread ??
|
||||
userDefaultModelSettings?.numThread,
|
||||
useMlock:
|
||||
currentChatModelSettings?.useMlock ??
|
||||
userDefaultModelSettings?.useMlock
|
||||
})
|
||||
const response = await questionOllama.invoke(promptForQuestion)
|
||||
query = response.content.toString()
|
||||
@ -1286,7 +1340,15 @@ export const useMessage = () => {
|
||||
userDefaultModelSettings?.repeatLastN,
|
||||
repeatPenalty:
|
||||
currentChatModelSettings?.repeatPenalty ??
|
||||
userDefaultModelSettings?.repeatPenalty
|
||||
userDefaultModelSettings?.repeatPenalty,
|
||||
tfsZ: currentChatModelSettings?.tfsZ ?? userDefaultModelSettings?.tfsZ,
|
||||
numKeep:
|
||||
currentChatModelSettings?.numKeep ?? userDefaultModelSettings?.numKeep,
|
||||
numThread:
|
||||
currentChatModelSettings?.numThread ??
|
||||
userDefaultModelSettings?.numThread,
|
||||
useMlock:
|
||||
currentChatModelSettings?.useMlock ?? userDefaultModelSettings?.useMlock
|
||||
})
|
||||
|
||||
let newMessage: Message[] = []
|
||||
|
@ -141,7 +141,15 @@ export const useMessageOption = () => {
|
||||
userDefaultModelSettings?.repeatLastN,
|
||||
repeatPenalty:
|
||||
currentChatModelSettings?.repeatPenalty ??
|
||||
userDefaultModelSettings?.repeatPenalty
|
||||
userDefaultModelSettings?.repeatPenalty,
|
||||
tfsZ: currentChatModelSettings?.tfsZ ?? userDefaultModelSettings?.tfsZ,
|
||||
numKeep:
|
||||
currentChatModelSettings?.numKeep ?? userDefaultModelSettings?.numKeep,
|
||||
numThread:
|
||||
currentChatModelSettings?.numThread ??
|
||||
userDefaultModelSettings?.numThread,
|
||||
useMlock:
|
||||
currentChatModelSettings?.useMlock ?? userDefaultModelSettings?.useMlock
|
||||
})
|
||||
|
||||
let newMessage: Message[] = []
|
||||
@ -231,7 +239,18 @@ export const useMessageOption = () => {
|
||||
userDefaultModelSettings?.repeatLastN,
|
||||
repeatPenalty:
|
||||
currentChatModelSettings?.repeatPenalty ??
|
||||
userDefaultModelSettings?.repeatPenalty
|
||||
userDefaultModelSettings?.repeatPenalty,
|
||||
tfsZ:
|
||||
currentChatModelSettings?.tfsZ ?? userDefaultModelSettings?.tfsZ,
|
||||
numKeep:
|
||||
currentChatModelSettings?.numKeep ??
|
||||
userDefaultModelSettings?.numKeep,
|
||||
numThread:
|
||||
currentChatModelSettings?.numThread ??
|
||||
userDefaultModelSettings?.numThread,
|
||||
useMlock:
|
||||
currentChatModelSettings?.useMlock ??
|
||||
userDefaultModelSettings?.useMlock
|
||||
})
|
||||
const response = await questionOllama.invoke(promptForQuestion)
|
||||
query = response.content.toString()
|
||||
@ -464,7 +483,15 @@ export const useMessageOption = () => {
|
||||
userDefaultModelSettings?.repeatLastN,
|
||||
repeatPenalty:
|
||||
currentChatModelSettings?.repeatPenalty ??
|
||||
userDefaultModelSettings?.repeatPenalty
|
||||
userDefaultModelSettings?.repeatPenalty,
|
||||
tfsZ: currentChatModelSettings?.tfsZ ?? userDefaultModelSettings?.tfsZ,
|
||||
numKeep:
|
||||
currentChatModelSettings?.numKeep ?? userDefaultModelSettings?.numKeep,
|
||||
numThread:
|
||||
currentChatModelSettings?.numThread ??
|
||||
userDefaultModelSettings?.numThread,
|
||||
useMlock:
|
||||
currentChatModelSettings?.useMlock ?? userDefaultModelSettings?.useMlock
|
||||
})
|
||||
|
||||
let newMessage: Message[] = []
|
||||
@ -719,7 +746,15 @@ export const useMessageOption = () => {
|
||||
userDefaultModelSettings?.repeatLastN,
|
||||
repeatPenalty:
|
||||
currentChatModelSettings?.repeatPenalty ??
|
||||
userDefaultModelSettings?.repeatPenalty
|
||||
userDefaultModelSettings?.repeatPenalty,
|
||||
tfsZ: currentChatModelSettings?.tfsZ ?? userDefaultModelSettings?.tfsZ,
|
||||
numKeep:
|
||||
currentChatModelSettings?.numKeep ?? userDefaultModelSettings?.numKeep,
|
||||
numThread:
|
||||
currentChatModelSettings?.numThread ??
|
||||
userDefaultModelSettings?.numThread,
|
||||
useMlock:
|
||||
currentChatModelSettings?.useMlock ?? userDefaultModelSettings?.useMlock
|
||||
})
|
||||
|
||||
let newMessage: Message[] = []
|
||||
@ -825,7 +860,18 @@ export const useMessageOption = () => {
|
||||
userDefaultModelSettings?.repeatLastN,
|
||||
repeatPenalty:
|
||||
currentChatModelSettings?.repeatPenalty ??
|
||||
userDefaultModelSettings?.repeatPenalty
|
||||
userDefaultModelSettings?.repeatPenalty,
|
||||
tfsZ:
|
||||
currentChatModelSettings?.tfsZ ?? userDefaultModelSettings?.tfsZ,
|
||||
numKeep:
|
||||
currentChatModelSettings?.numKeep ??
|
||||
userDefaultModelSettings?.numKeep,
|
||||
numThread:
|
||||
currentChatModelSettings?.numThread ??
|
||||
userDefaultModelSettings?.numThread,
|
||||
useMlock:
|
||||
currentChatModelSettings?.useMlock ??
|
||||
userDefaultModelSettings?.useMlock
|
||||
})
|
||||
const response = await questionOllama.invoke(promptForQuestion)
|
||||
query = response.content.toString()
|
||||
|
@ -103,6 +103,8 @@ export class ChatOllama
|
||||
|
||||
useMMap?: boolean;
|
||||
|
||||
useMlock?: boolean;
|
||||
|
||||
vocabOnly?: boolean;
|
||||
|
||||
seed?: number;
|
||||
@ -148,6 +150,7 @@ export class ChatOllama
|
||||
this.typicalP = fields.typicalP;
|
||||
this.useMLock = fields.useMLock;
|
||||
this.useMMap = fields.useMMap;
|
||||
this.useMlock = fields.useMlock;
|
||||
this.vocabOnly = fields.vocabOnly;
|
||||
this.format = fields.format;
|
||||
this.seed = fields.seed;
|
||||
@ -210,7 +213,7 @@ export class ChatOllama
|
||||
top_p: this.topP,
|
||||
min_p: this.minP,
|
||||
typical_p: this.typicalP,
|
||||
use_mlock: this.useMLock,
|
||||
use_mlock: this.useMlock,
|
||||
use_mmap: this.useMMap,
|
||||
vocab_only: this.vocabOnly,
|
||||
seed: this.seed,
|
||||
|
@ -20,7 +20,11 @@ export const pageAssistModel = async ({
|
||||
useMMap,
|
||||
minP,
|
||||
repeatLastN,
|
||||
repeatPenalty
|
||||
repeatPenalty,
|
||||
tfsZ,
|
||||
numKeep,
|
||||
numThread,
|
||||
useMlock,
|
||||
}: {
|
||||
model: string
|
||||
baseUrl: string
|
||||
@ -36,6 +40,10 @@ export const pageAssistModel = async ({
|
||||
minP?: number
|
||||
repeatPenalty?: number
|
||||
repeatLastN?: number
|
||||
tfsZ?: number,
|
||||
numKeep?: number,
|
||||
numThread?: number,
|
||||
useMlock?: boolean,
|
||||
}) => {
|
||||
if (model === "chrome::gemini-nano::page-assist") {
|
||||
return new ChatChromeAI({
|
||||
@ -80,7 +88,7 @@ export const pageAssistModel = async ({
|
||||
}
|
||||
}) as any
|
||||
}
|
||||
|
||||
console.log('useMlock', useMlock)
|
||||
return new ChatOllama({
|
||||
baseUrl,
|
||||
keepAlive,
|
||||
@ -96,5 +104,9 @@ export const pageAssistModel = async ({
|
||||
minP: minP,
|
||||
repeatPenalty: repeatPenalty,
|
||||
repeatLastN: repeatLastN,
|
||||
tfsZ,
|
||||
numKeep,
|
||||
numThread,
|
||||
useMlock
|
||||
})
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ export interface OllamaInput {
|
||||
useMLock?: boolean
|
||||
useMMap?: boolean
|
||||
vocabOnly?: boolean
|
||||
useMlock?: boolean
|
||||
seed?: number
|
||||
format?: StringWithAutocomplete<"json">
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ type ModelSettings = {
|
||||
useMMap?: boolean
|
||||
vocabOnly?: boolean
|
||||
minP?: number
|
||||
useMlock?: boolean
|
||||
}
|
||||
|
||||
const keys = [
|
||||
@ -65,6 +66,7 @@ const keys = [
|
||||
"useMMap",
|
||||
"vocabOnly",
|
||||
"minP",
|
||||
"useMlock"
|
||||
]
|
||||
|
||||
export const getAllModelSettings = async () => {
|
||||
|
@ -66,6 +66,8 @@ type CurrentChatModelSettings = {
|
||||
reset: () => void
|
||||
systemPrompt?: string
|
||||
setSystemPrompt: (systemPrompt: string) => void
|
||||
useMlock?: boolean
|
||||
setUseMlock: (useMlock: boolean) => void
|
||||
|
||||
setMinP: (minP: number) => void
|
||||
}
|
||||
@ -108,6 +110,7 @@ export const useStoreChatModelSettings = create<CurrentChatModelSettings>(
|
||||
systemPrompt: undefined,
|
||||
setMinP: (minP: number) => set({ minP }),
|
||||
setSystemPrompt: (systemPrompt: string) => set({ systemPrompt }),
|
||||
setUseMlock: (useMlock: boolean) => set({ useMlock }),
|
||||
reset: () =>
|
||||
set({
|
||||
f16KV: undefined,
|
||||
@ -141,6 +144,7 @@ export const useStoreChatModelSettings = create<CurrentChatModelSettings>(
|
||||
seed: undefined,
|
||||
systemPrompt: undefined,
|
||||
minP: undefined,
|
||||
useMlock: undefined,
|
||||
})
|
||||
})
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user