Skip to content

feat: add auto-chunking and client-side chunkFn for contextualizedEmbed - #33

Closed
fzowl wants to merge 2 commits into
fix/explicit-esm-import-extensionsfrom
feat/auto-chunking
Closed

fzowl wants to merge 2 commits into
fix/explicit-esm-import-extensionsfrom
feat/auto-chunking

Conversation

@fzowl

@fzowl fzowl commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add server-side auto-chunking support (enableAutoChunking, chunkSize, chunkOverlap) with snake_case serialization
  • Add response fields chunkerVersion and per-chunk text for auto-chunked results
  • Add client-side chunkFn callback parameter for custom text splitting before API call
  • Add defaultChunkFn built-in recursive text splitter (same separator hierarchy as Python SDK, no external deps)
  • Add applyChunking utility and ContextualizedEmbedOptions type
  • Validation mirrors Python SDK's chunking.py 1:1 (all 11 rules)
  • Protect modified Fern-generated files in .fernignore

Test plan

  • 7 wire tests: snake_case serialization, response deserialization, chunkFn sends chunked inputs
  • 41 validation unit tests: every rule from Python's chunking.py, applyChunking, defaultChunkFn
  • 10 integration tests: server-side auto-chunking, chunkFn, defaultChunkFn, flat input normalization
  • All 421 existing unit tests pass (zero regressions)
  • Coverage: src/extended/ExtendedClient.ts at 92.77% stmts, 97.72% branches, 100% funcs

fzowl added 2 commits June 11, 2026 18:28
Port Python SDK PR #54 auto-chunking feature to TypeScript. Adds
enableAutoChunking, chunkSize, chunkOverlap request fields with
snake_case serialization, chunkerVersion and text response fields,
and client-side validation matching Python's chunking.py 1:1.
Ports the chunk_fn feature from Python PR #54. Adds:
- chunkFn callback parameter for client-side text splitting
- applyChunking utility to apply chunk functions across nested inputs
- defaultChunkFn with recursive character text splitter (no deps)
- Validation: chunkFn cannot be combined with enableAutoChunking
- 16 new tests: chunkFn validation, applyChunking, defaultChunkFn,
  wire test, and 3 integration tests with real API
@fzowl

fzowl commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by new PR rebased on main

@fzowl fzowl closed this Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant