Skip to content

Commit

Permalink
chore(types): consistent naming for text block types (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored and RobertCraigie committed Apr 4, 2024
1 parent 06fc0f7 commit b1b743f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Types:
- <code><a href="./src/resources/messages.ts">MessageStopEvent</a></code>
- <code><a href="./src/resources/messages.ts">MessageStreamEvent</a></code>
- <code><a href="./src/resources/messages.ts">TextBlock</a></code>
- <code><a href="./src/resources/messages.ts">TextBlockParam</a></code>
- <code><a href="./src/resources/messages.ts">TextDelta</a></code>
- <code><a href="./src/resources/messages.ts">Usage</a></code>

Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export namespace Anthropic {
export import MessageStopEvent = API.MessageStopEvent;
export import MessageStreamEvent = API.MessageStreamEvent;
export import TextBlock = API.TextBlock;
export import TextBlockParam = API.TextBlockParam;
export import TextDelta = API.TextDelta;
export import Usage = API.Usage;
export import MessageCreateParams = API.MessageCreateParams;
Expand Down
1 change: 1 addition & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export {
MessageStopEvent,
MessageStreamEvent,
TextBlock,
TextBlockParam,
TextDelta,
Usage,
MessageCreateParams,
Expand Down
19 changes: 11 additions & 8 deletions src/resources/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ export class Messages extends APIResource {
}
}

export interface ContentBlock {
text: string;

type: 'text';
}
export type ContentBlock = TextBlock;

export interface ContentBlockDeltaEvent {
delta: TextDelta;
Expand All @@ -62,7 +58,7 @@ export interface ContentBlockDeltaEvent {
}

export interface ContentBlockStartEvent {
content_block: ContentBlock;
content_block: TextBlock;

index: number;

Expand Down Expand Up @@ -133,7 +129,7 @@ export interface Message {
* [{ "type": "text", "text": "B)" }]
* ```
*/
content: Array<ContentBlock>;
content: Array<TextBlock>;

/**
* The model that handled the request.
Expand Down Expand Up @@ -234,7 +230,7 @@ export interface MessageDeltaUsage {
}

export interface MessageParam {
content: string | Array<TextBlock | ImageBlockParam>;
content: string | Array<TextBlockParam | ImageBlockParam>;

role: 'user' | 'assistant';
}
Expand Down Expand Up @@ -263,6 +259,12 @@ export interface TextBlock {
type: 'text';
}

export interface TextBlockParam {
text: string;

type: 'text';
}

export interface TextDelta {
text: string;

Expand Down Expand Up @@ -720,6 +722,7 @@ export namespace Messages {
export import MessageStopEvent = MessagesAPI.MessageStopEvent;
export import MessageStreamEvent = MessagesAPI.MessageStreamEvent;
export import TextBlock = MessagesAPI.TextBlock;
export import TextBlockParam = MessagesAPI.TextBlockParam;
export import TextDelta = MessagesAPI.TextDelta;
export import Usage = MessagesAPI.Usage;
export import MessageCreateParams = MessagesAPI.MessageCreateParams;
Expand Down

0 comments on commit b1b743f

Please sign in to comment.