-
Notifications
You must be signed in to change notification settings - Fork 43
Add FileParserPlugin example for AI SDK v5 #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 03-prompt-caching-aisdk
Are you sure you want to change the base?
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive FileParserPlugin examples for AI SDK v5, demonstrating PDF processing capabilities through OpenRouter. The implementation includes test fixtures with verification codes and examples for both URL-based and data URI-based PDF processing.
Key Changes:
- Added two FileParserPlugin examples: URL-based PDF processing (with Claude 3.5 Sonnet) and multi-size PDF testing (with GPT-4o-mini)
- Created PDF fixtures (small, medium, large, xlarge) with JSON metadata containing verification codes
- Updated
@openrouter/ai-sdk-providerto v1.2.2 for improved schema validation
Reviewed Changes
Copilot reviewed 4 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
typescript/ai-sdk-v5/src/plugin-file-parser/file-parser-pdf-url.ts |
New example demonstrating PDF processing via public URLs using Claude 3.5 Sonnet (native PDF support) |
typescript/ai-sdk-v5/src/plugin-file-parser/file-parser-all-sizes.ts |
New example testing multiple PDF sizes with explicit FileParserPlugin configuration for GPT-4o-mini |
typescript/ai-sdk-v5/src/plugin-file-parser/README.md |
Documentation for the FileParserPlugin examples |
typescript/ai-sdk-v5/package.json |
Dependency update to @openrouter/ai-sdk-provider v1.2.2 |
fixtures/pdfs/small.pdf |
Test fixture PDF file (33KB) with verification code for testing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
08b17d0 to
5138ba6
Compare
edcaa49 to
7bf86b2
Compare
42726ef to
6a73a21
Compare
- Add PDF fixtures (small, medium, large, xlarge) with verification codes - Create comprehensive file-parser example testing all PDF sizes - Uses AI SDK's file attachment format with automatic plugin enablement - Validates extraction of verification codes from PDFs
- Update AI SDK example to use shared fixtures from pdf-example-fetch - Use absolute paths so examples work from any directory - Read verification codes from JSON metadata (inherited from parent branch) - Add file-parser-pdf-url.ts example
- Remove 'any' type assertion, use proper type narrowing - Fix import order with biome autofix
- Switch model from Claude 3.5 to GPT-4o-mini - Explicitly configure FileParserPlugin with Mistral OCR - Add clarifying comment about plugin necessity
Add @ts-expect-error with FIXME comment for usage token properties.
Include both examples with running instructions as suggested by Copilot review.
Copilot feedback: Overview section was incomplete/misleading about plugin behavior. Solution: Remove Overview section - complete behavior docs are in example file headers.
6a73a21 to
0147fbe
Compare
7bf86b2 to
34d735c
Compare
|
|
||
| const usage = result.providerMetadata?.openrouter?.usage; | ||
| if (usage && typeof usage === 'object' && 'cost' in usage) { | ||
| const cost = usage.cost as number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should assert the type
assert(typeof usage.cost === 'number')
Or something like that, I think
| console.log('URL: https://bitcoin.org/bitcoin.pdf'); | ||
| console.log(); | ||
|
|
||
| try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need try/catch here btw if the entry crash it will simply crash right?

Add FileParserPlugin example for AI SDK v5
Add shared fixtures module and JSON metadata
Fix stylecheck issues in AI SDK examples
Fix large.pdf OCR readability and switch to Claude 3.5 Sonnet
Update @openrouter/ai-sdk-provider to 1.2.2
Fixes schema validation error for file parser plugin responses.
The file type annotation is now properly supported in the response schema.
Update FileParserPlugin config for models without native PDF support
FileParserPlugin with Mistral OCR - Add clarifying comment about plugin
necessity