protocol-proxy 2.3.4 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/config-store.js +295 -225
- package/lib/converters/gemini-to-anthropic.js +286 -277
- package/lib/converters/gemini-to-openai.js +255 -240
- package/lib/converters/openai-to-anthropic.js +368 -329
- package/lib/logger.js +58 -0
- package/lib/proxy-manager.js +4 -0
- package/lib/proxy-server.js +636 -357
- package/lib/stats-store.js +3 -5
- package/package.json +51 -51
- package/public/app.js +1296 -972
- package/public/index.html +321 -277
- package/public/style.css +1448 -1189
- package/server.js +767 -655
package/lib/stats-store.js
CHANGED
|
@@ -194,14 +194,12 @@ function recordUsage(proxyId, provider, model, usage, estimated = false) {
|
|
|
194
194
|
`p:${proxyId}:${prov}:${mdl}`,
|
|
195
195
|
];
|
|
196
196
|
|
|
197
|
-
for (const
|
|
198
|
-
|
|
199
|
-
for (const key of keys) {
|
|
200
|
-
addToBuffer(period, bucket, key, prompt, completion, estimated);
|
|
201
|
-
}
|
|
197
|
+
for (const key of keys) {
|
|
198
|
+
addToBuffer('daily', dk, key, prompt, completion, estimated);
|
|
202
199
|
}
|
|
203
200
|
}
|
|
204
201
|
|
|
202
|
+
|
|
205
203
|
// ==================== 查询统计 ====================
|
|
206
204
|
|
|
207
205
|
function getStats(opts = {}) {
|
package/package.json
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "protocol-proxy",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "OpenAI / Anthropic 协议转换透明代理",
|
|
5
|
-
"main": "server.js",
|
|
6
|
-
"bin": {
|
|
7
|
-
"protocol-proxy": "server.js"
|
|
8
|
-
},
|
|
9
|
-
"files": [
|
|
10
|
-
"server.js",
|
|
11
|
-
"lib/",
|
|
12
|
-
"public/",
|
|
13
|
-
"config/",
|
|
14
|
-
"README.md"
|
|
15
|
-
],
|
|
16
|
-
"keywords": [
|
|
17
|
-
"proxy",
|
|
18
|
-
"openai",
|
|
19
|
-
"anthropic",
|
|
20
|
-
"api",
|
|
21
|
-
"protocol-converter"
|
|
22
|
-
],
|
|
23
|
-
"scripts": {
|
|
24
|
-
"start": "node server.js",
|
|
25
|
-
"dev": "node --watch server.js",
|
|
26
|
-
"build": "pkg . --out-path=dist"
|
|
27
|
-
},
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"cors": "^2.8.5",
|
|
30
|
-
"express": "^4.19.2"
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"pkg": "^5.8.1"
|
|
34
|
-
},
|
|
35
|
-
"pkg": {
|
|
36
|
-
"scripts": [
|
|
37
|
-
"lib/**/*.js"
|
|
38
|
-
],
|
|
39
|
-
"assets": [
|
|
40
|
-
"public/**/*"
|
|
41
|
-
],
|
|
42
|
-
"targets": [
|
|
43
|
-
"node20-win-x64"
|
|
44
|
-
],
|
|
45
|
-
"outputPath": "dist",
|
|
46
|
-
"options": []
|
|
47
|
-
},
|
|
48
|
-
"engines": {
|
|
49
|
-
"node": ">=20.0.0"
|
|
50
|
-
}
|
|
51
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "protocol-proxy",
|
|
3
|
+
"version": "2.5.0",
|
|
4
|
+
"description": "OpenAI / Anthropic 协议转换透明代理",
|
|
5
|
+
"main": "server.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"protocol-proxy": "server.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"server.js",
|
|
11
|
+
"lib/",
|
|
12
|
+
"public/",
|
|
13
|
+
"config/",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"keywords": [
|
|
17
|
+
"proxy",
|
|
18
|
+
"openai",
|
|
19
|
+
"anthropic",
|
|
20
|
+
"api",
|
|
21
|
+
"protocol-converter"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"start": "node server.js",
|
|
25
|
+
"dev": "node --watch server.js",
|
|
26
|
+
"build": "pkg . --out-path=dist"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"cors": "^2.8.5",
|
|
30
|
+
"express": "^4.19.2"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"pkg": "^5.8.1"
|
|
34
|
+
},
|
|
35
|
+
"pkg": {
|
|
36
|
+
"scripts": [
|
|
37
|
+
"lib/**/*.js"
|
|
38
|
+
],
|
|
39
|
+
"assets": [
|
|
40
|
+
"public/**/*"
|
|
41
|
+
],
|
|
42
|
+
"targets": [
|
|
43
|
+
"node20-win-x64"
|
|
44
|
+
],
|
|
45
|
+
"outputPath": "dist",
|
|
46
|
+
"options": []
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=20.0.0"
|
|
50
|
+
}
|
|
51
|
+
}
|