Skip to content

Commit

Permalink
docs: specify the format for keep_alive duration (#185)
Browse files Browse the repository at this point in the history
The Ollama API accepts a Go time.Duration as the keep_alive time parameter. Its not clearly documented anywhere how it expects the duration to be formatted, and the default behavior (numbers are seconds) is not expected. Adding documentation around this to make it easier to use keep_alive.
  • Loading branch information
BruceMacD authored Jan 2, 2025
1 parent db04fea commit a373c15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ollama.chat(request)
- `images` `<Uint8Array[] | string[]>`: (Optional) Images to be included in the message, either as Uint8Array or base64 encoded strings.
- `format` `<string>`: (Optional) Set the expected format of the response (`json`).
- `stream` `<boolean>`: (Optional) When true an `AsyncGenerator` is returned.
- `keep_alive` `<string | number>`: (Optional) How long to keep the model loaded.
- `keep_alive` `<string | number>`: (Optional) How long to keep the model loaded. A number (seconds) or a string with a duration unit suffix ("300ms", "1.5h", "2h45m", etc.)
- `tools` `<Tool[]>`: (Optional) A list of tool calls the model may make.
- `options` `<Options>`: (Optional) Options to configure the runtime.

Expand All @@ -93,7 +93,7 @@ ollama.generate(request)
- `images` `<Uint8Array[] | string[]>`: (Optional) Images to be included, either as Uint8Array or base64 encoded strings.
- `format` `<string>`: (Optional) Set the expected format of the response (`json`).
- `stream` `<boolean>`: (Optional) When true an `AsyncGenerator` is returned.
- `keep_alive` `<string | number>`: (Optional) How long to keep the model loaded.
- `keep_alive` `<string | number>`: (Optional) How long to keep the model loaded. A number (seconds) or a string with a duration unit suffix ("300ms", "1.5h", "2h45m", etc.)
- `options` `<Options>`: (Optional) Options to configure the runtime.
- Returns: `<GenerateResponse>`

Expand Down Expand Up @@ -186,7 +186,7 @@ ollama.embed(request)
- `model` `<string>` The name of the model used to generate the embeddings.
- `input` `<string> | <string[]>`: The input used to generate the embeddings.
- `truncate` `<boolean>`: (Optional) Truncate the input to fit the maximum context length supported by the model.
- `keep_alive` `<string | number>`: (Optional) How long to keep the model loaded.
- `keep_alive` `<string | number>`: (Optional) How long to keep the model loaded. A number (seconds) or a string with a duration unit suffix ("300ms", "1.5h", "2h45m", etc.)
- `options` `<Options>`: (Optional) Options to configure the runtime.
- Returns: `<EmbedResponse>`

Expand Down
8 changes: 4 additions & 4 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export interface GenerateRequest {
raw?: boolean
format?: string | object
images?: Uint8Array[] | string[]
keep_alive?: string | number
keep_alive?: string | number // a number (seconds) or a string with a duration unit suffix ("300ms", "1.5h", "2h45m", etc)

options?: Partial<Options>
}
Expand Down Expand Up @@ -100,7 +100,7 @@ export interface ChatRequest {
messages?: Message[]
stream?: boolean
format?: string | object
keep_alive?: string | number
keep_alive?: string | number // a number (seconds) or a string with a duration unit suffix ("300ms", "1.5h", "2h45m", etc)
tools?: Tool[]

options?: Partial<Options>
Expand Down Expand Up @@ -146,15 +146,15 @@ export interface EmbedRequest {
model: string
input: string | string[]
truncate?: boolean
keep_alive?: string | number
keep_alive?: string | number // a number (seconds) or a string with a duration unit suffix ("300ms", "1.5h", "2h45m", etc)

options?: Partial<Options>
}

export interface EmbeddingsRequest {
model: string
prompt: string
keep_alive?: string | number
keep_alive?: string | number // a number (seconds) or a string with a duration unit suffix ("300ms", "1.5h", "2h45m", etc)

options?: Partial<Options>
}
Expand Down

0 comments on commit a373c15

Please sign in to comment.