-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DRAFT] Make trim messages coherent #743
[DRAFT] Make trim messages coherent #743
Conversation
added a new strategy for trimming first message added docstrings and type hints
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hey @hyamanieu, appreciate the PR! the linting changes are making it hard to see the trim-message related changes made. Can you separate the 2 please? |
Hey @hyamanieu, thanks for being responsive. I'd like to merge this but I see 8 new / changed functions in Can we break these into more specific PR's? that way we can test each scenario individually and ensure no breaking changes to our build pipeline are pushed. Asking as we've spent the past few days having to deal with these issues. |
After discussion with Krrish, I will split this PR in 4 PRs:
I will also move the unit tests of trim_messages from test_utils.py to the new file I have made to test its depending subfunctions. Note: "deterministic" is not the proper word, but "coherent". |
you're amazing! @hyamanieu |
@hyamanieu any update on this ? We have another PR for message trimming #787 |
I'm currently under water, I'll check back again later and see how it goes with the state of the main branch. |
Looking at the changes in #787, the issues are dealing with separate problems. |
I am too far off so I'm closing for now. |
After discussing directly with the maintainers, I am suggesting this change. I can open an issue if it's necessary.
I did a bit more than just making
litellm.utils.trim_messages
coherentHere are the changes:
return_response_tokens
is set, with the second one being a number of tokens.[...]
rather than..
. To me LLMs are trained on large amount of human texts, and in case of partially quoting, most people (e.g. journalists) use[...]
, not..
which looks more like something out of a programming language or an accountant software. I'd like to reach out to @KillianLucas to see her take on it.content_trimming_strategy
. Se open quetions below.Open questions:
litellm.utils.shorten_message_content
. Yet I think it can be usefull for other people to have this other strategy...litellm.utils.shorten_message_content
?litellm.utils.get_token_count
as it's doing nothing more than callinglitellm.utils.token_counter
?