[PR #4568] [MERGED] fix: Use eval_duration for output TPS calculations in Ollama LLM provider #4676

Closed
opened 2026-02-22 18:36:18 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/4568
Author: @jonathanortega2023
Created: 10/21/2025
Status: Merged
Merged: 11/20/2025
Merged by: @timothycarambat

Base: masterHead: fix--Output-TPS-Metric


📝 Commits (8)

  • ca905f9 fix: Use eval_duration for output TPS calculations and add as a metric field
  • 5a62844 refactor usage of eval_duration from ollama metrics
  • a233373 Merge branch 'master' into pr-4568-branch
  • 809e5ac move eval_duration to usage
  • 7831b16 overwrite duration in ollama provider wip measureAsyncFunction optional param
  • b33c84d allow for overloaded duration in measureAsyncFunction
  • fc1d9ff Merge branch 'master' into fix--Output-TPS-Metric
  • 095457e simplify flow for duration tracking

📊 Changes

2 files changed (+13 additions, -6 deletions)

View changed files

📝 server/utils/AiProviders/ollama/index.js (+5 -2)
📝 server/utils/helpers/chat/LLMPerformanceMonitor.js (+8 -4)

📄 Description

Pull Request Type

  • 🐛 fix

Relevant Issues

resolves #4567

What is in this change?

What is in this change?

  • Updated LLMPerformanceMonitor to support provider duration timing for more accurate output TPS calculations
  • measureAsyncFunction accepts duration from output.usage.duration
  • Modified measureStream to accept duration from reportedUsage.duration if provided by the LLM provider
  • Updated Ollama provider to use eval_duration for more accurate TPS calculation

This is a generic enhancement that any provider can leverage to supply more accurate timing information, while maintaining backward compatibility with providers that don't supply duration metrics.

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated
  • I have tested my code functionality
  • Docker build succeeds locally

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Mintplex-Labs/anything-llm/pull/4568 **Author:** [@jonathanortega2023](https://github.com/jonathanortega2023) **Created:** 10/21/2025 **Status:** ✅ Merged **Merged:** 11/20/2025 **Merged by:** [@timothycarambat](https://github.com/timothycarambat) **Base:** `master` ← **Head:** `fix--Output-TPS-Metric` --- ### 📝 Commits (8) - [`ca905f9`](https://github.com/Mintplex-Labs/anything-llm/commit/ca905f957a055c80fb5580f180fd6956572dddc4) fix: Use eval_duration for output TPS calculations and add as a metric field - [`5a62844`](https://github.com/Mintplex-Labs/anything-llm/commit/5a62844fb9bcf9a730e68f0ebf7b2003b960eceb) refactor usage of eval_duration from ollama metrics - [`a233373`](https://github.com/Mintplex-Labs/anything-llm/commit/a2333731c6ed379fbee1d3495a0959be288ddeb9) Merge branch 'master' into pr-4568-branch - [`809e5ac`](https://github.com/Mintplex-Labs/anything-llm/commit/809e5acf73ca66c2885779805a215b4a2eb8a325) move eval_duration to usage - [`7831b16`](https://github.com/Mintplex-Labs/anything-llm/commit/7831b16a4197d50f381142af58c931db88d2f116) overwrite duration in ollama provider wip measureAsyncFunction optional param - [`b33c84d`](https://github.com/Mintplex-Labs/anything-llm/commit/b33c84d9e4fae4e097359bea9f7ab67a38946959) allow for overloaded duration in measureAsyncFunction - [`fc1d9ff`](https://github.com/Mintplex-Labs/anything-llm/commit/fc1d9ff027548b3f28b0909f519a87a9754db2e8) Merge branch 'master' into fix--Output-TPS-Metric - [`095457e`](https://github.com/Mintplex-Labs/anything-llm/commit/095457e619bdd0a55c046e87b15fcaf0946b1a9c) simplify flow for duration tracking ### 📊 Changes **2 files changed** (+13 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `server/utils/AiProviders/ollama/index.js` (+5 -2) 📝 `server/utils/helpers/chat/LLMPerformanceMonitor.js` (+8 -4) </details> ### 📄 Description ### Pull Request Type - [x] 🐛 fix ### Relevant Issues <!-- Use "resolves #xxx" to auto resolve on merge. Otherwise, please use "connect #xxx" --> resolves #4567 ### What is in this change? <!-- Describe the changes in this PR that are impactful to the repo. --> ## What is in this change? - Updated `LLMPerformanceMonitor` to support provider duration timing for more accurate output TPS calculations - `measureAsyncFunction` accepts `duration` from `output.usage.duration` - Modified `measureStream` to accept `duration` from `reportedUsage.duration` if provided by the LLM provider - Updated Ollama provider to use `eval_duration` for more accurate TPS calculation This is a generic enhancement that any provider can leverage to supply more accurate timing information, while maintaining backward compatibility with providers that don't supply duration metrics. ### Developer Validations <!-- All of the applicable items should be checked. --> - [x] I ran `yarn lint` from the root of the repo & committed changes - [x] Relevant documentation has been updated - [x] I have tested my code functionality - [x] Docker build succeeds locally --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-22 18:36:18 -05:00
yindo closed this issue 2026-02-22 18:36:19 -05:00
yindo changed title from [PR #4568] fix: Use eval_duration for output TPS calculations in Ollama LLM provider to [PR #4568] [MERGED] fix: Use eval_duration for output TPS calculations in Ollama LLM provider 2026-06-05 15:19:46 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#4676