Closed as not planned
Description
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
Metadata
Metadata
Assignees
Labels
No labels