mirror of
https://github.com/langgenius/dify-official-plugins.git
synced 2026-07-21 17:45:23 -04:00
[PR #1491] [MERGED] fix(gemini): usage metadata #1921
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/langgenius/dify-official-plugins/pull/1491
Author: @QIN2DIM
Created: 8/12/2025
Status: ✅ Merged
Merged: 8/12/2025
Merged by: @crazywoola
Base:
main← Head:gemini-usage📝 Commits (4)
8398b9bfeat(gemini): enhance token usage tracking and update dependencies075bfe9refactor(llm): extract token calculation logic into helper method0bfa25bUpdate llm.py0511ceafix(gemini): update google-genai to version 1.29.0📊 Changes
4 files changed (+77 additions, -25 deletions)
View changed files
📝
models/gemini/manifest.yaml(+1 -1)📝
models/gemini/models/llm/llm.py(+74 -22)📝
models/gemini/pyproject.toml(+1 -1)📝
models/gemini/requirements.txt(+1 -1)📄 Description
Related Issues or Context
Related: #1360
This PR introduces a solution to fully resolve token counting issues for
prompt_tokensandcompletion_tokensin multi-modal QA scenarios using the Gemini GenAI SDK.1. Accurate Token Counting in Multi-Modal QA
In the Gemini GenAI SDK, token statistics for
prompt_tokensandcompletion_tokenswere previously inaccurate in multi-modal QA scenarios, leading to inconsistencies in total token usage reporting.Implemented a solution that ensures:
total_token_countis always consistent.Due to current constraints in Dify:
This PR contains Changes to Non-Plugin
This PR contains Changes to Non-LLM Models Plugin
This PR contains Changes to LLM Models Plugin
Version Control (Any Changes to the Plugin Will Require Bumping the Version)
VersionField, Not in Meta Section)Dify Plugin SDK Version
dify_plugin>=0.3.0,<0.5.0is in requirements.txt (SDK docs)Environment Verification (If Any Code Changes)
Local Deployment Environment
SaaS Environment
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.