Skip to content

Commit

Permalink
mark embeddings() method as deprecated in favor of embed()
Browse files Browse the repository at this point in the history
- mark the `embeddings()` method as deprecated, `embed()` is a drop-in replacement that also allows for batch embeddings
- the embeddings method will continue to work as expected
- document the embed method
  • Loading branch information
BruceMacD committed Jul 15, 2024
1 parent 6ef65f4 commit b0e02dd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,19 @@ ollama.show(request)
- `options` `<Options>`: (Optional) Options to configure the runtime.
- Returns: `<ShowResponse>`

### embeddings
### embed

```javascript
ollama.embeddings(request)
ollama.embed(request)
```

- `request` `<Object>`: The request object containing embedding parameters.
- `model` `<string>` The name of the model used to generate the embeddings.
- `prompt` `<string>`: The prompt used to generate the embedding.
- `input` `<string>`: The input used to generate the embedding.
- `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.
- `options` `<Options>`: (Optional) Options to configure the runtime.
- Returns: `<EmbeddingsResponse>`
- Returns: `<EmbedResponse>`

### ps

Expand Down
1 change: 1 addition & 0 deletions src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ async encodeImage(image: Uint8Array | string): Promise<string> {

/**
* Embeds a text prompt into a vector.
* @deprecated Use the `embed` method instead.
* @param request {EmbeddingsRequest} - The request object.
* @returns {Promise<EmbeddingsResponse>} - The response object.
*/
Expand Down
6 changes: 6 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ export interface EmbedRequest {
options?: Partial<Options>
}

/**
* @deprecated Use the EmbedRequest interface with the embed() method instead.
*/
export interface EmbeddingsRequest {
model: string
prompt: string
Expand Down Expand Up @@ -163,6 +166,9 @@ export interface EmbedResponse {
embeddings: number[][]
}

/**
* @deprecated Use the embed() method with the EmbedResponse instead.
*/
export interface EmbeddingsResponse {
embedding: number[]
}
Expand Down

0 comments on commit b0e02dd

Please sign in to comment.