From a373c156155e87fa72a57ee31b8807be3f371724 Mon Sep 17 00:00:00 2001 From: Bruce MacDonald Date: Thu, 2 Jan 2025 11:28:16 -0800 Subject: [PATCH] docs: specify the format for keep_alive duration (#185) 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. --- README.md | 6 +++--- src/interfaces.ts | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index af522cc..a752c73 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ ollama.chat(request) - `images` ``: (Optional) Images to be included in the message, either as Uint8Array or base64 encoded strings. - `format` ``: (Optional) Set the expected format of the response (`json`). - `stream` ``: (Optional) When true an `AsyncGenerator` is returned. - - `keep_alive` ``: (Optional) How long to keep the model loaded. + - `keep_alive` ``: (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` ``: (Optional) A list of tool calls the model may make. - `options` ``: (Optional) Options to configure the runtime. @@ -93,7 +93,7 @@ ollama.generate(request) - `images` ``: (Optional) Images to be included, either as Uint8Array or base64 encoded strings. - `format` ``: (Optional) Set the expected format of the response (`json`). - `stream` ``: (Optional) When true an `AsyncGenerator` is returned. - - `keep_alive` ``: (Optional) How long to keep the model loaded. + - `keep_alive` ``: (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` ``: (Optional) Options to configure the runtime. - Returns: `` @@ -186,7 +186,7 @@ ollama.embed(request) - `model` `` The name of the model used to generate the embeddings. - `input` ` | `: The input used to generate the embeddings. - `truncate` ``: (Optional) Truncate the input to fit the maximum context length supported by the model. - - `keep_alive` ``: (Optional) How long to keep the model loaded. + - `keep_alive` ``: (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` ``: (Optional) Options to configure the runtime. - Returns: `` diff --git a/src/interfaces.ts b/src/interfaces.ts index a941c9f..8f8607c 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -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 } @@ -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 @@ -146,7 +146,7 @@ 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 } @@ -154,7 +154,7 @@ export interface EmbedRequest { 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 }