Spaces:
Running
Running
feat: Exclude error requests from latency stats and plots
Browse files- index.html +31 -14
index.html
CHANGED
@@ -694,16 +694,23 @@
|
|
694 |
const successRate = totalRequests > 0 ? ((successfulRequests / totalRequests) * 100).toFixed(1) : 0;
|
695 |
|
696 |
const validLatencies = rows
|
|
|
|
|
|
|
|
|
|
|
|
|
697 |
.map(r => r.duration_ms)
|
698 |
.filter(d => d !== null && d >= 0);
|
699 |
-
|
700 |
-
|
|
|
701 |
: 0;
|
702 |
|
703 |
-
// Calculate median latency per provider
|
704 |
const latencyByProvider = {};
|
705 |
-
|
706 |
-
if (row.duration_ms !== null && row.duration_ms >= 0) {
|
707 |
if (!latencyByProvider[row.provider_name]) {
|
708 |
latencyByProvider[row.provider_name] = [];
|
709 |
}
|
@@ -740,9 +747,10 @@
|
|
740 |
function createLatencyByProviderPlot(rows, selectedModelId) {
|
741 |
const titleContext = selectedModelId === 'all' ? '' : `for ${selectedModelId.split('/').pop()}`;
|
742 |
const dataByProvider = {};
|
743 |
-
|
|
|
744 |
if (!dataByProvider[row.provider_name]) dataByProvider[row.provider_name] = [];
|
745 |
-
if (row.duration_ms !== null && row.duration_ms >= 0) {
|
746 |
dataByProvider[row.provider_name].push(row.duration_ms);
|
747 |
}
|
748 |
});
|
@@ -802,10 +810,11 @@
|
|
802 |
|
803 |
function createLatencyByModelPlot(rows) { // Only shown for 'all'
|
804 |
const dataByModel = {};
|
805 |
-
|
|
|
806 |
const model = row.model_id;
|
807 |
if (!dataByModel[model]) dataByModel[model] = [];
|
808 |
-
if (row.duration_ms !== null && row.duration_ms >= 0) {
|
809 |
dataByModel[model].push(row.duration_ms);
|
810 |
}
|
811 |
});
|
@@ -866,8 +875,9 @@
|
|
866 |
const allProviders = new Set();
|
867 |
const allModels = new Set();
|
868 |
|
869 |
-
|
870 |
-
|
|
|
871 |
const provider = row.provider_name;
|
872 |
const model = row.model_id;
|
873 |
allProviders.add(provider);
|
@@ -923,9 +933,16 @@
|
|
923 |
const provider = row.provider_name;
|
924 |
if (!providerStats[provider]) providerStats[provider] = { total: 0, success: 0, errors: 0, latencies: [] };
|
925 |
providerStats[provider].total++;
|
926 |
-
if (row.response_status_code === 200)
|
927 |
-
|
928 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
929 |
});
|
930 |
|
931 |
// Create Header (only if it doesn't exist)
|
|
|
694 |
const successRate = totalRequests > 0 ? ((successfulRequests / totalRequests) * 100).toFixed(1) : 0;
|
695 |
|
696 |
const validLatencies = rows
|
697 |
+
.map(r => r.duration_ms)
|
698 |
+
.filter(d => d !== null && d >= 0); // Keep this filter for null/negative durations
|
699 |
+
|
700 |
+
// Filter for successful requests *before* calculating average latency
|
701 |
+
const successfulRows = rows.filter(r => r.response_status_code === 200);
|
702 |
+
const successfulLatencies = successfulRows
|
703 |
.map(r => r.duration_ms)
|
704 |
.filter(d => d !== null && d >= 0);
|
705 |
+
|
706 |
+
const avgLatency = successfulLatencies.length > 0
|
707 |
+
? (successfulLatencies.reduce((a, b) => a + b, 0) / successfulLatencies.length).toFixed(0)
|
708 |
: 0;
|
709 |
|
710 |
+
// Calculate median latency per provider using only successful requests
|
711 |
const latencyByProvider = {};
|
712 |
+
successfulRows.forEach(row => { // Iterate over successful rows only
|
713 |
+
if (row.duration_ms !== null && row.duration_ms >= 0) { // Still check for valid duration
|
714 |
if (!latencyByProvider[row.provider_name]) {
|
715 |
latencyByProvider[row.provider_name] = [];
|
716 |
}
|
|
|
747 |
function createLatencyByProviderPlot(rows, selectedModelId) {
|
748 |
const titleContext = selectedModelId === 'all' ? '' : `for ${selectedModelId.split('/').pop()}`;
|
749 |
const dataByProvider = {};
|
750 |
+
// Filter for successful requests before processing
|
751 |
+
rows.filter(r => r.response_status_code === 200).forEach(row => {
|
752 |
if (!dataByProvider[row.provider_name]) dataByProvider[row.provider_name] = [];
|
753 |
+
if (row.duration_ms !== null && row.duration_ms >= 0) { // Still check for valid duration
|
754 |
dataByProvider[row.provider_name].push(row.duration_ms);
|
755 |
}
|
756 |
});
|
|
|
810 |
|
811 |
function createLatencyByModelPlot(rows) { // Only shown for 'all'
|
812 |
const dataByModel = {};
|
813 |
+
// Filter for successful requests before processing
|
814 |
+
rows.filter(r => r.response_status_code === 200).forEach(row => {
|
815 |
const model = row.model_id;
|
816 |
if (!dataByModel[model]) dataByModel[model] = [];
|
817 |
+
if (row.duration_ms !== null && row.duration_ms >= 0) { // Still check for valid duration
|
818 |
dataByModel[model].push(row.duration_ms);
|
819 |
}
|
820 |
});
|
|
|
875 |
const allProviders = new Set();
|
876 |
const allModels = new Set();
|
877 |
|
878 |
+
// Filter for successful requests before processing
|
879 |
+
rows.filter(r => r.response_status_code === 200).forEach(row => {
|
880 |
+
if (row.duration_ms !== null && row.duration_ms >= 0) { // Still check for valid duration
|
881 |
const provider = row.provider_name;
|
882 |
const model = row.model_id;
|
883 |
allProviders.add(provider);
|
|
|
933 |
const provider = row.provider_name;
|
934 |
if (!providerStats[provider]) providerStats[provider] = { total: 0, success: 0, errors: 0, latencies: [] };
|
935 |
providerStats[provider].total++;
|
936 |
+
if (row.response_status_code === 200) {
|
937 |
+
providerStats[provider].success++;
|
938 |
+
// Only add latency for successful requests with valid duration
|
939 |
+
if (row.duration_ms !== null && row.duration_ms >= 0) {
|
940 |
+
providerStats[provider].latencies.push(row.duration_ms);
|
941 |
+
}
|
942 |
+
} else if (row.response_status_code !== null) {
|
943 |
+
providerStats[provider].errors++;
|
944 |
+
}
|
945 |
+
// Note: We no longer add latency if the request was not successful (status != 200)
|
946 |
});
|
947 |
|
948 |
// Create Header (only if it doesn't exist)
|