Skip to content

Conversation

Davda-James
Copy link

@Davda-James Davda-James commented Sep 21, 2025

Description:

earlier we have to use like below:

from langchain_core.messages import trim_messages
from langchain_core.messages.utils import count_tokens_approximately

trim_messages(..., token_counter=count_tokens_approximately)

Now can be used as like this also

from langchain_core.messages import trim_messages

trim_messages(..., token_counter="approximate")
  • Added tests
  • Lint and test: Run this as I made change in langchain/core, uv run --group test pytest tests/unit_tests/messages/test_utils.py -v
image

Copy link

vercel bot commented Sep 21, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
langchain Ignored Ignored Preview Sep 26, 2025 7:37pm

@github-actions github-actions bot added the core Related to the package `langchain-core` label Sep 21, 2025
Copy link

codspeed-hq bot commented Sep 21, 2025

CodSpeed WallTime Performance Report

Merging #33045 will not alter performance

Comparing Davda-James:feat/trim_messages-support-approx-alias (0048bc8) with master (9863023)

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 13 untouched

@Davda-James Davda-James changed the title feat(core) : can use now approx alias inplace of count_tokens_approximately, any of it works now feat(core):can use now approx alias inplace of count_tokens_approximately, any of it works now Sep 21, 2025
@Davda-James Davda-James changed the title feat(core):can use now approx alias inplace of count_tokens_approximately, any of it works now feat(core): can use now approx alias inplace of count_tokens_approximately, any of it works now Sep 21, 2025
@Davda-James Davda-James force-pushed the feat/trim_messages-support-approx-alias branch from a5ec2c6 to d7b4e02 Compare September 23, 2025 17:41
@github-actions github-actions bot added the dependencies Pull requests that update a dependency file label Sep 23, 2025
@Davda-James Davda-James changed the title feat(core): can use now approx alias inplace of count_tokens_approximately, any of it works now feat(core): can use now approximate alias inplace of count_tokens_approximately, any of it works now Sep 23, 2025
@github-actions github-actions bot added feature core Related to the package `langchain-core` dependencies Pull requests that update a dependency file and removed core Related to the package `langchain-core` dependencies Pull requests that update a dependency file labels Sep 24, 2025
@eyurtsev
Copy link
Collaborator

@Davda-James could you undo the changes in the lock file? And we can merge then?

@eyurtsev eyurtsev self-assigned this Sep 26, 2025
@Davda-James Davda-James force-pushed the feat/trim_messages-support-approx-alias branch from 0048bc8 to 75d30e6 Compare September 26, 2025 19:25
@github-actions github-actions bot added core Related to the package `langchain-core` dependencies Pull requests that update a dependency file labels Sep 26, 2025
@github-actions github-actions bot removed core Related to the package `langchain-core` dependencies Pull requests that update a dependency file labels Sep 26, 2025
@Davda-James
Copy link
Author

@eyurtsev reverted the lock file changes in new commit.

@Davda-James
Copy link
Author

Hey @eyurtsev any further changes needed or anything to add ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants