freellm 1.0.2 → 1.0.4
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/README.md +89 -89
- package/bin/cli.js +24 -24
- package/client-dist/assets/index-C63nKIEX.js +96 -0
- package/client-dist/index.html +13 -13
- package/dist/db/index.js +59 -59
- package/dist/index.js +4 -4
- package/package.json +57 -57
- package/client-dist/assets/index-DWxZZL6G.js +0 -93
package/dist/db/index.js
CHANGED
|
@@ -43,58 +43,58 @@ function getDb() {
|
|
|
43
43
|
return db;
|
|
44
44
|
}
|
|
45
45
|
function migrate() {
|
|
46
|
-
db.exec(`
|
|
47
|
-
CREATE TABLE IF NOT EXISTS settings (
|
|
48
|
-
key TEXT PRIMARY KEY,
|
|
49
|
-
value TEXT NOT NULL
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
CREATE TABLE IF NOT EXISTS sessions (
|
|
53
|
-
token TEXT PRIMARY KEY,
|
|
54
|
-
created_at INTEGER NOT NULL DEFAULT (unixepoch()),
|
|
55
|
-
expires_at INTEGER NOT NULL
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
CREATE TABLE IF NOT EXISTS provider_keys (
|
|
59
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
60
|
-
platform TEXT NOT NULL,
|
|
61
|
-
label TEXT NOT NULL DEFAULT '',
|
|
62
|
-
key_enc TEXT NOT NULL,
|
|
63
|
-
enabled INTEGER NOT NULL DEFAULT 1,
|
|
64
|
-
status TEXT NOT NULL DEFAULT 'unknown',
|
|
65
|
-
last_check INTEGER,
|
|
66
|
-
created_at INTEGER NOT NULL DEFAULT (unixepoch())
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
CREATE TABLE IF NOT EXISTS models (
|
|
70
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
71
|
-
platform TEXT NOT NULL,
|
|
72
|
-
model_id TEXT NOT NULL,
|
|
73
|
-
display_name TEXT NOT NULL,
|
|
74
|
-
supports_tools INTEGER NOT NULL DEFAULT 0,
|
|
75
|
-
supports_vision INTEGER NOT NULL DEFAULT 0,
|
|
76
|
-
supports_stream INTEGER NOT NULL DEFAULT 1,
|
|
77
|
-
type TEXT NOT NULL DEFAULT 'chat',
|
|
78
|
-
context_length INTEGER,
|
|
79
|
-
fallback_order INTEGER NOT NULL DEFAULT 999,
|
|
80
|
-
enabled INTEGER NOT NULL DEFAULT 1,
|
|
81
|
-
UNIQUE(platform, model_id)
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
CREATE TABLE IF NOT EXISTS analytics (
|
|
85
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
86
|
-
ts INTEGER NOT NULL DEFAULT (unixepoch()),
|
|
87
|
-
platform TEXT NOT NULL,
|
|
88
|
-
model_id TEXT NOT NULL,
|
|
89
|
-
prompt_tokens INTEGER NOT NULL DEFAULT 0,
|
|
90
|
-
complete_tokens INTEGER NOT NULL DEFAULT 0,
|
|
91
|
-
latency_ms INTEGER,
|
|
92
|
-
success INTEGER NOT NULL DEFAULT 1,
|
|
93
|
-
error_code TEXT
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
CREATE INDEX IF NOT EXISTS idx_analytics_ts ON analytics(ts);
|
|
97
|
-
CREATE INDEX IF NOT EXISTS idx_analytics_platform ON analytics(platform);
|
|
46
|
+
db.exec(`
|
|
47
|
+
CREATE TABLE IF NOT EXISTS settings (
|
|
48
|
+
key TEXT PRIMARY KEY,
|
|
49
|
+
value TEXT NOT NULL
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
CREATE TABLE IF NOT EXISTS sessions (
|
|
53
|
+
token TEXT PRIMARY KEY,
|
|
54
|
+
created_at INTEGER NOT NULL DEFAULT (unixepoch()),
|
|
55
|
+
expires_at INTEGER NOT NULL
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
CREATE TABLE IF NOT EXISTS provider_keys (
|
|
59
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
60
|
+
platform TEXT NOT NULL,
|
|
61
|
+
label TEXT NOT NULL DEFAULT '',
|
|
62
|
+
key_enc TEXT NOT NULL,
|
|
63
|
+
enabled INTEGER NOT NULL DEFAULT 1,
|
|
64
|
+
status TEXT NOT NULL DEFAULT 'unknown',
|
|
65
|
+
last_check INTEGER,
|
|
66
|
+
created_at INTEGER NOT NULL DEFAULT (unixepoch())
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
CREATE TABLE IF NOT EXISTS models (
|
|
70
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
71
|
+
platform TEXT NOT NULL,
|
|
72
|
+
model_id TEXT NOT NULL,
|
|
73
|
+
display_name TEXT NOT NULL,
|
|
74
|
+
supports_tools INTEGER NOT NULL DEFAULT 0,
|
|
75
|
+
supports_vision INTEGER NOT NULL DEFAULT 0,
|
|
76
|
+
supports_stream INTEGER NOT NULL DEFAULT 1,
|
|
77
|
+
type TEXT NOT NULL DEFAULT 'chat',
|
|
78
|
+
context_length INTEGER,
|
|
79
|
+
fallback_order INTEGER NOT NULL DEFAULT 999,
|
|
80
|
+
enabled INTEGER NOT NULL DEFAULT 1,
|
|
81
|
+
UNIQUE(platform, model_id)
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
CREATE TABLE IF NOT EXISTS analytics (
|
|
85
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
86
|
+
ts INTEGER NOT NULL DEFAULT (unixepoch()),
|
|
87
|
+
platform TEXT NOT NULL,
|
|
88
|
+
model_id TEXT NOT NULL,
|
|
89
|
+
prompt_tokens INTEGER NOT NULL DEFAULT 0,
|
|
90
|
+
complete_tokens INTEGER NOT NULL DEFAULT 0,
|
|
91
|
+
latency_ms INTEGER,
|
|
92
|
+
success INTEGER NOT NULL DEFAULT 1,
|
|
93
|
+
error_code TEXT
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
CREATE INDEX IF NOT EXISTS idx_analytics_ts ON analytics(ts);
|
|
97
|
+
CREATE INDEX IF NOT EXISTS idx_analytics_platform ON analytics(platform);
|
|
98
98
|
`);
|
|
99
99
|
seedModels();
|
|
100
100
|
}
|
|
@@ -154,9 +154,9 @@ function toggleModel(id, enabled) {
|
|
|
154
154
|
}
|
|
155
155
|
// ─── Analytics ───────────────────────────────────────────────────────────────
|
|
156
156
|
function logRequest(data) {
|
|
157
|
-
db.prepare(`
|
|
158
|
-
INSERT INTO analytics (platform, model_id, prompt_tokens, complete_tokens, latency_ms, success, error_code)
|
|
159
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
157
|
+
db.prepare(`
|
|
158
|
+
INSERT INTO analytics (platform, model_id, prompt_tokens, complete_tokens, latency_ms, success, error_code)
|
|
159
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
160
160
|
`).run(data.platform, data.model_id, data.prompt_tokens, data.complete_tokens, data.latency_ms, data.success ? 1 : 0, data.error_code ?? null);
|
|
161
161
|
}
|
|
162
162
|
function getAnalytics(windowHours = 24) {
|
|
@@ -211,10 +211,10 @@ function deleteSession(token) {
|
|
|
211
211
|
}
|
|
212
212
|
// ─── Seed models ─────────────────────────────────────────────────────────────
|
|
213
213
|
function upsertModel(m) {
|
|
214
|
-
db.prepare(`
|
|
215
|
-
INSERT INTO models (platform, model_id, display_name, supports_tools, supports_vision, supports_stream, type, context_length, fallback_order, enabled)
|
|
216
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
217
|
-
ON CONFLICT(platform, model_id) DO NOTHING
|
|
214
|
+
db.prepare(`
|
|
215
|
+
INSERT INTO models (platform, model_id, display_name, supports_tools, supports_vision, supports_stream, type, context_length, fallback_order, enabled)
|
|
216
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
217
|
+
ON CONFLICT(platform, model_id) DO NOTHING
|
|
218
218
|
`).run(m.platform, m.model_id, m.display_name, m.supports_tools, m.supports_vision, m.supports_stream, m.type, m.context_length ?? null, m.fallback_order, m.enabled);
|
|
219
219
|
}
|
|
220
220
|
function seedModels() {
|
package/dist/index.js
CHANGED
|
@@ -84,10 +84,10 @@ async function startServer(config = {}) {
|
|
|
84
84
|
}
|
|
85
85
|
else {
|
|
86
86
|
app.get('/', (_req, res) => {
|
|
87
|
-
res.send(`<html><body style="font-family:sans-serif;padding:2rem">
|
|
88
|
-
<h1>UniLLM is running</h1>
|
|
89
|
-
<p>API endpoint: <code>http://localhost:${port}/v1</code></p>
|
|
90
|
-
<p>Dashboard not built. Run <code>npm run build:client</code> to build the UI.</p>
|
|
87
|
+
res.send(`<html><body style="font-family:sans-serif;padding:2rem">
|
|
88
|
+
<h1>UniLLM is running</h1>
|
|
89
|
+
<p>API endpoint: <code>http://localhost:${port}/v1</code></p>
|
|
90
|
+
<p>Dashboard not built. Run <code>npm run build:client</code> to build the UI.</p>
|
|
91
91
|
</body></html>`);
|
|
92
92
|
});
|
|
93
93
|
}
|
package/package.json
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "freellm",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "One OpenAI-compatible endpoint for 15+ free LLM providers. Smart routing, failover, encrypted keys. Run with npx freellm.",
|
|
5
|
-
"keywords": ["llm", "openai", "proxy", "groq", "gemini", "mistral", "free", "api-gateway"],
|
|
6
|
-
"author": "",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"bin": {
|
|
9
|
-
"freellm": "bin/cli.js"
|
|
10
|
-
},
|
|
11
|
-
"main": "dist/index.js",
|
|
12
|
-
"files": [
|
|
13
|
-
"bin/",
|
|
14
|
-
"dist/",
|
|
15
|
-
"client-dist/"
|
|
16
|
-
],
|
|
17
|
-
"scripts": {
|
|
18
|
-
"dev": "concurrently \"npm run dev:server\" \"npm run dev:client\"",
|
|
19
|
-
"dev:server": "tsx watch src/cli.ts -- --no-open",
|
|
20
|
-
"dev:client": "vite --config client/vite.config.ts",
|
|
21
|
-
"build": "npm run build:server && npm run build:client",
|
|
22
|
-
"build:server": "tsc -p tsconfig.json",
|
|
23
|
-
"build:client": "vite build --config client/vite.config.ts",
|
|
24
|
-
"prepublishOnly": "npm run build",
|
|
25
|
-
"start": "node dist/cli.js",
|
|
26
|
-
"test": "vitest run"
|
|
27
|
-
},
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"chalk": "^5.3.0",
|
|
30
|
-
"compression": "^1.7.4",
|
|
31
|
-
"cookie-parser": "^1.4.6",
|
|
32
|
-
"cors": "^2.8.5",
|
|
33
|
-
"express": "^4.18.3",
|
|
34
|
-
"nanoid": "^5.0.7",
|
|
35
|
-
"open": "^10.1.0",
|
|
36
|
-
"react": "^18.2.0",
|
|
37
|
-
"react-dom": "^18.2.0"
|
|
38
|
-
},
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"@types/compression": "^1.7.5",
|
|
41
|
-
"@types/cookie-parser": "^1.4.7",
|
|
42
|
-
"@types/cors": "^2.8.17",
|
|
43
|
-
"@types/express": "^4.17.21",
|
|
44
|
-
"@types/node": "^22.0.0",
|
|
45
|
-
"@types/react": "^18.2.73",
|
|
46
|
-
"@types/react-dom": "^18.2.23",
|
|
47
|
-
"@vitejs/plugin-react": "^4.2.1",
|
|
48
|
-
"concurrently": "^8.2.2",
|
|
49
|
-
"tsx": "^4.7.1",
|
|
50
|
-
"typescript": "^5.4.3",
|
|
51
|
-
"vite": "^5.2.6",
|
|
52
|
-
"vitest": "^1.4.0"
|
|
53
|
-
},
|
|
54
|
-
"engines": {
|
|
55
|
-
"node": ">=22.5.0"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "freellm",
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "One OpenAI-compatible endpoint for 15+ free LLM providers. Smart routing, failover, encrypted keys. Run with npx freellm.",
|
|
5
|
+
"keywords": ["llm", "openai", "proxy", "groq", "gemini", "mistral", "free", "api-gateway"],
|
|
6
|
+
"author": "",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"bin": {
|
|
9
|
+
"freellm": "bin/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"bin/",
|
|
14
|
+
"dist/",
|
|
15
|
+
"client-dist/"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"dev": "concurrently \"npm run dev:server\" \"npm run dev:client\"",
|
|
19
|
+
"dev:server": "tsx watch src/cli.ts -- --no-open",
|
|
20
|
+
"dev:client": "vite --config client/vite.config.ts",
|
|
21
|
+
"build": "npm run build:server && npm run build:client",
|
|
22
|
+
"build:server": "tsc -p tsconfig.json",
|
|
23
|
+
"build:client": "vite build --config client/vite.config.ts",
|
|
24
|
+
"prepublishOnly": "npm run build",
|
|
25
|
+
"start": "node dist/cli.js",
|
|
26
|
+
"test": "vitest run"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"chalk": "^5.3.0",
|
|
30
|
+
"compression": "^1.7.4",
|
|
31
|
+
"cookie-parser": "^1.4.6",
|
|
32
|
+
"cors": "^2.8.5",
|
|
33
|
+
"express": "^4.18.3",
|
|
34
|
+
"nanoid": "^5.0.7",
|
|
35
|
+
"open": "^10.1.0",
|
|
36
|
+
"react": "^18.2.0",
|
|
37
|
+
"react-dom": "^18.2.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/compression": "^1.7.5",
|
|
41
|
+
"@types/cookie-parser": "^1.4.7",
|
|
42
|
+
"@types/cors": "^2.8.17",
|
|
43
|
+
"@types/express": "^4.17.21",
|
|
44
|
+
"@types/node": "^22.0.0",
|
|
45
|
+
"@types/react": "^18.2.73",
|
|
46
|
+
"@types/react-dom": "^18.2.23",
|
|
47
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
48
|
+
"concurrently": "^8.2.2",
|
|
49
|
+
"tsx": "^4.7.1",
|
|
50
|
+
"typescript": "^5.4.3",
|
|
51
|
+
"vite": "^5.2.6",
|
|
52
|
+
"vitest": "^1.4.0"
|
|
53
|
+
},
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=22.5.0"
|
|
56
|
+
}
|
|
57
|
+
}
|