@effect/ai-anthropic 4.0.0-beta.8 → 4.0.0-beta.81
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/dist/AnthropicClient.d.ts +93 -74
- package/dist/AnthropicClient.d.ts.map +1 -1
- package/dist/AnthropicClient.js +51 -19
- package/dist/AnthropicClient.js.map +1 -1
- package/dist/AnthropicConfig.d.ts +55 -10
- package/dist/AnthropicConfig.d.ts.map +1 -1
- package/dist/AnthropicConfig.js +30 -7
- package/dist/AnthropicConfig.js.map +1 -1
- package/dist/AnthropicError.d.ts +136 -37
- package/dist/AnthropicError.d.ts.map +1 -1
- package/dist/AnthropicError.js +1 -1
- package/dist/AnthropicLanguageModel.d.ts +362 -52
- package/dist/AnthropicLanguageModel.d.ts.map +1 -1
- package/dist/AnthropicLanguageModel.js +88 -21
- package/dist/AnthropicLanguageModel.js.map +1 -1
- package/dist/AnthropicTelemetry.d.ts +43 -16
- package/dist/AnthropicTelemetry.d.ts.map +1 -1
- package/dist/AnthropicTelemetry.js +15 -9
- package/dist/AnthropicTelemetry.js.map +1 -1
- package/dist/AnthropicTool.d.ts +1223 -289
- package/dist/AnthropicTool.d.ts.map +1 -1
- package/dist/AnthropicTool.js +859 -201
- package/dist/AnthropicTool.js.map +1 -1
- package/dist/Generated.d.ts +1 -1
- package/dist/Generated.js +1 -1
- package/dist/index.d.ts +8 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -29
- package/dist/index.js.map +1 -1
- package/dist/internal/errors.js +7 -7
- package/dist/internal/errors.js.map +1 -1
- package/package.json +3 -3
- package/src/AnthropicClient.ts +114 -104
- package/src/AnthropicConfig.ts +56 -11
- package/src/AnthropicError.ts +138 -37
- package/src/AnthropicLanguageModel.ts +395 -43
- package/src/AnthropicTelemetry.ts +48 -22
- package/src/AnthropicTool.ts +1216 -282
- package/src/Generated.ts +1 -1
- package/src/index.ts +8 -29
- package/src/internal/errors.ts +9 -7
|
@@ -5,26 +5,30 @@ import * as Telemetry from "effect/unstable/ai/Telemetry";
|
|
|
5
5
|
* The attributes used to describe telemetry in the context of Generative
|
|
6
6
|
* Artificial Intelligence (GenAI) Models requests and responses.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* **Details**
|
|
9
|
+
*
|
|
10
|
+
* These attributes follow the OpenTelemetry generative AI semantic
|
|
11
|
+
* conventions:
|
|
12
|
+
* https://opentelemetry.io/docs/specs/semconv/attributes-registry/gen-ai/
|
|
9
13
|
*
|
|
10
|
-
* @since 1.0.0
|
|
11
14
|
* @category models
|
|
15
|
+
* @since 4.0.0
|
|
12
16
|
*/
|
|
13
17
|
export type AnthropicTelemetryAttributes = Simplify<Telemetry.GenAITelemetryAttributes & Telemetry.AttributesWithPrefix<RequestAttributes, "gen_ai.anthropic.request"> & Telemetry.AttributesWithPrefix<ResponseAttributes, "gen_ai.anthropic.response">>;
|
|
14
18
|
/**
|
|
15
19
|
* All telemetry attributes which are part of the GenAI specification,
|
|
16
20
|
* including the Anthropic-specific attributes.
|
|
17
21
|
*
|
|
18
|
-
* @since 1.0.0
|
|
19
22
|
* @category models
|
|
23
|
+
* @since 4.0.0
|
|
20
24
|
*/
|
|
21
25
|
export type AllAttributes = Telemetry.AllAttributes & RequestAttributes & ResponseAttributes;
|
|
22
26
|
/**
|
|
23
27
|
* Telemetry attributes which are part of the GenAI specification and are
|
|
24
28
|
* namespaced by `gen_ai.anthropic.request`.
|
|
25
29
|
*
|
|
26
|
-
* @since 1.0.0
|
|
27
30
|
* @category models
|
|
31
|
+
* @since 4.0.0
|
|
28
32
|
*/
|
|
29
33
|
export interface RequestAttributes {
|
|
30
34
|
/**
|
|
@@ -40,8 +44,8 @@ export interface RequestAttributes {
|
|
|
40
44
|
* Telemetry attributes which are part of the GenAI specification and are
|
|
41
45
|
* namespaced by `gen_ai.anthropic.response`.
|
|
42
46
|
*
|
|
43
|
-
* @since 1.0.0
|
|
44
47
|
* @category models
|
|
48
|
+
* @since 4.0.0
|
|
45
49
|
*/
|
|
46
50
|
export interface ResponseAttributes {
|
|
47
51
|
/**
|
|
@@ -58,8 +62,10 @@ export interface ResponseAttributes {
|
|
|
58
62
|
readonly cacheReadInputTokens?: number | null | undefined;
|
|
59
63
|
}
|
|
60
64
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
65
|
+
* Options accepted by `addGenAIAnnotations`, combining standard GenAI telemetry attributes with optional Anthropic request and response attributes.
|
|
66
|
+
*
|
|
67
|
+
* @category options
|
|
68
|
+
* @since 4.0.0
|
|
63
69
|
*/
|
|
64
70
|
export type AnthropicTelemetryAttributeOptions = Telemetry.GenAITelemetryAttributeOptions & {
|
|
65
71
|
anthropic?: {
|
|
@@ -71,30 +77,51 @@ export type AnthropicTelemetryAttributeOptions = Telemetry.GenAITelemetryAttribu
|
|
|
71
77
|
* Applies the specified Anthropic GenAI telemetry attributes to the provided
|
|
72
78
|
* `Span`.
|
|
73
79
|
*
|
|
74
|
-
* **
|
|
80
|
+
* **When to use**
|
|
81
|
+
*
|
|
82
|
+
* Use to annotate an Anthropic model span with standard GenAI telemetry
|
|
83
|
+
* attributes and Anthropic-specific request or response metadata.
|
|
84
|
+
*
|
|
85
|
+
* **Gotchas**
|
|
86
|
+
*
|
|
87
|
+
* This method mutates the `Span` in place.
|
|
75
88
|
*
|
|
76
|
-
* @
|
|
77
|
-
* @
|
|
89
|
+
* @category annotations
|
|
90
|
+
* @since 4.0.0
|
|
78
91
|
*/
|
|
79
92
|
export declare const addGenAIAnnotations: {
|
|
80
93
|
/**
|
|
81
94
|
* Applies the specified Anthropic GenAI telemetry attributes to the provided
|
|
82
95
|
* `Span`.
|
|
83
96
|
*
|
|
84
|
-
* **
|
|
97
|
+
* **When to use**
|
|
85
98
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
99
|
+
* Use to annotate an Anthropic model span with standard GenAI telemetry
|
|
100
|
+
* attributes and Anthropic-specific request or response metadata.
|
|
101
|
+
*
|
|
102
|
+
* **Gotchas**
|
|
103
|
+
*
|
|
104
|
+
* This method mutates the `Span` in place.
|
|
105
|
+
*
|
|
106
|
+
* @category annotations
|
|
107
|
+
* @since 4.0.0
|
|
88
108
|
*/
|
|
89
109
|
(options: AnthropicTelemetryAttributeOptions): (span: Span) => void;
|
|
90
110
|
/**
|
|
91
111
|
* Applies the specified Anthropic GenAI telemetry attributes to the provided
|
|
92
112
|
* `Span`.
|
|
93
113
|
*
|
|
94
|
-
* **
|
|
114
|
+
* **When to use**
|
|
115
|
+
*
|
|
116
|
+
* Use to annotate an Anthropic model span with standard GenAI telemetry
|
|
117
|
+
* attributes and Anthropic-specific request or response metadata.
|
|
118
|
+
*
|
|
119
|
+
* **Gotchas**
|
|
120
|
+
*
|
|
121
|
+
* This method mutates the `Span` in place.
|
|
95
122
|
*
|
|
96
|
-
* @
|
|
97
|
-
* @
|
|
123
|
+
* @category annotations
|
|
124
|
+
* @since 4.0.0
|
|
98
125
|
*/
|
|
99
126
|
(span: Span, options: AnthropicTelemetryAttributeOptions): void;
|
|
100
127
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnthropicTelemetry.d.ts","sourceRoot":"","sources":["../src/AnthropicTelemetry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AnthropicTelemetry.d.ts","sourceRoot":"","sources":["../src/AnthropicTelemetry.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,SAAS,MAAM,8BAA8B,CAAA;AAEzD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,4BAA4B,GAAG,QAAQ,CAC/C,SAAS,CAAC,wBAAwB,GAClC,SAAS,CAAC,oBAAoB,CAAC,iBAAiB,EAAE,0BAA0B,CAAC,GAC7E,SAAS,CAAC,oBAAoB,CAAC,kBAAkB,EAAE,2BAA2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-
*
|
|
2
|
+
* The `AnthropicTelemetry` module defines Anthropic-specific telemetry
|
|
3
|
+
* attributes and a helper for adding them to a tracing span. It keeps the
|
|
4
|
+
* standard GenAI telemetry attributes and adds request and response metadata
|
|
5
|
+
* under the `gen_ai.anthropic.*` OpenTelemetry namespaces.
|
|
3
6
|
*
|
|
4
|
-
*
|
|
5
|
-
* semantic conventions, extending the base GenAI attributes with Anthropic-specific
|
|
6
|
-
* request and response metadata.
|
|
7
|
-
*
|
|
8
|
-
* @since 1.0.0
|
|
7
|
+
* @since 4.0.0
|
|
9
8
|
*/
|
|
10
9
|
import { dual } from "effect/Function";
|
|
11
10
|
import * as String from "effect/String";
|
|
@@ -16,10 +15,17 @@ const addAnthropicResponseAttributes = /*#__PURE__*/Telemetry.addSpanAttributes(
|
|
|
16
15
|
* Applies the specified Anthropic GenAI telemetry attributes to the provided
|
|
17
16
|
* `Span`.
|
|
18
17
|
*
|
|
19
|
-
* **
|
|
18
|
+
* **When to use**
|
|
19
|
+
*
|
|
20
|
+
* Use to annotate an Anthropic model span with standard GenAI telemetry
|
|
21
|
+
* attributes and Anthropic-specific request or response metadata.
|
|
22
|
+
*
|
|
23
|
+
* **Gotchas**
|
|
24
|
+
*
|
|
25
|
+
* This method mutates the `Span` in place.
|
|
20
26
|
*
|
|
21
|
-
* @
|
|
22
|
-
* @
|
|
27
|
+
* @category annotations
|
|
28
|
+
* @since 4.0.0
|
|
23
29
|
*/
|
|
24
30
|
export const addGenAIAnnotations = /*#__PURE__*/dual(2, (span, options) => {
|
|
25
31
|
Telemetry.addGenAIAnnotations(span, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnthropicTelemetry.js","names":["dual","String","Telemetry","addAnthropicRequestAttributes","addSpanAttributes","camelToSnake","addAnthropicResponseAttributes","addGenAIAnnotations","span","options","anthropic","request","response"],"sources":["../src/AnthropicTelemetry.ts"],"sourcesContent":[null],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"AnthropicTelemetry.js","names":["dual","String","Telemetry","addAnthropicRequestAttributes","addSpanAttributes","camelToSnake","addAnthropicResponseAttributes","addGenAIAnnotations","span","options","anthropic","request","response"],"sources":["../src/AnthropicTelemetry.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;AAQA,SAASA,IAAI,QAAQ,iBAAiB;AACtC,OAAO,KAAKC,MAAM,MAAM,eAAe;AAGvC,OAAO,KAAKC,SAAS,MAAM,8BAA8B;AAmFzD,MAAMC,6BAA6B,gBAAGD,SAAS,CAACE,iBAAiB,CAAC,0BAA0B,EAAEH,MAAM,CAACI,YAAY,CAEhH;AACD,MAAMC,8BAA8B,gBAAGJ,SAAS,CAACE,iBAAiB,CAAC,2BAA2B,EAAEH,MAAM,CAACI,YAAY,CAElH;AAED;;;;;;;;;;;;;;;;AAgBA,OAAO,MAAME,mBAAmB,gBAmC5BP,IAAI,CAAC,CAAC,EAAE,CAACQ,IAAU,EAAEC,OAA2C,KAAI;EACtEP,SAAS,CAACK,mBAAmB,CAACC,IAAI,EAAEC,OAAO,CAAC;EAC5C,IAAIA,OAAO,CAACC,SAAS,IAAI,IAAI,EAAE;IAC7B,IAAID,OAAO,CAACC,SAAS,CAACC,OAAO,IAAI,IAAI,EAAE;MACrCR,6BAA6B,CAACK,IAAI,EAAEC,OAAO,CAACC,SAAS,CAACC,OAAO,CAAC;IAChE;IACA,IAAIF,OAAO,CAACC,SAAS,CAACE,QAAQ,IAAI,IAAI,EAAE;MACtCN,8BAA8B,CAACE,IAAI,EAAEC,OAAO,CAACC,SAAS,CAACE,QAAQ,CAAC;IAClE;EACF;AACF,CAAC,CAAC","ignoreList":[]}
|