2
0
Эх сурвалжийг харах

Add additional options to embeddings.

saul 1 жил өмнө
parent
commit
3a8fc925d8
3 өөрчлөгдсөн 8 нэмэгдсэн , 5 устгасан
  1. 2 1
      README.md
  2. 1 1
      package.json
  3. 5 3
      src/index.ts

+ 2 - 1
README.md

@@ -126,11 +126,12 @@ Download a model from a the model registry. Cancelled pulls are resumed from whe
 ### embeddings
 
 ```javascript
-ollama.embeddings(model, prompt);
+ollama.embeddings(model, prompt, [parameters]);
 ```
 
 - `model` `<string>` The name of the model to generate embeddings for.
 - `prompt` `<string>` The prompt to generate embeddings with.
+- `parameters` `<ModelParameters>` Model Parameters.
 - Returns: `Promise<number[]>` The embeddings.
 
 Generate embeddings from a model.

+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
   "type": "module",
   "name": "ollama",
-  "version": "0.1.1",
+  "version": "0.2.0",
   "description": "Interface with an ollama instance over HTTP.",
   "main": "dist/index.js",
   "types": "dist/index.d.ts",

+ 5 - 3
src/index.ts

@@ -13,7 +13,8 @@ import type {
 	PullResult,
 	EmbeddingsResponse,
 	GenerateOptions,
-	GenerateRequest
+	GenerateRequest,
+	ModelParameters
 } from "./interfaces.js";
 
 export class Ollama {
@@ -131,10 +132,11 @@ export class Ollama {
 		}
 	}
 
-	async embeddings (model: string, prompt: string): Promise<number[]> {
+	async embeddings (model: string, prompt: string, parameters?: Partial<ModelParameters>): Promise<number[]> {
 		const response = await utils.post(`${this.config.address}/api/embeddings`, {
 			model,
-			prompt
+			prompt,
+			options: parameters ?? {}
 		});
 
 		const json = await response.json() as EmbeddingsResponse;