Skip to content

Commit d1be006

Browse files
RobertCraigiestainless-bot
authored andcommitted
refactor(types): improve metadata types (#546)
Co-authored-by: Stainless Bot <[email protected]>
1 parent e21e129 commit d1be006

File tree

6 files changed

+24
-36
lines changed

6 files changed

+24
-36
lines changed

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Types:
1717
- <code><a href="./src/resources/messages.ts">MessageStartEvent</a></code>
1818
- <code><a href="./src/resources/messages.ts">MessageStopEvent</a></code>
1919
- <code><a href="./src/resources/messages.ts">MessageStreamEvent</a></code>
20+
- <code><a href="./src/resources/messages.ts">Metadata</a></code>
2021
- <code><a href="./src/resources/messages.ts">Model</a></code>
2122
- <code><a href="./src/resources/messages.ts">RawContentBlockDeltaEvent</a></code>
2223
- <code><a href="./src/resources/messages.ts">RawContentBlockStartEvent</a></code>

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ export namespace Anthropic {
270270
export import MessageStartEvent = API.MessageStartEvent;
271271
export import MessageStopEvent = API.MessageStopEvent;
272272
export import MessageStreamEvent = API.MessageStreamEvent;
273+
export import Metadata = API.Metadata;
273274
export import Model = API.Model;
274275
export import RawContentBlockDeltaEvent = API.RawContentBlockDeltaEvent;
275276
export import RawContentBlockStartEvent = API.RawContentBlockStartEvent;

src/resources/beta/prompt-caching/messages.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ export interface MessageCreateParamsBase {
413413
/**
414414
* An object describing metadata about the request.
415415
*/
416-
metadata?: MessageCreateParams.Metadata;
416+
metadata?: MessagesAPI.Metadata;
417417

418418
/**
419419
* Custom text sequences that will cause the model to stop generating.
@@ -562,18 +562,9 @@ export interface MessageCreateParamsBase {
562562

563563
export namespace MessageCreateParams {
564564
/**
565-
* An object describing metadata about the request.
565+
* @deprecated use `Anthropic.Messages.Metadata` instead
566566
*/
567-
export interface Metadata {
568-
/**
569-
* An external identifier for the user who is associated with the request.
570-
*
571-
* This should be a uuid, hash value, or other opaque identifier. Anthropic may use
572-
* this id to help detect abuse. Do not include any identifying information such as
573-
* name, email address, or phone number.
574-
*/
575-
user_id?: string | null;
576-
}
567+
export type Metadata = MessagesAPI.Metadata;
577568

578569
/**
579570
* @deprecated use `Anthropic.Messages.ToolChoiceAuto` instead

src/resources/completions.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export interface CompletionCreateParamsBase {
117117
/**
118118
* An object describing metadata about the request.
119119
*/
120-
metadata?: CompletionCreateParams.Metadata;
120+
metadata?: MessagesAPI.Metadata;
121121

122122
/**
123123
* Sequences that will cause the model to stop generating.
@@ -174,18 +174,9 @@ export interface CompletionCreateParamsBase {
174174

175175
export namespace CompletionCreateParams {
176176
/**
177-
* An object describing metadata about the request.
177+
* @deprecated use `Anthropic.Messages.Metadata` instead
178178
*/
179-
export interface Metadata {
180-
/**
181-
* An external identifier for the user who is associated with the request.
182-
*
183-
* This should be a uuid, hash value, or other opaque identifier. Anthropic may use
184-
* this id to help detect abuse. Do not include any identifying information such as
185-
* name, email address, or phone number.
186-
*/
187-
user_id?: string | null;
188-
}
179+
export type Metadata = MessagesAPI.Metadata;
189180

190181
export type CompletionCreateParamsNonStreaming = CompletionsAPI.CompletionCreateParamsNonStreaming;
191182
export type CompletionCreateParamsStreaming = CompletionsAPI.CompletionCreateParamsStreaming;

src/resources/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export {
2323
MessageStartEvent,
2424
MessageStopEvent,
2525
MessageStreamEvent,
26+
Metadata,
2627
Model,
2728
RawContentBlockDeltaEvent,
2829
RawContentBlockStartEvent,

src/resources/messages.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,17 @@ export type MessageStopEvent = RawMessageStopEvent;
213213

214214
export type MessageStreamEvent = RawMessageStreamEvent;
215215

216+
export interface Metadata {
217+
/**
218+
* An external identifier for the user who is associated with the request.
219+
*
220+
* This should be a uuid, hash value, or other opaque identifier. Anthropic may use
221+
* this id to help detect abuse. Do not include any identifying information such as
222+
* name, email address, or phone number.
223+
*/
224+
user_id?: string | null;
225+
}
226+
216227
/**
217228
* The model that will complete your prompt.\n\nSee
218229
* [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -576,7 +587,7 @@ export interface MessageCreateParamsBase {
576587
/**
577588
* An object describing metadata about the request.
578589
*/
579-
metadata?: MessageCreateParams.Metadata;
590+
metadata?: Metadata;
580591

581592
/**
582593
* Custom text sequences that will cause the model to stop generating.
@@ -725,18 +736,9 @@ export interface MessageCreateParamsBase {
725736

726737
export namespace MessageCreateParams {
727738
/**
728-
* An object describing metadata about the request.
739+
* @deprecated use `Anthropic.Messages.ToolChoiceAuto` instead
729740
*/
730-
export interface Metadata {
731-
/**
732-
* An external identifier for the user who is associated with the request.
733-
*
734-
* This should be a uuid, hash value, or other opaque identifier. Anthropic may use
735-
* this id to help detect abuse. Do not include any identifying information such as
736-
* name, email address, or phone number.
737-
*/
738-
user_id?: string | null;
739-
}
741+
export type Metadata = MessagesAPI.Metadata;
740742

741743
/**
742744
* @deprecated use `Anthropic.Messages.ToolChoiceAuto` instead
@@ -794,6 +796,7 @@ export namespace Messages {
794796
export import MessageStartEvent = MessagesAPI.MessageStartEvent;
795797
export import MessageStopEvent = MessagesAPI.MessageStopEvent;
796798
export import MessageStreamEvent = MessagesAPI.MessageStreamEvent;
799+
export import Metadata = MessagesAPI.Metadata;
797800
export import Model = MessagesAPI.Model;
798801
export import RawContentBlockDeltaEvent = MessagesAPI.RawContentBlockDeltaEvent;
799802
export import RawContentBlockStartEvent = MessagesAPI.RawContentBlockStartEvent;

0 commit comments

Comments
 (0)