SaraS
Convex Community2y ago
2 replies
Sara

handling file type, and a small issue with a server package

Issue #1: I was trying to use the file system from google seen here -> google docs, in which I have a file called model.ts that already has some working structure (using async functions and convex built in functions), but when I try importing the GoogleAIFileManager I ran through this error:
⠋ Preparing Convex functions...
X [ERROR] Could not resolve "fs"

    node_modules/.pnpm/@google+generative-ai@0.16.0/node_modules/@google/generative-ai/dist/server/index.mjs:1:29:
      1 │ import { readFileSync } from 'fs';
        ╵                              ~~~~

  The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle
  for node? You can use "platform: 'node'" to do that, which will remove this error.

and after further investigation, this could be the possible soultion -> some guy on github threads
which I thought I'm already am?
I know my code is complaing about the second line here:
const genAI = new GoogleGenerativeAI(apiKey as string);
const fileManager = new GoogleAIFileManager(apiKey as string)

so what would you suggest in this case? do I wrap it in an action and not use it in another file?

Issue #2: I would like to pass my file as a file type to pass it through the google function that handles it for me without having to upload it somewhere or add to my cache history, and the code happend to complain that I used v.any() instead of defining it as a file like i did, what do I do in this case as a suggestion?

Error: File {} is not a supported Convex type (present at path .file in original object {"threadId":"m17a4k298pfydfecht4yevba7x6y1efy","content":"todododooleoeo","file":{}}). To learn about Convex's supported types, see https://docs.convex.dev/using/types.

what should I do in this case?
GitHub
Thanks for stopping by to let us know something could be better! PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. ...
Googleapis return "Module not found: can't resolve fs" when running...
Was this page helpful?