Skip to content

Commit

Permalink
feat(api): add models for chat completion structured message types (#107
Browse files Browse the repository at this point in the history
)
  • Loading branch information
stainless-app[bot] committed Dec 10, 2024
1 parent 0ef9509 commit d32c311
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 31 deletions.
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-306e608fb1d0f4916763729873c3e0f5f1da0b036df8139702bb3710a1250f44.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2FTogetherAI-890ae6b21096103dfc5905cbb90612ca33f46c8a6712b3620d4f44173626f8e5.yml
2 changes: 2 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Types:
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionSystemMessageParam</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionTool</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionToolMessageParam</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionStructuredMessageImageURL</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionStructuredMessageText</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionUsage</a></code>
- <code><a href="./src/resources/chat/completions.ts">ChatCompletionUserMessageParam</a></code>

Expand Down
4 changes: 4 additions & 0 deletions src/resources/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
ChatCompletionSystemMessageParam,
ChatCompletionTool,
ChatCompletionToolMessageParam,
ChatCompletionStructuredMessageImageURL,
ChatCompletionStructuredMessageText,
ChatCompletionUsage,
ChatCompletionUserMessageParam,
CompletionCreateParams,
Expand All @@ -38,6 +40,8 @@ export declare namespace Chat {
type ChatCompletionSystemMessageParam as ChatCompletionSystemMessageParam,
type ChatCompletionTool as ChatCompletionTool,
type ChatCompletionToolMessageParam as ChatCompletionToolMessageParam,
type ChatCompletionStructuredMessageImageURL as ChatCompletionStructuredMessageImageURL,
type ChatCompletionStructuredMessageText as ChatCompletionStructuredMessageText,
type ChatCompletionUsage as ChatCompletionUsage,
type ChatCompletionUserMessageParam as ChatCompletionUserMessageParam,
type CompletionCreateParams as CompletionCreateParams,
Expand Down
53 changes: 29 additions & 24 deletions src/resources/chat/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,27 @@ export interface ChatCompletionToolMessageParam {
tool_call_id?: string;
}

export interface ChatCompletionStructuredMessageImageURL {
image_url: ChatCompletionStructuredMessageImageURL.ImageURL;

type: 'image_url';
}

export namespace ChatCompletionStructuredMessageImageURL {
export interface ImageURL {
/**
* The URL of the image as a plain string.
*/
url: string;
}
}

export interface ChatCompletionStructuredMessageText {
text: string;

type: 'text';
}

export interface ChatCompletionUsage {
completion_tokens: number;

Expand Down Expand Up @@ -390,37 +411,19 @@ export namespace CompletionCreateParams {
* The content of the message, which can either be a simple string or a structured
* format.
*/
content: string | Array<Message.UnionMember0 | Message.UnionMember1>;
content:
| string
| Array<
| ChatCompletionsAPI.ChatCompletionStructuredMessageText
| ChatCompletionsAPI.ChatCompletionStructuredMessageImageURL
>;

/**
* The role of the messages author. Choice between: system, user, or assistant.
*/
role: 'system' | 'user' | 'assistant' | 'tool';
}

export namespace Message {
export interface UnionMember0 {
text: string;

type: 'text';
}

export interface UnionMember1 {
image_url: UnionMember1.ImageURL;

type: 'image_url';
}

export namespace UnionMember1 {
export interface ImageURL {
/**
* The URL of the image as a plain string.
*/
url: string;
}
}
}

export interface Name {
name: string;
}
Expand Down Expand Up @@ -473,6 +476,8 @@ export declare namespace Completions {
type ChatCompletionSystemMessageParam as ChatCompletionSystemMessageParam,
type ChatCompletionTool as ChatCompletionTool,
type ChatCompletionToolMessageParam as ChatCompletionToolMessageParam,
type ChatCompletionStructuredMessageImageURL as ChatCompletionStructuredMessageImageURL,
type ChatCompletionStructuredMessageText as ChatCompletionStructuredMessageText,
type ChatCompletionUsage as ChatCompletionUsage,
type ChatCompletionUserMessageParam as ChatCompletionUserMessageParam,
type CompletionCreateParams as CompletionCreateParams,
Expand Down
14 changes: 8 additions & 6 deletions src/resources/chat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@

export { Chat } from './chat';
export {
ChatCompletion,
ChatCompletionAssistantMessageParam,
ChatCompletionChunk,
ChatCompletionFunctionMessageParam,
ChatCompletionMessage,
ChatCompletionMessageParam,
ChatCompletionSystemMessageParam,
ChatCompletionTool,
ChatCompletionToolMessageParam,
ChatCompletionUsage,
ChatCompletionUserMessageParam,
CompletionCreateParams,
CompletionCreateParamsNonStreaming,
CompletionCreateParamsStreaming,
Completions,
type ChatCompletion,
type ChatCompletionChunk,
type ChatCompletionStructuredMessageImageURL,
type ChatCompletionStructuredMessageText,
type ChatCompletionUsage,
type CompletionCreateParams,
type CompletionCreateParamsNonStreaming,
type CompletionCreateParamsStreaming,
} from './completions';

0 comments on commit d32c311

Please sign in to comment.