Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
billytrend-cohere committed Jul 30, 2024
1 parent 0a09a0b commit 53202aa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as core from "./core";
import * as Cohere from "./api/index";
import * as serializers from "./serialization/index";
import urlJoin from "url-join";
import * as stream from "stream";
import * as stream from "readable-stream";
import * as errors from "./errors/index";
import { EmbedJobs } from "./api/resources/embedJobs/client/Client";
import { Datasets } from "./api/resources/datasets/client/Client";
Expand Down
42 changes: 21 additions & 21 deletions src/core/form-data-utils/FormDataWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export async function newFormData(): Promise<CrossPlatformFormData> {
class Node18FormData implements CrossPlatformFormData {
private fd:
| {
append(name: string, value: unknown, fileName?: string): void;
}
append(name: string, value: unknown, fileName?: string): void;
}
| undefined;

public async setup() {
Expand All @@ -50,7 +50,7 @@ class Node18FormData implements CrossPlatformFormData {
}

public async appendFile(key: string, value: unknown, fileName?: string): Promise<void> {
if (value instanceof (await import("stream")).Readable) {
if (value instanceof (await import("readable-stream")).Readable) {
this.fd?.append(key, {
type: undefined,
name: fileName,
Expand All @@ -67,7 +67,7 @@ class Node18FormData implements CrossPlatformFormData {
public async getRequest(): Promise<FormDataRequest<unknown>> {
const encoder = new (await import("form-data-encoder")).FormDataEncoder(this.fd as any);
return {
body: await (await import("stream")).Readable.from(encoder),
body: await (await import("readable-stream")).Readable.from(encoder),
headers: encoder.headers,
duplex: "half",
};
Expand All @@ -80,22 +80,22 @@ class Node18FormData implements CrossPlatformFormData {
class Node16FormData implements CrossPlatformFormData {
private fd:
| {
append(
name: string,
value: unknown,
options?:
| string
| {
header?: string | Headers;
knownLength?: number;
filename?: string;
filepath?: string;
contentType?: string;
}
): void;

getHeaders(): Record<string, string>;
}
append(
name: string,
value: unknown,
options?:
| string
| {
header?: string | Headers;
knownLength?: number;
filename?: string;
filepath?: string;
contentType?: string;
}
): void;

getHeaders(): Record<string, string>;
}
| undefined;

public async setup(): Promise<void> {
Expand All @@ -108,7 +108,7 @@ class Node16FormData implements CrossPlatformFormData {

public async appendFile(key: string, value: unknown, fileName?: string): Promise<void> {
let bufferedValue;
if (!(value instanceof (await import("stream")).Readable)) {
if (!(value instanceof (await import("readable-stream")).Readable)) {
bufferedValue = Buffer.from(await (value as any).arrayBuffer());
} else {
bufferedValue = value;
Expand Down
2 changes: 1 addition & 1 deletion src/core/streaming-fetcher/Stream.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Readable } from "stream";
import { Readable } from "readable-stream";
import { RUNTIME } from "../runtime";

export declare namespace Stream {
Expand Down

0 comments on commit 53202aa

Please sign in to comment.