File tree Expand file tree Collapse file tree 2 files changed +18
-18
lines changed Expand file tree Collapse file tree 2 files changed +18
-18
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,7 @@ setTimeout(() => {
6
6
ollama . abort ( )
7
7
} , 1000 ) // 1000 milliseconds = 1 second
8
8
9
- try {
10
- ollama . generate ( {
9
+ ollama . generate ( {
11
10
model : 'llama3.1' ,
12
11
prompt : 'Write a long story' ,
13
12
stream : true ,
@@ -17,11 +16,12 @@ try {
17
16
process . stdout . write ( chunk . response )
18
17
}
19
18
}
19
+ ) . catch (
20
+ ( error ) => {
21
+ if ( error . name === 'AbortError' ) {
22
+ console . log ( 'The request has been aborted' )
23
+ } else {
24
+ console . error ( 'An error occurred:' , error )
25
+ }
26
+ }
20
27
)
21
- } catch ( error ) {
22
- if ( error . name === 'AbortError' ) {
23
- console . log ( 'The request has been aborted' )
24
- } else {
25
- console . error ( 'An error occurred:' , error )
26
- }
27
- }
Original file line number Diff line number Diff line change @@ -9,8 +9,7 @@ setTimeout(() => {
9
9
stream . abort ( )
10
10
} , 1000 ) // 1000 milliseconds = 1 second
11
11
12
- try {
13
- ollama . generate ( {
12
+ ollama . generate ( {
14
13
model : 'llama3.1' ,
15
14
prompt : 'Write a long story' ,
16
15
stream : true ,
@@ -21,11 +20,12 @@ try {
21
20
process . stdout . write ( chunk . response )
22
21
}
23
22
}
23
+ ) . catch (
24
+ ( error ) => {
25
+ if ( error . name === 'AbortError' ) {
26
+ console . log ( 'The request has been aborted' )
27
+ } else {
28
+ console . error ( 'An error occurred:' , error )
29
+ }
30
+ }
24
31
)
25
- } catch ( error ) {
26
- if ( error . name === 'AbortError' ) {
27
- console . log ( 'The request has been aborted' )
28
- } else {
29
- console . error ( 'An error occurred:' , error )
30
- }
31
- }
You can’t perform that action at this time.
0 commit comments