Comments (7)
Create a global.d.ts
file in your project's root or type definition folder, then add the following code:
declare global {
type File = any;
}
export {};
This should fix the issue.
from openai-node.
Note, a temporary workaround is to add type File=any;
to the top of the index.d.ts
file in the dist
directory.
from openai-node.
Since it looks like you're using Node, in lieu of the workaround, you may be able to use one of the Node runtime configurations from tsconfig/bases, by adding it to your tsconfig.json
with "extends".
I ran into this same issue with undefined File
type in my Node 16 project, and resolved it by adding "extends": "@tsconfig/node16/tsconfig.json"
to my tsconfig.json
(full contents of my current working tsconfig.json
below, for reference)
{
"compilerOptions": {
"module": "commonjs",
"lib": ["ES2018"],
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"target": "es6",
"noImplicitAny": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"baseUrl": ".",
"paths": {
"*": [
"node_modules/*",
"src/types/*"
]
}
},
"include": [
"src/**/*"
],
"exclude": [
"src/public"
],
"extends": "@tsconfig/node16/tsconfig.json"
}
from openai-node.
It works for me! Thanks!
from openai-node.
Ran into this aswell
from openai-node.
This is fixed in our upcoming v4, which includes conveniences for file uploads.
from openai-node.
Non it's not solved still getting error with v4 and using ts-node
with tsconfig/paths
in Typescript
tsconfig.json
"ts-node": {
"require": ["tsconfig-paths/register"]
}
/test/node_modules/openai/_shims/formdata.js:6
exports.File = File;
^
ReferenceError: File is not defined
at Object.<anonymous> (/test/node_modules/openai/_shims/formdata.js:6:16)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Object.require.extensions.<computed> [as .js] (/usr/local/lib/node_modules/ts-node/src/index.ts:1608:43)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Function.Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/test/node_modules/openai/src/uploads.ts:66:15)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
What i found tsconfig-paths is picking this file _shims/formdata.js
but it should pick _shims/formdata.node.js
from openai-node.
Related Issues (20)
- Batch API - `files.content` not returning a `.jsonl` file format like documentation says HOT 2
- `Unrecognized request argument supplied: maxChatCompletions` | Object literal may only specify known properties, and maxChatCompletions does not exist in type: HOT 1
- Openai.beta.threads.messages.create give "Unknown parameter: 'role'" HOT 2
- TypeError: getDefaultAgent is not a function HOT 5
- Client-side URL sanitation in the SDK can be bypassed using prototype pollution HOT 1
- Bug Report: `openai.files.create` Method Hangs and Does Not Throw Errors in Docker Containers HOT 2
- Allow to create `OpenAI` client without specifying apiKey or to be defined as an environment variable. HOT 1
- Property 'text' does not exist on type 'MessageContent' HOT 2
- thread_id not recognized from Thread object HOT 5
- Can't build NextJS project with openai library. Getting: Type error: Private identifiers are only available when targeting ECMAScript 2015 and higher. HOT 5
- extra_body parameter support HOT 1
- Vector Store File CreateAndPoll with empty file, last_error.code returned is "invalid_file" but TS say not exist. HOT 1
- Arrays for model names
- OpenAIError: Final run has not been received HOT 1
- Stop using polyfills for Node.js HOT 5
- `openai.files.content` returns raw Response object
- Getting `Unhandled Rejection` event, randomly. HOT 3
- JSONSchema does not support recursive refs & zod also fails to convert similar schemas to JSONSchema correctly HOT 10
- Difficulty in importing { zodResponseFormat } from https://deno.land HOT 7
- `batches.list()` doesn't iterate properly with Azure OpenAI HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openai-node.