Skip to content

Commit 5e6b917

Browse files
authored
add keep_alive (#36)
1 parent b7a6839 commit 5e6b917

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ console.log(response.message.content)
2121
```
2222

2323
## Streaming responses
24+
2425
Response streaming can be enabled by setting `stream: true`, modifying function calls to return an `AsyncGenerator` where each part is an object in the stream.
2526

2627
```javascript
@@ -34,6 +35,7 @@ for await (const part of response) {
3435
```
3536

3637
## Create
38+
3739
```javascript
3840
import ollama from 'ollama'
3941

@@ -45,6 +47,7 @@ await ollama.create({ model: 'example', modelfile: modelfile })
4547
```
4648

4749
## API
50+
4851
The Ollama JavaScript library's API is designed around the [Ollama REST API](https://github.com/jmorganca/ollama/blob/main/docs/api.md)
4952

5053
### chat
@@ -61,8 +64,9 @@ ollama.chat(request)
6164
- `content` `<string>`: The content of the message.
6265
- `images` `<Uint8Array[] | string[]>`: (Optional) Images to be included in the message, either as Uint8Array or base64 encoded strings.
6366
- `format` `<string>`: (Optional) Set the expected format of the response (`json`).
64-
- `options` `<Options>`: (Optional) Options to configure the runtime.
6567
- `stream` `<boolean>`: (Optional) When true an `AsyncGenerator` is returned.
68+
- `keep_alive` `<string | number>`: (Optional) How long to keep the model loaded.
69+
- `options` `<Options>`: (Optional) Options to configure the runtime.
6670

6771
- Returns: `<ChatResponse>`
6872

@@ -80,8 +84,9 @@ ollama.generate(request)
8084
- `raw` `<boolean>`: (Optional) Bypass the prompt template and pass the prompt directly to the model.
8185
- `images` `<Uint8Array[] | string[]>`: (Optional) Images to be included, either as Uint8Array or base64 encoded strings.
8286
- `format` `<string>`: (Optional) Set the expected format of the response (`json`).
83-
- `options` `<Options>`: (Optional) Options to configure the runtime.
8487
- `stream` `<boolean>`: (Optional) When true an `AsyncGenerator` is returned.
88+
- `keep_alive` `<string | number>`: (Optional) How long to keep the model loaded.
89+
- `options` `<Options>`: (Optional) Options to configure the runtime.
8590
- Returns: `<GenerateResponse>`
8691

8792
### pull
@@ -176,6 +181,7 @@ ollama.embeddings(request)
176181
- `request` `<Object>`: The request object containing embedding parameters.
177182
- `model` `<string>` The name of the model used to generate the embeddings.
178183
- `prompt` `<string>`: The prompt used to generate the embedding.
184+
- `keep_alive` `<string | number>`: (Optional) How long to keep the model loaded.
179185
- `options` `<Options>`: (Optional) Options to configure the runtime.
180186
- Returns: `<EmbeddingsResponse>`
181187

src/interfaces.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export interface GenerateRequest {
5151
raw?: boolean
5252
format?: string
5353
images?: Uint8Array[] | string[]
54+
keep_alive?: string | number
5455

5556
options?: Partial<Options>
5657
}
@@ -66,6 +67,7 @@ export interface ChatRequest {
6667
messages?: Message[]
6768
stream?: boolean
6869
format?: string
70+
keep_alive?: string | number
6971

7072
options?: Partial<Options>
7173
}
@@ -112,6 +114,7 @@ export interface ShowRequest {
112114
export interface EmbeddingsRequest {
113115
model: string
114116
prompt: string
117+
keep_alive?: string | number
115118

116119
options?: Partial<Options>
117120
}

0 commit comments

Comments
 (0)