@axflow/models
Version:
Zero-dependency, modular SDK for building robust natural language applications
56 lines (53 loc) • 1.83 kB
text/typescript
type OllamaModelOptions = {
top_k?: number;
top_p?: number;
stop?: string;
temperature?: number;
repeat_penalty?: number;
repeat_last_n?: number;
num_threads?: number;
num_gpu?: number;
num_gqa?: number;
num_ctx?: number;
mirostat?: number;
mirostat_eta?: number;
mirostat_tau?: number;
tfs_z?: number;
};
declare namespace OllamaEmbeddingTypes {
type Request = {
model: string;
prompt: string;
options?: OllamaModelOptions;
};
type RequestOptions = {
apiUrl?: string;
fetch?: typeof fetch;
headers?: Record<string, string>;
signal?: AbortSignal;
};
type Response = {
embedding: number[];
};
}
/**
* Calculate text embeddings using a model served by Ollama.
*
* @see https://github.com/jmorganca/ollama/blob/main/docs/api.md#generate-embeddings
*
* @param request The request body sent to Ollama. It contains the prompt, the model, and some options.
* @param options
* @param options.apiUrl The url where the ollama embedding endpoint is served. Defaults to http://127.0.0.1:11434/api/embeddings.
* @param options.fetch A custom implementation of fetch. Defaults to globalThis.fetch.
* @param options.headers Optionally add additional HTTP headers to the request.
* @param options.signal An AbortSignal that can be used to abort the fetch request.
* @returns An object consisting of the text embeddings for the given prompt.
*/
declare function run(request: OllamaEmbeddingTypes.Request, options: OllamaEmbeddingTypes.RequestOptions): Promise<OllamaEmbeddingTypes.Response>;
/**
* An object that encapsulates methods for calling the Ollama Embeddings API.
*/
declare class OllamaEmbedding {
static run: typeof run;
}
export { OllamaEmbedding, OllamaEmbeddingTypes };