Skip to content

Conversation

@subtleGradient
Copy link
Contributor

Add FileParserPlugin example for AI SDK v5

  • 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

Add shared fixtures module and JSON metadata

  • Create shared/fixtures.ts with utilities for reading PDF fixtures
  • Use absolute paths so examples work from any directory
  • Read verification codes from JSON metadata instead of hard-coding
  • Update AI SDK example to use shared fixtures
  • Add JSON metadata files generated by generate-pdfs.sh script

Fix stylecheck issues in AI SDK examples

  • Remove 'any' type assertion, use proper type narrowing
  • Fix import order with biome autofix

Fix large.pdf OCR readability and switch to Claude 3.5 Sonnet

  • Regenerate large.pdf with larger font (96pt) for better OCR accuracy
  • Switch AI SDK example to Claude 3.5 Sonnet (native PDF support)
  • Tests: 4/4 passing

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

  • Switch model from Claude 3.5 to GPT-4o-mini - Explicitly configure
    FileParserPlugin with Mistral OCR - Add clarifying comment about plugin
    necessity

Copy link
Contributor Author

subtleGradient commented Nov 12, 2025

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.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@subtleGradient subtleGradient marked this pull request as ready for review November 12, 2025 21:37
Copilot AI review requested due to automatic review settings November 12, 2025 21:37
Copilot finished reviewing on behalf of subtleGradient November 12, 2025 21:42
Copy link

Copilot AI left a 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-provider to 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.

- 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.
@subtleGradient subtleGradient changed the base branch from 03-prompt-caching-aisdk to graphite-base/51 November 12, 2025 23:18
@subtleGradient subtleGradient changed the base branch from graphite-base/51 to 03-prompt-caching-aisdk November 12, 2025 23:25

const usage = result.providerMetadata?.openrouter?.usage;
if (usage && typeof usage === 'object' && 'cost' in usage) {
const cost = usage.cost as number;
Copy link

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 {
Copy link

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?

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.

3 participants