@effect/ai-anthropic 4.0.0-beta.3 → 4.0.0-beta.31
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 +11 -8
- 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 +15 -11
- 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.31",
|
|
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.31"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"effect": "^4.0.0-beta.
|
|
49
|
+
"effect": "^4.0.0-beta.31"
|
|
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.
|
|
@@ -469,6 +469,7 @@ export const make = Effect.fnUntraced(function*({ model, config: providerConfig
|
|
|
469
469
|
)
|
|
470
470
|
|
|
471
471
|
return yield* LanguageModel.make({
|
|
472
|
+
codecTransformer: toCodecAnthropic,
|
|
472
473
|
generateText: Effect.fnUntraced(function*(options) {
|
|
473
474
|
const config = yield* makeConfig
|
|
474
475
|
const toolNameMapper = new Tool.NameMapper(options.tools)
|
|
@@ -493,10 +494,7 @@ export const make = Effect.fnUntraced(function*({ model, config: providerConfig
|
|
|
493
494
|
return response
|
|
494
495
|
})
|
|
495
496
|
))
|
|
496
|
-
})
|
|
497
|
-
LanguageModel.CurrentCodecTransformer,
|
|
498
|
-
toCodecAnthropic
|
|
499
|
-
))
|
|
497
|
+
})
|
|
500
498
|
})
|
|
501
499
|
|
|
502
500
|
/**
|
|
@@ -624,7 +622,7 @@ const prepareMessages = Effect.fnUntraced(
|
|
|
624
622
|
|
|
625
623
|
const source = isUrlData(part.data)
|
|
626
624
|
? { type: "url", url: getUrlString(part.data) } as const
|
|
627
|
-
: { type: "base64", media_type: mediaType, data:
|
|
625
|
+
: { type: "base64", media_type: mediaType, data: Encoding.encodeBase64(part.data) } as const
|
|
628
626
|
|
|
629
627
|
content.push({ type: "image", source, cache_control: cacheControl })
|
|
630
628
|
} else if (part.mediaType === "application/pdf" || part.mediaType === "text/plain") {
|
|
@@ -642,12 +640,12 @@ const prepareMessages = Effect.fnUntraced(
|
|
|
642
640
|
? {
|
|
643
641
|
type: "base64",
|
|
644
642
|
media_type: "application/pdf",
|
|
645
|
-
data: typeof part.data === "string" ? part.data :
|
|
643
|
+
data: typeof part.data === "string" ? part.data : Encoding.encodeBase64(part.data)
|
|
646
644
|
} as const
|
|
647
645
|
: {
|
|
648
646
|
type: "text",
|
|
649
647
|
media_type: "text/plain",
|
|
650
|
-
data: typeof part.data === "string" ? part.data :
|
|
648
|
+
data: typeof part.data === "string" ? part.data : Encoding.encodeBase64(part.data)
|
|
651
649
|
} as const
|
|
652
650
|
|
|
653
651
|
content.push({
|
|
@@ -2380,14 +2378,20 @@ const makeStreamResponse = Effect.fnUntraced(
|
|
|
2380
2378
|
|
|
2381
2379
|
const params = contentBlock.providerExecuted === true
|
|
2382
2380
|
? finalParams
|
|
2383
|
-
: transformToolCallParams(
|
|
2381
|
+
: yield* transformToolCallParams(
|
|
2382
|
+
options.tools,
|
|
2383
|
+
contentBlock.name,
|
|
2384
|
+
Tool.unsafeSecureJsonParse(finalParams)
|
|
2385
|
+
)
|
|
2384
2386
|
|
|
2385
2387
|
parts.push({
|
|
2386
2388
|
type: "tool-call",
|
|
2387
2389
|
id: contentBlock.id,
|
|
2388
2390
|
name: contentBlock.name,
|
|
2389
2391
|
params,
|
|
2390
|
-
|
|
2392
|
+
...(Predicate.isNotUndefined(contentBlock.providerExecuted)
|
|
2393
|
+
? { providerExecuted: contentBlock.providerExecuted }
|
|
2394
|
+
: undefined),
|
|
2391
2395
|
...(Predicate.isNotUndefined(contentBlock.caller)
|
|
2392
2396
|
? { metadata: { anthropic: { caller: contentBlock.caller } } }
|
|
2393
2397
|
: undefined)
|