@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
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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"
|
|
@@ -17,10 +16,14 @@ import * as Telemetry from "effect/unstable/ai/Telemetry"
|
|
|
17
16
|
* The attributes used to describe telemetry in the context of Generative
|
|
18
17
|
* Artificial Intelligence (GenAI) Models requests and responses.
|
|
19
18
|
*
|
|
20
|
-
*
|
|
19
|
+
* **Details**
|
|
20
|
+
*
|
|
21
|
+
* These attributes follow the OpenTelemetry generative AI semantic
|
|
22
|
+
* conventions:
|
|
23
|
+
* https://opentelemetry.io/docs/specs/semconv/attributes-registry/gen-ai/
|
|
21
24
|
*
|
|
22
|
-
* @since 1.0.0
|
|
23
25
|
* @category models
|
|
26
|
+
* @since 4.0.0
|
|
24
27
|
*/
|
|
25
28
|
export type AnthropicTelemetryAttributes = Simplify<
|
|
26
29
|
& Telemetry.GenAITelemetryAttributes
|
|
@@ -32,8 +35,8 @@ export type AnthropicTelemetryAttributes = Simplify<
|
|
|
32
35
|
* All telemetry attributes which are part of the GenAI specification,
|
|
33
36
|
* including the Anthropic-specific attributes.
|
|
34
37
|
*
|
|
35
|
-
* @since 1.0.0
|
|
36
38
|
* @category models
|
|
39
|
+
* @since 4.0.0
|
|
37
40
|
*/
|
|
38
41
|
export type AllAttributes = Telemetry.AllAttributes & RequestAttributes & ResponseAttributes
|
|
39
42
|
|
|
@@ -41,8 +44,8 @@ export type AllAttributes = Telemetry.AllAttributes & RequestAttributes & Respon
|
|
|
41
44
|
* Telemetry attributes which are part of the GenAI specification and are
|
|
42
45
|
* namespaced by `gen_ai.anthropic.request`.
|
|
43
46
|
*
|
|
44
|
-
* @since 1.0.0
|
|
45
47
|
* @category models
|
|
48
|
+
* @since 4.0.0
|
|
46
49
|
*/
|
|
47
50
|
export interface RequestAttributes {
|
|
48
51
|
/**
|
|
@@ -59,8 +62,8 @@ export interface RequestAttributes {
|
|
|
59
62
|
* Telemetry attributes which are part of the GenAI specification and are
|
|
60
63
|
* namespaced by `gen_ai.anthropic.response`.
|
|
61
64
|
*
|
|
62
|
-
* @since 1.0.0
|
|
63
65
|
* @category models
|
|
66
|
+
* @since 4.0.0
|
|
64
67
|
*/
|
|
65
68
|
export interface ResponseAttributes {
|
|
66
69
|
/**
|
|
@@ -78,8 +81,10 @@ export interface ResponseAttributes {
|
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
84
|
+
* Options accepted by `addGenAIAnnotations`, combining standard GenAI telemetry attributes with optional Anthropic request and response attributes.
|
|
85
|
+
*
|
|
86
|
+
* @category options
|
|
87
|
+
* @since 4.0.0
|
|
83
88
|
*/
|
|
84
89
|
export type AnthropicTelemetryAttributeOptions = Telemetry.GenAITelemetryAttributeOptions & {
|
|
85
90
|
anthropic?: {
|
|
@@ -99,30 +104,51 @@ const addAnthropicResponseAttributes = Telemetry.addSpanAttributes("gen_ai.anthr
|
|
|
99
104
|
* Applies the specified Anthropic GenAI telemetry attributes to the provided
|
|
100
105
|
* `Span`.
|
|
101
106
|
*
|
|
102
|
-
* **
|
|
107
|
+
* **When to use**
|
|
108
|
+
*
|
|
109
|
+
* Use to annotate an Anthropic model span with standard GenAI telemetry
|
|
110
|
+
* attributes and Anthropic-specific request or response metadata.
|
|
111
|
+
*
|
|
112
|
+
* **Gotchas**
|
|
113
|
+
*
|
|
114
|
+
* This method mutates the `Span` in place.
|
|
103
115
|
*
|
|
104
|
-
* @
|
|
105
|
-
* @
|
|
116
|
+
* @category annotations
|
|
117
|
+
* @since 4.0.0
|
|
106
118
|
*/
|
|
107
119
|
export const addGenAIAnnotations: {
|
|
108
120
|
/**
|
|
109
121
|
* Applies the specified Anthropic GenAI telemetry attributes to the provided
|
|
110
122
|
* `Span`.
|
|
111
123
|
*
|
|
112
|
-
* **
|
|
124
|
+
* **When to use**
|
|
113
125
|
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
126
|
+
* Use to annotate an Anthropic model span with standard GenAI telemetry
|
|
127
|
+
* attributes and Anthropic-specific request or response metadata.
|
|
128
|
+
*
|
|
129
|
+
* **Gotchas**
|
|
130
|
+
*
|
|
131
|
+
* This method mutates the `Span` in place.
|
|
132
|
+
*
|
|
133
|
+
* @category annotations
|
|
134
|
+
* @since 4.0.0
|
|
116
135
|
*/
|
|
117
136
|
(options: AnthropicTelemetryAttributeOptions): (span: Span) => void
|
|
118
137
|
/**
|
|
119
138
|
* Applies the specified Anthropic GenAI telemetry attributes to the provided
|
|
120
139
|
* `Span`.
|
|
121
140
|
*
|
|
122
|
-
* **
|
|
141
|
+
* **When to use**
|
|
142
|
+
*
|
|
143
|
+
* Use to annotate an Anthropic model span with standard GenAI telemetry
|
|
144
|
+
* attributes and Anthropic-specific request or response metadata.
|
|
145
|
+
*
|
|
146
|
+
* **Gotchas**
|
|
147
|
+
*
|
|
148
|
+
* This method mutates the `Span` in place.
|
|
123
149
|
*
|
|
124
|
-
* @
|
|
125
|
-
* @
|
|
150
|
+
* @category annotations
|
|
151
|
+
* @since 4.0.0
|
|
126
152
|
*/
|
|
127
153
|
(span: Span, options: AnthropicTelemetryAttributeOptions): void
|
|
128
154
|
} = dual(2, (span: Span, options: AnthropicTelemetryAttributeOptions) => {
|