Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mark embeddings() method as deprecated in favor of embed() #111

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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> | <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 @@ -66,7 +66,7 @@
*/
protected async processStreamableRequest<T extends object>(
endpoint: string,
request: { stream?: boolean } & Record<string, any>,

Check warning on line 69 in src/browser.ts

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected any. Specify a different type

Check warning on line 69 in src/browser.ts

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected any. Specify a different type

Check warning on line 69 in src/browser.ts

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected any. Specify a different type
): Promise<T | AbortableAsyncIterator<T>> {
request.stream = request.stream ?? false
const host = `${this.config.host}/api/${endpoint}`
Expand Down Expand Up @@ -286,6 +286,7 @@

/**
* 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 @@
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 @@
embeddings: number[][]
}

/**
* @deprecated Use the embed() method with the EmbedResponse instead.
*/
export interface EmbeddingsResponse {
embedding: number[]
}
Expand Down Expand Up @@ -202,8 +208,8 @@
details: ModelDetails
messages: Message[]
modified_at: Date
model_info: Map<string, any>

Check warning on line 211 in src/interfaces.ts

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected any. Specify a different type

Check warning on line 211 in src/interfaces.ts

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected any. Specify a different type

Check warning on line 211 in src/interfaces.ts

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected any. Specify a different type
projector_info?: Map<string, any>

Check warning on line 212 in src/interfaces.ts

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected any. Specify a different type

Check warning on line 212 in src/interfaces.ts

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected any. Specify a different type

Check warning on line 212 in src/interfaces.ts

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected any. Specify a different type
}

export interface ListResponse {
Expand Down
Loading