-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add asChatMessages to @modelfusion/vercel-ai.
- Loading branch information
Showing
5 changed files
with
29 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Changelog | ||
|
||
## v1.1.0 - 2023-12-26 | ||
|
||
### Added | ||
|
||
- `asChatMessages()` to convert Vercel AI SDK `Message[]` to ModelFusion `ChatMessage[]`. |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Message } from "ai"; | ||
import { ChatMessage } from "modelfusion"; | ||
|
||
/** | ||
* Convert Vercel AI SDK messages to ModelFusion ChatMessages. | ||
*/ | ||
export function asChatMessages(messages: Message[]): ChatMessage[] { | ||
return messages.filter( | ||
// only user and assistant roles are supported: | ||
(message) => message.role === "user" || message.role === "assistant" | ||
) as ChatMessage[]; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./ModelFusionTextStream.js"; | ||
export * from "./asChatMessages.js"; |
ab6a840
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
modelfusion – ./
modelfusion-git-main-lgrammel.vercel.app
modelfusion-lgrammel.vercel.app
modelfusion.dev
www.modelfusion.dev