Skip to content

Commit 68895c0

Browse files
committed
chore(api): Ensure file.upload API remains in codebase after stainless sync
1 parent 70a0ddc commit 68895c0

File tree

3 files changed

+10
-29
lines changed

3 files changed

+10
-29
lines changed

README.md

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -77,35 +77,6 @@ const chatCompletion: Together.Chat.ChatCompletion = await client.chat.completio
7777

7878
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
7979

80-
## File uploads
81-
82-
Request parameters that correspond to file uploads can be passed in many different forms:
83-
84-
- `File` (or an object with the same structure)
85-
- a `fetch` `Response` (or an object with the same structure)
86-
- an `fs.ReadStream`
87-
- the return value of our `toFile` helper
88-
89-
```ts
90-
import fs from 'fs';
91-
import Together, { toFile } from 'together-ai';
92-
93-
const client = new Together();
94-
95-
// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
96-
await client.audio.transcriptions.create({ file: fs.createReadStream('/path/to/file') });
97-
98-
// Or if you have the web `File` API you can pass a `File` instance:
99-
await client.audio.transcriptions.create({ file: new File(['my bytes'], 'file') });
100-
101-
// You can also pass a `fetch` `Response`:
102-
await client.audio.transcriptions.create({ file: await fetch('https://somesite/file') });
103-
104-
// Finally, if none of the above are convenient, you can use our `toFile` helper:
105-
await client.audio.transcriptions.create({ file: await toFile(Buffer.from('my bytes'), 'file') });
106-
await client.audio.transcriptions.create({ file: await toFile(new Uint8Array([0, 1, 2]), 'file') });
107-
```
108-
10980
## Handling errors
11081

11182
When the library is unable to connect to the API,

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Methods:
6464
- <code title="get /files">client.files.<a href="./src/resources/files.ts">list</a>() -> FileListResponse</code>
6565
- <code title="delete /files/{id}">client.files.<a href="./src/resources/files.ts">delete</a>(id) -> FileDeleteResponse</code>
6666
- <code title="get /files/{id}/content">client.files.<a href="./src/resources/files.ts">content</a>(id) -> Response</code>
67+
- <code title="post /files/upload">client.files.<a href="./src/resources/files.ts">upload</a>({ ...params }) -> FileRetrieveResponse</code>
6768

6869
# FineTuning
6970

src/resources/files.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { APIPromise } from '../core/api-promise';
66
import { buildHeaders } from '../internal/headers';
77
import { RequestOptions } from '../internal/request-options';
88
import { path } from '../internal/utils/path';
9+
import { upload } from '../lib/upload';
910

1011
export class Files extends APIResource {
1112
/**
@@ -62,6 +63,14 @@ export class Files extends APIResource {
6263
__binaryResponse: true,
6364
});
6465
}
66+
67+
/**
68+
* Upload a file.
69+
* CUSTOM CODE. DO NOT LET STAINLESS REMOVE.
70+
*/
71+
upload(file: string, purpose: FilePurpose, check: boolean = true): APIPromise<FileRetrieveResponse> {
72+
return upload(this._client, file, purpose, check);
73+
}
6574
}
6675

6776
export interface FileObject {

0 commit comments

Comments
 (0)