Skip to content
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

Fix code block token count #153

Merged
merged 1 commit into from
Jan 25, 2024
Merged

Conversation

dalance
Copy link
Contributor

@dalance dalance commented Jan 24, 2024

This PR fixes wrong token count in code block reported at #150.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2acd3cd) 90.64% compared to head (4f3b869) 90.75%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #153      +/-   ##
==========================================
+ Coverage   90.64%   90.75%   +0.10%     
==========================================
  Files          11       11              
  Lines        2373     2400      +27     
  Branches     2373     2400      +27     
==========================================
+ Hits         2151     2178      +27     
  Misses        159      159              
  Partials       63       63              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -569,12 +569,22 @@ fn check_code_block_token_count(group: &[(usize, Event)]) -> usize {
let events = group.iter().map(|(_, event)| event);
let mut in_codeblock = false;
let mut max_token_count = 0;

// token_count should be taken over Text events
// because a continuous text may be splitted to some Text events.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: If this is about splitting a single text into several Text events, then several instead of some might be more accurate in this context.

@dalance
Copy link
Contributor Author

dalance commented Jan 25, 2024

@kdarkhan Thank you for your review. I've fixed the comment and max_token_count logic.

@kdarkhan kdarkhan merged commit fba1b0a into google:main Jan 25, 2024
7 checks passed
@kdarkhan
Copy link
Collaborator

Thanks, looks good!

@mgeisler mgeisler linked an issue Jan 25, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

group_events fuzz test is flaky
3 participants