PawanOsman / GoogleBard

GoogleBard - A reverse engineered API for Google Bard chatbot for NodeJS
https://bard.google.com
MIT License
415 stars 57 forks source link

Can't run in browser with NextJS #19

Closed alexkreidler closed 1 year ago

alexkreidler commented 1 year ago
./node_modules/.pnpm/dbcontext@1.0.4/node_modules/dbcontext/dist/classes/dbcontext.js:1:0
Module not found: Can't resolve 'fs'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/.pnpm/dbcontext@1.0.4/node_modules/dbcontext/dist/index.js
./node_modules/.pnpm/googlebard@1.0.6/node_modules/googlebard/dist/classes/app-dbcontext.js
./node_modules/.pnpm/googlebard@1.0.6/node_modules/googlebard/dist/classes/bard.js
./node_modules/.pnpm/googlebard@1.0.6/node_modules/googlebard/dist/index.js
./src/agents/babyagi/bard.ts
./src/agents/babyagi/service.ts
./src/agents/babyagi/index.ts
./src/components/Agent/Agent.tsx
./src/pages/index.tsx

The fs module doesn't exist in browser contexts. Maybe we could not import dbcontext if inMemory is true?

PawanOsman commented 1 year ago

you must only use the in-memory database if you use it in a browser environment, or you can create an API with it and use the API in the browser page

alexkreidler commented 1 year ago

Thanks for that info! I've also realized that the same-origin/cross-origin policies of Bard mean that any fetch request from the browser directly to the service will be denied, so we need a proxy.