Skip to content

Commit

Permalink
fix: handle both web ReadableStream and NodeJS.ReadableStream in form…
Browse files Browse the repository at this point in the history
… data
  • Loading branch information
devin-ai-integration[bot] committed Dec 24, 2024
1 parent d3719b1 commit 031b8ce
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/resources/messages.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FormData, File } from 'formdata-node';
import { ReadableStream } from 'node:stream/web';
import { Readable } from 'node:stream';
import APIClient, { RequestOptionsParams } from '../apiClient.js';
import { Overrides } from '../config.js';
import {
Expand Down Expand Up @@ -327,8 +328,8 @@ export class Messages extends Resource {
const contentId = attachment.contentId || `file${index}`;
// Handle different types of content (Buffer, ReadableStream, string)
let file;
if (attachment.content instanceof ReadableStream) {
// For ReadableStream, use it directly as the file
if (attachment.content instanceof ReadableStream || attachment.content instanceof Readable) {
// For ReadableStream or NodeJS.ReadableStream, use it directly as the file
file = attachment.content;
} else if (
attachment.content instanceof Buffer ||
Expand Down

0 comments on commit 031b8ce

Please sign in to comment.