Skip to content

Commit 7be94af

Browse files
feat(api): manual updates (#8)
1 parent a49c999 commit 7be94af

31 files changed

+83
-83
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ cd together-typescript
5555
# With yarn
5656
yarn link
5757
cd ../my-package
58-
yarn link together
58+
yarn link together-ai
5959

6060
# With pnpm
6161
pnpm link --global
6262
cd ../my-package
63-
pnpm link -—global together
63+
pnpm link -—global together-ai
6464
```
6565

6666
## Running tests

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Together Node API Library
22

3-
[![NPM version](https://img.shields.io/npm/v/together.svg)](https://npmjs.org/package/together)
3+
[![NPM version](https://img.shields.io/npm/v/together-ai.svg)](https://npmjs.org/package/together-ai)
44

55
This library provides convenient access to the Together REST API from server-side TypeScript or JavaScript.
66

@@ -11,7 +11,7 @@ It is generated with [Stainless](https://www.stainlessapi.com/).
1111
## Installation
1212

1313
```sh
14-
npm install together
14+
npm install together-ai
1515
```
1616

1717
## Usage
@@ -20,7 +20,7 @@ The full API of this library can be found in [api.md](api.md).
2020

2121
<!-- prettier-ignore -->
2222
```js
23-
import Together from 'together';
23+
import Together from 'together-ai';
2424

2525
const together = new Together({
2626
accessToken: process.env['TOGETHER_API_KEY'], // This is the default and can be omitted
@@ -43,7 +43,7 @@ main();
4343
We provide support for streaming responses using Server Sent Events (SSE).
4444

4545
```ts
46-
import Together from 'together';
46+
import Together from 'together-ai';
4747

4848
const together = new Together();
4949

@@ -66,7 +66,7 @@ This library includes TypeScript definitions for all request params and response
6666

6767
<!-- prettier-ignore -->
6868
```ts
69-
import Together from 'together';
69+
import Together from 'together-ai';
7070

7171
const together = new Together({
7272
accessToken: process.env['TOGETHER_API_KEY'], // This is the default and can be omitted
@@ -254,11 +254,11 @@ add the following import before your first import `from "Together"`:
254254
```ts
255255
// Tell TypeScript and the package to use the global web fetch instead of node-fetch.
256256
// Note, despite the name, this does not add any polyfills, but expects them to be provided if needed.
257-
import 'together/shims/web';
258-
import Together from 'together';
257+
import 'together-ai/shims/web';
258+
import Together from 'together-ai';
259259
```
260260

261-
To do the inverse, add `import "together/shims/node"` (which does import polyfills).
261+
To do the inverse, add `import "together-ai/shims/node"` (which does import polyfills).
262262
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/togethercomputer/together-typescript/tree/main/src/_shims#readme)).
263263

264264
### Logging and middleware
@@ -268,7 +268,7 @@ which can be used to inspect or alter the `Request` or `Response` before/after e
268268

269269
```ts
270270
import { fetch } from 'undici'; // as one example
271-
import Together from 'together';
271+
import Together from 'together-ai';
272272

273273
const client = new Together({
274274
fetch: async (url: RequestInfo, init?: RequestInit): Promise<Response> => {
@@ -330,7 +330,7 @@ TypeScript >= 4.5 is supported.
330330
The following runtimes are supported:
331331

332332
- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
333-
- Deno v1.28.0 or higher, using `import Together from "npm:together"`.
333+
- Deno v1.28.0 or higher, using `import Together from "npm:together-ai"`.
334334
- Bun 1.0 or later.
335335
- Cloudflare Workers.
336336
- Vercel Edge Runtime.

jest.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ const config: JestConfigWithTsJest = {
77
'^.+\\.(t|j)sx?$': ['@swc/jest', { sourceMaps: 'inline' }],
88
},
99
moduleNameMapper: {
10-
'^together$': '<rootDir>/src/index.ts',
11-
'^together/_shims/auto/(.*)$': '<rootDir>/src/_shims/auto/$1-node',
12-
'^together/(.*)$': '<rootDir>/src/$1',
10+
'^together-ai$': '<rootDir>/src/index.ts',
11+
'^together-ai/_shims/auto/(.*)$': '<rootDir>/src/_shims/auto/$1-node',
12+
'^together-ai/(.*)$': '<rootDir>/src/$1',
1313
},
1414
modulePathIgnorePatterns: [
1515
'<rootDir>/ecosystem-tests/',

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "together",
2+
"name": "together-ai",
33
"version": "0.1.0-alpha.1",
44
"description": "The official TypeScript library for the Together API",
55
"author": "Together <[email protected]>",
@@ -61,8 +61,8 @@
6161
"./shims/web.mjs"
6262
],
6363
"imports": {
64-
"together": ".",
65-
"together/*": "./src/*"
64+
"together-ai": ".",
65+
"together-ai/*": "./src/*"
6666
},
6767
"exports": {
6868
"./_shims/auto/*": {

scripts/build

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ node scripts/utils/check-version.cjs
88

99
# Build into dist and will publish the package from there,
1010
# so that src/resources/foo.ts becomes <package root>/resources/foo.js
11-
# This way importing from `"together/resources/foo"` works
11+
# This way importing from `"together-ai/resources/foo"` works
1212
# even with `"moduleResolution": "node"`
1313

1414
rm -rf dist; mkdir dist
@@ -47,8 +47,8 @@ node scripts/utils/postprocess-files.cjs
4747

4848
# make sure that nothing crashes when we require the output CJS or
4949
# import the output ESM
50-
(cd dist && node -e 'require("together")')
51-
(cd dist && node -e 'import("together")' --input-type=module)
50+
(cd dist && node -e 'require("together-ai")')
51+
(cd dist && node -e 'import("together-ai")' --input-type=module)
5252

5353
if command -v deno &> /dev/null && [ -e ./scripts/build-deno ]
5454
then

scripts/utils/postprocess-files.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const fs = require('fs');
22
const path = require('path');
33
const { parse } = require('@typescript-eslint/parser');
44

5-
const pkgImportPath = process.env['PKG_IMPORT_PATH'] ?? 'together/';
5+
const pkgImportPath = process.env['PKG_IMPORT_PATH'] ?? 'together-ai/';
66

77
const distDir =
88
process.env['DIST_PATH'] ?
@@ -142,7 +142,7 @@ async function postprocess() {
142142

143143
if (file.endsWith('.d.ts')) {
144144
// work around bad tsc behavior
145-
// if we have `import { type Readable } from 'together/_shims/index'`,
145+
// if we have `import { type Readable } from 'together-ai/_shims/index'`,
146146
// tsc sometimes replaces `Readable` with `import("stream").Readable` inline
147147
// in the output .d.ts
148148
transformed = transformed.replace(/import\("stream"\).Readable/g, 'Readable');

src/_shims/README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# 👋 Wondering what everything in here does?
22

3-
`together` supports a wide variety of runtime environments like Node.js, Deno, Bun, browsers, and various
3+
`together-ai` supports a wide variety of runtime environments like Node.js, Deno, Bun, browsers, and various
44
edge runtimes, as well as both CommonJS (CJS) and EcmaScript Modules (ESM).
55

6-
To do this, `together` provides shims for either using `node-fetch` when in Node (because `fetch` is still experimental there) or the global `fetch` API built into the environment when not in Node.
6+
To do this, `together-ai` provides shims for either using `node-fetch` when in Node (because `fetch` is still experimental there) or the global `fetch` API built into the environment when not in Node.
77

88
It uses [conditional exports](https://nodejs.org/api/packages.html#conditional-exports) to
99
automatically select the correct shims for each environment. However, conditional exports are a fairly new
@@ -15,32 +15,32 @@ getting the wrong raw `Response` type from `.asResponse()`, for example.
1515

1616
The user can work around these issues by manually importing one of:
1717

18-
- `import 'together/shims/node'`
19-
- `import 'together/shims/web'`
18+
- `import 'together-ai/shims/node'`
19+
- `import 'together-ai/shims/web'`
2020

2121
All of the code here in `_shims` handles selecting the automatic default shims or manual overrides.
2222

2323
### How it works - Runtime
2424

25-
Runtime shims get installed by calling `setShims` exported by `together/_shims/registry`.
25+
Runtime shims get installed by calling `setShims` exported by `together-ai/_shims/registry`.
2626

27-
Manually importing `together/shims/node` or `together/shims/web`, calls `setShims` with the respective runtime shims.
27+
Manually importing `together-ai/shims/node` or `together-ai/shims/web`, calls `setShims` with the respective runtime shims.
2828

29-
All client code imports shims from `together/_shims/index`, which:
29+
All client code imports shims from `together-ai/_shims/index`, which:
3030

3131
- checks if shims have been set manually
32-
- if not, calls `setShims` with the shims from `together/_shims/auto/runtime`
33-
- re-exports the installed shims from `together/_shims/registry`.
32+
- if not, calls `setShims` with the shims from `together-ai/_shims/auto/runtime`
33+
- re-exports the installed shims from `together-ai/_shims/registry`.
3434

35-
`together/_shims/auto/runtime` exports web runtime shims.
36-
If the `node` export condition is set, the export map replaces it with `together/_shims/auto/runtime-node`.
35+
`together-ai/_shims/auto/runtime` exports web runtime shims.
36+
If the `node` export condition is set, the export map replaces it with `together-ai/_shims/auto/runtime-node`.
3737

3838
### How it works - Type time
3939

40-
All client code imports shim types from `together/_shims/index`, which selects the manual types from `together/_shims/manual-types` if they have been declared, otherwise it exports the auto types from `together/_shims/auto/types`.
40+
All client code imports shim types from `together-ai/_shims/index`, which selects the manual types from `together-ai/_shims/manual-types` if they have been declared, otherwise it exports the auto types from `together-ai/_shims/auto/types`.
4141

42-
`together/_shims/manual-types` exports an empty namespace.
43-
Manually importing `together/shims/node` or `together/shims/web` merges declarations into this empty namespace, so they get picked up by `together/_shims/index`.
42+
`together-ai/_shims/manual-types` exports an empty namespace.
43+
Manually importing `together-ai/shims/node` or `together-ai/shims/web` merges declarations into this empty namespace, so they get picked up by `together-ai/_shims/index`.
4444

45-
`together/_shims/auto/types` exports web type definitions.
46-
If the `node` export condition is set, the export map replaces it with `together/_shims/auto/types-node`, though TS only picks this up if `"moduleResolution": "nodenext"` or `"moduleResolution": "bundler"`.
45+
`together-ai/_shims/auto/types` exports web type definitions.
46+
If the `node` export condition is set, the export map replaces it with `together-ai/_shims/auto/types-node`, though TS only picks this up if `"moduleResolution": "nodenext"` or `"moduleResolution": "bundler"`.

src/_shims/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
33
*/
44
import { manual } from './manual-types';
5-
import * as auto from 'together/_shims/auto/types';
5+
import * as auto from 'together-ai/_shims/auto/types';
66
import { type RequestOptions } from '../core';
77

88
type SelectType<Manual, Auto> = unknown extends Manual ? Auto : Manual;

src/_shims/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
33
*/
44
const shims = require('./registry');
5-
const auto = require('together/_shims/auto/runtime');
5+
const auto = require('together-ai/_shims/auto/runtime');
66
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
77
for (const property of Object.keys(shims)) {
88
Object.defineProperty(exports, property, {

src/_shims/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
33
*/
44
import * as shims from './registry.mjs';
5-
import * as auto from 'together/_shims/auto/runtime';
5+
import * as auto from 'together-ai/_shims/auto/runtime';
66
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
77
export * from './registry.mjs';

0 commit comments

Comments
 (0)