Skip to content

Commit

Permalink
refactor(types): improve metadata types (#546)
Browse files Browse the repository at this point in the history
Co-authored-by: Stainless Bot <dev@stainlessapi.com>
  • Loading branch information
RobertCraigie and stainless-bot authored Oct 8, 2024
1 parent fc2d823 commit 3fe538b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 36 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">MessageStartEvent</a></code>
- <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">Metadata</a></code>
- <code><a href="./src/resources/messages.ts">Model</a></code>
- <code><a href="./src/resources/messages.ts">RawContentBlockDeltaEvent</a></code>
- <code><a href="./src/resources/messages.ts">RawContentBlockStartEvent</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 @@ -270,6 +270,7 @@ export namespace Anthropic {
export import MessageStartEvent = API.MessageStartEvent;
export import MessageStopEvent = API.MessageStopEvent;
export import MessageStreamEvent = API.MessageStreamEvent;
export import Metadata = API.Metadata;
export import Model = API.Model;
export import RawContentBlockDeltaEvent = API.RawContentBlockDeltaEvent;
export import RawContentBlockStartEvent = API.RawContentBlockStartEvent;
Expand Down
15 changes: 3 additions & 12 deletions src/resources/beta/prompt-caching/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ export interface MessageCreateParamsBase {
/**
* An object describing metadata about the request.
*/
metadata?: MessageCreateParams.Metadata;
metadata?: MessagesAPI.Metadata;

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

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

/**
* @deprecated use `Anthropic.Messages.ToolChoiceAuto` instead
Expand Down
15 changes: 3 additions & 12 deletions src/resources/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export interface CompletionCreateParamsBase {
/**
* An object describing metadata about the request.
*/
metadata?: CompletionCreateParams.Metadata;
metadata?: MessagesAPI.Metadata;

/**
* Sequences that will cause the model to stop generating.
Expand Down Expand Up @@ -174,18 +174,9 @@ export interface CompletionCreateParamsBase {

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

export type CompletionCreateParamsNonStreaming = CompletionsAPI.CompletionCreateParamsNonStreaming;
export type CompletionCreateParamsStreaming = CompletionsAPI.CompletionCreateParamsStreaming;
Expand Down
1 change: 1 addition & 0 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export {
MessageStartEvent,
MessageStopEvent,
MessageStreamEvent,
Metadata,
Model,
RawContentBlockDeltaEvent,
RawContentBlockStartEvent,
Expand Down
27 changes: 15 additions & 12 deletions src/resources/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,17 @@ export type MessageStopEvent = RawMessageStopEvent;

export type MessageStreamEvent = RawMessageStreamEvent;

export interface Metadata {
/**
* An external identifier for the user who is associated with the request.
*
* This should be a uuid, hash value, or other opaque identifier. Anthropic may use
* this id to help detect abuse. Do not include any identifying information such as
* name, email address, or phone number.
*/
user_id?: string | null;
}

/**
* The model that will complete your prompt.\n\nSee
* [models](https://docs.anthropic.com/en/docs/models-overview) for additional
Expand Down Expand Up @@ -576,7 +587,7 @@ export interface MessageCreateParamsBase {
/**
* An object describing metadata about the request.
*/
metadata?: MessageCreateParams.Metadata;
metadata?: Metadata;

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

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

/**
* @deprecated use `Anthropic.Messages.ToolChoiceAuto` instead
Expand Down Expand Up @@ -794,6 +796,7 @@ export namespace Messages {
export import MessageStartEvent = MessagesAPI.MessageStartEvent;
export import MessageStopEvent = MessagesAPI.MessageStopEvent;
export import MessageStreamEvent = MessagesAPI.MessageStreamEvent;
export import Metadata = MessagesAPI.Metadata;
export import Model = MessagesAPI.Model;
export import RawContentBlockDeltaEvent = MessagesAPI.RawContentBlockDeltaEvent;
export import RawContentBlockStartEvent = MessagesAPI.RawContentBlockStartEvent;
Expand Down

0 comments on commit 3fe538b

Please sign in to comment.