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

I'm trying to integrate this project with a frontend, #358

Closed
pfeducode opened this issue Feb 17, 2023 · 3 comments
Closed

I'm trying to integrate this project with a frontend, #358

pfeducode opened this issue Feb 17, 2023 · 3 comments

Comments

@pfeducode
Copy link

pfeducode commented Feb 17, 2023

Describe the feature

I'm trying to integrate this project with a frontend, but I'm encountering version conflicts when using Umi. I attempted to integrate it with nodejs+koa2, but that also failed. I'm hoping to run this project as a standalone service to provide an API for the frontend, which will help avoid version conflicts. If you can help me get this project up and running as a standalone service, it would be very helpful. Thank you.
image

@transitive-bullshit
Copy link
Owner

Hmmm, gpt-3-encoder definitely has problems.

I'm not sure the exact issue you're running into, but I'm looking to replace that dependency.

This may be helpful for you:

async function example() {
  // To use ESM in CommonJS, you can use a dynamic import
  const { ChatGPTAPI } = await import(https://github.com/transitive-bullshit/chatgpt-api)

  const api = new ChatGPTAPI({ apiKey: process.env.OPENAI_API_KEY })

  const res = await api.sendMessage('Hello World!')
  console.log(res.text)
}

#336 and #334 look related as they all have to do with compat issues with gpt-3-encoder.

@JamieMcDonnell
Copy link

Hey there,
I just tried to spin up my first Vue3/Quasar/ChatGPT project and hit this issue. Trying to include the ChatGPTAPI from your repo directly gives me a CORS error. I'm running currently on localhost:9000.

Any chance you can whitelist localhost?

Thanks!!

@transitive-bullshit
Copy link
Owner

Try the new version https://github.com/transitive-bullshit/chatgpt-api/releases/tag/v4.6.0

It replaces the troublesome gpt-3-encoder with a better dependency.

Any chance you can whitelist localhost?

Any CORS issues are happening in your webapp and have nothing to do with this project.

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

3 participants