Merge branch 'main' into Ssstars-patch-2
This commit is contained in:
commit
2e31e52607
@ -1,6 +1,11 @@
|
|||||||
import { useCallback, useEffect, useState } from 'react'
|
import { useCallback, useEffect, useState } from 'react'
|
||||||
|
|
||||||
import { InferenceEngine, Model } from '@janhq/core'
|
import {
|
||||||
|
InferenceEngine,
|
||||||
|
Model,
|
||||||
|
ModelRuntimeParams,
|
||||||
|
ModelSettingParams,
|
||||||
|
} from '@janhq/core'
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Select,
|
Select,
|
||||||
@ -29,6 +34,7 @@ import useRecommendedModel from '@/hooks/useRecommendedModel'
|
|||||||
import { toGibibytes } from '@/utils/converter'
|
import { toGibibytes } from '@/utils/converter'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
ModelParams,
|
||||||
activeThreadAtom,
|
activeThreadAtom,
|
||||||
getActiveThreadIdAtom,
|
getActiveThreadIdAtom,
|
||||||
setThreadModelParamsAtom,
|
setThreadModelParamsAtom,
|
||||||
@ -59,6 +65,15 @@ export default function DropdownListSidebar() {
|
|||||||
|
|
||||||
const { recommendedModel, downloadedModels } = useRecommendedModel()
|
const { recommendedModel, downloadedModels } = useRecommendedModel()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default value for max_tokens and ctx_len
|
||||||
|
* Its to avoid OOM issue since a model can set a big number for these settings
|
||||||
|
*/
|
||||||
|
const defaultValue = (value?: number) => {
|
||||||
|
if (value && value < 4096) return value
|
||||||
|
return 4096
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSelected(recommendedModel)
|
setSelected(recommendedModel)
|
||||||
setSelectedModel(recommendedModel)
|
setSelectedModel(recommendedModel)
|
||||||
@ -66,9 +81,12 @@ export default function DropdownListSidebar() {
|
|||||||
if (activeThread) {
|
if (activeThread) {
|
||||||
const finishInit = threadStates[activeThread.id].isFinishInit ?? true
|
const finishInit = threadStates[activeThread.id].isFinishInit ?? true
|
||||||
if (finishInit) return
|
if (finishInit) return
|
||||||
const modelParams = {
|
const modelParams: ModelParams = {
|
||||||
...recommendedModel?.parameters,
|
...recommendedModel?.parameters,
|
||||||
...recommendedModel?.settings,
|
...recommendedModel?.settings,
|
||||||
|
// This is to set default value for these settings instead of maximum value
|
||||||
|
max_tokens: defaultValue(recommendedModel?.parameters.max_tokens),
|
||||||
|
ctx_len: defaultValue(recommendedModel?.settings.ctx_len),
|
||||||
}
|
}
|
||||||
setThreadModelParams(activeThread.id, modelParams)
|
setThreadModelParams(activeThread.id, modelParams)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,11 +12,6 @@ export const getConfigurationsData = (
|
|||||||
) => {
|
) => {
|
||||||
const componentData: SettingComponentData[] = []
|
const componentData: SettingComponentData[] = []
|
||||||
|
|
||||||
const defaultValue = (value?: number) => {
|
|
||||||
if (value && value < 4096) return value
|
|
||||||
return 4096
|
|
||||||
}
|
|
||||||
|
|
||||||
Object.keys(settings).forEach((key: string) => {
|
Object.keys(settings).forEach((key: string) => {
|
||||||
const componentSetting = presetConfiguration[key]
|
const componentSetting = presetConfiguration[key]
|
||||||
|
|
||||||
@ -32,16 +27,10 @@ export const getConfigurationsData = (
|
|||||||
case 'max_tokens':
|
case 'max_tokens':
|
||||||
componentSetting.controllerData.max =
|
componentSetting.controllerData.max =
|
||||||
selectedModel?.parameters.max_tokens || 4096
|
selectedModel?.parameters.max_tokens || 4096
|
||||||
componentSetting.controllerData.value = defaultValue(
|
|
||||||
selectedModel?.parameters.max_tokens
|
|
||||||
)
|
|
||||||
break
|
break
|
||||||
case 'ctx_len':
|
case 'ctx_len':
|
||||||
componentSetting.controllerData.max =
|
componentSetting.controllerData.max =
|
||||||
selectedModel?.settings.ctx_len || 4096
|
selectedModel?.settings.ctx_len || 4096
|
||||||
componentSetting.controllerData.value = defaultValue(
|
|
||||||
selectedModel?.settings.ctx_len
|
|
||||||
)
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user