Skip to content

Commit

Permalink
fix(core): Add run name for trimMessages (#7517)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 authored Jan 13, 2025
1 parent dbda6d0 commit de63626
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions langchain-core/src/messages/tests/message_utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,12 @@ describe("trimMessages can trim", () => {
"langchain_core",
"runnables",
]);
expect("func" in trimmedMessages).toBeTruthy();
expect("bound" in trimmedMessages).toBeTruthy();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expect("func" in (trimmedMessages as any).bound).toBeTruthy();
// `func` is protected, so we need to cast it to any to access it
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expect(typeof (trimmedMessages as any).func).toBe("function");
expect(typeof (trimmedMessages as any).bound.func).toBe("function");
});
});

Expand Down
4 changes: 3 additions & 1 deletion langchain-core/src/messages/transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,9 @@ export function trimMessages(
const trimmerOptions = messagesOrOptions;
return RunnableLambda.from((input: BaseMessage[]) =>
_trimMessagesHelper(input, trimmerOptions)
);
).withConfig({
runName: "trim_messages",
});
}
}

Expand Down

0 comments on commit de63626

Please sign in to comment.