Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
[!IMPORTANT]
Please review the checklist below before submitting your pull request.
[x] Please open an issue before creating a PR or link to an existing issue
[x] I have performed a self-review of my own code
[x] I have commented my code, particularly in hard-to-understand areas
[x] I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
Description
The submitted this bug fixes the https://github.com/langgenius/dify/issues/7911, cause the language model of 1, the Spark at the end of the returned flow without a clear identity, so every time back to have the usage the value, However, the _handle_invoke_result_stream method in base_app_runner.py checks whether usage exists. If it exists, it is no longer assigned. As a result, usage only stores the value of the iterator.
In the llm.py file of Spark's large language model, the _handle_generate_stream_response method completion_tokens calculates the value in each iteration without adding up
Fixes #7911
Type of Change
[x] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
[ ] This change requires a documentation update, included: Dify Document
[ ] Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
[ ] Dependency upgrade
Testing Instructions
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist:
dev/reformat
(backend) andcd web && npx lint-staged
(frontend) to appease the lint godsDescription
The submitted this bug fixes the https://github.com/langgenius/dify/issues/7911, cause the language model of 1, the Spark at the end of the returned flow without a clear identity, so every time back to have the usage the value, However, the _handle_invoke_result_stream method in base_app_runner.py checks whether usage exists. If it exists, it is no longer assigned. As a result, usage only stores the value of the iterator.
Fixes #7911
Type of Change
Testing Instructions
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration