Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(types): improve metadata types #546

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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