feat: add output token limit utils for chat generators - #12305
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
|
The current idea assumes that Haystack knows how each provider names this parameter. A potential solution I'd prefer: provide each ChatGenerator with a public field like Another idea, as you also suggest, is to add this param to the What do you think? |
I think this could work. However, I would want to set this up in such a way that it can be easily extended later to other keys. If this is set up well we could use this for passing down other common generation kwargs in a standardized way like temperature, reasoning level, etc.
Yeah I agree this would cause a conflict and also I'm not sure if I want to greatly expand the run method signature (thinking of what I mention above about adding more keys in the future).
I agree that I would much prefer having this info stored on the specific implementation itself. Do you think we could take your first idea and make it more extensible? |
I think yes. We could potentially store a dictionary in the ChatGenerator with the mapping: Haystack concept -> Provider-specific key. (Just an idea, haven't tried) If we have doubts about the implementation and we decide to do this, I'd just make the field(s) private for the moment. |
Okay sounds good, I'll take a look into this! |
|
Moving back to draft while looking into a new solution |
|
Closing as superseded by #12328 |
Related Issues
Proposed Changes:
Add util method for resolving how to pass down a max token limit from the Summarization Compactor down to the Chat Generator. We need to know the token limit at the Compactor level so we can properly account for how large the expected summary is when computing how much of the previous chat history should be summarized.
The method I chose here is to create a util method that allows us to pass down a max token limit through the
generation_kwargsruntime params of the ChatGenerator.However, I am wondering if a better solution would be to directly expose this as a standardized param name on the ChatGenerators run method instead of needing this util method.
How did you test it?
Added new tests.
Notes for the reviewer
I made this a standalone PR so its easier to discuss whether we like this solution and to reduce the PR size of the eventual summarization compactor.
I'd appreciate your thoughts on whether it makes sense to open issues to update our ChatGenerators to use a standardized param name like
max_output_tokensinstead of needing to maintain/update this dict.Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.