Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 0.10.0 #86

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ yarn-error.log
codegen.log
Brewfile.lock.json
dist
/deno
dist-deno
/*.tgz
.idea/

2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.9.0"
".": "0.10.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 16
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2FTogetherAI-3950390ec89ef1e5aec351d8e841d511ebc0a3ccec5bbf0d4c73157d1f9d7c1d.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2FTogetherAI-692e6d7ba3069e890bfe0fcb77a92f52bd5991cc571acaae6e679e4190a936e1.yml
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# Changelog

## 0.10.0 (2024-11-27)

Full Changelog: [v0.9.0...v0.10.0](https://github.com/togethercomputer/together-typescript/compare/v0.9.0...v0.10.0)

### Features

* **api:** api update ([#89](https://github.com/togethercomputer/together-typescript/issues/89)) ([57feb67](https://github.com/togethercomputer/together-typescript/commit/57feb67b12cf751f61c99efbe4307f095171e4c6))
* **api:** api update ([#92](https://github.com/togethercomputer/together-typescript/issues/92)) ([175e523](https://github.com/togethercomputer/together-typescript/commit/175e523d9f0866ffb7f1caac7706a548beb90edd))
* **api:** api update ([#95](https://github.com/togethercomputer/together-typescript/issues/95)) ([b54fc92](https://github.com/togethercomputer/together-typescript/commit/b54fc92dd5a57911f8929e10ba9f4b14f21573fb))
* **api:** api update ([#96](https://github.com/togethercomputer/together-typescript/issues/96)) ([794ee52](https://github.com/togethercomputer/together-typescript/commit/794ee52c0b8158e0ac1c6c8cc7cdb20efe878164))
* **api:** api update ([#97](https://github.com/togethercomputer/together-typescript/issues/97)) ([8f485c9](https://github.com/togethercomputer/together-typescript/commit/8f485c99096c992563ba9ab1c3b48164c745ccc2))


### Bug Fixes

* **internal:** fix import ([be8bc88](https://github.com/togethercomputer/together-typescript/commit/be8bc881e221419d866e15b09d5db865c063404a))


### Chores

* **internal:** version bump ([#83](https://github.com/togethercomputer/together-typescript/issues/83)) ([2e9673e](https://github.com/togethercomputer/together-typescript/commit/2e9673ea076868d839da23475010ff9b788b46b2))
* rebuild project due to codegen change ([#87](https://github.com/togethercomputer/together-typescript/issues/87)) ([800fd5a](https://github.com/togethercomputer/together-typescript/commit/800fd5ac7f9a3583af76f53f4252cd7b903c502b))
* rebuild project due to codegen change ([#88](https://github.com/togethercomputer/together-typescript/issues/88)) ([7db117f](https://github.com/togethercomputer/together-typescript/commit/7db117f28947071b3a70367dbcb3e33ec9e3726a))
* rebuild project due to codegen change ([#90](https://github.com/togethercomputer/together-typescript/issues/90)) ([7d5a9b4](https://github.com/togethercomputer/together-typescript/commit/7d5a9b4e1cade5623708a7a482dd6378ee9d2e9c))
* rebuild project due to codegen change ([#91](https://github.com/togethercomputer/together-typescript/issues/91)) ([1703fbc](https://github.com/togethercomputer/together-typescript/commit/1703fbc7a85ee7579e98e3f74ff3a859d27cb3c0))
* remove redundant word in comment ([#94](https://github.com/togethercomputer/together-typescript/issues/94)) ([bedbb68](https://github.com/togethercomputer/together-typescript/commit/bedbb684c0a7d6fadabbea07f0bcd124cb1bd180))


### Documentation

* remove suggestion to use `npm` call out ([#93](https://github.com/togethercomputer/together-typescript/issues/93)) ([52bdca6](https://github.com/togethercomputer/together-typescript/commit/52bdca6a299965f96b65082d2dcff62a3771e1b4))

## 0.9.0 (2024-11-05)

Full Changelog: [v0.8.0...v0.9.0](https://github.com/togethercomputer/together-typescript/compare/v0.8.0...v0.9.0)
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,15 @@ TypeScript >= 4.5 is supported.

The following runtimes are supported:

- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)
- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
- Deno v1.28.0 or higher.
- Bun 1.0 or later.
- Cloudflare Workers.
- Vercel Edge Runtime.
- Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time).
- Nitro v2.6 or greater.

Note that React Native is not supported at this time.

If you are interested in other runtime environments, please open or upvote an issue on GitHub.
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "together-ai",
"version": "0.9.0",
"version": "0.10.0",
"description": "The official TypeScript library for the Together API",
"author": "Together <[email protected]>",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -50,7 +50,6 @@
"jest": "^29.4.0",
"prettier": "^3.0.0",
"ts-jest": "^29.1.0",
"ts-morph": "^19.0.0",
"ts-node": "^10.5.0",
"tsc-multi": "^1.1.0",
"tsconfig-paths": "^4.0.0",
Expand Down
4 changes: 2 additions & 2 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ npm exec tsc-multi
# copy over handwritten .js/.mjs/.d.ts files
cp src/_shims/*.{d.ts,js,mjs,md} dist/_shims
cp src/_shims/auto/*.{d.ts,js,mjs} dist/_shims/auto
# we need to add exports = module.exports = Together Node to index.js;
# we need to add exports = module.exports = Together to index.js;
# No way to get that from index.ts because it would cause compile errors
# when building .mjs
node scripts/utils/fix-index-exports.cjs
Expand All @@ -50,7 +50,7 @@ node scripts/utils/postprocess-files.cjs
(cd dist && node -e 'require("together-ai")')
(cd dist && node -e 'import("together-ai")' --input-type=module)

if command -v deno &> /dev/null && [ -e ./scripts/build-deno ]
if [ -e ./scripts/build-deno ]
then
./scripts/build-deno
fi
10 changes: 5 additions & 5 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ export abstract class APIClient {
error: Object | undefined,
message: string | undefined,
headers: Headers | undefined,
) {
): APIError {
return APIError.generate(status, error, message, headers);
}

Expand Down Expand Up @@ -682,17 +682,17 @@ export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
return await this.#client.requestAPIList(this.constructor as any, nextOptions);
}

async *iterPages() {
async *iterPages(): AsyncGenerator<this> {
// eslint-disable-next-line @typescript-eslint/no-this-alias
let page: AbstractPage<Item> = this;
let page: this = this;
yield page;
while (page.hasNextPage()) {
page = await page.getNextPage();
yield page;
}
}

async *[Symbol.asyncIterator]() {
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
for await (const page of this.iterPages()) {
for (const item of page.getPaginatedItems()) {
yield item;
Expand Down Expand Up @@ -735,7 +735,7 @@ export class PagePromise<
* console.log(item)
* }
*/
async *[Symbol.asyncIterator]() {
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
const page = await this;
for await (const item of page) {
yield item;
Expand Down
2 changes: 1 addition & 1 deletion src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class APIError extends TogetherError {
errorResponse: Object | undefined,
message: string | undefined,
headers: Headers | undefined,
) {
): APIError {
if (!status) {
return new APIConnectionError({ message, cause: castToError(errorResponse) });
}
Expand Down
140 changes: 90 additions & 50 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,42 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Errors from './error';
import * as Uploads from './uploads';
import { type Agent } from './_shims/index';
import * as Core from './core';
import * as Errors from './error';
import * as Uploads from './uploads';
import * as API from './resources/index';
import * as TopLevelAPI from './resources/top-level';
import { RerankParams, RerankResponse } from './resources/top-level';
import {
Completion,
CompletionCreateParams,
CompletionCreateParamsNonStreaming,
CompletionCreateParamsStreaming,
Completions,
LogProbs,
ToolChoice,
Tools,
} from './resources/completions';
import { Embedding, EmbeddingCreateParams, Embeddings } from './resources/embeddings';
import {
FileDeleteResponse,
FileListResponse,
FileObject,
FileRetrieveResponse,
Files,
} from './resources/files';
import {
FineTune,
FineTuneCreateParams,
FineTuneDownloadParams,
FineTuneDownloadResponse,
FineTuneEvent,
FineTuneListResponse,
FineTuneResource,
} from './resources/fine-tune';
import { ImageCreateParams, ImageFile, Images } from './resources/images';
import { ModelListResponse, Models } from './resources/models';
import { Chat } from './resources/chat/chat';

export interface ClientOptions {
/**
Expand Down Expand Up @@ -174,7 +205,62 @@ export class Together extends Core.APIClient {
static fileFromPath = Uploads.fileFromPath;
}

export const {
Together.Chat = Chat;
Together.Completions = Completions;
Together.Embeddings = Embeddings;
Together.Files = Files;
Together.FineTuneResource = FineTuneResource;
Together.Images = Images;
Together.Models = Models;
export declare namespace Together {
export type RequestOptions = Core.RequestOptions;

export { type RerankResponse as RerankResponse, type RerankParams as RerankParams };

export { Chat as Chat };

export {
Completions as Completions,
type Completion as Completion,
type LogProbs as LogProbs,
type ToolChoice as ToolChoice,
type Tools as Tools,
type CompletionCreateParams as CompletionCreateParams,
type CompletionCreateParamsNonStreaming as CompletionCreateParamsNonStreaming,
type CompletionCreateParamsStreaming as CompletionCreateParamsStreaming,
};

export {
Embeddings as Embeddings,
type Embedding as Embedding,
type EmbeddingCreateParams as EmbeddingCreateParams,
};

export {
Files as Files,
type FileObject as FileObject,
type FileRetrieveResponse as FileRetrieveResponse,
type FileListResponse as FileListResponse,
type FileDeleteResponse as FileDeleteResponse,
};

export {
FineTuneResource as FineTuneResource,
type FineTune as FineTune,
type FineTuneEvent as FineTuneEvent,
type FineTuneListResponse as FineTuneListResponse,
type FineTuneDownloadResponse as FineTuneDownloadResponse,
type FineTuneCreateParams as FineTuneCreateParams,
type FineTuneDownloadParams as FineTuneDownloadParams,
};

export { Images as Images, type ImageFile as ImageFile, type ImageCreateParams as ImageCreateParams };

export { Models as Models, type ModelListResponse as ModelListResponse };
}

export { toFile, fileFromPath } from './uploads';
export {
TogetherError,
APIError,
APIConnectionError,
Expand All @@ -188,52 +274,6 @@ export const {
InternalServerError,
PermissionDeniedError,
UnprocessableEntityError,
} = Errors;

export import toFile = Uploads.toFile;
export import fileFromPath = Uploads.fileFromPath;

export namespace Together {
export import RequestOptions = Core.RequestOptions;

export import RerankResponse = API.RerankResponse;
export import RerankParams = API.RerankParams;

export import Chat = API.Chat;

export import Completions = API.Completions;
export import Completion = API.Completion;
export import LogProbs = API.LogProbs;
export import ToolChoice = API.ToolChoice;
export import Tools = API.Tools;
export import CompletionCreateParams = API.CompletionCreateParams;
export import CompletionCreateParamsNonStreaming = API.CompletionCreateParamsNonStreaming;
export import CompletionCreateParamsStreaming = API.CompletionCreateParamsStreaming;

export import Embeddings = API.Embeddings;
export import Embedding = API.Embedding;
export import EmbeddingCreateParams = API.EmbeddingCreateParams;

export import Files = API.Files;
export import FileObject = API.FileObject;
export import FileRetrieveResponse = API.FileRetrieveResponse;
export import FileListResponse = API.FileListResponse;
export import FileDeleteResponse = API.FileDeleteResponse;

export import FineTuneResource = API.FineTuneResource;
export import FineTune = API.FineTune;
export import FineTuneEvent = API.FineTuneEvent;
export import FineTuneListResponse = API.FineTuneListResponse;
export import FineTuneDownloadResponse = API.FineTuneDownloadResponse;
export import FineTuneCreateParams = API.FineTuneCreateParams;
export import FineTuneDownloadParams = API.FineTuneDownloadParams;

export import Images = API.Images;
export import ImageFile = API.ImageFile;
export import ImageCreateParams = API.ImageCreateParams;

export import Models = API.Models;
export import ModelListResponse = API.ModelListResponse;
}
} from './error';

export default Together;
3 changes: 1 addition & 2 deletions src/lib/AbstractChatCompletionRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import {
ChatCompletionStreamingToolRunnerParams,
} from './ChatCompletionStreamingRunner';
import { isAssistantMessage, isFunctionMessage, isToolMessage } from './chatCompletionUtils';
import { Chat } from 'together-ai/resources';
import ChatCompletionUsage = Chat.ChatCompletionUsage;
import { ChatCompletionUsage } from 'together-ai/resources/chat/completions';

const DEFAULT_MAX_CHAT_COMPLETIONS = 10;
export interface RunnerOptions extends Core.RequestOptions {
Expand Down
53 changes: 37 additions & 16 deletions src/resources/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,46 @@

import { APIResource } from '../../resource';
import * as CompletionsAPI from './completions';
import {
ChatCompletion,
ChatCompletionAssistantMessageParam,
ChatCompletionChunk,
ChatCompletionFunctionMessageParam,
ChatCompletionMessage,
ChatCompletionMessageParam,
ChatCompletionSystemMessageParam,
ChatCompletionTool,
ChatCompletionToolMessageParam,
ChatCompletionUsage,
ChatCompletionUserMessageParam,
CompletionCreateParams,
CompletionCreateParamsNonStreaming,
CompletionCreateParamsStreaming,
Completions,
} from './completions';

export class Chat extends APIResource {
completions: CompletionsAPI.Completions = new CompletionsAPI.Completions(this._client);
}

export namespace Chat {
export import Completions = CompletionsAPI.Completions;
export import ChatCompletion = CompletionsAPI.ChatCompletion;
export import ChatCompletionAssistantMessageParam = CompletionsAPI.ChatCompletionAssistantMessageParam;
export import ChatCompletionChunk = CompletionsAPI.ChatCompletionChunk;
export import ChatCompletionFunctionMessageParam = CompletionsAPI.ChatCompletionFunctionMessageParam;
export import ChatCompletionMessage = CompletionsAPI.ChatCompletionMessage;
export import ChatCompletionMessageParam = CompletionsAPI.ChatCompletionMessageParam;
export import ChatCompletionSystemMessageParam = CompletionsAPI.ChatCompletionSystemMessageParam;
export import ChatCompletionTool = CompletionsAPI.ChatCompletionTool;
export import ChatCompletionToolMessageParam = CompletionsAPI.ChatCompletionToolMessageParam;
export import ChatCompletionUsage = CompletionsAPI.ChatCompletionUsage;
export import ChatCompletionUserMessageParam = CompletionsAPI.ChatCompletionUserMessageParam;
export import CompletionCreateParams = CompletionsAPI.CompletionCreateParams;
export import CompletionCreateParamsNonStreaming = CompletionsAPI.CompletionCreateParamsNonStreaming;
export import CompletionCreateParamsStreaming = CompletionsAPI.CompletionCreateParamsStreaming;
Chat.Completions = Completions;

export declare namespace Chat {
export {
Completions as Completions,
type ChatCompletion as ChatCompletion,
type ChatCompletionAssistantMessageParam as ChatCompletionAssistantMessageParam,
type ChatCompletionChunk as ChatCompletionChunk,
type ChatCompletionFunctionMessageParam as ChatCompletionFunctionMessageParam,
type ChatCompletionMessage as ChatCompletionMessage,
type ChatCompletionMessageParam as ChatCompletionMessageParam,
type ChatCompletionSystemMessageParam as ChatCompletionSystemMessageParam,
type ChatCompletionTool as ChatCompletionTool,
type ChatCompletionToolMessageParam as ChatCompletionToolMessageParam,
type ChatCompletionUsage as ChatCompletionUsage,
type ChatCompletionUserMessageParam as ChatCompletionUserMessageParam,
type CompletionCreateParams as CompletionCreateParams,
type CompletionCreateParamsNonStreaming as CompletionCreateParamsNonStreaming,
type CompletionCreateParamsStreaming as CompletionCreateParamsStreaming,
};
}
Loading