feat: 0.2.0 add drop-in SDK adapters, examples, benchmarks, fuller tests - #1
Merged
Conversation
Adds an adoption-focused release without changing the core ContextOptimizer API. Wraps the OpenAI and Anthropic SDKs so a one-line swap turns any existing chat call into an auto-trimmed one, and ships the runnable examples, benchmarks, and tests reviewers expect to see before they star a library. - src/adapters/openai.ts + src/adapters/anthropic.ts: withOptimizer(client, config) returns a client whose chat.completions.create / messages.create intercepts messages and runs ctx-opt before forwarding. The Anthropic adapter hoists system for the optimizer view and splits it back out for the API. Both expose client, optimizer, lastMeta. - Subpath exports ctx-opt/openai and ctx-opt/anthropic via tsup multi-entry build. openai and @anthropic-ai/sdk are optional peer deps. - examples/: openai, anthropic, summarizer-with-real-Anthropic, langchain. - benchmarks/run.ts: reproducible head-to-head of all 4 strategies. Results pasted into README. - tests/strategies/relevance.test.ts + hybrid.test.ts: fill the coverage gap. tests/adapters/*: full adapter suites with mock SDKs. 21 to 52 tests. - CHANGELOG.md following Keep-a-Changelog. README updated with the adapter quick-start, benchmark table, and changelog link. - Documents in CHANGELOG a known limitation: the hybrid pipeline shares recentWindow between phases, so the post-relevance set is rarely compressible. Summarizer falls through to its sliding-window fallback. Splitting the windows is queued for a future release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an adoption-focused release without changing the core ContextOptimizer API. Wraps the OpenAI and Anthropic SDKs so a one-line swap turns any existing chat call into an auto-trimmed one, and ships the runnable examples, benchmarks, and tests reviewers expect to see before they star a library.