Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 0 additions & 70 deletions .changeset/great-eyes-buy.md

This file was deleted.

63 changes: 63 additions & 0 deletions packages/ai/ai/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,68 @@
# @effect/ai

## 0.31.0

### Minor Changes

- [#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.

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.

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.

```ts
import * as AnthropicClient from "@effect/ai-anthropic/AnthropicClient"
import * as AnthropicLanguageModel from "@effect/ai-anthropic/AnthropicLanguageModel"
import * as LanguageModel from "@effect/ai/LanguageModel"
import * as Tool from "@effect/ai/Tool"
import * as Toolkit from "@effect/ai/Toolkit"
import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
import { Config, Effect, Layer, Schema, Stream } from "effect"

const Claude = AnthropicLanguageModel.model("claude-4-sonnet-20250514")

const MyTool = Tool.make("MyTool", {
description: "An example of a tool with success and failure types",
failureMode: "return", // Return errors in the response
parameters: { bar: Schema.Number },
success: Schema.Number,
failure: Schema.Struct({ reason: Schema.Literal("reason-1", "reason-2") })
})

const MyToolkit = Toolkit.make(MyTool)

const MyToolkitLayer = MyToolkit.toLayer({
MyTool: () => Effect.succeed(42)
})

const program = LanguageModel.streamText({
prompt: "Tell me about the meaning of life",
toolkit: MyToolkit
}).pipe(
Stream.runForEach((part) => {
if (part.type === "tool-result" && part.name === "MyTool") {
// The `isFailure` property can be used to discriminate whether the result
// of a tool call is a success or a failure
if (part.isFailure) {
part.result
// ^? { readonly reason: "reason-1" | "reason-2"; }
} else {
part.result
// ^? number
}
}
return Effect.void
}),
Effect.provide(Claude)
)

const Anthropic = AnthropicClient.layerConfig({
apiKey: Config.redacted("ANTHROPIC_API_KEY")
}).pipe(Layer.provide(NodeHttpClient.layerUndici))

program.pipe(Effect.provide([Anthropic, MyToolkitLayer]), Effect.runPromise)
```

## 0.30.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ai/ai/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@effect/ai",
"type": "module",
"version": "0.30.0",
"version": "0.31.0",
"license": "MIT",
"description": "Effect modules for working with AI apis",
"homepage": "https://effect.website",
Expand Down
69 changes: 69 additions & 0 deletions packages/ai/amazon-bedrock/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,74 @@
# @effect/ai-amazon-bedrock

## 0.11.0

### Minor Changes

- [#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.

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.

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.

```ts
import * as AnthropicClient from "@effect/ai-anthropic/AnthropicClient"
import * as AnthropicLanguageModel from "@effect/ai-anthropic/AnthropicLanguageModel"
import * as LanguageModel from "@effect/ai/LanguageModel"
import * as Tool from "@effect/ai/Tool"
import * as Toolkit from "@effect/ai/Toolkit"
import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
import { Config, Effect, Layer, Schema, Stream } from "effect"

const Claude = AnthropicLanguageModel.model("claude-4-sonnet-20250514")

const MyTool = Tool.make("MyTool", {
description: "An example of a tool with success and failure types",
failureMode: "return", // Return errors in the response
parameters: { bar: Schema.Number },
success: Schema.Number,
failure: Schema.Struct({ reason: Schema.Literal("reason-1", "reason-2") })
})

const MyToolkit = Toolkit.make(MyTool)

const MyToolkitLayer = MyToolkit.toLayer({
MyTool: () => Effect.succeed(42)
})

const program = LanguageModel.streamText({
prompt: "Tell me about the meaning of life",
toolkit: MyToolkit
}).pipe(
Stream.runForEach((part) => {
if (part.type === "tool-result" && part.name === "MyTool") {
// The `isFailure` property can be used to discriminate whether the result
// of a tool call is a success or a failure
if (part.isFailure) {
part.result
// ^? { readonly reason: "reason-1" | "reason-2"; }
} else {
part.result
// ^? number
}
}
return Effect.void
}),
Effect.provide(Claude)
)

const Anthropic = AnthropicClient.layerConfig({
apiKey: Config.redacted("ANTHROPIC_API_KEY")
}).pipe(Layer.provide(NodeHttpClient.layerUndici))

program.pipe(Effect.provide([Anthropic, MyToolkitLayer]), Effect.runPromise)
```

### Patch Changes

- Updated dependencies [[`4c3bdfb`](https://github.com/Effect-TS/effect/commit/4c3bdfbcbc2dcd7ecd6321df3e4a504af19de825)]:
- @effect/ai-anthropic@0.21.0
- @effect/ai@0.31.0

## 0.10.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ai/amazon-bedrock/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@effect/ai-amazon-bedrock",
"type": "module",
"version": "0.10.0",
"version": "0.11.0",
"license": "MIT",
"description": "Effect modules for working with Amazon Bedrock AI apis",
"homepage": "https://effect.website",
Expand Down
68 changes: 68 additions & 0 deletions packages/ai/anthropic/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,73 @@
# @effect/ai-anthropic

## 0.21.0

### Minor Changes

- [#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.

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.

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.

```ts
import * as AnthropicClient from "@effect/ai-anthropic/AnthropicClient"
import * as AnthropicLanguageModel from "@effect/ai-anthropic/AnthropicLanguageModel"
import * as LanguageModel from "@effect/ai/LanguageModel"
import * as Tool from "@effect/ai/Tool"
import * as Toolkit from "@effect/ai/Toolkit"
import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
import { Config, Effect, Layer, Schema, Stream } from "effect"

const Claude = AnthropicLanguageModel.model("claude-4-sonnet-20250514")

const MyTool = Tool.make("MyTool", {
description: "An example of a tool with success and failure types",
failureMode: "return", // Return errors in the response
parameters: { bar: Schema.Number },
success: Schema.Number,
failure: Schema.Struct({ reason: Schema.Literal("reason-1", "reason-2") })
})

const MyToolkit = Toolkit.make(MyTool)

const MyToolkitLayer = MyToolkit.toLayer({
MyTool: () => Effect.succeed(42)
})

const program = LanguageModel.streamText({
prompt: "Tell me about the meaning of life",
toolkit: MyToolkit
}).pipe(
Stream.runForEach((part) => {
if (part.type === "tool-result" && part.name === "MyTool") {
// The `isFailure` property can be used to discriminate whether the result
// of a tool call is a success or a failure
if (part.isFailure) {
part.result
// ^? { readonly reason: "reason-1" | "reason-2"; }
} else {
part.result
// ^? number
}
}
return Effect.void
}),
Effect.provide(Claude)
)

const Anthropic = AnthropicClient.layerConfig({
apiKey: Config.redacted("ANTHROPIC_API_KEY")
}).pipe(Layer.provide(NodeHttpClient.layerUndici))

program.pipe(Effect.provide([Anthropic, MyToolkitLayer]), Effect.runPromise)
```

### Patch Changes

- Updated dependencies [[`4c3bdfb`](https://github.com/Effect-TS/effect/commit/4c3bdfbcbc2dcd7ecd6321df3e4a504af19de825)]:
- @effect/ai@0.31.0

## 0.20.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ai/anthropic/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@effect/ai-anthropic",
"type": "module",
"version": "0.20.0",
"version": "0.21.0",
"license": "MIT",
"description": "Effect modules for working with AI apis",
"homepage": "https://effect.website",
Expand Down
68 changes: 68 additions & 0 deletions packages/ai/google/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,73 @@
# @effect/ai-google

## 0.10.0

### Minor Changes

- [#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.

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.

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.

```ts
import * as AnthropicClient from "@effect/ai-anthropic/AnthropicClient"
import * as AnthropicLanguageModel from "@effect/ai-anthropic/AnthropicLanguageModel"
import * as LanguageModel from "@effect/ai/LanguageModel"
import * as Tool from "@effect/ai/Tool"
import * as Toolkit from "@effect/ai/Toolkit"
import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
import { Config, Effect, Layer, Schema, Stream } from "effect"

const Claude = AnthropicLanguageModel.model("claude-4-sonnet-20250514")

const MyTool = Tool.make("MyTool", {
description: "An example of a tool with success and failure types",
failureMode: "return", // Return errors in the response
parameters: { bar: Schema.Number },
success: Schema.Number,
failure: Schema.Struct({ reason: Schema.Literal("reason-1", "reason-2") })
})

const MyToolkit = Toolkit.make(MyTool)

const MyToolkitLayer = MyToolkit.toLayer({
MyTool: () => Effect.succeed(42)
})

const program = LanguageModel.streamText({
prompt: "Tell me about the meaning of life",
toolkit: MyToolkit
}).pipe(
Stream.runForEach((part) => {
if (part.type === "tool-result" && part.name === "MyTool") {
// The `isFailure` property can be used to discriminate whether the result
// of a tool call is a success or a failure
if (part.isFailure) {
part.result
// ^? { readonly reason: "reason-1" | "reason-2"; }
} else {
part.result
// ^? number
}
}
return Effect.void
}),
Effect.provide(Claude)
)

const Anthropic = AnthropicClient.layerConfig({
apiKey: Config.redacted("ANTHROPIC_API_KEY")
}).pipe(Layer.provide(NodeHttpClient.layerUndici))

program.pipe(Effect.provide([Anthropic, MyToolkitLayer]), Effect.runPromise)
```

### Patch Changes

- Updated dependencies [[`4c3bdfb`](https://github.com/Effect-TS/effect/commit/4c3bdfbcbc2dcd7ecd6321df3e4a504af19de825)]:
- @effect/ai@0.31.0

## 0.9.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ai/google/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@effect/ai-google",
"type": "module",
"version": "0.9.0",
"version": "0.10.0",
"license": "MIT",
"description": "Effect modules for working with AI apis",
"homepage": "https://effect.website",
Expand Down
Loading