-
Notifications
You must be signed in to change notification settings - Fork 705
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
Removed token count of user message #836
Removed token count of user message #836
Conversation
@tdechanterac Thanks for figuring this out! The code in ChatPlugin.cs is quite "dense" (to use an euphemism). I had to spend quite some time reading it to fully understand the impact of that one-line change. I think your fix would make the code better. But the code would still not be guaranteed to include the user prompt because a big enough portion of the token budget could be taken by memories. So I came up with bigger change that I think is "safer" and more closely respects the original intent of the code: #839 Please take a look at it and feel free to comment on it. This new PR would make your change no longer needed. While I was at it, I made a few related changes to make ChatPlugin.cs more readable too. |
Thank you ! |
### Motivation and Context The user message is not added to the GPT completion request when the token count of the prompt exceeds 50% of the configuration. This fix is inspired by #836 ### Description Fix budget calculation and clarify / simplify code. ### Contribution Checklist - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [Contribution Guidelines](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄
### Motivation and Context The user message is not added to the GPT completion request when the token count of the prompt exceeds 50% of the configuration. This fix is inspired by microsoft#836 ### Description Fix budget calculation and clarify / simplify code. ### Contribution Checklist - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [Contribution Guidelines](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄
### Motivation and Context The user message is not added to the GPT completion request when the token count of the prompt exceeds 50% of the configuration. This fix is inspired by microsoft#836 ### Description Fix budget calculation and clarify / simplify code. ### Contribution Checklist - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [Contribution Guidelines](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄
Motivation and Context
The user message is not added to the GPT completion request when the token count of the prompt exceeds 50% of the configuration.
We can now use large prompts in ChatCopilot.
Description
The method
GetChatContextTokenLimit
fromChatPlugin
was used to count the user message, indicating that it needed to be added. However, it was never added directly; instead, it was added by theGetAllowedChatHistoryAsync
method.For example, if you have a configuration with:
CompletionTokenLimit
: 4096ResponseTokenLimit
: 1024and the following prompt:
You end up with a completion request that only contains the user intent, and the bot responds with:
Note: We could also address this issue by adding the user message directly into the chat history and ensuring that the message is not added a second time in
GetAllowedChatHistoryAsync
.