You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Confirm this is a feature request for the Node library and not the underlying OpenAI API.
This is a feature request for the Node library
Describe the feature or improvement you're requesting
Testing projects using OpenAI is unusually difficult due to import-time errors if the OpenAI library (mistakenly) believes fetch libraries are missing.
Turning this into a warning, or removing and just adding documentation telling users to use the shim, would remove the need for elaborate mocking, shimming and jest setup files.
See #304 for examples of the work arounds developers need to do to develop and test projects using OpenAI, simply due to this error being thrown.
Example using the latest version of jest and OpenAI:
llm-test.js
import 'web-streams-polyfill/es6' // doent work
import 'openai/shims/node'; // doesnt work
import 'openai/shims/web'; // doesnt work
jest.mock('openai'); // doesnt work
import LLM from './llm.js';
llm.js
import OpenAI from "openai"
Error:
this environment is missing the following Web Fetch API type: fetch is not defined. Add one of these imports before your first `import … from 'openai'`:
- `import 'openai/shims/node'` (if you're running on Node)
- `import 'openai/shims/web'` (otherwise)
Additional context
No response
The text was updated successfully, but these errors were encountered:
Sorry about this. These problems will go away once #402 is merged.
In the meantime, if you import 'openai/shims/node'; you can't also import 'openai/shims/web';. If doing the node shim doesn't work, you must do import 'openai/shims/web';and also bring in fetch as a global if your environment doesn't provide it by default.
In the meantime, we unfortunately don't plan to add any other ameliorations, so I'm going to close this as wontfix.
Confirm this is a feature request for the Node library and not the underlying OpenAI API.
Describe the feature or improvement you're requesting
Testing projects using OpenAI is unusually difficult due to import-time errors if the OpenAI library (mistakenly) believes fetch libraries are missing.
Turning this into a warning, or removing and just adding documentation telling users to use the shim, would remove the need for elaborate mocking, shimming and jest setup files.
See #304 for examples of the work arounds developers need to do to develop and test projects using OpenAI, simply due to this error being thrown.
Example using the latest version of jest and OpenAI:
llm-test.js
llm.js
Error:
Additional context
No response
The text was updated successfully, but these errors were encountered: