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(anthropic): include cached tokens in usage count logs #947

Merged
merged 6 commits into from
Feb 11, 2025

Conversation

evalstate
Copy link
Contributor

cache_creation_input_tokens and cache_read_input_tokens were not being
added to the usage total recorded in goose.log. This fix includes
those categories in the calculation of "input tokens" as per the API guide.

refs: https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching#tracking-cache-performance

@angiejones angiejones self-requested a review February 6, 2025 17:46
@evalstate
Copy link
Contributor Author

Earlier failures were due to:

  1. Formatting issue
  2. Clippy failure

Branch updated to latest and

  • cargo clean
  • cargo clippy
  • cargo build
  • cargo test

run clean.

image

The development build has been re-tested, the highlighted entry is from ./target/debug/goose and usage verified with the anthropic console.

The warning:

[Lint Electron Desktop App: ui/desktop/src/App.tsx#L77](https://github.com/block/goose/pull/947/files#annotation_31733017641)
Unexpected any. Specify a different type

is not introduced by this change.

@angiejones angiejones requested a review from salman1993 February 8, 2025 18:42
@angiejones
Copy link
Collaborator

thank you @evalstate!

@salman1993 good with merging this one?

@lily-de
Copy link
Collaborator

lily-de commented Feb 11, 2025

Hi @evalstate,

Thank you for your contribution! Before we can proceed with merging your pull request, it needs to be updated with the latest changes from the main branch to ensure compatibility and ease of integration. Here are the steps you can follow to update your branch:

  1. Ensure Your Local Main Branch is Up to Date:
    First, make sure you have the latest changes from the main repository:

    git checkout main
    git pull upstream main

    Replace upstream with the remote name of the main repository if you've used a different one.

  2. Checkout Your PR Branch:
    Switch back to your branch associated with the pull request:

    git checkout [your-branch-name]
  3. Merge or Rebase Main into Your Branch:
    You can either merge the main branch into your PR branch to maintain the history, or rebase for a cleaner commit history. Here’s how you can do both:

    • Merge:

      git merge main

      This command will bring your branch up to date with the main branch while preserving the history of changes.

    • Rebase:

      git rebase main

      Rebasing will linearize your commit history based on the main branch. If you encounter conflicts during rebase, you’ll need to resolve them and then continue the rebase with git rebase --continue.

  4. Push the Updated Branch:
    After merging or rebasing, push your branch to update the pull request:

    git push origin [your-branch-name] --force

    Use the --force flag if you've performed a rebase or otherwise rewritten the history.

Once you've updated your branch, please let me know by commenting on the pull request, and I'll take another look.

Thank you!

@angiejones angiejones requested a review from lily-de February 11, 2025 02:58
@angiejones angiejones merged commit 162348d into block:main Feb 11, 2025
6 checks passed
laanak08 pushed a commit that referenced this pull request Feb 13, 2025
Co-authored-by: angiejones <jones.angie@gmail.com>
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.

3 participants