@axflow/models
Version:
Zero-dependency, modular SDK for building robust natural language applications
54 lines (51 loc) • 1.85 kB
text/typescript
type SharedRequestOptions = {
apiKey?: string;
apiUrl?: string;
fetch?: typeof fetch;
headers?: Record<string, string>;
signal?: AbortSignal;
};
declare namespace CohereEmbeddingTypes {
type Request = {
texts: string[];
model?: string;
truncate?: 'NONE' | 'START' | 'END';
input_type?: string;
};
type RequestOptions = SharedRequestOptions;
type Response = {
id: string;
embeddings: number[][];
texts: string[];
meta: {
api_version: {
version: string;
is_deprecated?: boolean;
is_experimental?: boolean;
};
warnings: string[];
};
};
}
/**
* Calculate text embeddings using the Cohere API.
*
* @see https://docs.cohere.com/reference/embed
*
* @param request The request body sent to Cohere. See Cohere's documentation for /v1/embed for supported parameters.
* @param options
* @param options.apiKey Cohere API key.
* @param options.apiUrl The url of the Cohere (or compatible) API. Defaults to https://api.cohere.ai/v1/embed.
* @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 and other metadata. See Cohere's documentation for /v1/embed.
*/
declare function run(request: CohereEmbeddingTypes.Request, options: CohereEmbeddingTypes.RequestOptions): Promise<CohereEmbeddingTypes.Response>;
/**
* An object that encapsulates methods for calling the Cohere Embed API.
*/
declare class CohereEmbedding {
static run: typeof run;
}
export { CohereEmbedding, CohereEmbeddingTypes };