Skip to content

fix(firmware): skip LiteLLM cost calculation for firmware models - #6

Closed
b3nw wants to merge 16 commits into
devfrom
feature/firmware-quota-tracking
Closed

b3nw wants to merge 16 commits into
devfrom
feature/firmware-quota-tracking

Conversation

@b3nw

@b3nw b3nw commented Jan 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Skip LiteLLM cost calculation for Firmware.ai models to eliminate log spam and errors
  • Firmware.ai uses custom model naming (firmware/anthropic/claude-sonnet-4-5) not in LiteLLM's pricing database
  • Added skip_cost_calculation = True class attribute to FirmwareProvider
  • Expanded docstring documenting the OpenAI-compatible routing architecture

Problem

Firmware provider was generating noisy logs:

Provider List: https://docs.litellm.ai/docs/providers  (5x per request)
Could not calculate cost for model firmware/anthropic/claude-haiku-4-5: litellm.BadRequestError

Test plan

  • Deploy to llm-proxy container and verify no more "Provider List" spam
  • Verify cost calculation errors are gone from logs
  • Confirm firmware model requests still work correctly

Mirrowel and others added 16 commits January 21, 2026 12:22
feat(nanogpt): add NanoGPT provider with subscription quota tracking
fix(chutes): enable quota display in TUI
Updates the release workflow to accurately link contributors to their GitHub profiles in the changelog, replacing static author name generation.

- Update `cliff.toml` to output temporary placeholders containing commit SHA, email, and name.
- Add a workflow step to resolve placeholders using a multi-tiered strategy:
  - Batch resolution via the GitHub Compare API.
  - Individual lookup via the Commit API.
  - Parsing of `noreply` email addresses.
  - Fallback to the original git author name.
- Configure the release creation step to use the resolved changelog content.
…notes

This update modifies the changelog generation process to highlight community contributions by parsing merge commits directly.

- Update `cliff.toml` to skip merge commits in the default parser to avoid duplication.
- Implement a script in the build workflow to identify merge commits in the release range.
- Fetch PR titles and author information using the GitHub CLI.
- Append a dedicated "Community Contributions" section to the generated changelog.
The build workflow previously failed to resolve a reference tag if the current branch had no specific build tags. This update introduces a robust resolution strategy:

- scans parent branches (main, master, develop, dev) to find the closest common ancestor
- selects the "best" tag based on the shortest commit distance from the merge-base
- adds a final fallback to search for any ancestor tag if branch-specific resolution fails
Refactors the build workflow to consolidate user-configurable options into a top-level environment configuration section for better maintainability.

- centralize configuration for build branches, stable branches, and fallback strategies
- move release asset file lists and descriptions to global variables
- implement dynamic injection of release files into platform-specific archives
- add templated generation for experimental build warnings in release notes
- update release pruning step to use centralized retention settings
…nd MIT proxy

Replaces the monolithic licensing model with a component-specific approach to better govern redistribution and contribution rights. The core logic (`rotator_library`) adopts strong copyleft protections to ensure open collaboration, while the interface layer (`proxy_app`) maintains permissive terms for maximum compatibility.

*   **Granular Attribution**: Systematically injected `SPDX-License-Identifier` tags and copyright headers into all source files to establish clear provenance.
*   **Regulatory Update**: Modified the root `LICENSE` to serve as a directory for component-specific terms rather than a single blanket text.
*   **Package Definition**: Adjusted `pyproject.toml` classifiers to accurately declare the LGPL status of the library.
- Add `CONTRIBUTING.md` with development setup, project structure, and licensing instructions
- Create structured GitHub issue templates for bug reports and feature requests
- Add pull request template with testing and compliance checklist
- Configure GitHub issue template settings
Implement quota tracking for Firmware.ai provider using their /api/v1/quota
endpoint. The provider tracks a 5-hour rolling window quota where `used` is
already a 0-1 ratio from the API.

- Add FirmwareQuotaTracker mixin with configurable api_base
- Add FirmwareProvider with background job for periodic quota refresh
- Parse ISO 8601 reset timestamps with proper Z suffix handling
- Validate API response types and clamp remaining fraction to 0.0-1.0
- Support FIRMWARE_QUOTA_REFRESH_INTERVAL env var (default: 300s)
feat(quota): Add Firmware.ai quota tracking with 5-hour rolling window
Replace `logger` with `raw_logger` in the `chat_completions` function to ensure the final response is successfully logged when a JSON decoding error occurs.
Users with FIRMWARE_API_KEY_* but no FIRMWARE_API_BASE were getting
errors because LiteLLM doesn't recognize firmware as a native provider.

This adds a specific fallback to use firmware's default api_base
(https://app.firmware.ai/api/v1) when not explicitly configured.
Firmware.ai uses custom model naming (e.g., firmware/anthropic/claude-sonnet-4-5)
that isn't in LiteLLM's pricing database, causing "Provider List" spam and
BadRequestError during cost calculation.

Add skip_cost_calculation=True to FirmwareProvider to prevent these errors.
The provider is OpenAI-compatible and routes through LiteLLM's OpenAI provider
with api_base override, so no custom acompletion() logic is needed.
@b3nw b3nw closed this Jan 23, 2026
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @b3nw, 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 addresses an issue with noisy logs caused by LiteLLM's inability to calculate costs for Firmware.ai models. It introduces a flag to skip cost calculations for these models and enhances documentation. Additionally, it adds issue templates and a contributing guide to improve project maintainability and contributor experience. Several provider implementations were updated to improve quota tracking and model discovery.

Highlights

  • Cost Calculation: The pull request skips LiteLLM cost calculation for Firmware.ai models due to custom model naming conventions that are incompatible with LiteLLM's pricing database.
  • Firmware Provider: A skip_cost_calculation = True attribute has been added to the FirmwareProvider class to disable cost calculations.
  • Documentation: The docstring has been expanded to provide more comprehensive documentation of the OpenAI-compatible routing architecture.
  • Issue Templates: Added issue templates for bug reports and feature requests to standardize issue reporting.
  • Contributing Guide: Added a contributing guide to help new contributors get started with the project.
  • Licensing: Updated the LICENSE file to clarify the licensing of different components of the project.
  • Quota Tracking: Improved quota tracking for Firmware.ai and NanoGPT providers, including background job configuration and usage reset configurations.
  • Model Discovery: Enhanced model discovery for NanoGPT, including dynamic discovery from the API and fallback to hardcoded models.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/build.yml
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.

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

Copy link
Copy Markdown

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 fix for the Firmware.ai provider to prevent log spam, which is a valuable improvement. However, the scope of this PR is very broad, including the addition of a completely new nanogpt provider, new GitHub issue and PR templates, contribution guidelines, and widespread license header additions. While these are all positive changes for the repository, bundling them into a single PR makes it difficult to review and understand the core fix. In the future, please try to submit smaller, more focused pull requests for different features or maintenance tasks.

My review focuses on the code changes. I've found a couple of areas for improvement related to code consistency and maintainability. Please see my detailed comments.




def __init__(self):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For consistency with other providers in the codebase (e.g., FirmwareProvider) and for better maintainability, it's a good practice to accept *args, **kwargs and call super().__init__(*args, **kwargs) here, even if the base classes currently don't have an __init__. This makes the class more robust to future changes in its base classes.

Please update the method signature and add the super() call as the first line in the __init__ method.

Suggested change
def __init__(self):
def __init__(self, *args, **kwargs):

Comment on lines +900 to +917
# Check "models" section first (for per_model mode and quota tracking)
models_data = cred_data.get("models", {})
if models_data:
# Get first model name and extract provider prefix
first_model = next(iter(models_data.keys()), None)
if first_model and "/" in first_model:
provider = first_model.split("/")[0].lower()
return provider

# Fallback to "daily" section (legacy structure)
daily_data = cred_data.get("daily", {})
daily_models = daily_data.get("models", {})
if daily_models:
# Get first model name and extract provider prefix
first_model = next(iter(daily_models.keys()), None)
if first_model and "/" in first_model:
provider = first_model.split("/")[0].lower()
return provider

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This block contains duplicated logic for extracting the provider from models_data and daily_models. This can be refactored into a loop to improve code clarity and reduce redundancy.

Suggested change
# Check "models" section first (for per_model mode and quota tracking)
models_data = cred_data.get("models", {})
if models_data:
# Get first model name and extract provider prefix
first_model = next(iter(models_data.keys()), None)
if first_model and "/" in first_model:
provider = first_model.split("/")[0].lower()
return provider
# Fallback to "daily" section (legacy structure)
daily_data = cred_data.get("daily", {})
daily_models = daily_data.get("models", {})
if daily_models:
# Get first model name and extract provider prefix
first_model = next(iter(daily_models.keys()), None)
if first_model and "/" in first_model:
provider = first_model.split("/")[0].lower()
return provider
# Check "models" and "daily" sections for model data to infer provider
for model_source in [
cred_data.get("models", {}),
cred_data.get("daily", {}).get("models", {}),
]:
if model_source:
first_model = next(iter(model_source.keys()), None)
if first_model and "/" in first_model:
return first_model.split("/")[0].lower()

@b3nw
b3nw deleted the feature/firmware-quota-tracking branch January 23, 2026 05:17
b3nw pushed a commit that referenced this pull request May 31, 2026
Gemini CLI, Qwen Code and IFlow integration with Oauth and Enhance Provider Capabilities, Enhanced Credential Management, and more.
b3nw pushed a commit that referenced this pull request May 31, 2026
Introduces a comprehensive CustomTkinter-based GUI application for managing model ignore/whitelist rules per provider, accessible from the settings tool.

- Created model_filter_gui.py with full-featured visual editor (2600+ lines)
- Implemented dual synchronized model lists showing unfiltered and filtered states
- Added color-coded rule chips with visual association to affected models
- Real-time pattern preview as users type filter rules
- Interactive click/right-click functionality for model-rule relationships
- Context menus for quick actions (add to ignore/whitelist, copy names)
- Comprehensive help documentation with keyboard shortcuts
- Unsaved changes detection with save/discard/cancel workflow
- Background prefetching of models for all providers to improve responsiveness
- Integration with settings tool as menu option #6

The GUI provides pattern matching with exact match, prefix wildcard (*), and match-all support. Whitelist rules take priority over ignore rules. All changes are persisted to .env file using IGNORE_MODELS_* and WHITELIST_MODELS_* variables.
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