Entity addition request
Request to add a new entity
Entity name (required)
Chunk or file ID (required)
User name performing the operation (required)
Entity type (required) - e.g., "PERSON", "ORGANIZATION", "LOCATION", "PRODUCT"
Optionaldescription?: stringEntity description (optional)
OptionalupdateType?: "chunk" | "file"Update type: 'chunk' for single chunk, 'file' for all chunks (default: 'chunk')
Promise resolving to AddEntityResponse:
response - Success status (boolean)chunksUpdated - Number of chunks where entity was addedchunksSkipped - Number of chunks skipped (already had entity)fileHash - File hash if file-level updateupdatedEntity - Name of the entity that was addedimport { addEntity } from "@cpod/sdk";
// Add entity to a specific chunk
const result = await addEntity({
entity: "John Smith",
id: "chunk-abc123",
userName: "admin@example.com",
entityType: "PERSON",
description: "CEO of Acme Corp",
updateType: "chunk",
});
console.log(`Added to ${result.chunksUpdated} chunks`);
// Add entity to all chunks of a file
const fileResult = await addEntity({
entity: "Acme Corporation",
id: "95d47a820fcc0a667004a6da403b3d29",
userName: "admin@example.com",
entityType: "ORGANIZATION",
updateType: "file",
});
Add a new entity to document chunks
Adds a named entity to a single chunk or all chunks of a file. Useful for manual entity annotation or correction.