From d32c3110fd50470cbb563bfa5213fb6bf831ecc6 Mon Sep 17 00:00:00 2001
From: "stainless-app[bot]"
<142633134+stainless-app[bot]@users.noreply.github.com>
Date: Tue, 10 Dec 2024 21:13:09 +0000
Subject: [PATCH] feat(api): add models for chat completion structured message
types (#107)
---
.stats.yml | 2 +-
api.md | 2 ++
src/resources/chat/chat.ts | 4 +++
src/resources/chat/completions.ts | 53 +++++++++++++++++--------------
src/resources/chat/index.ts | 14 ++++----
5 files changed, 44 insertions(+), 31 deletions(-)
diff --git a/.stats.yml b/.stats.yml
index b0050f5..72cf23c 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -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
diff --git a/api.md b/api.md
index a4b600d..d7780f7 100644
--- a/api.md
+++ b/api.md
@@ -23,6 +23,8 @@ Types:
- ChatCompletionSystemMessageParam
- ChatCompletionTool
- ChatCompletionToolMessageParam
+- ChatCompletionStructuredMessageImageURL
+- ChatCompletionStructuredMessageText
- ChatCompletionUsage
- ChatCompletionUserMessageParam
diff --git a/src/resources/chat/chat.ts b/src/resources/chat/chat.ts
index 6f0778f..0dd8f8d 100644
--- a/src/resources/chat/chat.ts
+++ b/src/resources/chat/chat.ts
@@ -12,6 +12,8 @@ import {
ChatCompletionSystemMessageParam,
ChatCompletionTool,
ChatCompletionToolMessageParam,
+ ChatCompletionStructuredMessageImageURL,
+ ChatCompletionStructuredMessageText,
ChatCompletionUsage,
ChatCompletionUserMessageParam,
CompletionCreateParams,
@@ -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,
diff --git a/src/resources/chat/completions.ts b/src/resources/chat/completions.ts
index 603defb..26fcf5c 100644
--- a/src/resources/chat/completions.ts
+++ b/src/resources/chat/completions.ts
@@ -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;
@@ -390,7 +411,12 @@ export namespace CompletionCreateParams {
* The content of the message, which can either be a simple string or a structured
* format.
*/
- content: string | Array;
+ content:
+ | string
+ | Array<
+ | ChatCompletionsAPI.ChatCompletionStructuredMessageText
+ | ChatCompletionsAPI.ChatCompletionStructuredMessageImageURL
+ >;
/**
* The role of the messages author. Choice between: system, user, or assistant.
@@ -398,29 +424,6 @@ export namespace CompletionCreateParams {
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;
}
@@ -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,
diff --git a/src/resources/chat/index.ts b/src/resources/chat/index.ts
index 89c8a6d..2f80d74 100644
--- a/src/resources/chat/index.ts
+++ b/src/resources/chat/index.ts
@@ -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';