mirror of
https://github.com/langgenius/dify-plugin-sdks.git
synced 2026-07-21 18:05:30 -04:00
[PR #189] [MERGED] fix: corrected latency accuracy #210
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-plugin-sdks/pull/189
Author: @immortal-wm
Created: 8/7/2025
Status: ✅ Merged
Merged: 9/16/2025
Merged by: @Yeuoly
Base:
main← Head:fix/latency-issue📝 Commits (5)
b33c3dffix latency calc24aed38feat: add timing context management to AIModel for latency tracking533edc9feat: implement ModelFactory for dynamic model instance creation002b702feat: add unit tests for model registry and mock model providere8b6a99apply ruff📊 Changes
13 files changed (+540 additions, -74 deletions)
View changed files
➕
python/dify_plugin/core/model_factory.py(+39 -0)📝
python/dify_plugin/core/plugin_registration.py(+8 -7)➕
python/dify_plugin/interfaces/exec/ai_model.py(+6 -0)📝
python/dify_plugin/interfaces/model/ai_model.py(+26 -1)📝
python/dify_plugin/interfaces/model/large_language_model.py(+35 -31)📝
python/dify_plugin/interfaces/model/moderation_model.py(+5 -7)📝
python/dify_plugin/interfaces/model/rerank_model.py(+5 -6)📝
python/dify_plugin/interfaces/model/speech2text_model.py(+5 -4)📝
python/dify_plugin/interfaces/model/text_embedding_model.py(+5 -7)📝
python/dify_plugin/interfaces/model/tts_model.py(+17 -11)➕
python/tests/interfaces/model/test_ai_model_timing_context.py(+84 -0)➕
python/tests/interfaces/model/test_llm_timing_context.py(+132 -0)➕
python/tests/test_model_registry_get_model.py(+173 -0)📄 Description
The latency is much smaller than the actual execution time because each LLM call doesn't have its own started_at timestamp— they all share the same class variable.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.