-
-
Notifications
You must be signed in to change notification settings - Fork 312
Refactor the AI packages #4766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Refactor the AI packages #4766
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
🦋 Changeset detectedLatest commit: 68b6d0b The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
d44688b
to
2e9a8bb
Compare
tim-smart
reviewed
Apr 22, 2025
tim-smart
reviewed
Apr 22, 2025
tim-smart
approved these changes
Apr 22, 2025
This was referenced Apr 23, 2025
c332850
to
67293f7
Compare
…tial llm invocations
tim-smart
reviewed
May 9, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type
Description
This release includes a complete refactor of the internals of the base
@effect/ai
library, with a focus on flexibility for the end user and incorporation of more information from model providers.Notable Changes
AiLanguageModel
andAiEmbeddingModel
The
Completions
service from@effect/ai
has been renamed toAiLanguageModel
, and theEmbeddings
service has similarly been renamed toAiEmbeddingModel
. In addition,Completions.create
andCompletions.toolkit
have been unified intoAiLanguageModel.generateText
. Similarly,Completions.stream
andCompletions.toolkitStream
have been unified intoAiLanguageModel.streamText
.Structured Outputs
Completions.structured
has been renamed toAiLanguageModel.generateObject
, and this method now returns a specializedAiResponse.WithStructuredOutput
type, which contains avalue
property with the result of the structured output call. This enhancement prevents the end user from having to unnecessarily unwrap anOption
.AiModel
andAiPlan
The
.provide
method on a builtAiModel
/AiPlan
has been renamed to.use
to improve clarity given that a user is using the services provided by the model / plan to run a particular piece of code.In addition, the
AiPlan.fromModel
constructor has been simplified intoAiPlan.make
, which allows you to create an initialAiPlan
with multiple steps incorporated.For example:
AiInput
andAiResponse
The
AiInput
andAiResponse
types have been refactored to allow inclusion of more information and metadata from model providers where possible, such as reasoning output and prompt cache token utilization.In addition, for an
AiResponse
you can now access metadata that is specific to a given provider. For example, when using OpenAi to generate audio, you can check the input and output audio tokens used:AiTool
andAiToolkit
The
AiToolkit
has been completely refactored to simplify creating a collection of tools and using those tools in requests to model providers. A newAiTool
data type has also been introduced to simplify defining tools for a toolkit.AiToolkit.implement
has been renamed toAiToolkit.toLayer
for clarity, and defining handlers is now very similar to the way handlers are defined in the@effect/rpc
library.A complete example of an
AiToolkit
implementation and usage can be found below: