{"payload":{"feedbackUrl":"https://github.com/orgs/community/discussions/53140","repo":{"id":633964365,"defaultBranch":"master","name":"openai-node","ownerLogin":"Pedroglp","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2023-04-28T17:30:38.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/4466094?v=4","public":true,"private":false,"isOrgOwned":false},"refInfo":{"name":"","listCacheKey":"v0:1682704038.369628","currentOid":""},"activityList":{"items":[{"before":"51b1340e3182c4cb5d43a5b771606ecdd93a60f4","after":"da389bfd90b067d8d4ede671e9a45175083b53b9","ref":"refs/heads/patch-1","pushedAt":"2023-04-28T17:47:17.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"Pedroglp","name":"Pedro Gabriel","path":"/Pedroglp","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/4466094?s=80&v=4"},"commit":{"message":"File needs to be a ReadStream\n\nWhile using it together with Typescript, the compiler was saying to use file as File type. Although if you use it as File type you are going to have the following error:\r\n\r\nTypeError: source.on is not a function\r\n at DelayedStream.create (/Users/pedrogabriel/healthmeet/node_modules/delayed-stream/lib/delayed_stream.js:33:10)\r\n at CombinedStream.append (/Users/pedrogabriel/healthmeet/node_modules/combined-stream/lib/combined_stream.js:45:37)\r\n at FormData.append (/Users/pedrogabriel/healthmeet/node_modules/form-data/lib/form_data.js:75:3)\r\n at Object. (/Users/pedrogabriel/healthmeet/node_modules/openai/dist/api.js:572:36)\r\n at Generator.next ()\r\n at /Users/pedrogabriel/healthmeet/node_modules/openai/dist/api.js:21:71\r\n at new Promise ()\r\n at __awaiter (/Users/pedrogabriel/healthmeet/node_modules/openai/dist/api.js:17:12)\r\n at Object.createTranscription (/Users/pedrogabriel/healthmeet/node_modules/openai/dist/api.js:555:108)\r\n at Object. (/Users/pedrogabriel/healthmeet/node_modules/openai/dist/api.js:1209:75)\r\n\r\nBecause values of formData object can only by any of these: string, Buffer, Stream. One solution is either change the type on the API contract or convert the file to Stream before posting it or change the API signature. Even at openai docs, before sending the file the method fs.createReadStream() is called.\r\n\r\nAll in all, if we want to use the file Path the fs.createReadStream should be inside Openai lib.\r\nIf we want to not change the openai lib, we need to change the signature to ReadStream\r\n\r\nconst { Configuration, OpenAIApi } = require(\"openai\");\r\nconst configuration = new Configuration({\r\n apiKey: process.env.OPENAI_API_KEY,\r\n});\r\nconst openai = new OpenAIApi(configuration);\r\nconst resp = await openai.createTranscription(\r\n fs.createReadStream(\"audio.mp3\"),\r\n \"whisper-1\"\r\n);","shortMessageHtmlLink":"File needs to be a ReadStream"}}],"hasNextPage":false,"hasPreviousPage":false,"activityType":"all","actor":null,"timePeriod":"all","sort":"DESC","perPage":30,"cursor":"djE6ks8AAAADInr5xQA","startCursor":null,"endCursor":null}},"title":"Activity ยท Pedroglp/openai-node"}