fix: override cpu_threads setting from model.json (#2789)
This commit is contained in:
parent
e54e7c04b3
commit
da161cd159
@ -63,11 +63,11 @@ const runModel = async (modelId: string, settingParams?: ModelSettingParams): Pr
|
|||||||
|
|
||||||
const nitroResourceProbe = await getSystemResourceInfo()
|
const nitroResourceProbe = await getSystemResourceInfo()
|
||||||
const nitroModelSettings: NitroModelSettings = {
|
const nitroModelSettings: NitroModelSettings = {
|
||||||
|
// This is critical and requires real CPU physical core count (or performance core)
|
||||||
|
cpu_threads: Math.max(1, nitroResourceProbe.numCpuPhysicalCore),
|
||||||
...modelMetadata.settings,
|
...modelMetadata.settings,
|
||||||
...settingParams,
|
...settingParams,
|
||||||
llama_model_path: modelBinaryPath,
|
llama_model_path: modelBinaryPath,
|
||||||
// This is critical and requires real CPU physical core count (or performance core)
|
|
||||||
cpu_threads: Math.max(1, nitroResourceProbe.numCpuPhysicalCore),
|
|
||||||
...(modelMetadata.settings.mmproj && {
|
...(modelMetadata.settings.mmproj && {
|
||||||
mmproj: join(modelFolderFullPath, modelMetadata.settings.mmproj),
|
mmproj: join(modelFolderFullPath, modelMetadata.settings.mmproj),
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -15,6 +15,8 @@ export const readEmbeddingEngine = (engineName: string) => {
|
|||||||
const settingDirectoryPath = path.join(
|
const settingDirectoryPath = path.join(
|
||||||
getJanDataFolderPath(),
|
getJanDataFolderPath(),
|
||||||
'settings',
|
'settings',
|
||||||
|
'@janhq',
|
||||||
|
// TODO: James - To be removed
|
||||||
engineName === 'openai'
|
engineName === 'openai'
|
||||||
? 'inference-openai-extension'
|
? 'inference-openai-extension'
|
||||||
: 'inference-groq-extension',
|
: 'inference-groq-extension',
|
||||||
|
|||||||
@ -131,10 +131,11 @@ async function loadModel(
|
|||||||
if (!llama_model_path) return Promise.reject('No GGUF model file found')
|
if (!llama_model_path) return Promise.reject('No GGUF model file found')
|
||||||
|
|
||||||
currentSettings = {
|
currentSettings = {
|
||||||
|
cpu_threads: Math.max(1, nitroResourceProbe.numCpuPhysicalCore),
|
||||||
|
// model.settings can override the default settings
|
||||||
...params.model.settings,
|
...params.model.settings,
|
||||||
llama_model_path,
|
llama_model_path,
|
||||||
// This is critical and requires real CPU physical core count (or performance core)
|
// This is critical and requires real CPU physical core count (or performance core)
|
||||||
cpu_threads: Math.max(1, nitroResourceProbe.numCpuPhysicalCore),
|
|
||||||
...(params.model.settings.mmproj && {
|
...(params.model.settings.mmproj && {
|
||||||
mmproj: path.isAbsolute(params.model.settings.mmproj)
|
mmproj: path.isAbsolute(params.model.settings.mmproj)
|
||||||
? params.model.settings.mmproj
|
? params.model.settings.mmproj
|
||||||
|
|||||||
@ -67,54 +67,54 @@ export class FileLogger extends Logger {
|
|||||||
const size = maxFileSizeBytes ?? 1 * 1024 * 1024 // 1 MB
|
const size = maxFileSizeBytes ?? 1 * 1024 * 1024 // 1 MB
|
||||||
const days = daysToKeep ?? 7 // 7 days
|
const days = daysToKeep ?? 7 // 7 days
|
||||||
const logDirectory = path.join(getJanDataFolderPath(), 'logs')
|
const logDirectory = path.join(getJanDataFolderPath(), 'logs')
|
||||||
|
|
||||||
// Perform log cleaning
|
// Perform log cleaning
|
||||||
const currentDate = new Date()
|
const currentDate = new Date()
|
||||||
fs.readdir(logDirectory, (err, files) => {
|
if (fs.existsSync(logDirectory))
|
||||||
if (err) {
|
fs.readdir(logDirectory, (err, files) => {
|
||||||
console.error('Error reading log directory:', err)
|
if (err) {
|
||||||
return
|
console.error('Error reading log directory:', err)
|
||||||
}
|
return
|
||||||
|
}
|
||||||
|
|
||||||
files.forEach((file) => {
|
files.forEach((file) => {
|
||||||
const filePath = path.join(logDirectory, file)
|
const filePath = path.join(logDirectory, file)
|
||||||
fs.stat(filePath, (err, stats) => {
|
fs.stat(filePath, (err, stats) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error('Error getting file stats:', err)
|
console.error('Error getting file stats:', err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check size
|
// Check size
|
||||||
if (stats.size > size) {
|
if (stats.size > size) {
|
||||||
fs.unlink(filePath, (err) => {
|
|
||||||
if (err) {
|
|
||||||
console.error('Error deleting log file:', err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
console.debug(
|
|
||||||
`Deleted log file due to exceeding size limit: ${filePath}`
|
|
||||||
)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
// Check age
|
|
||||||
const creationDate = new Date(stats.ctime)
|
|
||||||
const daysDifference = Math.floor(
|
|
||||||
(currentDate.getTime() - creationDate.getTime()) /
|
|
||||||
(1000 * 3600 * 24)
|
|
||||||
)
|
|
||||||
if (daysDifference > days) {
|
|
||||||
fs.unlink(filePath, (err) => {
|
fs.unlink(filePath, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error('Error deleting log file:', err)
|
console.error('Error deleting log file:', err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.debug(`Deleted old log file: ${filePath}`)
|
console.debug(
|
||||||
|
`Deleted log file due to exceeding size limit: ${filePath}`
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
// Check age
|
||||||
|
const creationDate = new Date(stats.ctime)
|
||||||
|
const daysDifference = Math.floor(
|
||||||
|
(currentDate.getTime() - creationDate.getTime()) /
|
||||||
|
(1000 * 3600 * 24)
|
||||||
|
)
|
||||||
|
if (daysDifference > days) {
|
||||||
|
fs.unlink(filePath, (err) => {
|
||||||
|
if (err) {
|
||||||
|
console.error('Error deleting log file:', err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
console.debug(`Deleted old log file: ${filePath}`)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
// Schedule the next execution with doubled delays
|
// Schedule the next execution with doubled delays
|
||||||
this.timeout = setTimeout(
|
this.timeout = setTimeout(
|
||||||
|
|||||||
@ -97,7 +97,7 @@ const ServerLogs = (props: ServerLogsProps) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="overflow-hidden">
|
<div className="overflow-hidden">
|
||||||
{logs.length > 1 ? (
|
{logs.length > 0 ? (
|
||||||
<div className="h-full overflow-auto">
|
<div className="h-full overflow-auto">
|
||||||
<code className="inline-block whitespace-pre-line text-xs">
|
<code className="inline-block whitespace-pre-line text-xs">
|
||||||
{logs.slice(-limit).map((log, i) => {
|
{logs.slice(-limit).map((log, i) => {
|
||||||
|
|||||||
@ -165,6 +165,21 @@ export const presetConfiguration: Record<string, SettingComponentProps> = {
|
|||||||
requireModelReload: true,
|
requireModelReload: true,
|
||||||
configType: 'setting',
|
configType: 'setting',
|
||||||
},
|
},
|
||||||
|
cpu_threads: {
|
||||||
|
key: 'cpu_threads',
|
||||||
|
title: 'CPU Threads',
|
||||||
|
description:
|
||||||
|
'Determines CPU inference threads, limited by hardware and OS. (Maximum determined by system)',
|
||||||
|
controllerType: 'slider',
|
||||||
|
controllerProps: {
|
||||||
|
min: 0,
|
||||||
|
max: 128,
|
||||||
|
step: 1,
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
requireModelReload: true,
|
||||||
|
configType: 'setting',
|
||||||
|
},
|
||||||
// assistant
|
// assistant
|
||||||
chunk_size: {
|
chunk_size: {
|
||||||
key: 'chunk_size',
|
key: 'chunk_size',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user