@effect/ai-anthropic 4.0.0-beta.2 → 4.0.0-beta.21
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 +1 -1
- package/dist/AnthropicClient.d.ts.map +1 -1
- package/dist/AnthropicError.d.ts +22 -32
- package/dist/AnthropicError.d.ts.map +1 -1
- package/dist/AnthropicLanguageModel.d.ts +29 -25
- package/dist/AnthropicLanguageModel.d.ts.map +1 -1
- package/dist/AnthropicLanguageModel.js +9 -7
- package/dist/AnthropicLanguageModel.js.map +1 -1
- package/dist/AnthropicTool.d.ts +15 -15
- package/dist/Generated.d.ts +12317 -5916
- package/dist/Generated.d.ts.map +1 -1
- package/dist/Generated.js +2325 -922
- package/dist/Generated.js.map +1 -1
- package/package.json +3 -3
- package/src/AnthropicClient.ts +1 -1
- package/src/AnthropicError.ts +24 -32
- package/src/AnthropicLanguageModel.ts +13 -7
- package/src/Generated.ts +3758 -1822
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/ai-anthropic",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "An Anthropic provider integration for Effect AI SDK",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"provenance": true
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"effect": "^4.0.0-beta.
|
|
46
|
+
"effect": "^4.0.0-beta.21"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"effect": "^4.0.0-beta.
|
|
49
|
+
"effect": "^4.0.0-beta.21"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"codegen": "effect-utils codegen",
|
package/src/AnthropicClient.ts
CHANGED
|
@@ -372,7 +372,7 @@ export const layerConfig = (options?: {
|
|
|
372
372
|
* If not provided, requests will be made without authentication (useful for
|
|
373
373
|
* proxied setups or testing).
|
|
374
374
|
*/
|
|
375
|
-
readonly apiKey?: Config.Config<Redacted.Redacted<string
|
|
375
|
+
readonly apiKey?: Config.Config<Redacted.Redacted<string> | undefined> | undefined
|
|
376
376
|
|
|
377
377
|
/**
|
|
378
378
|
* The base URL for the Anthropic API.
|
package/src/AnthropicError.ts
CHANGED
|
@@ -61,51 +61,43 @@ export type AnthropicRateLimitMetadata = AnthropicErrorMetadata & {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
declare module "effect/unstable/ai/AiError" {
|
|
64
|
-
export interface
|
|
65
|
-
readonly
|
|
66
|
-
readonly anthropic?: AnthropicRateLimitMetadata | null
|
|
67
|
-
}
|
|
64
|
+
export interface RateLimitErrorMetadata {
|
|
65
|
+
readonly anthropic?: AnthropicRateLimitMetadata | null
|
|
68
66
|
}
|
|
69
67
|
|
|
70
|
-
export interface
|
|
71
|
-
readonly
|
|
72
|
-
readonly anthropic?: AnthropicErrorMetadata | null
|
|
73
|
-
}
|
|
68
|
+
export interface QuotaExhaustedErrorMetadata {
|
|
69
|
+
readonly anthropic?: AnthropicErrorMetadata | null
|
|
74
70
|
}
|
|
75
71
|
|
|
76
|
-
export interface
|
|
77
|
-
readonly
|
|
78
|
-
readonly anthropic?: AnthropicErrorMetadata | null
|
|
79
|
-
}
|
|
72
|
+
export interface AuthenticationErrorMetadata {
|
|
73
|
+
readonly anthropic?: AnthropicErrorMetadata | null
|
|
80
74
|
}
|
|
81
75
|
|
|
82
|
-
export interface
|
|
83
|
-
readonly
|
|
84
|
-
readonly anthropic?: AnthropicErrorMetadata | null
|
|
85
|
-
}
|
|
76
|
+
export interface ContentPolicyErrorMetadata {
|
|
77
|
+
readonly anthropic?: AnthropicErrorMetadata | null
|
|
86
78
|
}
|
|
87
79
|
|
|
88
|
-
export interface
|
|
89
|
-
readonly
|
|
90
|
-
readonly anthropic?: AnthropicErrorMetadata | null
|
|
91
|
-
}
|
|
80
|
+
export interface InvalidRequestErrorMetadata {
|
|
81
|
+
readonly anthropic?: AnthropicErrorMetadata | null
|
|
92
82
|
}
|
|
93
83
|
|
|
94
|
-
export interface
|
|
95
|
-
readonly
|
|
96
|
-
readonly anthropic?: AnthropicErrorMetadata | null
|
|
97
|
-
}
|
|
84
|
+
export interface InternalProviderErrorMetadata {
|
|
85
|
+
readonly anthropic?: AnthropicErrorMetadata | null
|
|
98
86
|
}
|
|
99
87
|
|
|
100
|
-
export interface
|
|
101
|
-
readonly
|
|
102
|
-
readonly anthropic?: AnthropicErrorMetadata | null
|
|
103
|
-
}
|
|
88
|
+
export interface InvalidOutputErrorMetadata {
|
|
89
|
+
readonly anthropic?: AnthropicErrorMetadata | null
|
|
104
90
|
}
|
|
105
91
|
|
|
106
|
-
export interface
|
|
107
|
-
readonly
|
|
108
|
-
|
|
109
|
-
|
|
92
|
+
export interface StructuredOutputErrorMetadata {
|
|
93
|
+
readonly anthropic?: AnthropicErrorMetadata | null
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface UnsupportedSchemaErrorMetadata {
|
|
97
|
+
readonly anthropic?: AnthropicErrorMetadata | null
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface UnknownErrorMetadata {
|
|
101
|
+
readonly anthropic?: AnthropicErrorMetadata | null
|
|
110
102
|
}
|
|
111
103
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import * as Arr from "effect/Array"
|
|
6
6
|
import * as DateTime from "effect/DateTime"
|
|
7
7
|
import * as Effect from "effect/Effect"
|
|
8
|
-
import * as
|
|
8
|
+
import * as Encoding from "effect/Encoding"
|
|
9
9
|
import { dual } from "effect/Function"
|
|
10
10
|
import * as Layer from "effect/Layer"
|
|
11
11
|
import * as Predicate from "effect/Predicate"
|
|
@@ -408,7 +408,7 @@ export const model = (
|
|
|
408
408
|
model: (string & {}) | Model,
|
|
409
409
|
config?: Omit<typeof Config.Service, "model">
|
|
410
410
|
): AiModel.Model<"anthropic", LanguageModel.LanguageModel, AnthropicClient> =>
|
|
411
|
-
AiModel.make("anthropic", layer({ model, config }))
|
|
411
|
+
AiModel.make("anthropic", model, layer({ model, config }))
|
|
412
412
|
|
|
413
413
|
/**
|
|
414
414
|
* Creates an Anthropic language model service.
|
|
@@ -624,7 +624,7 @@ const prepareMessages = Effect.fnUntraced(
|
|
|
624
624
|
|
|
625
625
|
const source = isUrlData(part.data)
|
|
626
626
|
? { type: "url", url: getUrlString(part.data) } as const
|
|
627
|
-
: { type: "base64", media_type: mediaType, data:
|
|
627
|
+
: { type: "base64", media_type: mediaType, data: Encoding.encodeBase64(part.data) } as const
|
|
628
628
|
|
|
629
629
|
content.push({ type: "image", source, cache_control: cacheControl })
|
|
630
630
|
} else if (part.mediaType === "application/pdf" || part.mediaType === "text/plain") {
|
|
@@ -642,12 +642,12 @@ const prepareMessages = Effect.fnUntraced(
|
|
|
642
642
|
? {
|
|
643
643
|
type: "base64",
|
|
644
644
|
media_type: "application/pdf",
|
|
645
|
-
data: typeof part.data === "string" ? part.data :
|
|
645
|
+
data: typeof part.data === "string" ? part.data : Encoding.encodeBase64(part.data)
|
|
646
646
|
} as const
|
|
647
647
|
: {
|
|
648
648
|
type: "text",
|
|
649
649
|
media_type: "text/plain",
|
|
650
|
-
data: typeof part.data === "string" ? part.data :
|
|
650
|
+
data: typeof part.data === "string" ? part.data : Encoding.encodeBase64(part.data)
|
|
651
651
|
} as const
|
|
652
652
|
|
|
653
653
|
content.push({
|
|
@@ -2380,14 +2380,20 @@ const makeStreamResponse = Effect.fnUntraced(
|
|
|
2380
2380
|
|
|
2381
2381
|
const params = contentBlock.providerExecuted === true
|
|
2382
2382
|
? finalParams
|
|
2383
|
-
: transformToolCallParams(
|
|
2383
|
+
: yield* transformToolCallParams(
|
|
2384
|
+
options.tools,
|
|
2385
|
+
contentBlock.name,
|
|
2386
|
+
Tool.unsafeSecureJsonParse(finalParams)
|
|
2387
|
+
)
|
|
2384
2388
|
|
|
2385
2389
|
parts.push({
|
|
2386
2390
|
type: "tool-call",
|
|
2387
2391
|
id: contentBlock.id,
|
|
2388
2392
|
name: contentBlock.name,
|
|
2389
2393
|
params,
|
|
2390
|
-
|
|
2394
|
+
...(Predicate.isNotUndefined(contentBlock.providerExecuted)
|
|
2395
|
+
? { providerExecuted: contentBlock.providerExecuted }
|
|
2396
|
+
: undefined),
|
|
2391
2397
|
...(Predicate.isNotUndefined(contentBlock.caller)
|
|
2392
2398
|
? { metadata: { anthropic: { caller: contentBlock.caller } } }
|
|
2393
2399
|
: undefined)
|