@axflow/models
Version:
Zero-dependency, modular SDK for building robust natural language applications
35 lines (32 loc) • 836 B
JavaScript
// src/cohere/embedding.ts
import { POST } from "@axflow/models/shared";
// src/cohere/shared.ts
function headers(apiKey, customHeaders) {
const headers2 = {
accept: "application/json",
"content-type": "application/json",
...customHeaders
};
if (typeof apiKey === "string") {
headers2.authorization = `Bearer ${apiKey}`;
}
return headers2;
}
// src/cohere/embedding.ts
var COHERE_API_URL = "https://api.cohere.ai/v1/embed";
async function run(request, options) {
const url = options.apiUrl || COHERE_API_URL;
const response = await POST(url, {
headers: headers(options.apiKey, options.headers),
body: JSON.stringify(request),
fetch: options.fetch,
signal: options.signal
});
return response.json();
}
var CohereEmbedding = class {
static run = run;
};
export {
CohereEmbedding
};