//native
type Cohere = {
apiKey: string;
};
/**
* Create an Embed Job
* This API launches an async Embed job for a [Dataset](https://docs.cohere.com/docs/datasets) of type `embed-input`. The result of a completed embed job is new Dataset of type `embed-output`, which contains the original text entries and the corresponding embeddings.
*/
export async function main(
auth: Cohere,
body: {
model: string;
dataset_id: string;
input_type:
| "search_document"
| "search_query"
| "classification"
| "clustering"
| "image";
name?: string;
embedding_types?: "float" | "int8" | "uint8" | "binary" | "ubinary"[];
truncate?: "START" | "END";
},
) {
const url = new URL(`https://api.cohere.com/v1/embed-jobs`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.apiKey,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago