Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +2 -1
- templates/dashboard.html +43 -3
app.py
CHANGED
@@ -974,7 +974,8 @@ def dashboard():
|
|
974 |
model_stats=model_usage_stats,
|
975 |
total_tokens=total_tokens,
|
976 |
compute_points=compute_points,
|
977 |
-
compute_points_log=compute_points_log
|
|
|
978 |
)
|
979 |
|
980 |
|
|
|
974 |
model_stats=model_usage_stats,
|
975 |
total_tokens=total_tokens,
|
976 |
compute_points=compute_points,
|
977 |
+
compute_points_log=compute_points_log,
|
978 |
+
space_url=SPACE_URL # 传递空间URL
|
979 |
)
|
980 |
|
981 |
|
templates/dashboard.html
CHANGED
@@ -459,6 +459,26 @@
|
|
459 |
margin-top: 1rem;
|
460 |
}
|
461 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
462 |
/* 媒体查询 */
|
463 |
@media (max-width: 768px) {
|
464 |
.container {
|
@@ -648,7 +668,7 @@
|
|
648 |
<div class="card-header">
|
649 |
<h2 class="card-title">
|
650 |
<span class="card-icon">📈</span>
|
651 |
-
|
652 |
</h2>
|
653 |
<button id="toggleModelStats" class="btn-toggle">显示全部</button>
|
654 |
</div>
|
@@ -661,6 +681,7 @@
|
|
661 |
<th>输入Token</th>
|
662 |
<th>输出Token</th>
|
663 |
<th>总Token</th>
|
|
|
664 |
</tr>
|
665 |
</thead>
|
666 |
<tbody>
|
@@ -671,12 +692,19 @@
|
|
671 |
<td class="token-count">{{ stats.prompt_tokens|int }}</td>
|
672 |
<td class="token-count">{{ stats.completion_tokens|int }}</td>
|
673 |
<td class="token-count">{{ stats.total_tokens|int }}</td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
674 |
</tr>
|
675 |
{% endfor %}
|
676 |
</tbody>
|
677 |
</table>
|
678 |
<div class="token-note">
|
679 |
-
<small>* Token
|
680 |
</div>
|
681 |
</div>
|
682 |
</div>
|
@@ -690,15 +718,27 @@
|
|
690 |
</div>
|
691 |
<div class="endpoint-item">
|
692 |
<p>获取模型列表:</p>
|
|
|
|
|
|
|
693 |
<a href="/v1/models" class="endpoint-url" target="_blank">GET /v1/models</a>
|
|
|
694 |
</div>
|
695 |
<div class="endpoint-item">
|
696 |
<p>聊天补全:</p>
|
697 |
-
|
|
|
|
|
|
|
|
|
698 |
</div>
|
699 |
<div class="endpoint-item">
|
700 |
<p>健康检查:</p>
|
|
|
|
|
|
|
701 |
<a href="/health" class="endpoint-url" target="_blank">GET /health</a>
|
|
|
702 |
</div>
|
703 |
</div>
|
704 |
|
|
|
459 |
margin-top: 1rem;
|
460 |
}
|
461 |
|
462 |
+
/* Token计算方式标签 */
|
463 |
+
.token-method {
|
464 |
+
padding: 0.2rem 0.5rem;
|
465 |
+
border-radius: 4px;
|
466 |
+
font-size: 0.8rem;
|
467 |
+
font-weight: 500;
|
468 |
+
}
|
469 |
+
|
470 |
+
.token-method.tiktoken {
|
471 |
+
background: rgba(54, 211, 153, 0.2);
|
472 |
+
color: var(--success-color);
|
473 |
+
border: 1px solid rgba(54, 211, 153, 0.3);
|
474 |
+
}
|
475 |
+
|
476 |
+
.token-method.estimate {
|
477 |
+
background: rgba(251, 189, 35, 0.2);
|
478 |
+
color: var(--warning-color);
|
479 |
+
border: 1px solid rgba(251, 189, 35, 0.3);
|
480 |
+
}
|
481 |
+
|
482 |
/* 媒体查询 */
|
483 |
@media (max-width: 768px) {
|
484 |
.container {
|
|
|
668 |
<div class="card-header">
|
669 |
<h2 class="card-title">
|
670 |
<span class="card-icon">📈</span>
|
671 |
+
模型使用统计与Token计算方式
|
672 |
</h2>
|
673 |
<button id="toggleModelStats" class="btn-toggle">显示全部</button>
|
674 |
</div>
|
|
|
681 |
<th>输入Token</th>
|
682 |
<th>输出Token</th>
|
683 |
<th>总Token</th>
|
684 |
+
<th>计算方式</th>
|
685 |
</tr>
|
686 |
</thead>
|
687 |
<tbody>
|
|
|
692 |
<td class="token-count">{{ stats.prompt_tokens|int }}</td>
|
693 |
<td class="token-count">{{ stats.completion_tokens|int }}</td>
|
694 |
<td class="token-count">{{ stats.total_tokens|int }}</td>
|
695 |
+
<td>
|
696 |
+
{% if "gpt" in model.lower() or "claude" in model.lower() or model in ["llama-3", "mistral", "gemma"] %}
|
697 |
+
<span class="token-method tiktoken">精确</span>
|
698 |
+
{% else %}
|
699 |
+
<span class="token-method estimate">估算</span>
|
700 |
+
{% endif %}
|
701 |
+
</td>
|
702 |
</tr>
|
703 |
{% endfor %}
|
704 |
</tbody>
|
705 |
</table>
|
706 |
<div class="token-note">
|
707 |
+
<small>* Token计算方式:<span class="token-method tiktoken">精确</span> 表示使用tiktoken准确计算,<span class="token-method estimate">估算</span> 表示使用估算方法(约4字符=1token)。所有统计数据仅供参考,不代表实际计费标准。</small>
|
708 |
</div>
|
709 |
</div>
|
710 |
</div>
|
|
|
718 |
</div>
|
719 |
<div class="endpoint-item">
|
720 |
<p>获取模型列表:</p>
|
721 |
+
{% if space_url %}
|
722 |
+
<a href="{{ space_url }}/v1/models" class="endpoint-url" target="_blank">GET {{ space_url }}/v1/models</a>
|
723 |
+
{% else %}
|
724 |
<a href="/v1/models" class="endpoint-url" target="_blank">GET /v1/models</a>
|
725 |
+
{% endif %}
|
726 |
</div>
|
727 |
<div class="endpoint-item">
|
728 |
<p>聊天补全:</p>
|
729 |
+
{% if space_url %}
|
730 |
+
<code class="endpoint-url">POST {{ space_url }}/v1/chat/completions</code>
|
731 |
+
{% else %}
|
732 |
+
<code class="endpoint-url">POST /v1/chat/completions</code>
|
733 |
+
{% endif %}
|
734 |
</div>
|
735 |
<div class="endpoint-item">
|
736 |
<p>健康检查:</p>
|
737 |
+
{% if space_url %}
|
738 |
+
<a href="{{ space_url }}/health" class="endpoint-url" target="_blank">GET {{ space_url }}/health</a>
|
739 |
+
{% else %}
|
740 |
<a href="/health" class="endpoint-url" target="_blank">GET /health</a>
|
741 |
+
{% endif %}
|
742 |
</div>
|
743 |
</div>
|
744 |
|