File tree 5 files changed +32
-11
lines changed
5 files changed +32
-11
lines changed Original file line number Diff line number Diff line change @@ -4,4 +4,4 @@ node_modules
4
4
.vscode-test /
5
5
* .vsix
6
6
model.gguf
7
- server
7
+ . / server
Original file line number Diff line number Diff line change 6
6
{
7
7
"label" : " build" ,
8
8
"type" : " npm" ,
9
- "script" : " esbuild- watch" ,
10
- "problemMatcher" : " $esbuild " ,
9
+ "script" : " watch" ,
10
+ "problemMatcher" : " $tsc-watch " ,
11
11
"isBackground" : true ,
12
12
"presentation" : {
13
13
"reveal" : " never"
Original file line number Diff line number Diff line change @@ -11,4 +11,4 @@ node_modules
11
11
** /* .map
12
12
** /* .ts
13
13
model.gguf
14
- server
14
+ . / server
Original file line number Diff line number Diff line change
1
+ export { stopServer , startServer } from "./serverManager" ;
Original file line number Diff line number Diff line change 1
1
import { ChildProcessWithoutNullStreams , spawn } from "child_process" ;
2
- import { downloadModel , downloadServer } from "./download" ;
3
- import Logger from "./logger" ;
4
- import statusBar from "./statusBar" ;
2
+ import { downloadModel , downloadServer } from ".. /download" ;
3
+ import Logger from ".. /logger" ;
4
+ import statusBar from ".. /statusBar" ;
5
5
6
6
let server : ChildProcessWithoutNullStreams | null ;
7
7
8
+ export const serverReady = async ( ) => {
9
+ try {
10
+ const res = await fetch ( "http://localhost:39129/model.json" , {
11
+ method : "GET" ,
12
+ } ) ;
13
+ if ( res . ok ) {
14
+ return true ;
15
+ } else {
16
+ return false ;
17
+ }
18
+ } catch ( error ) {
19
+ return false ;
20
+ }
21
+ } ;
22
+
8
23
export const startServer = async ( ) => {
24
+ const serverIsStarted = await serverReady ( ) ;
25
+ if ( serverIsStarted ) {
26
+ Logger . info ( "Server is started already." ) ;
27
+ return ;
28
+ }
29
+
9
30
const { stopTask } = statusBar . startTask ( ) ;
10
31
const serverPath = await downloadServer ( ) ;
11
32
const modelPath = await downloadModel ( ) ;
@@ -23,12 +44,10 @@ export const startServer = async () => {
23
44
"39129" ,
24
45
"--parallel" ,
25
46
"4" ,
26
- "--threads" ,
27
- "8" ,
28
- "--threads-batch" ,
29
- "8" ,
30
47
"--ctx-size" ,
31
48
"2048" ,
49
+ "--cont-batching" ,
50
+ "--embedding" ,
32
51
] ,
33
52
{
34
53
detached : false ,
@@ -50,6 +69,7 @@ export const startServer = async () => {
50
69
server . on ( "close" , ( code ) => {
51
70
Logger . trace ( `child process exited with code ${ code } ` , "llama" ) ;
52
71
} ) ;
72
+ await serverReady ( ) ;
53
73
stopTask ( ) ;
54
74
} ;
55
75
You can’t perform that action at this time.
0 commit comments