Skip to content

Conversation

@c4pt0r
Copy link

@c4pt0r c4pt0r commented May 18, 2023

Sometimes, I don't want to discard the remaining output, might be useful :)
So, this pull request adds a new feature to the token counting command-line interface. The new -s or --split option allows users to split their input text into multiple files, each containing a specific number of tokens.

Changes

  1. A new option (-s, --split) has been added to the click.command() decorator in the cli function.
  2. The cli function has been updated to handle this new option. When the split and truncate options are used together, the script splits the input tokens into groups of the specified size and writes each group to a separate file.
  3. A new helper function grouper has been added to split an iterable into fixed-length chunks.
  4. The split function now decodes each chunk before writing to the respective output file.

    This commit introduces a new option (-s, --split) to the command-line interface
    of the token counting script. The new option allows users to split their input
    text into multiple files, each containing a specific number of tokens.

    When the split option is used in conjunction with the truncate option (-t, --truncate),
    the script splits the tokens into groups of the specified size and writes each group
    into a separate file. The output files are named using the provided filename and are
    appended with '.part' followed by the chunk index.

    A new helper function 'grouper' has been added to divide the iterable (tokens) into
    fixed-size chunks.

    The split function ensures that each chunk is decoded before being written to its
    respective output file.
@c4pt0r
Copy link
Author

c4pt0r commented May 18, 2023

By the way, thank you for the great handy tools (llm / ttok / strip-tags).

@simonw
Copy link
Owner

simonw commented May 19, 2023

I opened an issue to discuss this here:

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.

2 participants