const H = {
Authorization: `Bearer ${MP_API_KEY}`,
"X-Namespace": MP_NAMESPACE,
"Content-Type": "application/json",
};
const cluster = await (await fetch(`${MP_API_URL}/v1/clusters`, {
method: "POST",
headers: H,
body: JSON.stringify({
cluster_name: "content_tree",
collection_ids: ["col_content"],
cluster_type: "vector",
vector_config: {
feature_uri: "mixpeek://text_extractor@v1/multilingual_e5_large_instruct_v1",
clustering_method: "kmeans",
algorithm_params: { n_clusters: 3 },
hierarchical: true,
max_hierarchy_depth: 2,
},
llm_labeling: {
enabled: true,
provider: "typesafe",
model_name: "jev-latest",
candidate_labels: ["Product Ads", "Sports", "Cooking", "Pharmaceutical Ads",
"Car Ads", "Skateboarding", "Surfing", "Baking", "Grilling"],
labeling_inputs: { input_mappings: [
{ input_key: "text", source_type: "payload", path: "content" }] },
},
}),
})).json();
await fetch(`${MP_API_URL}/v1/clusters/${cluster.cluster_id}/execute`, { method: "POST", headers: H });