Skip to content

chunks

Package github.com/emergent-company/emergent.memory/apps/server/pkg/sdk/chunks

The chunks client provides access to document chunks — the text segments produced by the chunking pipeline after document ingestion.

func (c *Client) List(ctx context.Context, opts *ListOptions) (*ListResponse, error)
func (c *Client) Delete(ctx context.Context, id string) error
func (c *Client) BulkDelete(ctx context.Context, ids []string) (*BulkDeletionSummary, error)
func (c *Client) DeleteByDocument(ctx context.Context, documentID string) (*DocumentChunksDeletionResult, error)
func (c *Client) BulkDeleteByDocuments(ctx context.Context, documentIDs []string) (*BulkDocumentChunksDeletionSummary, error)
type Chunk struct {
ID string
DocumentID string
Content string
Index int
Metadata *ChunkMetadata
CreatedAt time.Time
}
type ChunkMetadata struct {
SourceType string
PageNumber int
Section string
Tokens int
}
type ListOptions struct {
DocumentID string
Limit int
Offset int
}
type ListResponse struct {
Chunks []Chunk
Total int
}
type BulkDeletionSummary struct {
Deleted int
Failed int
Results []DeletionResult
}
// List chunks for a document
resp, err := client.Chunks.List(ctx, &chunks.ListOptions{
DocumentID: "doc_abc123",
Limit: 50,
})
for _, chunk := range resp.Chunks {
fmt.Printf("[%d] %s\n", chunk.Index, chunk.Content[:min(80, len(chunk.Content))])
}
// Delete all chunks for a document
result, err := client.Chunks.DeleteByDocument(ctx, "doc_abc123")
fmt.Printf("Deleted %d chunks\n", result.Deleted)