Skip to content

Commit 5127df4

Browse files
authored
Merge pull request #4386 from janhq/chore/add-cpu-threads-cortex-extension-settings
chore: add cpu_threads settings in cortex extension
2 parents 502bd92 + 27e40c3 commit 5127df4

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.7
1+
1.0.8-rc1

extensions/inference-cortex-extension/resources/default_settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818
"placeholder": "4"
1919
}
2020
},
21+
{
22+
"key": "cpu_threads",
23+
"title": "CPU Threads",
24+
"description": "The number of threads to use for inferencing (CPU MODE ONLY)",
25+
"controllerType": "input",
26+
"controllerProps": {
27+
"value": "",
28+
"placeholder": "4"
29+
}
30+
},
2131
{
2232
"key": "flash_attn",
2333
"title": "Flash Attention enabled",

extensions/inference-cortex-extension/src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export enum Settings {
4343
flash_attn = 'flash_attn',
4444
cache_type = 'cache_type',
4545
use_mmap = 'use_mmap',
46+
cpu_threads = 'cpu_threads',
4647
}
4748

4849
/**
@@ -66,6 +67,7 @@ export default class JanInferenceCortexExtension extends LocalOAIEngine {
6667
flash_attn: boolean = true
6768
use_mmap: boolean = true
6869
cache_type: string = 'f16'
70+
cpu_threads?: number
6971

7072
/**
7173
* The URL for making inference requests.
@@ -105,6 +107,10 @@ export default class JanInferenceCortexExtension extends LocalOAIEngine {
105107
this.flash_attn = await this.getSetting<boolean>(Settings.flash_attn, true)
106108
this.use_mmap = await this.getSetting<boolean>(Settings.use_mmap, true)
107109
this.cache_type = await this.getSetting<string>(Settings.cache_type, 'f16')
110+
const threads_number = Number(
111+
await this.getSetting<string>(Settings.cpu_threads, '')
112+
)
113+
if (!Number.isNaN(threads_number)) this.cpu_threads = threads_number
108114

109115
this.queue.add(() => this.clean())
110116

@@ -150,6 +156,9 @@ export default class JanInferenceCortexExtension extends LocalOAIEngine {
150156
this.cache_type = value as string
151157
} else if (key === Settings.use_mmap && typeof value === 'boolean') {
152158
this.use_mmap = value as boolean
159+
} else if (key === Settings.cpu_threads && typeof value === 'string') {
160+
const threads_number = Number(value)
161+
if (!Number.isNaN(threads_number)) this.cpu_threads = threads_number
153162
}
154163
}
155164

@@ -207,6 +216,7 @@ export default class JanInferenceCortexExtension extends LocalOAIEngine {
207216
flash_attn: this.flash_attn,
208217
cache_type: this.cache_type,
209218
use_mmap: this.use_mmap,
219+
...(this.cpu_threads ? { cpu_threads: this.cpu_threads } : {}),
210220
},
211221
timeout: false,
212222
signal,

0 commit comments

Comments
 (0)