Skip to content
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

Add new AI.toMarkdown() method #3604

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

G4brym
Copy link
Member

@G4brym G4brym commented Feb 25, 2025

No description provided.

Comment on lines 249 to 251
data: btoa(
String.fromCharCode(...new Uint8Array(await file.blob.arrayBuffer()))
),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels extremely convoluted. I believe you ought to be able to make use of internal-node:internal-buffer here and just use Buffer.from(await file.blob.arrayBuffer()).toString('base64')) here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this import as you are suggesting import { Buffer } from 'internal-node:internal-buffer';
throws this error: src/cloudflare/internal/ai-api.ts(6,24): error TS2307: Cannot find module 'internal-node:internal-buffer' or its corresponding type declarations.
I didn't find any other cloudflare/* file importing anything from internal-node so it might be a simple configuration missing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current implementation limits the length of the string to 65k. Using spread operator means that you are bounded by the V8's argument limitation.

Copy link
Member Author

@G4brym G4brym Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would prefer to use the internal-node version, but I'm unable to import it using import { Buffer } from 'internal-node:internal-buffer';

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to import the Buffer class, so i changed the implementation to stop using the spread operator, this should bypass the 65k limit

@G4brym G4brym force-pushed the add-to-markdown-method branch from 56108de to 9080063 Compare February 26, 2025 11:00
@G4brym G4brym marked this pull request as ready for review February 26, 2025 11:03
@G4brym G4brym requested review from a team as code owners February 26, 2025 11:03
@G4brym G4brym requested review from anonrig and ketanhwr February 26, 2025 11:03
Comment on lines 249 to 251
data: btoa(
String.fromCharCode(...new Uint8Array(await file.blob.arrayBuffer()))
),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current implementation limits the length of the string to 65k. Using spread operator means that you are bounded by the V8's argument limitation.

@G4brym G4brym force-pushed the add-to-markdown-method branch 4 times, most recently from e7c7ee3 to 0c96292 Compare February 27, 2025 12:03
@G4brym G4brym force-pushed the add-to-markdown-method branch from 0c96292 to 45a8dbd Compare February 27, 2025 14:14
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