@anthropic-ai/sdk 0.20.9 → 0.21.1
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.
- package/CHANGELOG.md +24 -0
- package/_vendor/partial-json-parser/parser.d.ts +3 -0
- package/_vendor/partial-json-parser/parser.d.ts.map +1 -0
- package/_vendor/partial-json-parser/parser.js +224 -0
- package/_vendor/partial-json-parser/parser.js.map +1 -0
- package/_vendor/partial-json-parser/parser.mjs +221 -0
- package/_vendor/partial-json-parser/parser.mjs.map +1 -0
- package/lib/ToolsBetaMessageStream.d.ts +95 -0
- package/lib/ToolsBetaMessageStream.d.ts.map +1 -0
- package/lib/ToolsBetaMessageStream.js +459 -0
- package/lib/ToolsBetaMessageStream.js.map +1 -0
- package/lib/ToolsBetaMessageStream.mjs +455 -0
- package/lib/ToolsBetaMessageStream.mjs.map +1 -0
- package/package.json +2 -2
- package/resources/beta/tools/index.d.ts +1 -1
- package/resources/beta/tools/index.d.ts.map +1 -1
- package/resources/beta/tools/index.js.map +1 -1
- package/resources/beta/tools/index.mjs.map +1 -1
- package/resources/beta/tools/messages.d.ts +351 -20
- package/resources/beta/tools/messages.d.ts.map +1 -1
- package/resources/beta/tools/messages.js +11 -2
- package/resources/beta/tools/messages.js.map +1 -1
- package/resources/beta/tools/messages.mjs +9 -1
- package/resources/beta/tools/messages.mjs.map +1 -1
- package/resources/beta/tools/tools.d.ts +5 -0
- package/resources/beta/tools/tools.d.ts.map +1 -1
- package/resources/beta/tools/tools.js.map +1 -1
- package/resources/beta/tools/tools.mjs.map +1 -1
- package/resources/completions.d.ts +11 -19
- package/resources/completions.d.ts.map +1 -1
- package/resources/completions.js.map +1 -1
- package/resources/completions.mjs.map +1 -1
- package/resources/messages.d.ts +24 -24
- package/src/_shims/auto/runtime-bun.ts +1 -1
- package/src/_shims/auto/runtime-node.ts +1 -1
- package/src/_shims/auto/runtime.ts +1 -1
- package/src/_shims/auto/types-node.ts +1 -1
- package/src/_shims/bun-runtime.ts +2 -2
- package/src/_shims/index.d.ts +3 -3
- package/src/_shims/index.mjs +1 -1
- package/src/_shims/node-runtime.ts +3 -3
- package/src/_shims/registry.ts +1 -1
- package/src/_shims/web-runtime.ts +3 -3
- package/src/_vendor/partial-json-parser/README.md +3 -0
- package/src/_vendor/partial-json-parser/parser.ts +262 -0
- package/src/core.ts +6 -6
- package/src/error.ts +1 -1
- package/src/index.ts +5 -5
- package/src/lib/MessageStream.ts +5 -5
- package/src/lib/ToolsBetaMessageStream.ts +561 -0
- package/src/resource.ts +1 -1
- package/src/resources/beta/beta.ts +2 -2
- package/src/resources/beta/index.ts +2 -2
- package/src/resources/beta/tools/index.ts +7 -2
- package/src/resources/beta/tools/messages.ts +405 -29
- package/src/resources/beta/tools/tools.ts +7 -2
- package/src/resources/completions.ts +16 -24
- package/src/resources/index.ts +3 -3
- package/src/resources/messages.ts +31 -31
- package/src/shims/node.ts +3 -3
- package/src/shims/web.ts +3 -3
- package/src/streaming.ts +4 -4
- package/src/uploads.ts +4 -4
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as Core from '@anthropic-ai/sdk/core';
|
|
2
2
|
import { APIPromise } from '@anthropic-ai/sdk/core';
|
|
3
3
|
import { APIResource } from '@anthropic-ai/sdk/resource';
|
|
4
|
+
import { ToolsBetaMessageStream } from '@anthropic-ai/sdk/lib/ToolsBetaMessageStream';
|
|
5
|
+
export { ToolsBetaMessageStream } from '@anthropic-ai/sdk/lib/ToolsBetaMessageStream';
|
|
4
6
|
import * as ToolsMessagesAPI from '@anthropic-ai/sdk/resources/beta/tools/messages';
|
|
5
7
|
import * as MessagesAPI from '@anthropic-ai/sdk/resources/messages';
|
|
6
8
|
import { Stream } from '@anthropic-ai/sdk/streaming';
|
|
@@ -11,12 +13,20 @@ export declare class Messages extends APIResource {
|
|
|
11
13
|
* Send a structured list of input messages with text and/or image content, and the
|
|
12
14
|
* model will generate the next message in the conversation.
|
|
13
15
|
*
|
|
14
|
-
* The Messages API can be used for
|
|
15
|
-
*
|
|
16
|
+
* The Messages API can be used for either single queries or stateless multi-turn
|
|
17
|
+
* conversations.
|
|
16
18
|
*/
|
|
17
19
|
create(body: MessageCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise<ToolsBetaMessage>;
|
|
18
|
-
create(body: MessageCreateParamsStreaming, options?: Core.RequestOptions): APIPromise<Stream<
|
|
19
|
-
create(body: MessageCreateParamsBase, options?: Core.RequestOptions): APIPromise<Stream<
|
|
20
|
+
create(body: MessageCreateParamsStreaming, options?: Core.RequestOptions): APIPromise<Stream<ToolsBetaMessageStreamEvent>>;
|
|
21
|
+
create(body: MessageCreateParamsBase, options?: Core.RequestOptions): APIPromise<Stream<ToolsBetaMessageStreamEvent> | ToolsBetaMessage>;
|
|
22
|
+
/**
|
|
23
|
+
* Create a Message stream
|
|
24
|
+
*/
|
|
25
|
+
stream(body: MessageStreamParams, options?: Core.RequestOptions): ToolsBetaMessageStream;
|
|
26
|
+
}
|
|
27
|
+
export interface InputJsonDelta {
|
|
28
|
+
partial_json: string;
|
|
29
|
+
type: 'input_json_delta';
|
|
20
30
|
}
|
|
21
31
|
export interface Tool {
|
|
22
32
|
/**
|
|
@@ -53,7 +63,7 @@ export declare namespace Tool {
|
|
|
53
63
|
export interface ToolResultBlockParam {
|
|
54
64
|
tool_use_id: string;
|
|
55
65
|
type: 'tool_result';
|
|
56
|
-
content?: Array<MessagesAPI.TextBlockParam>;
|
|
66
|
+
content?: Array<MessagesAPI.TextBlockParam | MessagesAPI.ImageBlockParam>;
|
|
57
67
|
is_error?: boolean;
|
|
58
68
|
}
|
|
59
69
|
export interface ToolUseBlock {
|
|
@@ -69,6 +79,16 @@ export interface ToolUseBlockParam {
|
|
|
69
79
|
type: 'tool_use';
|
|
70
80
|
}
|
|
71
81
|
export type ToolsBetaContentBlock = MessagesAPI.TextBlock | ToolUseBlock;
|
|
82
|
+
export interface ToolsBetaContentBlockDeltaEvent {
|
|
83
|
+
delta: MessagesAPI.TextDelta | InputJsonDelta;
|
|
84
|
+
index: number;
|
|
85
|
+
type: 'content_block_delta';
|
|
86
|
+
}
|
|
87
|
+
export interface ToolsBetaContentBlockStartEvent {
|
|
88
|
+
content_block: MessagesAPI.TextBlock | ToolUseBlock;
|
|
89
|
+
index: number;
|
|
90
|
+
type: 'content_block_start';
|
|
91
|
+
}
|
|
72
92
|
export interface ToolsBetaMessage {
|
|
73
93
|
/**
|
|
74
94
|
* Unique object identifier.
|
|
@@ -168,6 +188,7 @@ export interface ToolsBetaMessageParam {
|
|
|
168
188
|
content: string | Array<MessagesAPI.TextBlockParam | MessagesAPI.ImageBlockParam | ToolUseBlockParam | ToolResultBlockParam>;
|
|
169
189
|
role: 'user' | 'assistant';
|
|
170
190
|
}
|
|
191
|
+
export type ToolsBetaMessageStreamEvent = MessagesAPI.MessageStartEvent | MessagesAPI.MessageDeltaEvent | MessagesAPI.MessageStopEvent | ToolsBetaContentBlockStartEvent | ToolsBetaContentBlockDeltaEvent | MessagesAPI.ContentBlockStopEvent;
|
|
171
192
|
export type MessageCreateParams = MessageCreateParamsNonStreaming | MessageCreateParamsStreaming;
|
|
172
193
|
export interface MessageCreateParamsBase {
|
|
173
194
|
/**
|
|
@@ -177,7 +198,7 @@ export interface MessageCreateParamsBase {
|
|
|
177
198
|
* only specifies the absolute maximum number of tokens to generate.
|
|
178
199
|
*
|
|
179
200
|
* Different models have different maximum values for this parameter. See
|
|
180
|
-
* [models](https://docs.anthropic.com/
|
|
201
|
+
* [models](https://docs.anthropic.com/en/docs/models-overview) for details.
|
|
181
202
|
*/
|
|
182
203
|
max_tokens: number;
|
|
183
204
|
/**
|
|
@@ -259,20 +280,20 @@ export interface MessageCreateParamsBase {
|
|
|
259
280
|
* We currently support the `base64` source type for images, and the `image/jpeg`,
|
|
260
281
|
* `image/png`, `image/gif`, and `image/webp` media types.
|
|
261
282
|
*
|
|
262
|
-
* See [examples](https://docs.anthropic.com/
|
|
263
|
-
*
|
|
283
|
+
* See [examples](https://docs.anthropic.com/en/api/messages-examples) for more
|
|
284
|
+
* input examples.
|
|
264
285
|
*
|
|
265
286
|
* Note that if you want to include a
|
|
266
|
-
* [system prompt](https://docs.anthropic.com/
|
|
267
|
-
*
|
|
287
|
+
* [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
|
|
288
|
+
* the top-level `system` parameter — there is no `"system"` role for input
|
|
268
289
|
* messages in the Messages API.
|
|
269
290
|
*/
|
|
270
291
|
messages: Array<ToolsBetaMessageParam>;
|
|
271
292
|
/**
|
|
272
293
|
* The model that will complete your prompt.
|
|
273
294
|
*
|
|
274
|
-
* See [models](https://docs.anthropic.com/
|
|
275
|
-
*
|
|
295
|
+
* See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
|
|
296
|
+
* details and options.
|
|
276
297
|
*/
|
|
277
298
|
model: string;
|
|
278
299
|
/**
|
|
@@ -294,8 +315,8 @@ export interface MessageCreateParamsBase {
|
|
|
294
315
|
/**
|
|
295
316
|
* Whether to incrementally stream the response using server-sent events.
|
|
296
317
|
*
|
|
297
|
-
* See [streaming](https://docs.anthropic.com/
|
|
298
|
-
*
|
|
318
|
+
* See [streaming](https://docs.anthropic.com/en/api/messages-streaming) for
|
|
319
|
+
* details.
|
|
299
320
|
*/
|
|
300
321
|
stream?: boolean;
|
|
301
322
|
/**
|
|
@@ -303,7 +324,7 @@ export interface MessageCreateParamsBase {
|
|
|
303
324
|
*
|
|
304
325
|
* A system prompt is a way of providing context and instructions to Claude, such
|
|
305
326
|
* as specifying a particular goal or role. See our
|
|
306
|
-
* [guide to system prompts](https://docs.anthropic.com/
|
|
327
|
+
* [guide to system prompts](https://docs.anthropic.com/en/docs/system-prompts).
|
|
307
328
|
*/
|
|
308
329
|
system?: string;
|
|
309
330
|
/**
|
|
@@ -317,6 +338,11 @@ export interface MessageCreateParamsBase {
|
|
|
317
338
|
* deterministic.
|
|
318
339
|
*/
|
|
319
340
|
temperature?: number;
|
|
341
|
+
/**
|
|
342
|
+
* How the model should use the provided tools. The model can use a specific tool,
|
|
343
|
+
* any available tool, or decide by itself.
|
|
344
|
+
*/
|
|
345
|
+
tool_choice?: MessageCreateParams.ToolChoiceAuto | MessageCreateParams.ToolChoiceAny | MessageCreateParams.ToolChoiceTool;
|
|
320
346
|
/**
|
|
321
347
|
* [beta] Definitions of tools that the model may use.
|
|
322
348
|
*
|
|
@@ -385,7 +411,7 @@ export interface MessageCreateParamsBase {
|
|
|
385
411
|
* functions, or more generally whenever you want the model to produce a particular
|
|
386
412
|
* JSON structure of output.
|
|
387
413
|
*
|
|
388
|
-
* See our [beta guide](https://docs.anthropic.com/
|
|
414
|
+
* See our [beta guide](https://docs.anthropic.com/en/docs/tool-use) for more
|
|
389
415
|
* details.
|
|
390
416
|
*/
|
|
391
417
|
tools?: Array<Tool>;
|
|
@@ -426,6 +452,28 @@ export declare namespace MessageCreateParams {
|
|
|
426
452
|
*/
|
|
427
453
|
user_id?: string | null;
|
|
428
454
|
}
|
|
455
|
+
/**
|
|
456
|
+
* The model will automatically decide whether to use tools.
|
|
457
|
+
*/
|
|
458
|
+
interface ToolChoiceAuto {
|
|
459
|
+
type: 'auto';
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* The model will use any available tools.
|
|
463
|
+
*/
|
|
464
|
+
interface ToolChoiceAny {
|
|
465
|
+
type: 'any';
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* The model will use the specified tool with `tool_choice.name`.
|
|
469
|
+
*/
|
|
470
|
+
interface ToolChoiceTool {
|
|
471
|
+
/**
|
|
472
|
+
* The name of the tool to use.
|
|
473
|
+
*/
|
|
474
|
+
name: string;
|
|
475
|
+
type: 'tool';
|
|
476
|
+
}
|
|
429
477
|
type MessageCreateParamsNonStreaming = ToolsMessagesAPI.MessageCreateParamsNonStreaming;
|
|
430
478
|
type MessageCreateParamsStreaming = ToolsMessagesAPI.MessageCreateParamsStreaming;
|
|
431
479
|
}
|
|
@@ -433,8 +481,8 @@ export interface MessageCreateParamsNonStreaming extends MessageCreateParamsBase
|
|
|
433
481
|
/**
|
|
434
482
|
* Whether to incrementally stream the response using server-sent events.
|
|
435
483
|
*
|
|
436
|
-
* See [streaming](https://docs.anthropic.com/
|
|
437
|
-
*
|
|
484
|
+
* See [streaming](https://docs.anthropic.com/en/api/messages-streaming) for
|
|
485
|
+
* details.
|
|
438
486
|
*/
|
|
439
487
|
stream?: false;
|
|
440
488
|
}
|
|
@@ -442,21 +490,304 @@ export interface MessageCreateParamsStreaming extends MessageCreateParamsBase {
|
|
|
442
490
|
/**
|
|
443
491
|
* Whether to incrementally stream the response using server-sent events.
|
|
444
492
|
*
|
|
445
|
-
* See [streaming](https://docs.anthropic.com/
|
|
446
|
-
*
|
|
493
|
+
* See [streaming](https://docs.anthropic.com/en/api/messages-streaming) for
|
|
494
|
+
* details.
|
|
447
495
|
*/
|
|
448
496
|
stream: true;
|
|
449
497
|
}
|
|
498
|
+
export interface MessageStreamParams {
|
|
499
|
+
/**
|
|
500
|
+
* The maximum number of tokens to generate before stopping.
|
|
501
|
+
*
|
|
502
|
+
* Note that our models may stop _before_ reaching this maximum. This parameter
|
|
503
|
+
* only specifies the absolute maximum number of tokens to generate.
|
|
504
|
+
*
|
|
505
|
+
* Different models have different maximum values for this parameter. See
|
|
506
|
+
* [models](https://docs.anthropic.com/en/docs/models-overview) for details.
|
|
507
|
+
*/
|
|
508
|
+
max_tokens: number;
|
|
509
|
+
/**
|
|
510
|
+
* Input messages.
|
|
511
|
+
*
|
|
512
|
+
* Our models are trained to operate on alternating `user` and `assistant`
|
|
513
|
+
* conversational turns. When creating a new `Message`, you specify the prior
|
|
514
|
+
* conversational turns with the `messages` parameter, and the model then generates
|
|
515
|
+
* the next `Message` in the conversation.
|
|
516
|
+
*
|
|
517
|
+
* Each input message must be an object with a `role` and `content`. You can
|
|
518
|
+
* specify a single `user`-role message, or you can include multiple `user` and
|
|
519
|
+
* `assistant` messages. The first message must always use the `user` role.
|
|
520
|
+
*
|
|
521
|
+
* If the final message uses the `assistant` role, the response content will
|
|
522
|
+
* continue immediately from the content in that message. This can be used to
|
|
523
|
+
* constrain part of the model's response.
|
|
524
|
+
*
|
|
525
|
+
* Example with a single `user` message:
|
|
526
|
+
*
|
|
527
|
+
* ```json
|
|
528
|
+
* [{ "role": "user", "content": "Hello, Claude" }]
|
|
529
|
+
* ```
|
|
530
|
+
*
|
|
531
|
+
* Example with multiple conversational turns:
|
|
532
|
+
*
|
|
533
|
+
* ```json
|
|
534
|
+
* [
|
|
535
|
+
* { "role": "user", "content": "Hello there." },
|
|
536
|
+
* { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
|
|
537
|
+
* { "role": "user", "content": "Can you explain LLMs in plain English?" }
|
|
538
|
+
* ]
|
|
539
|
+
* ```
|
|
540
|
+
*
|
|
541
|
+
* Example with a partially-filled response from Claude:
|
|
542
|
+
*
|
|
543
|
+
* ```json
|
|
544
|
+
* [
|
|
545
|
+
* {
|
|
546
|
+
* "role": "user",
|
|
547
|
+
* "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
|
|
548
|
+
* },
|
|
549
|
+
* { "role": "assistant", "content": "The best answer is (" }
|
|
550
|
+
* ]
|
|
551
|
+
* ```
|
|
552
|
+
*
|
|
553
|
+
* Each input message `content` may be either a single `string` or an array of
|
|
554
|
+
* content blocks, where each block has a specific `type`. Using a `string` for
|
|
555
|
+
* `content` is shorthand for an array of one content block of type `"text"`. The
|
|
556
|
+
* following input messages are equivalent:
|
|
557
|
+
*
|
|
558
|
+
* ```json
|
|
559
|
+
* { "role": "user", "content": "Hello, Claude" }
|
|
560
|
+
* ```
|
|
561
|
+
*
|
|
562
|
+
* ```json
|
|
563
|
+
* { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
|
|
564
|
+
* ```
|
|
565
|
+
*
|
|
566
|
+
* Starting with Claude 3 models, you can also send image content blocks:
|
|
567
|
+
*
|
|
568
|
+
* ```json
|
|
569
|
+
* {
|
|
570
|
+
* "role": "user",
|
|
571
|
+
* "content": [
|
|
572
|
+
* {
|
|
573
|
+
* "type": "image",
|
|
574
|
+
* "source": {
|
|
575
|
+
* "type": "base64",
|
|
576
|
+
* "media_type": "image/jpeg",
|
|
577
|
+
* "data": "/9j/4AAQSkZJRg..."
|
|
578
|
+
* }
|
|
579
|
+
* },
|
|
580
|
+
* { "type": "text", "text": "What is in this image?" }
|
|
581
|
+
* ]
|
|
582
|
+
* }
|
|
583
|
+
* ```
|
|
584
|
+
*
|
|
585
|
+
* We currently support the `base64` source type for images, and the `image/jpeg`,
|
|
586
|
+
* `image/png`, `image/gif`, and `image/webp` media types.
|
|
587
|
+
*
|
|
588
|
+
* See [examples](https://docs.anthropic.com/en/api/messages-examples) for more
|
|
589
|
+
* input examples.
|
|
590
|
+
*
|
|
591
|
+
* Note that if you want to include a
|
|
592
|
+
* [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
|
|
593
|
+
* the top-level `system` parameter — there is no `"system"` role for input
|
|
594
|
+
* messages in the Messages API.
|
|
595
|
+
*/
|
|
596
|
+
messages: Array<ToolsBetaMessageParam>;
|
|
597
|
+
/**
|
|
598
|
+
* The model that will complete your prompt.
|
|
599
|
+
*
|
|
600
|
+
* See [models](https://docs.anthropic.com/en/docs/models-overview) for additional
|
|
601
|
+
* details and options.
|
|
602
|
+
*/
|
|
603
|
+
model: string;
|
|
604
|
+
/**
|
|
605
|
+
* An object describing metadata about the request.
|
|
606
|
+
*/
|
|
607
|
+
metadata?: MessageStreamParams.Metadata;
|
|
608
|
+
/**
|
|
609
|
+
* Custom text sequences that will cause the model to stop generating.
|
|
610
|
+
*
|
|
611
|
+
* Our models will normally stop when they have naturally completed their turn,
|
|
612
|
+
* which will result in a response `stop_reason` of `"end_turn"`.
|
|
613
|
+
*
|
|
614
|
+
* If you want the model to stop generating when it encounters custom strings of
|
|
615
|
+
* text, you can use the `stop_sequences` parameter. If the model encounters one of
|
|
616
|
+
* the custom sequences, the response `stop_reason` value will be `"stop_sequence"`
|
|
617
|
+
* and the response `stop_sequence` value will contain the matched stop sequence.
|
|
618
|
+
*/
|
|
619
|
+
stop_sequences?: Array<string>;
|
|
620
|
+
/**
|
|
621
|
+
* System prompt.
|
|
622
|
+
*
|
|
623
|
+
* A system prompt is a way of providing context and instructions to Claude, such
|
|
624
|
+
* as specifying a particular goal or role. See our
|
|
625
|
+
* [guide to system prompts](https://docs.anthropic.com/en/docs/system-prompts).
|
|
626
|
+
*/
|
|
627
|
+
system?: string;
|
|
628
|
+
/**
|
|
629
|
+
* Amount of randomness injected into the response.
|
|
630
|
+
*
|
|
631
|
+
* Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
|
|
632
|
+
* for analytical / multiple choice, and closer to `1.0` for creative and
|
|
633
|
+
* generative tasks.
|
|
634
|
+
*
|
|
635
|
+
* Note that even with `temperature` of `0.0`, the results will not be fully
|
|
636
|
+
* deterministic.
|
|
637
|
+
*/
|
|
638
|
+
temperature?: number;
|
|
639
|
+
/**
|
|
640
|
+
* How the model should use the provided tools. The model can use a specific tool,
|
|
641
|
+
* any available tool, or decide by itself.
|
|
642
|
+
*/
|
|
643
|
+
tool_choice?: MessageStreamParams.ToolChoiceAuto | MessageStreamParams.ToolChoiceAny | MessageStreamParams.ToolChoiceTool;
|
|
644
|
+
/**
|
|
645
|
+
* [beta] Definitions of tools that the model may use.
|
|
646
|
+
*
|
|
647
|
+
* If you include `tools` in your API request, the model may return `tool_use`
|
|
648
|
+
* content blocks that represent the model's use of those tools. You can then run
|
|
649
|
+
* those tools using the tool input generated by the model and then optionally
|
|
650
|
+
* return results back to the model using `tool_result` content blocks.
|
|
651
|
+
*
|
|
652
|
+
* Each tool definition includes:
|
|
653
|
+
*
|
|
654
|
+
* - `name`: Name of the tool.
|
|
655
|
+
* - `description`: Optional, but strongly-recommended description of the tool.
|
|
656
|
+
* - `input_schema`: [JSON schema](https://json-schema.org/) for the tool `input`
|
|
657
|
+
* shape that the model will produce in `tool_use` output content blocks.
|
|
658
|
+
*
|
|
659
|
+
* For example, if you defined `tools` as:
|
|
660
|
+
*
|
|
661
|
+
* ```json
|
|
662
|
+
* [
|
|
663
|
+
* {
|
|
664
|
+
* "name": "get_stock_price",
|
|
665
|
+
* "description": "Get the current stock price for a given ticker symbol.",
|
|
666
|
+
* "input_schema": {
|
|
667
|
+
* "type": "object",
|
|
668
|
+
* "properties": {
|
|
669
|
+
* "ticker": {
|
|
670
|
+
* "type": "string",
|
|
671
|
+
* "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
|
|
672
|
+
* }
|
|
673
|
+
* },
|
|
674
|
+
* "required": ["ticker"]
|
|
675
|
+
* }
|
|
676
|
+
* }
|
|
677
|
+
* ]
|
|
678
|
+
* ```
|
|
679
|
+
*
|
|
680
|
+
* And then asked the model "What's the S&P 500 at today?", the model might produce
|
|
681
|
+
* `tool_use` content blocks in the response like this:
|
|
682
|
+
*
|
|
683
|
+
* ```json
|
|
684
|
+
* [
|
|
685
|
+
* {
|
|
686
|
+
* "type": "tool_use",
|
|
687
|
+
* "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
|
|
688
|
+
* "name": "get_stock_price",
|
|
689
|
+
* "input": { "ticker": "^GSPC" }
|
|
690
|
+
* }
|
|
691
|
+
* ]
|
|
692
|
+
* ```
|
|
693
|
+
*
|
|
694
|
+
* You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
|
|
695
|
+
* input, and return the following back to the model in a subsequent `user`
|
|
696
|
+
* message:
|
|
697
|
+
*
|
|
698
|
+
* ```json
|
|
699
|
+
* [
|
|
700
|
+
* {
|
|
701
|
+
* "type": "tool_result",
|
|
702
|
+
* "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
|
|
703
|
+
* "content": "259.75 USD"
|
|
704
|
+
* }
|
|
705
|
+
* ]
|
|
706
|
+
* ```
|
|
707
|
+
*
|
|
708
|
+
* Tools can be used for workflows that include running client-side tools and
|
|
709
|
+
* functions, or more generally whenever you want the model to produce a particular
|
|
710
|
+
* JSON structure of output.
|
|
711
|
+
*
|
|
712
|
+
* See our [beta guide](https://docs.anthropic.com/en/docs/tool-use) for more
|
|
713
|
+
* details.
|
|
714
|
+
*/
|
|
715
|
+
tools?: Array<Tool>;
|
|
716
|
+
/**
|
|
717
|
+
* Only sample from the top K options for each subsequent token.
|
|
718
|
+
*
|
|
719
|
+
* Used to remove "long tail" low probability responses.
|
|
720
|
+
* [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
|
|
721
|
+
*
|
|
722
|
+
* Recommended for advanced use cases only. You usually only need to use
|
|
723
|
+
* `temperature`.
|
|
724
|
+
*/
|
|
725
|
+
top_k?: number;
|
|
726
|
+
/**
|
|
727
|
+
* Use nucleus sampling.
|
|
728
|
+
*
|
|
729
|
+
* In nucleus sampling, we compute the cumulative distribution over all the options
|
|
730
|
+
* for each subsequent token in decreasing probability order and cut it off once it
|
|
731
|
+
* reaches a particular probability specified by `top_p`. You should either alter
|
|
732
|
+
* `temperature` or `top_p`, but not both.
|
|
733
|
+
*
|
|
734
|
+
* Recommended for advanced use cases only. You usually only need to use
|
|
735
|
+
* `temperature`.
|
|
736
|
+
*/
|
|
737
|
+
top_p?: number;
|
|
738
|
+
}
|
|
739
|
+
export declare namespace MessageStreamParams {
|
|
740
|
+
/**
|
|
741
|
+
* An object describing metadata about the request.
|
|
742
|
+
*/
|
|
743
|
+
interface Metadata {
|
|
744
|
+
/**
|
|
745
|
+
* An external identifier for the user who is associated with the request.
|
|
746
|
+
*
|
|
747
|
+
* This should be a uuid, hash value, or other opaque identifier. Anthropic may use
|
|
748
|
+
* this id to help detect abuse. Do not include any identifying information such as
|
|
749
|
+
* name, email address, or phone number.
|
|
750
|
+
*/
|
|
751
|
+
user_id?: string | null;
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* The model will automatically decide whether to use tools.
|
|
755
|
+
*/
|
|
756
|
+
interface ToolChoiceAuto {
|
|
757
|
+
type: 'auto';
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* The model will use any available tools.
|
|
761
|
+
*/
|
|
762
|
+
interface ToolChoiceAny {
|
|
763
|
+
type: 'any';
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* The model will use the specified tool with `tool_choice.name`.
|
|
767
|
+
*/
|
|
768
|
+
interface ToolChoiceTool {
|
|
769
|
+
/**
|
|
770
|
+
* The name of the tool to use.
|
|
771
|
+
*/
|
|
772
|
+
name: string;
|
|
773
|
+
type: 'tool';
|
|
774
|
+
}
|
|
775
|
+
}
|
|
450
776
|
export declare namespace Messages {
|
|
777
|
+
export import InputJsonDelta = ToolsMessagesAPI.InputJsonDelta;
|
|
451
778
|
export import Tool = ToolsMessagesAPI.Tool;
|
|
452
779
|
export import ToolResultBlockParam = ToolsMessagesAPI.ToolResultBlockParam;
|
|
453
780
|
export import ToolUseBlock = ToolsMessagesAPI.ToolUseBlock;
|
|
454
781
|
export import ToolUseBlockParam = ToolsMessagesAPI.ToolUseBlockParam;
|
|
455
782
|
export import ToolsBetaContentBlock = ToolsMessagesAPI.ToolsBetaContentBlock;
|
|
783
|
+
export import ToolsBetaContentBlockDeltaEvent = ToolsMessagesAPI.ToolsBetaContentBlockDeltaEvent;
|
|
784
|
+
export import ToolsBetaContentBlockStartEvent = ToolsMessagesAPI.ToolsBetaContentBlockStartEvent;
|
|
456
785
|
export import ToolsBetaMessage = ToolsMessagesAPI.ToolsBetaMessage;
|
|
457
786
|
export import ToolsBetaMessageParam = ToolsMessagesAPI.ToolsBetaMessageParam;
|
|
787
|
+
export import ToolsBetaMessageStreamEvent = ToolsMessagesAPI.ToolsBetaMessageStreamEvent;
|
|
458
788
|
export import MessageCreateParams = ToolsMessagesAPI.MessageCreateParams;
|
|
459
789
|
export import MessageCreateParamsNonStreaming = ToolsMessagesAPI.MessageCreateParamsNonStreaming;
|
|
460
790
|
export import MessageCreateParamsStreaming = ToolsMessagesAPI.MessageCreateParamsStreaming;
|
|
791
|
+
export import MessageStreamParams = ToolsMessagesAPI.MessageStreamParams;
|
|
461
792
|
}
|
|
462
793
|
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/resources/beta/tools/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,KAAK,gBAAgB,MAAM,iDAAiD,CAAC;AACpF,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,gBAAgB,CAAC;IAC1G,MAAM,CACJ,IAAI,EAAE,4BAA4B,EAClC,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAC5B,UAAU,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/resources/beta/tools/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,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,KAAK,gBAAgB,MAAM,iDAAiD,C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BAAoB,CAAC;IAC3E,MAAM,QAAQ,YAAY,GAAG,gBAAgB,CAAC,YAAY,CAAC;IAC3D,MAAM,QAAQ,iBAAiB,GAAG,gBAAgB,CAAC,iBAAiB,CAAC;IACrE,MAAM,QAAQ,qBAAqB,GAAG,gBAAgB,CAAC,qBAAqB,CAAC;IAC7E,MAAM,QAAQ,+BAA+B,GAAG,gBAAgB,CAAC,+BAA+B,CAAC;IACjG,MAAM,QAAQ,+BAA+B,GAAG,gBAAgB,CAAC,+BAA+B,CAAC;IACjG,MAAM,QAAQ,gBAAgB,GAAG,gBAAgB,CAAC,gBAAgB,CAAC;IACnE,MAAM,QAAQ,qBAAqB,GAAG,gBAAgB,CAAC,qBAAqB,CAAC;IAC7E,MAAM,QAAQ,2BAA2B,GAAG,gBAAgB,CAAC,2BAA2B,CAAC;IACzF,MAAM,QAAQ,mBAAmB,GAAG,gBAAgB,CAAC,mBAAmB,CAAC;IACzE,MAAM,QAAQ,+BAA+B,GAAG,gBAAgB,CAAC,+BAA+B,CAAC;IACjG,MAAM,QAAQ,4BAA4B,GAAG,gBAAgB,CAAC,4BAA4B,CAAC;IAC3F,MAAM,QAAQ,mBAAmB,GAAG,gBAAgB,CAAC,mBAAmB,CAAC;CAC1E"}
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.Messages = void 0;
|
|
4
|
+
exports.Messages = exports.ToolsBetaMessageStream = void 0;
|
|
5
5
|
const resource_1 = require("@anthropic-ai/sdk/resource");
|
|
6
|
+
const ToolsBetaMessageStream_1 = require("@anthropic-ai/sdk/lib/ToolsBetaMessageStream");
|
|
7
|
+
var ToolsBetaMessageStream_2 = require("@anthropic-ai/sdk/lib/ToolsBetaMessageStream");
|
|
8
|
+
Object.defineProperty(exports, "ToolsBetaMessageStream", { enumerable: true, get: function () { return ToolsBetaMessageStream_2.ToolsBetaMessageStream; } });
|
|
6
9
|
class Messages extends resource_1.APIResource {
|
|
7
10
|
create(body, options) {
|
|
8
11
|
return this._client.post('/v1/messages?beta=tools', {
|
|
9
12
|
body,
|
|
10
13
|
timeout: 600000,
|
|
11
14
|
...options,
|
|
12
|
-
headers: { 'anthropic-beta': 'tools-2024-
|
|
15
|
+
headers: { 'anthropic-beta': 'tools-2024-05-16', ...options?.headers },
|
|
13
16
|
stream: body.stream ?? false,
|
|
14
17
|
});
|
|
15
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Create a Message stream
|
|
21
|
+
*/
|
|
22
|
+
stream(body, options) {
|
|
23
|
+
return ToolsBetaMessageStream_1.ToolsBetaMessageStream.createMessage(this, body, options);
|
|
24
|
+
}
|
|
16
25
|
}
|
|
17
26
|
exports.Messages = Messages;
|
|
18
27
|
(function (Messages) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/resources/beta/tools/messages.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAItF,yDAAyD;
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/resources/beta/tools/messages.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAItF,yDAAyD;AACzD,yFAAsF;AACtF,uFAAsF;AAA7E,gIAAA,sBAAsB,OAAA;AAK/B,MAAa,QAAS,SAAQ,sBAAW;IAmBvC,MAAM,CACJ,IAAyB,EACzB,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,yBAAyB,EAAE;YAClD,IAAI;YACJ,OAAO,EAAE,MAAM;YACf,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;YACtE,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,KAAK;SAC7B,CAAmF,CAAC;IACvF,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAyB,EAAE,OAA6B;QAC7D,OAAO,+CAAsB,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;CACF;AAtCD,4BAsCC;AAy0BD,WAAiB,QAAQ;AAgBzB,CAAC,EAhBgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAgBxB"}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
import { APIResource } from '@anthropic-ai/sdk/resource';
|
|
3
|
+
import { ToolsBetaMessageStream } from '@anthropic-ai/sdk/lib/ToolsBetaMessageStream';
|
|
4
|
+
export { ToolsBetaMessageStream } from '@anthropic-ai/sdk/lib/ToolsBetaMessageStream';
|
|
3
5
|
export class Messages extends APIResource {
|
|
4
6
|
create(body, options) {
|
|
5
7
|
return this._client.post('/v1/messages?beta=tools', {
|
|
6
8
|
body,
|
|
7
9
|
timeout: 600000,
|
|
8
10
|
...options,
|
|
9
|
-
headers: { 'anthropic-beta': 'tools-2024-
|
|
11
|
+
headers: { 'anthropic-beta': 'tools-2024-05-16', ...options?.headers },
|
|
10
12
|
stream: body.stream ?? false,
|
|
11
13
|
});
|
|
12
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Create a Message stream
|
|
17
|
+
*/
|
|
18
|
+
stream(body, options) {
|
|
19
|
+
return ToolsBetaMessageStream.createMessage(this, body, options);
|
|
20
|
+
}
|
|
13
21
|
}
|
|
14
22
|
(function (Messages) {
|
|
15
23
|
})(Messages || (Messages = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.mjs","sourceRoot":"","sources":["../../../src/resources/beta/tools/messages.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAI/E,EAAE,WAAW,EAAE,MAAM,4BAA4B;
|
|
1
|
+
{"version":3,"file":"messages.mjs","sourceRoot":"","sources":["../../../src/resources/beta/tools/messages.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAI/E,EAAE,WAAW,EAAE,MAAM,4BAA4B;OACjD,EAAE,sBAAsB,EAAE,MAAM,8CAA8C;OAC9E,EAAE,sBAAsB,EAAE,MAAM,8CAA8C;AAKrF,MAAM,OAAO,QAAS,SAAQ,WAAW;IAmBvC,MAAM,CACJ,IAAyB,EACzB,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,yBAAyB,EAAE;YAClD,IAAI;YACJ,OAAO,EAAE,MAAM;YACf,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;YACtE,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,KAAK;SAC7B,CAAmF,CAAC;IACvF,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAyB,EAAE,OAA6B;QAC7D,OAAO,sBAAsB,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;CACF;AAy0BD,WAAiB,QAAQ;AAgBzB,CAAC,EAhBgB,QAAQ,KAAR,QAAQ,QAgBxB"}
|
|
@@ -5,15 +5,20 @@ export declare class Tools extends APIResource {
|
|
|
5
5
|
}
|
|
6
6
|
export declare namespace Tools {
|
|
7
7
|
export import Messages = MessagesAPI.Messages;
|
|
8
|
+
export import InputJsonDelta = MessagesAPI.InputJsonDelta;
|
|
8
9
|
export import Tool = MessagesAPI.Tool;
|
|
9
10
|
export import ToolResultBlockParam = MessagesAPI.ToolResultBlockParam;
|
|
10
11
|
export import ToolUseBlock = MessagesAPI.ToolUseBlock;
|
|
11
12
|
export import ToolUseBlockParam = MessagesAPI.ToolUseBlockParam;
|
|
12
13
|
export import ToolsBetaContentBlock = MessagesAPI.ToolsBetaContentBlock;
|
|
14
|
+
export import ToolsBetaContentBlockDeltaEvent = MessagesAPI.ToolsBetaContentBlockDeltaEvent;
|
|
15
|
+
export import ToolsBetaContentBlockStartEvent = MessagesAPI.ToolsBetaContentBlockStartEvent;
|
|
13
16
|
export import ToolsBetaMessage = MessagesAPI.ToolsBetaMessage;
|
|
14
17
|
export import ToolsBetaMessageParam = MessagesAPI.ToolsBetaMessageParam;
|
|
18
|
+
export import ToolsBetaMessageStreamEvent = MessagesAPI.ToolsBetaMessageStreamEvent;
|
|
15
19
|
export import MessageCreateParams = MessagesAPI.MessageCreateParams;
|
|
16
20
|
export import MessageCreateParamsNonStreaming = MessagesAPI.MessageCreateParamsNonStreaming;
|
|
17
21
|
export import MessageCreateParamsStreaming = MessagesAPI.MessageCreateParamsStreaming;
|
|
22
|
+
export import MessageStreamParams = MessagesAPI.MessageStreamParams;
|
|
18
23
|
}
|
|
19
24
|
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/resources/beta/tools/tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,WAAW,MAAM,iDAAiD,CAAC;AAE/E,qBAAa,KAAM,SAAQ,WAAW;IACpC,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAA0C;CACzE;AAED,yBAAiB,KAAK,CAAC;IACrB,MAAM,QAAQ,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;IAC9C,MAAM,QAAQ,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC;IACtC,MAAM,QAAQ,oBAAoB,GAAG,WAAW,CAAC,oBAAoB,CAAC;IACtE,MAAM,QAAQ,YAAY,GAAG,WAAW,CAAC,YAAY,CAAC;IACtD,MAAM,QAAQ,iBAAiB,GAAG,WAAW,CAAC,iBAAiB,CAAC;IAChE,MAAM,QAAQ,qBAAqB,GAAG,WAAW,CAAC,qBAAqB,CAAC;IACxE,MAAM,QAAQ,gBAAgB,GAAG,WAAW,CAAC,gBAAgB,CAAC;IAC9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AA2B,CAAC;IACpF,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":"tools.js","sourceRoot":"","sources":["../../../src/resources/beta/tools/tools.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtF,yDAAyD;AACzD,6FAA+E;AAE/E,MAAa,KAAM,SAAQ,sBAAW;IAAtC;;QACE,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1E,CAAC;CAAA;AAFD,sBAEC;AAED,WAAiB,KAAK;IACN,cAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/resources/beta/tools/tools.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtF,yDAAyD;AACzD,6FAA+E;AAE/E,MAAa,KAAM,SAAQ,sBAAW;IAAtC;;QACE,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1E,CAAC;CAAA;AAFD,sBAEC;AAED,WAAiB,KAAK;IACN,cAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;AAgBhD,CAAC,EAjBgB,KAAK,GAAL,aAAK,KAAL,aAAK,QAiBrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.mjs","sourceRoot":"","sources":["../../../src/resources/beta/tools/tools.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE,MAAM,4BAA4B;OACjD,KAAK,WAAW,MAAM,iDAAiD;AAE9E,MAAM,OAAO,KAAM,SAAQ,WAAW;IAAtC;;QACE,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1E,CAAC;CAAA;AAED,WAAiB,KAAK;IACN,cAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.mjs","sourceRoot":"","sources":["../../../src/resources/beta/tools/tools.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE,MAAM,4BAA4B;OACjD,KAAK,WAAW,MAAM,iDAAiD;AAE9E,MAAM,OAAO,KAAM,SAAQ,WAAW;IAAtC;;QACE,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1E,CAAC;CAAA;AAED,WAAiB,KAAK;IACN,cAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;AAgBhD,CAAC,EAjBgB,KAAK,KAAL,KAAK,QAiBrB"}
|