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

[v13] assist: Refactor token counting #29753

Merged
merged 1 commit into from Jul 31, 2023
Merged

Commits on Jul 21, 2023

  1. assist: Refactor token counting

    With the actor model, tokens can be used in multiple ways (picking
    tools, invoking them, ...), which don't necessarily end up in a final
    action (sometimes we return a nextStep instead). Streaming responses
    were another challenge: the agent returned without the completion being
    over (it returned a routine streaming the deltas sent by the model).
    
    This PR introduces a TokenCounter interface that abstracts synchronous
    and asynchronous token counting. All token-consuming operations must
    return a TokenCounter. TokensCounters are stored in the agent state and
    returned once the agent exists. Finally, the token counters are
    evaluated asynchronously to give the streaming completion requests
    enough time to finish.
    hugoShaka authored and github-actions committed Jul 21, 2023
    Configuration menu
    Copy the full SHA
    26a4bfc View commit details
    Browse the repository at this point in the history