feat(ai-anthropic): support GCP Vertex for the antrophic adapter#989
feat(ai-anthropic): support GCP Vertex for the antrophic adapter#989flxwu wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThe Anthropic adapter now supports injected Anthropic-compatible Messages clients through ChangesAnthropic client injection
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Provider
participant createAnthropicChatWithClient
participant AnthropicTextAdapter
participant InjectedAnthropicClient
Provider->>createAnthropicChatWithClient: provide model and client
createAnthropicChatWithClient->>AnthropicTextAdapter: construct adapter
AnthropicTextAdapter->>InjectedAnthropicClient: call beta.messages.create
InjectedAnthropicClient-->>AnthropicTextAdapter: return message stream
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/ai-anthropic/tests/client-injection-type-safety.test.ts (1)
1-18: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPlace this unit test alongside its source.
This test covers
packages/ai-anthropic/src/utils/client.tsbut is located underpackages/ai-anthropic/tests/. Move it to a colocated*.test.tsfile beside the source.As per coding guidelines, unit tests must be placed in
*.test.tsfiles alongside the source they cover.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/ai-anthropic/tests/client-injection-type-safety.test.ts` around lines 1 - 18, Move the type-safety tests from the package-level tests directory into a colocated *.test.ts file beside the client utility source, preserving both expectTypeOf cases and their existing assertions.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/ai-anthropic/tests/client-injection-type-safety.test.ts`:
- Around line 1-18: Move the type-safety tests from the package-level tests
directory into a colocated *.test.ts file beside the client utility source,
preserving both expectTypeOf cases and their existing assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 13203040-11ca-436c-b87b-49b2da387ca3
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (12)
.changeset/anthropic-client-injection.mdREADME.mddocs/adapters/anthropic.mddocs/config.jsonpackages/ai-anthropic/package.jsonpackages/ai-anthropic/src/adapters/text.tspackages/ai-anthropic/src/index.tspackages/ai-anthropic/src/utils/client.tspackages/ai-anthropic/tests/anthropic-adapter.test.tspackages/ai-anthropic/tests/client-injection-type-safety.test.tstesting/e2e/package.jsontesting/e2e/src/lib/providers.ts
|
Great! |
🎯 Changes
AnthropicMessagesClientcontract aroundbeta.messages.create.createAnthropicChatWithClientfor preconfigured authentication and transport while preserving the existing API-key factories.The adapter's request mapping, streaming, tools, media, usage, and structured-output behavior are unchanged. Authentication and endpoint-specific feature support remain the injected client's responsibility.
🧪 Verification
pnpm test:pr(281/281 affected targets succeeded; declaration scan clean)pnpm --filter @tanstack/ai-e2e test:e2e(389 passed, 1 skipped; run on an isolated local port because 3010 was occupied)✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit