transitive-bullshit / agentic

AI agent stdlib that works with any LLM and TypeScript AI SDK.
https://agentic.so
MIT License
16.38k stars 2.14k forks source link

Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation #592

Closed cuongdnv2307 closed 4 months ago

cuongdnv2307 commented 1 year ago

Verify latest release

Verify webapp is working

Environment details

Node version : v18.16.1 Windows 11

Describe the Bug

I got the below error

Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation at ChatGPTAPI.fetchCallImpl (main.js?attr=NWlR-sncM9PvO9IsjgmYJYLNIizg-ac57kqKv5nTKmfgLQ2njijxl0idxUoSQhvA:2923:25) at window.fetch [as _fetch] (main.js?attr=NWlR-sncM9PvO9IsjgmYJYLNIizg-ac57kqKv5nTKmfgLQ2njijxl0idxUoSQhvA:2925:55) at Promise.then.promptTokens (chatgpt-api.ts:251:1) at new Promise () at ChatGPTAPI.sendMessage (chatgpt-api.ts:182:1) at async example (App.js:12:1)

kumavis commented 1 year ago

same issue, chatgpt@5.2.5 on chrome

kumavis commented 1 year ago

workaround:

    const api = new ChatGPTAPI({
      apiKey,
      // workaround for https://github.com/transitive-bullshit/chatgpt-api/issues/592
      fetch: self.fetch.bind(self),
    })
pstong216 commented 8 months ago

solution for macOS

const api = new ChatGPTAPI({
      apiKey,
      fetch: window.fetch.bind(window),
  })
yaochiqkl commented 7 months ago

same issue on Chrome version 122.0.6261.112 macOS (arm64)

image
zangguojun commented 6 months ago

workaround:

    const api = new ChatGPTAPI({
      apiKey,
      // workaround for https://github.com/transitive-bullshit/chatgpt-api/issues/592
      fetch: self.fetch.bind(self),
    })

I did solve the fetch problem in the above way, but there were new problems.

   chatgpt.js?v=4d2c40ad:386 Uncaught (in promise) ReferenceError: Buffer is not defined
    at Object.stringify [as serialize] (chatgpt.js?v=4d2c40ad:386:16)
    at chatgpt.js?v=4d2c40ad:589:28
    at async ChatGPTAPI._defaultUpsertMessage (chatgpt.js?v=4d2c40ad:2158:5)
    at async Promise.all (:5173/index 0)
await in (匿名)(异步)       
transitive-bullshit commented 4 months ago

This project is undergoing a major revamp; closing out old issues as part of the prep process.

The chatgpt package is pretty outdated at this point. I recommend that you use the openai package or the openai-fetch package instead.