Skip to content

Conversation

Mandolaro
Copy link
Collaborator

πŸ“ Summary

  • 1. Rewrite Cost Calculation

βœ… Checklist

Copy link
Contributor

Summary of Changes

Hello @Mandolaro, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request undertakes a substantial architectural refactoring aimed at enhancing the server-side cost calculation and LLM tracing framework. By modularizing the integration logic for various LLM providers into separate, dedicated sub-packages, the system gains improved maintainability and scalability. The changes also introduce more detailed token usage metrics, particularly for caching, which will enable a more precise understanding of resource consumption and cost implications.

Highlights

  • Modular LLM Tracing Architecture: The core LLM tracing and cost calculation logic has been significantly refactored. Provider-specific implementations for OpenAI, Anthropic, Together, Google GenAI, and Groq are now moved into dedicated sub-packages, improving code organization, maintainability, and extensibility.
  • Enhanced Usage Metrics: New attributes have been introduced to track cache-related token counts (e.g., GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS, GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS), providing more granular insights into LLM usage and potential cost optimizations.
  • Decorator Module Refactoring: Utility decorators like use_once and dont_throw have been moved into their own distinct files within the judgeval.utils.decorators package, promoting a cleaner and more focused module structure.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with πŸ‘ and πŸ‘Ž on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@Mandolaro Mandolaro changed the base branch from main to staging September 27, 2025 20:27
@Mandolaro Mandolaro closed this Sep 27, 2025
@Mandolaro Mandolaro reopened this Sep 27, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a significant and well-structured refactoring to move LLM cost calculation to the server side. The client-side logic is now modularized into provider-specific wrappers, which greatly improves maintainability. The changes correctly focus on sending token usage data to the backend instead of calculating costs on the client.

I've identified a few issues:

  • A critical issue where an e2e test will fail due to the removal of a cost-related attribute key.
  • A high-severity issue regarding duplicated code in the new llm module structure.
  • A high-severity regression where cached token tracking for OpenAI has been lost.
  • A medium-severity issue regarding a removed type hint.

Overall, this is a great refactoring. Addressing these points will make it even better.

Copy link
Contributor

@abhishekg999 abhishekg999 left a comment

Choose a reason for hiding this comment

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

lets see it in staging

@abhishekg999 abhishekg999 self-requested a review October 8, 2025 18:28
@Mandolaro Mandolaro enabled auto-merge (squash) October 8, 2025 19:06
@Mandolaro Mandolaro disabled auto-merge October 8, 2025 19:15
@Mandolaro Mandolaro merged commit 1af9c3a into staging Oct 8, 2025
14 of 17 checks passed
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