feat(providers): add Amazon Bedrock LLM provider support#63
feat(providers): add Amazon Bedrock LLM provider support#63oshorefueled merged 6 commits intomainfrom
Conversation
📝 WalkthroughWalkthroughAdds Amazon Bedrock as a new LLM provider, upgrades AI SDK dependencies, updates structured-output token fields from promptTokens/completionTokens to inputTokens/outputTokens, extends environment/config schemas and templates for Bedrock credentials, and adds/updates tests for Bedrock and output-based responses. Changes
Sequence Diagram(s)mermaid Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/provider-factory.test.ts (1)
157-172: Duplicate test cases — two tests with identical setup and assertion.
"throws error for unsupported provider type"(Line 158) and"throws descriptive error for invalid provider type"(Line 166) use the exact sameenvConfigandexpect(...).toThrow(...)assertion. One of them should be removed or differentiated (e.g., to testnullorundefinedseparately, which Line 174 already covers).🧹 Proposed fix — remove the redundant test
- it('throws descriptive error for invalid provider type', () => { - const envConfig = { - LLM_PROVIDER: 'unsupported-provider', - } as unknown as EnvConfig; - - expect(() => createProvider(envConfig)).toThrow('Unsupported provider type: unsupported-provider'); - }); -🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/provider-factory.test.ts` around lines 157 - 172, Two tests ("throws error for unsupported provider type" and "throws descriptive error for invalid provider type") duplicate the same setup and assertion; remove one of them or change the second to a distinct scenario. Update the test suite around createProvider to either delete the redundant "throws descriptive error for invalid provider type" case or modify it to supply a different envConfig (e.g., LLM_PROVIDER: null/undefined or an empty string) and assert the appropriate error message so each test verifies a unique failure path.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/schemas/env-schemas.ts`:
- Around line 58-64: BEDROCK_CONFIG_SCHEMA currently allows AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY to be optional and empty strings which permits one key
without the other; update BEDROCK_CONFIG_SCHEMA to require non-empty strings
(use z.string().min(1).optional() or similar) for both AWS_ACCESS_KEY_ID and
AWS_SECRET_ACCESS_KEY and add a .refine() on BEDROCK_CONFIG_SCHEMA to enforce
the paired-credential rule (either both present/non-empty or both
absent/undefined) so that createAmazonBedrock receives either a complete
credential pair or none.
---
Nitpick comments:
In `@tests/provider-factory.test.ts`:
- Around line 157-172: Two tests ("throws error for unsupported provider type"
and "throws descriptive error for invalid provider type") duplicate the same
setup and assertion; remove one of them or change the second to a distinct
scenario. Update the test suite around createProvider to either delete the
redundant "throws descriptive error for invalid provider type" case or modify it
to supply a different envConfig (e.g., LLM_PROVIDER: null/undefined or an empty
string) and assert the appropriate error message so each test verifies a unique
failure path.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (7)
package.jsonsrc/config/global-config.tssrc/providers/provider-factory.tssrc/providers/vercel-ai-provider.tssrc/schemas/env-schemas.tstests/provider-factory.test.tstests/vercel-ai-provider.test.ts
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/schemas/env-schemas.ts (1)
79-90: Consider adding apathto the Zod issue for better error targeting.Without a
path, the validation error is reported at the root object level. Adding a path helps downstream error handling (e.g., field-level error display) pinpoint the problematic field.💡 Suggested improvement
ctx.addIssue({ code: z.ZodIssueCode.custom, message: 'AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must both be provided or both be omitted', + path: ['AWS_ACCESS_KEY_ID'], });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/schemas/env-schemas.ts` around lines 79 - 90, The superRefine block for ProviderType.AmazonBedrock currently adds a root-level issue via ctx.addIssue; update that call to include a path so the error targets the relevant fields (e.g., set path to ['AWS_ACCESS_KEY_ID','AWS_SECRET_ACCESS_KEY'] or to each field as appropriate) when detecting the mismatched presence of AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in .superRefine (referencing data.LLM_PROVIDER, ProviderType.AmazonBedrock, ctx.addIssue).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/schemas/env-schemas.ts`:
- Around line 79-90: The superRefine block for ProviderType.AmazonBedrock
currently adds a root-level issue via ctx.addIssue; update that call to include
a path so the error targets the relevant fields (e.g., set path to
['AWS_ACCESS_KEY_ID','AWS_SECRET_ACCESS_KEY'] or to each field as appropriate)
when detecting the mismatched presence of AWS_ACCESS_KEY_ID and
AWS_SECRET_ACCESS_KEY in .superRefine (referencing data.LLM_PROVIDER,
ProviderType.AmazonBedrock, ctx.addIssue).
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.env.examplesrc/schemas/env-schemas.ts
✅ Files skipped from review due to trivial changes (1)
- .env.example
@ai-sdk/amazon-bedrockConfiguration
Users can now configure Amazon Bedrock in
~/.vectorlint/config.toml: