Skip to content

Conversation

@Davda-James
Copy link
Contributor

@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

@vercel
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 `langchain-core` package issues & PRs label Sep 21, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Sep 21, 2025

CodSpeed Performance Report

Merging #33045 will not alter performance

Comparing Davda-James:feat/trim_messages-support-approx-alias (0834892) with master (72f1d79)

⚠️ 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
⏩ 21 skipped1

Footnotes

  1. 21 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@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 (e.g. `pyproject.toml` or `uv.lock`) 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 For PRs that implement a new feature; NOT A FEATURE REQUEST core `langchain-core` package issues & PRs dependencies Pull requests that update a dependency file (e.g. `pyproject.toml` or `uv.lock`) and removed core `langchain-core` package issues & PRs dependencies Pull requests that update a dependency file (e.g. `pyproject.toml` or `uv.lock`) 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 `langchain-core` package issues & PRs dependencies Pull requests that update a dependency file (e.g. `pyproject.toml` or `uv.lock`) labels Sep 26, 2025
@github-actions github-actions bot removed core `langchain-core` package issues & PRs dependencies Pull requests that update a dependency file (e.g. `pyproject.toml` or `uv.lock`) labels Sep 26, 2025
@Davda-James
Copy link
Contributor Author

@eyurtsev reverted the lock file changes in new commit.

@Davda-James
Copy link
Contributor Author

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

@mdrxy mdrxy added the core `langchain-core` package issues & PRs label Nov 24, 2025
@mdrxy mdrxy changed the title feat(core): can use now approximate alias inplace of count_tokens_approximately, any of it works now feat(core): can use now approximate alias inplace of count_tokens_approximately Dec 19, 2025
@github-actions github-actions bot added feature For PRs that implement a new feature; NOT A FEATURE REQUEST and removed feature For PRs that implement a new feature; NOT A FEATURE REQUEST labels Dec 19, 2025
@mdrxy mdrxy changed the title feat(core): can use now approximate alias inplace of count_tokens_approximately feat(core): add 'approximate' alias inplace of count_tokens_approximately Dec 20, 2025
@mdrxy mdrxy changed the title feat(core): add 'approximate' alias inplace of count_tokens_approximately feat(core): add 'approximate' alias in place of count_tokens_approximately Dec 20, 2025
@github-actions github-actions bot added feature For PRs that implement a new feature; NOT A FEATURE REQUEST and removed feature For PRs that implement a new feature; NOT A FEATURE REQUEST labels Dec 20, 2025
@mdrxy mdrxy merged commit 4fbeffc into langchain-ai:master Dec 20, 2025
88 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core `langchain-core` package issues & PRs feature For PRs that implement a new feature; NOT A FEATURE REQUEST

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants