you hua le rizhi de xianshi
This commit is contained in:
parent
e373295cf5
commit
4c6bede153
5 changed files with 33 additions and 4 deletions
12
README.md
12
README.md
|
|
@ -159,6 +159,18 @@ api2cursor/
|
||||||
- `file_path` → `path` 字段映射
|
- `file_path` → `path` 字段映射
|
||||||
- `finish_reason` 修正
|
- `finish_reason` 修正
|
||||||
|
|
||||||
|
|
||||||
|
============================
|
||||||
|
增加缓存,在api2cursor里面的body修改中加个你喜欢的随意字段:
|
||||||
|
{
|
||||||
|
"prompt_cache_key": "GPT5-4-xxx-xxx"
|
||||||
|
}
|
||||||
|
openai 开 fast 模式
|
||||||
|
{
|
||||||
|
"service_tier": "priority"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
## 许可证
|
## 许可证
|
||||||
|
|
||||||
[MIT](LICENSE)
|
[MIT](LICENSE)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','PingFang SC','Micr
|
||||||
input,select,button,textarea{font-family:inherit;font-size:inherit}
|
input,select,button,textarea{font-family:inherit;font-size:inherit}
|
||||||
a{color:var(--primary);text-decoration:none}
|
a{color:var(--primary);text-decoration:none}
|
||||||
code{background:var(--input);padding:1px 5px;border-radius:4px;font-size:12px;font-family:Consolas,Monaco,monospace}
|
code{background:var(--input);padding:1px 5px;border-radius:4px;font-size:12px;font-family:Consolas,Monaco,monospace}
|
||||||
.container{max-width:960px;margin:0 auto;padding:0 20px}
|
.container{width:min(100%,1680px);margin:0 auto;padding:0 20px}
|
||||||
|
|
||||||
#login{display:flex;align-items:center;justify-content:center;min-height:100vh;background:linear-gradient(145deg,#0b1120 0%,#121a2e 50%,#0b1120 100%)}
|
#login{display:flex;align-items:center;justify-content:center;min-height:100vh;background:linear-gradient(145deg,#0b1120 0%,#121a2e 50%,#0b1120 100%)}
|
||||||
.login-card{background:var(--card);border:1px solid var(--border);border-radius:16px;padding:40px;width:380px;box-shadow:0 20px 60px rgba(0,0,0,.4)}
|
.login-card{background:var(--card);border:1px solid var(--border);border-radius:16px;padding:40px;width:380px;box-shadow:0 20px 60px rgba(0,0,0,.4)}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>API 2 Cursor - 管理面板</title>
|
<title>API 2 Cursor - 管理面板</title>
|
||||||
<link rel="stylesheet" href="/static/admin.css">
|
<link rel="stylesheet" href="/static/admin.css?v=20260505-2">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
@ -190,6 +190,6 @@
|
||||||
|
|
||||||
<div class="toast-area" id="toasts"></div>
|
<div class="toast-area" id="toasts"></div>
|
||||||
|
|
||||||
<script src="/static/admin.js"></script>
|
<script src="/static/admin.js?v=20260505-2"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,10 @@ async function loadRequestLogs() {
|
||||||
let html = '<div class="request-logs-wrap"><table class="stats-table request-logs-table"><thead><tr><th>请求时间</th><th>请求模型</th><th>实际模型</th><th>上游 URL</th><th>Tokens</th><th>耗时</th><th>状态</th></tr></thead><tbody>';
|
let html = '<div class="request-logs-wrap"><table class="stats-table request-logs-table"><thead><tr><th>请求时间</th><th>请求模型</th><th>实际模型</th><th>上游 URL</th><th>Tokens</th><th>耗时</th><th>状态</th></tr></thead><tbody>';
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
const usage = item.usage || {};
|
const usage = item.usage || {};
|
||||||
const tokens = '输 ' + fmtNum(usage.input_tokens) + ' / 出 ' + fmtNum(usage.output_tokens) + ' / 总 ' + fmtNum(usage.total_tokens);
|
let tokens = '输 ' + fmtNum(usage.input_tokens) + ' / 出 ' + fmtNum(usage.output_tokens) + ' / 总 ' + fmtNum(usage.total_tokens);
|
||||||
|
if (Number(usage.cache_read_tokens || 0) > 0 || Number(usage.cache_write_tokens || 0) > 0) {
|
||||||
|
tokens += ' / 缓存读 ' + fmtNum(usage.cache_read_tokens) + ' / 缓存写 ' + fmtNum(usage.cache_write_tokens);
|
||||||
|
}
|
||||||
const statusClass = item.status === 'ok' ? 'status-ok' : 'status-error';
|
const statusClass = item.status === 'ok' ? 'status-ok' : 'status-error';
|
||||||
const statusText = item.status === 'ok' ? '成功' : '异常';
|
const statusText = item.status === 'ok' ? '成功' : '异常';
|
||||||
html += '<tr>'
|
html += '<tr>'
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,24 @@ def _normalize_usage(usage: dict[str, Any] | None) -> dict[str, int]:
|
||||||
usage.get('completion_tokens', usage.get('output_tokens', 0))
|
usage.get('completion_tokens', usage.get('output_tokens', 0))
|
||||||
)
|
)
|
||||||
total_tokens = _safe_int(usage.get('total_tokens', input_tokens + output_tokens))
|
total_tokens = _safe_int(usage.get('total_tokens', input_tokens + output_tokens))
|
||||||
|
|
||||||
|
prompt_details = usage.get('prompt_tokens_details')
|
||||||
|
input_details = usage.get('input_tokens_details')
|
||||||
|
|
||||||
|
cache_read_tokens = _safe_int(usage.get('cache_read_input_tokens', 0))
|
||||||
|
cache_write_tokens = _safe_int(usage.get('cache_creation_input_tokens', 0))
|
||||||
|
|
||||||
|
if isinstance(prompt_details, dict):
|
||||||
|
cache_read_tokens = max(cache_read_tokens, _safe_int(prompt_details.get('cached_tokens', 0)))
|
||||||
|
if isinstance(input_details, dict):
|
||||||
|
cache_read_tokens = max(cache_read_tokens, _safe_int(input_details.get('cached_tokens', 0)))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'input_tokens': input_tokens,
|
'input_tokens': input_tokens,
|
||||||
'output_tokens': output_tokens,
|
'output_tokens': output_tokens,
|
||||||
'total_tokens': total_tokens,
|
'total_tokens': total_tokens,
|
||||||
|
'cache_read_tokens': cache_read_tokens,
|
||||||
|
'cache_write_tokens': cache_write_tokens,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue