refactor(chat): clean up various /compact issues #1169
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of changes:
Couple issues remain:
/compact. This is because we push the assistant message onResponseEvent::EndStreamand again later in the same function. We don't get any validation errors for this, so this is apparently acceptable for now.calculate_char_countfunction does not take context files into account. This is because we send the result ofas_sendable_conversation_stateto the model which includes the result ofcontext_messages, butcalculate_char_countdoes not use this output. Instead,as_sendable_conversation_stateshould be heavily refactored to not mutateConversationState, so we can decouple our actual request data from the internal app representation (ie,ConversationState) more appropriately.Since we only underestimate rather than overestimate token count, this should still be fine at the moment.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.