Skip to content

Commit

Permalink
chore(internal): version bump (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stainless Bot committed Nov 11, 2024
1 parent e8119a6 commit 2e9673e
Show file tree
Hide file tree
Showing 18 changed files with 216 additions and 151 deletions.
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 scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -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
133 changes: 88 additions & 45 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,7 @@ export class Together extends Core.APIClient {
static fileFromPath = Uploads.fileFromPath;
}

export const {
export {
TogetherError,
APIError,
APIConnectionError,
Expand All @@ -188,52 +219,64 @@ export const {
InternalServerError,
PermissionDeniedError,
UnprocessableEntityError,
} = Errors;
} from './error';

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;
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 default Together;
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,
};
}
32 changes: 17 additions & 15 deletions src/resources/chat/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,19 +438,21 @@ export interface CompletionCreateParamsStreaming extends CompletionCreateParamsB
stream: true;
}

export namespace Completions {
export import ChatCompletion = ChatCompletionsAPI.ChatCompletion;
export import ChatCompletionAssistantMessageParam = ChatCompletionsAPI.ChatCompletionAssistantMessageParam;
export import ChatCompletionChunk = ChatCompletionsAPI.ChatCompletionChunk;
export import ChatCompletionFunctionMessageParam = ChatCompletionsAPI.ChatCompletionFunctionMessageParam;
export import ChatCompletionMessage = ChatCompletionsAPI.ChatCompletionMessage;
export import ChatCompletionMessageParam = ChatCompletionsAPI.ChatCompletionMessageParam;
export import ChatCompletionSystemMessageParam = ChatCompletionsAPI.ChatCompletionSystemMessageParam;
export import ChatCompletionTool = ChatCompletionsAPI.ChatCompletionTool;
export import ChatCompletionToolMessageParam = ChatCompletionsAPI.ChatCompletionToolMessageParam;
export import ChatCompletionUsage = ChatCompletionsAPI.ChatCompletionUsage;
export import ChatCompletionUserMessageParam = ChatCompletionsAPI.ChatCompletionUserMessageParam;
export import CompletionCreateParams = ChatCompletionsAPI.CompletionCreateParams;
export import CompletionCreateParamsNonStreaming = ChatCompletionsAPI.CompletionCreateParamsNonStreaming;
export import CompletionCreateParamsStreaming = ChatCompletionsAPI.CompletionCreateParamsStreaming;
export declare namespace Completions {
export {
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,
};
}
18 changes: 10 additions & 8 deletions src/resources/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,14 @@ export interface CompletionCreateParamsStreaming extends CompletionCreateParamsB
stream: true;
}

export namespace Completions {
export import Completion = CompletionsAPI.Completion;
export import LogProbs = CompletionsAPI.LogProbs;
export import ToolChoice = CompletionsAPI.ToolChoice;
export import Tools = CompletionsAPI.Tools;
export import CompletionCreateParams = CompletionsAPI.CompletionCreateParams;
export import CompletionCreateParamsNonStreaming = CompletionsAPI.CompletionCreateParamsNonStreaming;
export import CompletionCreateParamsStreaming = CompletionsAPI.CompletionCreateParamsStreaming;
export declare namespace Completions {
export {
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,
};
}
6 changes: 2 additions & 4 deletions src/resources/embeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { APIResource } from '../resource';
import * as Core from '../core';
import * as EmbeddingsAPI from './embeddings';

export class Embeddings extends APIResource {
/**
Expand Down Expand Up @@ -50,7 +49,6 @@ export interface EmbeddingCreateParams {
| (string & {});
}

export namespace Embeddings {
export import Embedding = EmbeddingsAPI.Embedding;
export import EmbeddingCreateParams = EmbeddingsAPI.EmbeddingCreateParams;
export declare namespace Embeddings {
export { type Embedding as Embedding, type EmbeddingCreateParams as EmbeddingCreateParams };
}
13 changes: 7 additions & 6 deletions src/resources/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { APIResource } from '../resource';
import * as Core from '../core';
import * as FilesAPI from './files';
import { type Response } from '../_shims/index';

export class Files extends APIResource {
Expand Down Expand Up @@ -104,9 +103,11 @@ export interface FileDeleteResponse {
deleted?: boolean;
}

export namespace Files {
export import FileObject = FilesAPI.FileObject;
export import FileRetrieveResponse = FilesAPI.FileRetrieveResponse;
export import FileListResponse = FilesAPI.FileListResponse;
export import FileDeleteResponse = FilesAPI.FileDeleteResponse;
export declare namespace Files {
export {
type FileObject as FileObject,
type FileRetrieveResponse as FileRetrieveResponse,
type FileListResponse as FileListResponse,
type FileDeleteResponse as FileDeleteResponse,
};
}
Loading

0 comments on commit 2e9673e

Please sign in to comment.