Skip to content

Commit

Permalink
fix: fromLanguageModelMessages (#1167)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom authored Nov 13, 2024
1 parent e07a636 commit e8f2b89
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { LanguageModelV1Message } from "@ai-sdk/provider";
import { CoreMessage, ToolCallContentPart } from "../../../types";
import { Writable } from "stream";

type fromLanguageModelMessagesOptions = {
mergeSteps: boolean;
Expand Down Expand Up @@ -105,9 +106,11 @@ export const fromLanguageModelMessages = (
if (toolCall.toolName !== tool.toolName)
throw new Error("Tool call name mismatch.");

toolCall.result = tool.result;
type Writable<T> = { -readonly [P in keyof T]: T[P] };
const writable = toolCall as Writable<ToolCallContentPart>;
writable.result = tool.result;
if (tool.isError) {
toolCall.isError = true;
writable.isError = true;
}
}

Expand Down

0 comments on commit e8f2b89

Please sign in to comment.