@anthropic-ai/sdk 0.14.1 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,11 +9,11 @@ export declare class Messages extends APIResource {
9
9
  /**
10
10
  * Create a Message.
11
11
  *
12
- * Send a structured list of input messages, and the model will generate the next
13
- * message in the conversation.
12
+ * Send a structured list of input messages with text and/or image content, and the
13
+ * model will generate the next message in the conversation.
14
14
  *
15
- * Messages can be used for either single queries to the model or for multi-turn
16
- * conversations.
15
+ * The Messages API can be used for for either single queries or stateless
16
+ * multi-turn conversations.
17
17
  */
18
18
  create(body: MessageCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise<Message>;
19
19
  create(body: MessageCreateParamsStreaming, options?: Core.RequestOptions): APIPromise<Stream<MessageStreamEvent>>;
@@ -41,6 +41,17 @@ export interface ContentBlockStopEvent {
41
41
  index: number;
42
42
  type: 'content_block_stop';
43
43
  }
44
+ export interface ImageBlockParam {
45
+ source: ImageBlockParam.Source;
46
+ type?: 'image';
47
+ }
48
+ export declare namespace ImageBlockParam {
49
+ interface Source {
50
+ data: string;
51
+ media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp';
52
+ type?: 'base64';
53
+ }
54
+ }
44
55
  export interface Message {
45
56
  /**
46
57
  * Unique object identifier.
@@ -52,7 +63,7 @@ export interface Message {
52
63
  * Content generated by the model.
53
64
  *
54
65
  * This is an array of content blocks, each of which has a `type` that determines
55
- * its shape. Currently, the only `type` available is `"text"`.
66
+ * its shape. Currently, the only `type` in responses is `"text"`.
56
67
  *
57
68
  * Example:
58
69
  *
@@ -72,10 +83,7 @@ export interface Message {
72
83
  * "role": "user",
73
84
  * "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
74
85
  * },
75
- * {
76
- * "role": "assistant",
77
- * "content": "The best answer is ("
78
- * }
86
+ * { "role": "assistant", "content": "The best answer is (" }
79
87
  * ]
80
88
  * ```
81
89
  *
@@ -113,14 +121,31 @@ export interface Message {
113
121
  */
114
122
  stop_reason: 'end_turn' | 'max_tokens' | 'stop_sequence' | null;
115
123
  /**
116
- * Which custom stop sequence was generated.
124
+ * Which custom stop sequence was generated, if any.
117
125
  *
118
- * This value will be non-null if one of your custom stop sequences was generated.
126
+ * This value will be a non-null string if one of your custom stop sequences was
127
+ * generated.
119
128
  */
120
129
  stop_sequence: string | null;
130
+ /**
131
+ * Object type.
132
+ *
133
+ * For Messages, this is always `"message"`.
134
+ */
121
135
  type: 'message';
122
136
  /**
123
- * Container for the number of tokens used.
137
+ * Billing and rate-limit usage.
138
+ *
139
+ * Anthropic's API bills and rate-limits by token counts, as tokens represent the
140
+ * underlying cost to our systems.
141
+ *
142
+ * Under the hood, the API transforms requests into a format suitable for the
143
+ * model. The model's output then goes through a parsing stage before becoming an
144
+ * API response. As a result, the token counts in `usage` will not match one-to-one
145
+ * with the exact visible content of an API request or response.
146
+ *
147
+ * For example, `output_tokens` will be non-zero, even for an empty string response
148
+ * from Claude.
124
149
  */
125
150
  usage: Usage;
126
151
  }
@@ -128,7 +153,18 @@ export interface MessageDeltaEvent {
128
153
  delta: MessageDeltaEvent.Delta;
129
154
  type: 'message_delta';
130
155
  /**
131
- * Container for the number of tokens used.
156
+ * Billing and rate-limit usage.
157
+ *
158
+ * Anthropic's API bills and rate-limits by token counts, as tokens represent the
159
+ * underlying cost to our systems.
160
+ *
161
+ * Under the hood, the API transforms requests into a format suitable for the
162
+ * model. The model's output then goes through a parsing stage before becoming an
163
+ * API response. As a result, the token counts in `usage` will not match one-to-one
164
+ * with the exact visible content of an API request or response.
165
+ *
166
+ * For example, `output_tokens` will be non-zero, even for an empty string response
167
+ * from Claude.
132
168
  */
133
169
  usage: MessageDeltaUsage;
134
170
  }
@@ -145,7 +181,7 @@ export interface MessageDeltaUsage {
145
181
  output_tokens: number;
146
182
  }
147
183
  export interface MessageParam {
148
- content: string | Array<TextBlock>;
184
+ content: string | Array<TextBlock | ImageBlockParam>;
149
185
  role: 'user' | 'assistant';
150
186
  }
151
187
  export interface MessageStartEvent {
@@ -183,8 +219,7 @@ export interface MessageCreateParamsBase {
183
219
  * only specifies the absolute maximum number of tokens to generate.
184
220
  *
185
221
  * Different models have different maximum values for this parameter. See
186
- * [input and output sizes](https://docs.anthropic.com/claude/reference/input-and-output-sizes)
187
- * for details.
222
+ * [models](https://docs.anthropic.com/claude/docs/models-overview) for details.
188
223
  */
189
224
  max_tokens: number;
190
225
  /**
@@ -223,15 +258,18 @@ export interface MessageCreateParamsBase {
223
258
  *
224
259
  * ```json
225
260
  * [
226
- * { "role": "user", "content": "Please describe yourself using only JSON" },
227
- * { "role": "assistant", "content": "Here is my JSON description:\n{" }
261
+ * {
262
+ * "role": "user",
263
+ * "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
264
+ * },
265
+ * { "role": "assistant", "content": "The best answer is (" }
228
266
  * ]
229
267
  * ```
230
268
  *
231
269
  * Each input message `content` may be either a single `string` or an array of
232
- * content blocks, where each block has a specific `type`. Using a `string` is
233
- * shorthand for an array of one content block of type `"text"`. The following
234
- * input messages are equivalent:
270
+ * content blocks, where each block has a specific `type`. Using a `string` for
271
+ * `content` is shorthand for an array of one content block of type `"text"`. The
272
+ * following input messages are equivalent:
235
273
  *
236
274
  * ```json
237
275
  * { "role": "user", "content": "Hello, Claude" }
@@ -241,26 +279,41 @@ export interface MessageCreateParamsBase {
241
279
  * { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
242
280
  * ```
243
281
  *
244
- * See our
245
- * [guide to prompt design](https://docs.anthropic.com/claude/docs/introduction-to-prompt-design)
246
- * for more details on how to best construct prompts.
282
+ * Starting with Claude 3 models, you can also send image content blocks:
283
+ *
284
+ * ```json
285
+ * {
286
+ * "role": "user",
287
+ * "content": [
288
+ * {
289
+ * "type": "image",
290
+ * "source": {
291
+ * "type": "base64",
292
+ * "media_type": "image/jpeg",
293
+ * "data": "/9j/4AAQSkZJRg..."
294
+ * }
295
+ * },
296
+ * { "type": "text", "text": "What is in this image?" }
297
+ * ]
298
+ * }
299
+ * ```
300
+ *
301
+ * We currently support the `base64` source type for images, and the `image/jpeg`,
302
+ * `image/png`, `image/gif`, and `image/webp` media types.
303
+ *
304
+ * See [examples](https://docs.anthropic.com/claude/reference/messages-examples)
305
+ * for more input examples.
247
306
  *
248
307
  * Note that if you want to include a
249
- * [system prompt](https://docs.anthropic.com/claude/docs/how-to-use-system-prompts),
250
- * you can use the top-level `system` parameter — there is no `"system"` role for
251
- * input messages in the Messages API.
308
+ * [system prompt](https://docs.anthropic.com/claude/docs/system-prompts), you can
309
+ * use the top-level `system` parameter — there is no `"system"` role for input
310
+ * messages in the Messages API.
252
311
  */
253
312
  messages: Array<MessageParam>;
254
313
  /**
255
314
  * The model that will complete your prompt.
256
315
  *
257
- * As we improve Claude, we develop new versions of it that you can query. The
258
- * `model` parameter controls which version of Claude responds to your request.
259
- * Right now we offer two model families: Claude, and Claude Instant. You can use
260
- * them by setting `model` to `"claude-2.1"` or `"claude-instant-1.2"`,
261
- * respectively.
262
- *
263
- * See [models](https://docs.anthropic.com/claude/reference/selecting-a-model) for
316
+ * See [models](https://docs.anthropic.com/claude/docs/models-overview) for
264
317
  * additional details and options.
265
318
  */
266
319
  model: string;
@@ -292,14 +345,18 @@ export interface MessageCreateParamsBase {
292
345
  *
293
346
  * A system prompt is a way of providing context and instructions to Claude, such
294
347
  * as specifying a particular goal or role. See our
295
- * [guide to system prompts](https://docs.anthropic.com/claude/docs/how-to-use-system-prompts).
348
+ * [guide to system prompts](https://docs.anthropic.com/claude/docs/system-prompts).
296
349
  */
297
350
  system?: string;
298
351
  /**
299
352
  * Amount of randomness injected into the response.
300
353
  *
301
- * Defaults to 1. Ranges from 0 to 1. Use temp closer to 0 for analytical /
302
- * multiple choice, and closer to 1 for creative and generative tasks.
354
+ * Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
355
+ * for analytical / multiple choice, and closer to `1.0` for creative and
356
+ * generative tasks.
357
+ *
358
+ * Note that even with `temperature` of `0.0`, the results will not be fully
359
+ * deterministic.
303
360
  */
304
361
  temperature?: number;
305
362
  /**
@@ -307,6 +364,9 @@ export interface MessageCreateParamsBase {
307
364
  *
308
365
  * Used to remove "long tail" low probability responses.
309
366
  * [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
367
+ *
368
+ * Recommended for advanced use cases only. You usually only need to use
369
+ * `temperature`.
310
370
  */
311
371
  top_k?: number;
312
372
  /**
@@ -316,6 +376,9 @@ export interface MessageCreateParamsBase {
316
376
  * for each subsequent token in decreasing probability order and cut it off once it
317
377
  * reaches a particular probability specified by `top_p`. You should either alter
318
378
  * `temperature` or `top_p`, but not both.
379
+ *
380
+ * Recommended for advanced use cases only. You usually only need to use
381
+ * `temperature`.
319
382
  */
320
383
  top_p?: number;
321
384
  }
@@ -362,8 +425,7 @@ export interface MessageStreamParams {
362
425
  * only specifies the absolute maximum number of tokens to generate.
363
426
  *
364
427
  * Different models have different maximum values for this parameter. See
365
- * [input and output sizes](https://docs.anthropic.com/claude/reference/input-and-output-sizes)
366
- * for details.
428
+ * [models](https://docs.anthropic.com/claude/docs/models-overview) for details.
367
429
  */
368
430
  max_tokens: number;
369
431
  /**
@@ -402,15 +464,18 @@ export interface MessageStreamParams {
402
464
  *
403
465
  * ```json
404
466
  * [
405
- * { "role": "user", "content": "Please describe yourself using only JSON" },
406
- * { "role": "assistant", "content": "Here is my JSON description:\n{" }
467
+ * {
468
+ * "role": "user",
469
+ * "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
470
+ * },
471
+ * { "role": "assistant", "content": "The best answer is (" }
407
472
  * ]
408
473
  * ```
409
474
  *
410
475
  * Each input message `content` may be either a single `string` or an array of
411
- * content blocks, where each block has a specific `type`. Using a `string` is
412
- * shorthand for an array of one content block of type `"text"`. The following
413
- * input messages are equivalent:
476
+ * content blocks, where each block has a specific `type`. Using a `string` for
477
+ * `content` is shorthand for an array of one content block of type `"text"`. The
478
+ * following input messages are equivalent:
414
479
  *
415
480
  * ```json
416
481
  * { "role": "user", "content": "Hello, Claude" }
@@ -420,26 +485,41 @@ export interface MessageStreamParams {
420
485
  * { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
421
486
  * ```
422
487
  *
423
- * See our
424
- * [guide to prompt design](https://docs.anthropic.com/claude/docs/introduction-to-prompt-design)
425
- * for more details on how to best construct prompts.
488
+ * Starting with Claude 3 models, you can also send image content blocks:
489
+ *
490
+ * ```json
491
+ * {
492
+ * "role": "user",
493
+ * "content": [
494
+ * {
495
+ * "type": "image",
496
+ * "source": {
497
+ * "type": "base64",
498
+ * "media_type": "image/jpeg",
499
+ * "data": "/9j/4AAQSkZJRg..."
500
+ * }
501
+ * },
502
+ * { "type": "text", "text": "What is in this image?" }
503
+ * ]
504
+ * }
505
+ * ```
506
+ *
507
+ * We currently support the `base64` source type for images, and the `image/jpeg`,
508
+ * `image/png`, `image/gif`, and `image/webp` media types.
509
+ *
510
+ * See [examples](https://docs.anthropic.com/claude/reference/messages-examples)
511
+ * for more input examples.
426
512
  *
427
513
  * Note that if you want to include a
428
- * [system prompt](https://docs.anthropic.com/claude/docs/how-to-use-system-prompts),
429
- * you can use the top-level `system` parameter — there is no `"system"` role for
430
- * input messages in the Messages API.
514
+ * [system prompt](https://docs.anthropic.com/claude/docs/system-prompts), you can
515
+ * use the top-level `system` parameter — there is no `"system"` role for input
516
+ * messages in the Messages API.
431
517
  */
432
518
  messages: Array<MessageParam>;
433
519
  /**
434
520
  * The model that will complete your prompt.
435
521
  *
436
- * As we improve Claude, we develop new versions of it that you can query. The
437
- * `model` parameter controls which version of Claude responds to your request.
438
- * Right now we offer two model families: Claude, and Claude Instant. You can use
439
- * them by setting `model` to `"claude-2.1"` or `"claude-instant-1.2"`,
440
- * respectively.
441
- *
442
- * See [models](https://docs.anthropic.com/claude/reference/selecting-a-model) for
522
+ * See [models](https://docs.anthropic.com/claude/docs/models-overview) for
443
523
  * additional details and options.
444
524
  */
445
525
  model: string;
@@ -464,14 +544,18 @@ export interface MessageStreamParams {
464
544
  *
465
545
  * A system prompt is a way of providing context and instructions to Claude, such
466
546
  * as specifying a particular goal or role. See our
467
- * [guide to system prompts](https://docs.anthropic.com/claude/docs/how-to-use-system-prompts).
547
+ * [guide to system prompts](https://docs.anthropic.com/claude/docs/system-prompts).
468
548
  */
469
549
  system?: string;
470
550
  /**
471
551
  * Amount of randomness injected into the response.
472
552
  *
473
- * Defaults to 1. Ranges from 0 to 1. Use temp closer to 0 for analytical /
474
- * multiple choice, and closer to 1 for creative and generative tasks.
553
+ * Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
554
+ * for analytical / multiple choice, and closer to `1.0` for creative and
555
+ * generative tasks.
556
+ *
557
+ * Note that even with `temperature` of `0.0`, the results will not be fully
558
+ * deterministic.
475
559
  */
476
560
  temperature?: number;
477
561
  /**
@@ -479,6 +563,9 @@ export interface MessageStreamParams {
479
563
  *
480
564
  * Used to remove "long tail" low probability responses.
481
565
  * [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
566
+ *
567
+ * Recommended for advanced use cases only. You usually only need to use
568
+ * `temperature`.
482
569
  */
483
570
  top_k?: number;
484
571
  /**
@@ -488,6 +575,9 @@ export interface MessageStreamParams {
488
575
  * for each subsequent token in decreasing probability order and cut it off once it
489
576
  * reaches a particular probability specified by `top_p`. You should either alter
490
577
  * `temperature` or `top_p`, but not both.
578
+ *
579
+ * Recommended for advanced use cases only. You usually only need to use
580
+ * `temperature`.
491
581
  */
492
582
  top_p?: number;
493
583
  }
@@ -511,6 +601,7 @@ export declare namespace Messages {
511
601
  export import ContentBlockDeltaEvent = MessagesAPI.ContentBlockDeltaEvent;
512
602
  export import ContentBlockStartEvent = MessagesAPI.ContentBlockStartEvent;
513
603
  export import ContentBlockStopEvent = MessagesAPI.ContentBlockStopEvent;
604
+ export import ImageBlockParam = MessagesAPI.ImageBlockParam;
514
605
  export import Message = MessagesAPI.Message;
515
606
  export import MessageDeltaEvent = MessagesAPI.MessageDeltaEvent;
516
607
  export import MessageDeltaUsage = MessagesAPI.MessageDeltaUsage;
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/resources/messages.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,KAAK,WAAW,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAErD,qBAAa,QAAS,SAAQ,WAAW;IACvC;;;;;;;;OAQG;IACH,MAAM,CAAC,IAAI,EAAE,+BAA+B,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;IACjG,MAAM,CACJ,IAAI,EAAE,4BAA4B,EAClC,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAC5B,UAAU,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;IACzC,MAAM,CACJ,IAAI,EAAE,uBAAuB,EAC7B,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAC5B,UAAU,CAAC,MAAM,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC;IAanD;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,aAAa;CAGhF;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IAEb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,K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,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;IAChD,MAAM,QAAQ,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC;IACxC,MAAM,QAAQ,mBAAmB,GAAG,WAAW,CAAC,mBAAmB,CAAC;IACpE,MAAM,QAAQ,+BAA+B,GAAG,WAAW,CAAC,+BAA+B,CAAC;IAC5F,MAAM,QAAQ,4BAA4B,GAAG,WAAW,CAAC,4BAA4B,CAAC;IACtF,MAAM,QAAQ,mBAAmB,GAAG,WAAW,CAAC,mBAAmB,CAAC;CACrE"}
@@ -1 +1 @@
1
- {"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/resources/messages.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAIrD,yDAAyD;AACzD,uEAAoE;AACpE,qEAAoE;AAA3D,8GAAA,aAAa,OAAA;AAItB,MAAa,QAAS,SAAQ,sBAAW;IAmBvC,MAAM,CACJ,IAAyB,EACzB,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE;YACvC,IAAI;YACJ,OAAO,EAAE,MAAM;YACf,GAAG,OAAO;YACV,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,KAAK;SAC7B,CAAiE,CAAC;IACrE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAyB,EAAE,OAA6B;QAC7D,OAAO,6BAAa,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;CACF;AArCD,4BAqCC;AAwiBD,WAAiB,QAAQ;AAmBzB,CAAC,EAnBgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAmBxB"}
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../src/resources/messages.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAIrD,yDAAyD;AACzD,uEAAoE;AACpE,qEAAoE;AAA3D,8GAAA,aAAa,OAAA;AAItB,MAAa,QAAS,SAAQ,sBAAW;IAmBvC,MAAM,CACJ,IAAyB,EACzB,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE;YACvC,IAAI;YACJ,OAAO,EAAE,MAAM;YACf,GAAG,OAAO;YACV,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,KAAK;SAC7B,CAAiE,CAAC;IACrE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAyB,EAAE,OAA6B;QAC7D,OAAO,6BAAa,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;CACF;AArCD,4BAqCC;AAuoBD,WAAiB,QAAQ;AAoBzB,CAAC,EApBgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAoBxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"messages.mjs","sourceRoot":"","sources":["../src/resources/messages.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAI9C,EAAE,WAAW,EAAE,MAAM,4BAA4B;OACjD,EAAE,aAAa,EAAE,MAAM,qCAAqC;OAC5D,EAAE,aAAa,EAAE,MAAM,qCAAqC;AAInE,MAAM,OAAO,QAAS,SAAQ,WAAW;IAmBvC,MAAM,CACJ,IAAyB,EACzB,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE;YACvC,IAAI;YACJ,OAAO,EAAE,MAAM;YACf,GAAG,OAAO;YACV,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,KAAK;SAC7B,CAAiE,CAAC;IACrE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAyB,EAAE,OAA6B;QAC7D,OAAO,aAAa,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;CACF;AAwiBD,WAAiB,QAAQ;AAmBzB,CAAC,EAnBgB,QAAQ,KAAR,QAAQ,QAmBxB"}
1
+ {"version":3,"file":"messages.mjs","sourceRoot":"","sources":["../src/resources/messages.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAI9C,EAAE,WAAW,EAAE,MAAM,4BAA4B;OACjD,EAAE,aAAa,EAAE,MAAM,qCAAqC;OAC5D,EAAE,aAAa,EAAE,MAAM,qCAAqC;AAInE,MAAM,OAAO,QAAS,SAAQ,WAAW;IAmBvC,MAAM,CACJ,IAAyB,EACzB,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE;YACvC,IAAI;YACJ,OAAO,EAAE,MAAM;YACf,GAAG,OAAO;YACV,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,KAAK;SAC7B,CAAiE,CAAC;IACrE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAyB,EAAE,OAA6B;QAC7D,OAAO,aAAa,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;CACF;AAuoBD,WAAiB,QAAQ;AAoBzB,CAAC,EApBgB,QAAQ,KAAR,QAAQ,QAoBxB"}
package/src/index.ts CHANGED
@@ -241,6 +241,7 @@ export namespace Anthropic {
241
241
  export import ContentBlockDeltaEvent = API.ContentBlockDeltaEvent;
242
242
  export import ContentBlockStartEvent = API.ContentBlockStartEvent;
243
243
  export import ContentBlockStopEvent = API.ContentBlockStopEvent;
244
+ export import ImageBlockParam = API.ImageBlockParam;
244
245
  export import Message = API.Message;
245
246
  export import MessageDeltaEvent = API.MessageDeltaEvent;
246
247
  export import MessageDeltaUsage = API.MessageDeltaUsage;
@@ -468,13 +468,16 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
468
468
 
469
469
  [Symbol.asyncIterator](): AsyncIterator<MessageStreamEvent> {
470
470
  const pushQueue: MessageStreamEvent[] = [];
471
- const readQueue: ((chunk: MessageStreamEvent | undefined) => void)[] = [];
471
+ const readQueue: {
472
+ resolve: (chunk: MessageStreamEvent | undefined) => void;
473
+ reject: (error: unknown) => void;
474
+ }[] = [];
472
475
  let done = false;
473
476
 
474
477
  this.on('streamEvent', (event) => {
475
478
  const reader = readQueue.shift();
476
479
  if (reader) {
477
- reader(event);
480
+ reader.resolve(event);
478
481
  } else {
479
482
  pushQueue.push(event);
480
483
  }
@@ -483,7 +486,23 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
483
486
  this.on('end', () => {
484
487
  done = true;
485
488
  for (const reader of readQueue) {
486
- reader(undefined);
489
+ reader.resolve(undefined);
490
+ }
491
+ readQueue.length = 0;
492
+ });
493
+
494
+ this.on('abort', (err) => {
495
+ done = true;
496
+ for (const reader of readQueue) {
497
+ reader.reject(err);
498
+ }
499
+ readQueue.length = 0;
500
+ });
501
+
502
+ this.on('error', (err) => {
503
+ done = true;
504
+ for (const reader of readQueue) {
505
+ reader.reject(err);
487
506
  }
488
507
  readQueue.length = 0;
489
508
  });
@@ -494,9 +513,9 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
494
513
  if (done) {
495
514
  return { value: undefined, done: true };
496
515
  }
497
- return new Promise<MessageStreamEvent | undefined>((resolve) => readQueue.push(resolve)).then(
498
- (chunk) => (chunk ? { value: chunk, done: false } : { value: undefined, done: true }),
499
- );
516
+ return new Promise<MessageStreamEvent | undefined>((resolve, reject) =>
517
+ readQueue.push({ resolve, reject }),
518
+ ).then((chunk) => (chunk ? { value: chunk, done: false } : { value: undefined, done: true }));
500
519
  }
501
520
  const chunk = pushQueue.shift()!;
502
521
  return { value: chunk, done: false };
@@ -69,6 +69,11 @@ export interface Completion {
69
69
  */
70
70
  stop_reason: string | null;
71
71
 
72
+ /**
73
+ * Object type.
74
+ *
75
+ * For Text Completions, this is always `"completion"`.
76
+ */
72
77
  type: 'completion';
73
78
  }
74
79
 
@@ -86,16 +91,10 @@ export interface CompletionCreateParamsBase {
86
91
  /**
87
92
  * The model that will complete your prompt.
88
93
  *
89
- * As we improve Claude, we develop new versions of it that you can query. The
90
- * `model` parameter controls which version of Claude responds to your request.
91
- * Right now we offer two model families: Claude, and Claude Instant. You can use
92
- * them by setting `model` to `"claude-2.1"` or `"claude-instant-1.2"`,
93
- * respectively.
94
- *
95
- * See [models](https://docs.anthropic.com/claude/reference/selecting-a-model) for
94
+ * See [models](https://docs.anthropic.com/claude/docs/models-overview) for
96
95
  * additional details and options.
97
96
  */
98
- model: (string & {}) | 'claude-2.1' | 'claude-instant-1';
97
+ model: (string & {}) | 'claude-3-opus-20240229' | 'claude-2.1' | 'claude-instant-1';
99
98
 
100
99
  /**
101
100
  * The prompt that you want Claude to complete.
@@ -141,8 +140,12 @@ export interface CompletionCreateParamsBase {
141
140
  /**
142
141
  * Amount of randomness injected into the response.
143
142
  *
144
- * Defaults to 1. Ranges from 0 to 1. Use temp closer to 0 for analytical /
145
- * multiple choice, and closer to 1 for creative and generative tasks.
143
+ * Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
144
+ * for analytical / multiple choice, and closer to `1.0` for creative and
145
+ * generative tasks.
146
+ *
147
+ * Note that even with `temperature` of `0.0`, the results will not be fully
148
+ * deterministic.
146
149
  */
147
150
  temperature?: number;
148
151
 
@@ -151,6 +154,9 @@ export interface CompletionCreateParamsBase {
151
154
  *
152
155
  * Used to remove "long tail" low probability responses.
153
156
  * [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
157
+ *
158
+ * Recommended for advanced use cases only. You usually only need to use
159
+ * `temperature`.
154
160
  */
155
161
  top_k?: number;
156
162
 
@@ -161,6 +167,9 @@ export interface CompletionCreateParamsBase {
161
167
  * for each subsequent token in decreasing probability order and cut it off once it
162
168
  * reaches a particular probability specified by `top_p`. You should either alter
163
169
  * `temperature` or `top_p`, but not both.
170
+ *
171
+ * Recommended for advanced use cases only. You usually only need to use
172
+ * `temperature`.
164
173
  */
165
174
  top_p?: number;
166
175
  }
@@ -12,6 +12,7 @@ export {
12
12
  ContentBlockDeltaEvent,
13
13
  ContentBlockStartEvent,
14
14
  ContentBlockStopEvent,
15
+ ImageBlockParam,
15
16
  Message,
16
17
  MessageDeltaEvent,
17
18
  MessageDeltaUsage,