Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: Temporarily disable cost calculation due to pricing accuracy issues (#439)

LearningCircuitce1578dde0c0
diff --git a/src/local_deep_research/metrics/pricing/cost_calculator.py b/src/local_deep_research/metrics/pricing/cost_calculator.py
index b851e31e23..83206ac7f6 100644
--- a/src/local_deep_research/metrics/pricing/cost_calculator.py
+++ b/src/local_deep_research/metrics/pricing/cost_calculator.py
@@ -51,11 +51,11 @@ class CostCalculator:
self.cache.set(f"model:{cache_key}", pricing)
return pricing
- # Fallback
+ # No pricing found
logger.warning(
- f"No pricing found for {model_name} (provider: {provider}), using default"
+ f"No pricing found for {model_name} (provider: {provider})"
)
- return {"prompt": 0.001, "completion": 0.002}
+ return None
async def calculate_cost(
self,
@@ -72,6 +72,16 @@ class CostCalculator:
"""
pricing = await self.get_model_pricing(model_name, provider)
+ # If no pricing found, return zero cost
+ if pricing is None:
+ return {
+ "prompt_cost": 0.0,
+ "completion_cost": 0.0,
+ "total_cost": 0.0,
+ "pricing_used": None,
+ "error": "No pricing data available for this model",
+ }
+
# Convert tokens to thousands for pricing calculation
prompt_cost = (prompt_tokens / 1000) * pricing["prompt"]
completion_cost = (completion_tokens / 1000) * pricing["completion"]
@@ -141,24 +151,25 @@ class CostCalculator:
# Use cached pricing only
pricing = self.cache.get_model_pricing(model_name)
if not pricing:
- # Use static fallback
+ # Use static fallback with exact matching only
fetcher = PricingFetcher()
+ # Try exact match
pricing = fetcher.static_pricing.get(model_name)
if not pricing:
- # Find partial match
- for (
- static_model,
- static_pricing,
- ) in fetcher.static_pricing.items():
- if (
- static_model.lower() in model_name.lower()
- or model_name.lower() in static_model.lower()
- ):
- pricing = static_pricing
- break
-
- if not pricing:
- pricing = {"prompt": 0.001, "completion": 0.002}
+ # Try exact match without provider prefix
+ if "/" in model_name:
+ model_only = model_name.split("/")[-1]
+ pricing = fetcher.static_pricing.get(model_only)
+
+ # If no pricing found, return zero cost
+ if not pricing:
+ return {
+ "prompt_cost": 0.0,
+ "completion_cost": 0.0,
+ "total_cost": 0.0,
+ "pricing_used": None,
+ "error": "No pricing data available for this model",
+ }
prompt_cost = (prompt_tokens / 1000) * pricing["prompt"]
completion_cost = (completion_tokens / 1000) * pricing["completion"]
diff --git a/src/local_deep_research/metrics/pricing/pricing_fetcher.py b/src/local_deep_research/metrics/pricing/pricing_fetcher.py
index 393a858d2c..1a9d3f011f 100644
--- a/src/local_deep_research/metrics/pricing/pricing_fetcher.py
+++ b/src/local_deep_research/metrics/pricing/pricing_fetcher.py
@@ -152,31 +152,33 @@ class PricingFetcher:
# Fallback to static pricing with provider priority
if provider:
- # First try provider-specific lookup
+ # First try provider-specific lookup with exact matching
provider_models = self._get_models_by_provider(provider)
- for static_model, pricing in provider_models.items():
- if (
- static_model.lower() in model_name
- or model_name in static_model.lower()
- ):
- return pricing
-
- # General model name matching
- for static_model, pricing in self.static_pricing.items():
- if (
- static_model.lower() in model_name
- or model_name in static_model.lower()
- ):
- return pricing
-
- # Default pricing for unknown models
+ # Try exact match
+ if model_name in provider_models:
+ return provider_models[model_name]
+ # Try exact match without provider prefix
+ if "/" in model_name:
+ model_only = model_name.split("/")[-1]
+ if model_only in provider_models:
+ return provider_models[model_only]
+
+ # Exact model name matching only
+ # First try exact match
+ if model_name in self.static_pricing:
+ return self.static_pricing[model_name]
+
+ # Try exact match without provider prefix (e.g., "openai/gpt-4o-mini" -> "gpt-4o-mini")
+ if "/" in model_name:
+ model_only = model_name.split("/")[-1]
+ if model_only in self.static_pricing:
+ return self.static_pricing[model_only]
+
+ # No pricing found - return None instead of default pricing
logger.warning(
f"No pricing found for model: {model_name}, provider: {provider}"
)
- return {
- "prompt": 0.001,
- "completion": 0.002,
- } # Default to GPT-3.5 pricing
+ return None
def _get_models_by_provider(
self, provider: str
diff --git a/src/local_deep_research/web/static/js/components/details.js b/src/local_deep_research/web/static/js/components/details.js
index 767da8d28e..c15382db9a 100644
--- a/src/local_deep_research/web/static/js/components/details.js
+++ b/src/local_deep_research/web/static/js/components/details.js
@@ -658,6 +658,10 @@
// Load cost data
async function loadCostData() {
try {
+ // Temporarily disable cost calculation until pricing logic is optimized
+ document.getElementById('total-cost').textContent = '-';
+ return;
+
const response = await fetch(`/metrics/api/research-costs/${researchId}`);
if (response.ok) {
const data = await response.json();
@@ -667,7 +671,7 @@
}
} catch (error) {
console.error('Error loading cost data:', error);
- document.getElementById('total-cost').textContent = '$0.00';
+ document.getElementById('total-cost').textContent = '-';
}
}
diff --git a/src/local_deep_research/web/templates/pages/cost_analytics.html b/src/local_deep_research/web/templates/pages/cost_analytics.html
index e01e04daec..8f32fbafbd 100644
--- a/src/local_deep_research/web/templates/pages/cost_analytics.html
+++ b/src/local_deep_research/web/templates/pages/cost_analytics.html
@@ -794,6 +794,10 @@
async function loadCostData() {
try {
+ // Temporarily disable cost analytics until pricing logic is optimized
+ showTemporarilyDisabled();
+ return;
+
showLoading();
const response = await fetch(`/metrics/api/cost-analytics?period=${currentPeriod}`);
@@ -1216,6 +1220,26 @@
document.getElementById('error').style.display = 'none';
document.getElementById('no-data').style.display = 'block';
}
+
+ function showTemporarilyDisabled() {
+ document.getElementById('loading').style.display = 'none';
+ document.getElementById('cost-content').style.display = 'none';
+ document.getElementById('error').style.display = 'none';
+ document.getElementById('no-data').style.display = 'block';
+
+ // Update the no-data message to indicate temporary disable
+ const noDataContainer = document.getElementById('no-data');
+ if (noDataContainer) {
+ noDataContainer.innerHTML = `
+ <div class="no-data-container">
+ <div class="no-data-icon">⚠️</div>
+ <h3>Cost Analytics Temporarily Disabled</h3>
+ <p>Cost calculation is temporarily disabled while we optimize the pricing logic to ensure accuracy.</p>
+ <p>This prevents showing misleading cost information. The feature will be re-enabled once the pricing system is improved.</p>
+ </div>
+ `;
+ }
+ }
})();
</script>
{% endblock %}