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

DOMException [InvalidCharacterError]: Invalid character #1505

Closed
bernaferrari opened this issue May 6, 2024 · 1 comment
Closed

DOMException [InvalidCharacterError]: Invalid character #1505

bernaferrari opened this issue May 6, 2024 · 1 comment
Assignees

Comments

@bernaferrari
Copy link

bernaferrari commented May 6, 2024

Description

Just sending a simple PNG to GPT I'm getting this:

    const stream = await streamObject({
      model: openai.chat("gpt-4-turbo"),
      schema: z.object({
        children: z.array(z.object({})),
      }),
      system: `Do this`,
      messages: [formatVercelUserMessage(userMessage, base64Image)],
    });


export const formatVercelUserMessage = (
  message: string,
  base64Image?: string | null
): CoreUserMessage => {
  if (base64Image) {
    return {
      role: "user",
      content: [
        { type: "text", text: message },
        {
          type: "image",
          image: base64Image,
        },
      ],
    };
  }

  return {
    role: "user",
    content: message,
  };
};
 ⨯ unhandledRejection: DOMException [InvalidCharacterError]: Invalid character
    at atob (node:buffer:1269:13)
    at convertBase64ToUint8Array (webpack-internal:///(action-browser)/../node_modules/.pnpm/@[email protected][email protected]/node_modules/@ai-sdk/provider-utils/dist/index.mjs:396:35)
    at convertDataContentToUint8Array (webpack-internal:///(action-browser)/../node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/ai/dist/index.mjs:121:93)
    at eval (webpack-internal:///(action-browser)/../node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/ai/dist/index.mjs:171:44)
    at Array.map (<anonymous>)
    at eval (webpack-internal:///(action-browser)/../node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/ai/dist/index.mjs:156:42)
    at Array.map (<anonymous>)
    at convertToLanguageModelPrompt (webpack-internal:///(action-browser)/../node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/ai/dist/index.mjs:145:28)
    at streamObject (webpack-internal:///(action-browser)/../node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected][email protected][email protected]/node_modules/ai/dist/index.mjs:1053:17)
    at eval (webpack-internal:///(action-browser)/./app/playground/actions.tsx:64:79)

Example image being sent:
image

@lgrammel
Copy link
Collaborator

#1569

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

No branches or pull requests

2 participants