Skip to content

Commit b448792

Browse files
Version Packages (#5623)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 9ce78f4 commit b448792

File tree

13 files changed

+410
-76
lines changed

13 files changed

+410
-76
lines changed

.changeset/great-eyes-buy.md

Lines changed: 0 additions & 70 deletions
This file was deleted.

packages/ai/ai/CHANGELOG.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,68 @@
11
# @effect/ai
22

3+
## 0.31.0
4+
5+
### Minor Changes
6+
7+
- [#5621](https://github.com/Effect-TS/effect/pull/5621) [`4c3bdfb`](https://github.com/Effect-TS/effect/commit/4c3bdfbcbc2dcd7ecd6321df3e4a504af19de825) Thanks @IMax153! - Remove `Either` / `EitherEncoded` from tool call results.
8+
9+
Specifically, the encoding of tool call results as an `Either` / `EitherEncoded` has been removed and is replaced by encoding the tool call success / failure directly into the `result` property.
10+
11+
To allow type-safe discrimination between a tool call result which was a success vs. one that was a failure, an `isFailure` property has also been added to the `"tool-result"` part. If `isFailure` is `true`, then the tool call handler result was an error.
12+
13+
```ts
14+
import * as AnthropicClient from "@effect/ai-anthropic/AnthropicClient"
15+
import * as AnthropicLanguageModel from "@effect/ai-anthropic/AnthropicLanguageModel"
16+
import * as LanguageModel from "@effect/ai/LanguageModel"
17+
import * as Tool from "@effect/ai/Tool"
18+
import * as Toolkit from "@effect/ai/Toolkit"
19+
import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
20+
import { Config, Effect, Layer, Schema, Stream } from "effect"
21+
22+
const Claude = AnthropicLanguageModel.model("claude-4-sonnet-20250514")
23+
24+
const MyTool = Tool.make("MyTool", {
25+
description: "An example of a tool with success and failure types",
26+
failureMode: "return", // Return errors in the response
27+
parameters: { bar: Schema.Number },
28+
success: Schema.Number,
29+
failure: Schema.Struct({ reason: Schema.Literal("reason-1", "reason-2") })
30+
})
31+
32+
const MyToolkit = Toolkit.make(MyTool)
33+
34+
const MyToolkitLayer = MyToolkit.toLayer({
35+
MyTool: () => Effect.succeed(42)
36+
})
37+
38+
const program = LanguageModel.streamText({
39+
prompt: "Tell me about the meaning of life",
40+
toolkit: MyToolkit
41+
}).pipe(
42+
Stream.runForEach((part) => {
43+
if (part.type === "tool-result" && part.name === "MyTool") {
44+
// The `isFailure` property can be used to discriminate whether the result
45+
// of a tool call is a success or a failure
46+
if (part.isFailure) {
47+
part.result
48+
// ^? { readonly reason: "reason-1" | "reason-2"; }
49+
} else {
50+
part.result
51+
// ^? number
52+
}
53+
}
54+
return Effect.void
55+
}),
56+
Effect.provide(Claude)
57+
)
58+
59+
const Anthropic = AnthropicClient.layerConfig({
60+
apiKey: Config.redacted("ANTHROPIC_API_KEY")
61+
}).pipe(Layer.provide(NodeHttpClient.layerUndici))
62+
63+
program.pipe(Effect.provide([Anthropic, MyToolkitLayer]), Effect.runPromise)
64+
```
65+
366
## 0.30.0
467

568
### Minor Changes

packages/ai/ai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@effect/ai",
33
"type": "module",
4-
"version": "0.30.0",
4+
"version": "0.31.0",
55
"license": "MIT",
66
"description": "Effect modules for working with AI apis",
77
"homepage": "https://effect.website",

packages/ai/amazon-bedrock/CHANGELOG.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,74 @@
11
# @effect/ai-amazon-bedrock
22

3+
## 0.11.0
4+
5+
### Minor Changes
6+
7+
- [#5621](https://github.com/Effect-TS/effect/pull/5621) [`4c3bdfb`](https://github.com/Effect-TS/effect/commit/4c3bdfbcbc2dcd7ecd6321df3e4a504af19de825) Thanks @IMax153! - Remove `Either` / `EitherEncoded` from tool call results.
8+
9+
Specifically, the encoding of tool call results as an `Either` / `EitherEncoded` has been removed and is replaced by encoding the tool call success / failure directly into the `result` property.
10+
11+
To allow type-safe discrimination between a tool call result which was a success vs. one that was a failure, an `isFailure` property has also been added to the `"tool-result"` part. If `isFailure` is `true`, then the tool call handler result was an error.
12+
13+
```ts
14+
import * as AnthropicClient from "@effect/ai-anthropic/AnthropicClient"
15+
import * as AnthropicLanguageModel from "@effect/ai-anthropic/AnthropicLanguageModel"
16+
import * as LanguageModel from "@effect/ai/LanguageModel"
17+
import * as Tool from "@effect/ai/Tool"
18+
import * as Toolkit from "@effect/ai/Toolkit"
19+
import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
20+
import { Config, Effect, Layer, Schema, Stream } from "effect"
21+
22+
const Claude = AnthropicLanguageModel.model("claude-4-sonnet-20250514")
23+
24+
const MyTool = Tool.make("MyTool", {
25+
description: "An example of a tool with success and failure types",
26+
failureMode: "return", // Return errors in the response
27+
parameters: { bar: Schema.Number },
28+
success: Schema.Number,
29+
failure: Schema.Struct({ reason: Schema.Literal("reason-1", "reason-2") })
30+
})
31+
32+
const MyToolkit = Toolkit.make(MyTool)
33+
34+
const MyToolkitLayer = MyToolkit.toLayer({
35+
MyTool: () => Effect.succeed(42)
36+
})
37+
38+
const program = LanguageModel.streamText({
39+
prompt: "Tell me about the meaning of life",
40+
toolkit: MyToolkit
41+
}).pipe(
42+
Stream.runForEach((part) => {
43+
if (part.type === "tool-result" && part.name === "MyTool") {
44+
// The `isFailure` property can be used to discriminate whether the result
45+
// of a tool call is a success or a failure
46+
if (part.isFailure) {
47+
part.result
48+
// ^? { readonly reason: "reason-1" | "reason-2"; }
49+
} else {
50+
part.result
51+
// ^? number
52+
}
53+
}
54+
return Effect.void
55+
}),
56+
Effect.provide(Claude)
57+
)
58+
59+
const Anthropic = AnthropicClient.layerConfig({
60+
apiKey: Config.redacted("ANTHROPIC_API_KEY")
61+
}).pipe(Layer.provide(NodeHttpClient.layerUndici))
62+
63+
program.pipe(Effect.provide([Anthropic, MyToolkitLayer]), Effect.runPromise)
64+
```
65+
66+
### Patch Changes
67+
68+
- Updated dependencies [[`4c3bdfb`](https://github.com/Effect-TS/effect/commit/4c3bdfbcbc2dcd7ecd6321df3e4a504af19de825)]:
69+
- @effect/ai-anthropic@0.21.0
70+
- @effect/ai@0.31.0
71+
372
## 0.10.0
473

574
### Minor Changes

packages/ai/amazon-bedrock/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@effect/ai-amazon-bedrock",
33
"type": "module",
4-
"version": "0.10.0",
4+
"version": "0.11.0",
55
"license": "MIT",
66
"description": "Effect modules for working with Amazon Bedrock AI apis",
77
"homepage": "https://effect.website",

packages/ai/anthropic/CHANGELOG.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,73 @@
11
# @effect/ai-anthropic
22

3+
## 0.21.0
4+
5+
### Minor Changes
6+
7+
- [#5621](https://github.com/Effect-TS/effect/pull/5621) [`4c3bdfb`](https://github.com/Effect-TS/effect/commit/4c3bdfbcbc2dcd7ecd6321df3e4a504af19de825) Thanks @IMax153! - Remove `Either` / `EitherEncoded` from tool call results.
8+
9+
Specifically, the encoding of tool call results as an `Either` / `EitherEncoded` has been removed and is replaced by encoding the tool call success / failure directly into the `result` property.
10+
11+
To allow type-safe discrimination between a tool call result which was a success vs. one that was a failure, an `isFailure` property has also been added to the `"tool-result"` part. If `isFailure` is `true`, then the tool call handler result was an error.
12+
13+
```ts
14+
import * as AnthropicClient from "@effect/ai-anthropic/AnthropicClient"
15+
import * as AnthropicLanguageModel from "@effect/ai-anthropic/AnthropicLanguageModel"
16+
import * as LanguageModel from "@effect/ai/LanguageModel"
17+
import * as Tool from "@effect/ai/Tool"
18+
import * as Toolkit from "@effect/ai/Toolkit"
19+
import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
20+
import { Config, Effect, Layer, Schema, Stream } from "effect"
21+
22+
const Claude = AnthropicLanguageModel.model("claude-4-sonnet-20250514")
23+
24+
const MyTool = Tool.make("MyTool", {
25+
description: "An example of a tool with success and failure types",
26+
failureMode: "return", // Return errors in the response
27+
parameters: { bar: Schema.Number },
28+
success: Schema.Number,
29+
failure: Schema.Struct({ reason: Schema.Literal("reason-1", "reason-2") })
30+
})
31+
32+
const MyToolkit = Toolkit.make(MyTool)
33+
34+
const MyToolkitLayer = MyToolkit.toLayer({
35+
MyTool: () => Effect.succeed(42)
36+
})
37+
38+
const program = LanguageModel.streamText({
39+
prompt: "Tell me about the meaning of life",
40+
toolkit: MyToolkit
41+
}).pipe(
42+
Stream.runForEach((part) => {
43+
if (part.type === "tool-result" && part.name === "MyTool") {
44+
// The `isFailure` property can be used to discriminate whether the result
45+
// of a tool call is a success or a failure
46+
if (part.isFailure) {
47+
part.result
48+
// ^? { readonly reason: "reason-1" | "reason-2"; }
49+
} else {
50+
part.result
51+
// ^? number
52+
}
53+
}
54+
return Effect.void
55+
}),
56+
Effect.provide(Claude)
57+
)
58+
59+
const Anthropic = AnthropicClient.layerConfig({
60+
apiKey: Config.redacted("ANTHROPIC_API_KEY")
61+
}).pipe(Layer.provide(NodeHttpClient.layerUndici))
62+
63+
program.pipe(Effect.provide([Anthropic, MyToolkitLayer]), Effect.runPromise)
64+
```
65+
66+
### Patch Changes
67+
68+
- Updated dependencies [[`4c3bdfb`](https://github.com/Effect-TS/effect/commit/4c3bdfbcbc2dcd7ecd6321df3e4a504af19de825)]:
69+
- @effect/ai@0.31.0
70+
371
## 0.20.0
472

573
### Minor Changes

packages/ai/anthropic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@effect/ai-anthropic",
33
"type": "module",
4-
"version": "0.20.0",
4+
"version": "0.21.0",
55
"license": "MIT",
66
"description": "Effect modules for working with AI apis",
77
"homepage": "https://effect.website",

packages/ai/google/CHANGELOG.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,73 @@
11
# @effect/ai-google
22

3+
## 0.10.0
4+
5+
### Minor Changes
6+
7+
- [#5621](https://github.com/Effect-TS/effect/pull/5621) [`4c3bdfb`](https://github.com/Effect-TS/effect/commit/4c3bdfbcbc2dcd7ecd6321df3e4a504af19de825) Thanks @IMax153! - Remove `Either` / `EitherEncoded` from tool call results.
8+
9+
Specifically, the encoding of tool call results as an `Either` / `EitherEncoded` has been removed and is replaced by encoding the tool call success / failure directly into the `result` property.
10+
11+
To allow type-safe discrimination between a tool call result which was a success vs. one that was a failure, an `isFailure` property has also been added to the `"tool-result"` part. If `isFailure` is `true`, then the tool call handler result was an error.
12+
13+
```ts
14+
import * as AnthropicClient from "@effect/ai-anthropic/AnthropicClient"
15+
import * as AnthropicLanguageModel from "@effect/ai-anthropic/AnthropicLanguageModel"
16+
import * as LanguageModel from "@effect/ai/LanguageModel"
17+
import * as Tool from "@effect/ai/Tool"
18+
import * as Toolkit from "@effect/ai/Toolkit"
19+
import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
20+
import { Config, Effect, Layer, Schema, Stream } from "effect"
21+
22+
const Claude = AnthropicLanguageModel.model("claude-4-sonnet-20250514")
23+
24+
const MyTool = Tool.make("MyTool", {
25+
description: "An example of a tool with success and failure types",
26+
failureMode: "return", // Return errors in the response
27+
parameters: { bar: Schema.Number },
28+
success: Schema.Number,
29+
failure: Schema.Struct({ reason: Schema.Literal("reason-1", "reason-2") })
30+
})
31+
32+
const MyToolkit = Toolkit.make(MyTool)
33+
34+
const MyToolkitLayer = MyToolkit.toLayer({
35+
MyTool: () => Effect.succeed(42)
36+
})
37+
38+
const program = LanguageModel.streamText({
39+
prompt: "Tell me about the meaning of life",
40+
toolkit: MyToolkit
41+
}).pipe(
42+
Stream.runForEach((part) => {
43+
if (part.type === "tool-result" && part.name === "MyTool") {
44+
// The `isFailure` property can be used to discriminate whether the result
45+
// of a tool call is a success or a failure
46+
if (part.isFailure) {
47+
part.result
48+
// ^? { readonly reason: "reason-1" | "reason-2"; }
49+
} else {
50+
part.result
51+
// ^? number
52+
}
53+
}
54+
return Effect.void
55+
}),
56+
Effect.provide(Claude)
57+
)
58+
59+
const Anthropic = AnthropicClient.layerConfig({
60+
apiKey: Config.redacted("ANTHROPIC_API_KEY")
61+
}).pipe(Layer.provide(NodeHttpClient.layerUndici))
62+
63+
program.pipe(Effect.provide([Anthropic, MyToolkitLayer]), Effect.runPromise)
64+
```
65+
66+
### Patch Changes
67+
68+
- Updated dependencies [[`4c3bdfb`](https://github.com/Effect-TS/effect/commit/4c3bdfbcbc2dcd7ecd6321df3e4a504af19de825)]:
69+
- @effect/ai@0.31.0
70+
371
## 0.9.0
472

573
### Minor Changes

packages/ai/google/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@effect/ai-google",
33
"type": "module",
4-
"version": "0.9.0",
4+
"version": "0.10.0",
55
"license": "MIT",
66
"description": "Effect modules for working with AI apis",
77
"homepage": "https://effect.website",

0 commit comments

Comments
 (0)