PublicAffairs / openai-gemini

Gemini ➜ OpenAI API proxy. Serverless!
https://my-openai-gemini-demo.vercel.app/
MIT License
382 stars 238 forks source link

No such module "node:buffer" (Cloudflare workers-playground) #1

Closed mjtechguy closed 9 months ago

mjtechguy commented 9 months ago

Looks like a very cool project. Thanks for creating this.

Question about Cloudflare.

I pasted the contents of worker.mjs into the index.js in the cloudflare worker. I get this error when I try to deploy.

Uncaught Error: No such module "node:buffer". imported from "index.js" (Code: 10021)

Any ideas?

meronogbai commented 9 months ago

I think you have to replace the base64 encoding logic!

See pointer below:

https://github.com/PublicAffairs/openai-gemini/blob/6d9241a27d53391d34cf5989410865c543bbc4a8/src/worker.mjs#L2

mjtechguy commented 9 months ago

Thanks. Not sure what to modify as I am not a dev. But I will ask ChatGPT. 😆

johnd0e commented 9 months ago

Any ideas?

Thank you for pointing this out. It seems that current version can not be "just pasted", because it depends on wrangler.toml option:

https://github.com/PublicAffairs/openai-gemini/blob/6d9241a27d53391d34cf5989410865c543bbc4a8/wrangler.toml#L4

But you can use this branch instead: https://github.com/PublicAffairs/openai-gemini/blob/resize-images/src/worker.mjs

mjtechguy commented 9 months ago

Worked perfectly. It is responding as expected. Thanks so much for this!