Spaces:
Running
Running
ffreemt
commited on
Commit
•
89e5382
1
Parent(s):
6dac806
Update prefix /hf in /src/api/routes
Browse files- .gitignore +3 -0
- dist/index.cjs +10 -6
- dist/index.cjs.map +0 -0
- dist/index.js +10 -6
- dist/index.js.map +0 -0
- src/api/routes/chat.ts +2 -1
- src/api/routes/models.ts +2 -1
- src/api/routes/ping.ts +2 -1
- src/api/routes/token.ts +2 -1
- src/lib/server.ts +5 -3
.gitignore
CHANGED
@@ -1 +1,4 @@
|
|
1 |
node_modules
|
|
|
|
|
|
|
|
1 |
node_modules
|
2 |
+
dist
|
3 |
+
logs
|
4 |
+
dist/
|
dist/index.cjs
CHANGED
@@ -991,7 +991,7 @@ var Server = class {
|
|
991 |
}
|
992 |
/**
|
993 |
* 附加路由
|
994 |
-
*
|
995 |
* @param routes 路由列表
|
996 |
*/
|
997 |
attachRoutes(routes) {
|
@@ -1028,7 +1028,7 @@ var Server = class {
|
|
1028 |
}
|
1029 |
/**
|
1030 |
* 请求处理
|
1031 |
-
*
|
1032 |
* @param ctx 上下文
|
1033 |
* @param routeFn 路由方法
|
1034 |
*/
|
@@ -1538,7 +1538,8 @@ var chat_default = {
|
|
1538 |
|
1539 |
// src/api/routes/chat.ts
|
1540 |
var chat_default2 = {
|
1541 |
-
prefix:
|
|
|
1542 |
post: {
|
1543 |
"/completions": async (request) => {
|
1544 |
request.validate("body.conversation_id", (v) => import_lodash13.default.isUndefined(v) || import_lodash13.default.isString(v)).validate("body.messages", import_lodash13.default.isArray).validate("headers.authorization", import_lodash13.default.isString);
|
@@ -1566,7 +1567,8 @@ var chat_default2 = {
|
|
1566 |
|
1567 |
// src/api/routes/ping.ts
|
1568 |
var ping_default = {
|
1569 |
-
prefix:
|
|
|
1570 |
get: {
|
1571 |
"": async () => "pong"
|
1572 |
}
|
@@ -1575,7 +1577,8 @@ var ping_default = {
|
|
1575 |
// src/api/routes/token.ts
|
1576 |
var import_lodash14 = __toESM(require("lodash"), 1);
|
1577 |
var token_default = {
|
1578 |
-
prefix:
|
|
|
1579 |
post: {
|
1580 |
"/check": async (request) => {
|
1581 |
request.validate("body.token", import_lodash14.default.isString);
|
@@ -1589,7 +1592,8 @@ var token_default = {
|
|
1589 |
|
1590 |
// src/api/routes/models.ts
|
1591 |
var models_default = {
|
1592 |
-
prefix:
|
|
|
1593 |
get: {
|
1594 |
"/models": async () => {
|
1595 |
return {
|
|
|
991 |
}
|
992 |
/**
|
993 |
* 附加路由
|
994 |
+
*
|
995 |
* @param routes 路由列表
|
996 |
*/
|
997 |
attachRoutes(routes) {
|
|
|
1028 |
}
|
1029 |
/**
|
1030 |
* 请求处理
|
1031 |
+
*
|
1032 |
* @param ctx 上下文
|
1033 |
* @param routeFn 路由方法
|
1034 |
*/
|
|
|
1538 |
|
1539 |
// src/api/routes/chat.ts
|
1540 |
var chat_default2 = {
|
1541 |
+
// prefix: '/v1/chat',
|
1542 |
+
prefix: "/hf/v1/chat",
|
1543 |
post: {
|
1544 |
"/completions": async (request) => {
|
1545 |
request.validate("body.conversation_id", (v) => import_lodash13.default.isUndefined(v) || import_lodash13.default.isString(v)).validate("body.messages", import_lodash13.default.isArray).validate("headers.authorization", import_lodash13.default.isString);
|
|
|
1567 |
|
1568 |
// src/api/routes/ping.ts
|
1569 |
var ping_default = {
|
1570 |
+
// prefix: '/ping',
|
1571 |
+
prefix: "/hf/ping",
|
1572 |
get: {
|
1573 |
"": async () => "pong"
|
1574 |
}
|
|
|
1577 |
// src/api/routes/token.ts
|
1578 |
var import_lodash14 = __toESM(require("lodash"), 1);
|
1579 |
var token_default = {
|
1580 |
+
// prefix: '/token',
|
1581 |
+
prefix: "/hf/token",
|
1582 |
post: {
|
1583 |
"/check": async (request) => {
|
1584 |
request.validate("body.token", import_lodash14.default.isString);
|
|
|
1592 |
|
1593 |
// src/api/routes/models.ts
|
1594 |
var models_default = {
|
1595 |
+
// prefix: '/v1',
|
1596 |
+
prefix: "/hf/v1",
|
1597 |
get: {
|
1598 |
"/models": async () => {
|
1599 |
return {
|
dist/index.cjs.map
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
dist/index.js
CHANGED
@@ -967,7 +967,7 @@ var Server = class {
|
|
967 |
}
|
968 |
/**
|
969 |
* 附加路由
|
970 |
-
*
|
971 |
* @param routes 路由列表
|
972 |
*/
|
973 |
attachRoutes(routes) {
|
@@ -1004,7 +1004,7 @@ var Server = class {
|
|
1004 |
}
|
1005 |
/**
|
1006 |
* 请求处理
|
1007 |
-
*
|
1008 |
* @param ctx 上下文
|
1009 |
* @param routeFn 路由方法
|
1010 |
*/
|
@@ -1514,7 +1514,8 @@ var chat_default = {
|
|
1514 |
|
1515 |
// src/api/routes/chat.ts
|
1516 |
var chat_default2 = {
|
1517 |
-
prefix:
|
|
|
1518 |
post: {
|
1519 |
"/completions": async (request) => {
|
1520 |
request.validate("body.conversation_id", (v) => _13.isUndefined(v) || _13.isString(v)).validate("body.messages", _13.isArray).validate("headers.authorization", _13.isString);
|
@@ -1542,7 +1543,8 @@ var chat_default2 = {
|
|
1542 |
|
1543 |
// src/api/routes/ping.ts
|
1544 |
var ping_default = {
|
1545 |
-
prefix:
|
|
|
1546 |
get: {
|
1547 |
"": async () => "pong"
|
1548 |
}
|
@@ -1551,7 +1553,8 @@ var ping_default = {
|
|
1551 |
// src/api/routes/token.ts
|
1552 |
import _14 from "lodash";
|
1553 |
var token_default = {
|
1554 |
-
prefix:
|
|
|
1555 |
post: {
|
1556 |
"/check": async (request) => {
|
1557 |
request.validate("body.token", _14.isString);
|
@@ -1565,7 +1568,8 @@ var token_default = {
|
|
1565 |
|
1566 |
// src/api/routes/models.ts
|
1567 |
var models_default = {
|
1568 |
-
prefix:
|
|
|
1569 |
get: {
|
1570 |
"/models": async () => {
|
1571 |
return {
|
|
|
967 |
}
|
968 |
/**
|
969 |
* 附加路由
|
970 |
+
*
|
971 |
* @param routes 路由列表
|
972 |
*/
|
973 |
attachRoutes(routes) {
|
|
|
1004 |
}
|
1005 |
/**
|
1006 |
* 请求处理
|
1007 |
+
*
|
1008 |
* @param ctx 上下文
|
1009 |
* @param routeFn 路由方法
|
1010 |
*/
|
|
|
1514 |
|
1515 |
// src/api/routes/chat.ts
|
1516 |
var chat_default2 = {
|
1517 |
+
// prefix: '/v1/chat',
|
1518 |
+
prefix: "/hf/v1/chat",
|
1519 |
post: {
|
1520 |
"/completions": async (request) => {
|
1521 |
request.validate("body.conversation_id", (v) => _13.isUndefined(v) || _13.isString(v)).validate("body.messages", _13.isArray).validate("headers.authorization", _13.isString);
|
|
|
1543 |
|
1544 |
// src/api/routes/ping.ts
|
1545 |
var ping_default = {
|
1546 |
+
// prefix: '/ping',
|
1547 |
+
prefix: "/hf/ping",
|
1548 |
get: {
|
1549 |
"": async () => "pong"
|
1550 |
}
|
|
|
1553 |
// src/api/routes/token.ts
|
1554 |
import _14 from "lodash";
|
1555 |
var token_default = {
|
1556 |
+
// prefix: '/token',
|
1557 |
+
prefix: "/hf/token",
|
1558 |
post: {
|
1559 |
"/check": async (request) => {
|
1560 |
request.validate("body.token", _14.isString);
|
|
|
1568 |
|
1569 |
// src/api/routes/models.ts
|
1570 |
var models_default = {
|
1571 |
+
// prefix: '/v1',
|
1572 |
+
prefix: "/hf/v1",
|
1573 |
get: {
|
1574 |
"/models": async () => {
|
1575 |
return {
|
dist/index.js.map
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
src/api/routes/chat.ts
CHANGED
@@ -6,7 +6,8 @@ import chat from '@/api/controllers/chat.ts';
|
|
6 |
|
7 |
export default {
|
8 |
|
9 |
-
prefix: '/v1/chat',
|
|
|
10 |
|
11 |
post: {
|
12 |
|
|
|
6 |
|
7 |
export default {
|
8 |
|
9 |
+
// prefix: '/v1/chat',
|
10 |
+
prefix: '/hf/v1/chat',
|
11 |
|
12 |
post: {
|
13 |
|
src/api/routes/models.ts
CHANGED
@@ -2,7 +2,8 @@ import _ from 'lodash';
|
|
2 |
|
3 |
export default {
|
4 |
|
5 |
-
prefix: '/v1',
|
|
|
6 |
|
7 |
get: {
|
8 |
'/models': async () => {
|
|
|
2 |
|
3 |
export default {
|
4 |
|
5 |
+
// prefix: '/v1',
|
6 |
+
prefix: '/hf/v1',
|
7 |
|
8 |
get: {
|
9 |
'/models': async () => {
|
src/api/routes/ping.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
export default {
|
2 |
-
prefix: '/ping',
|
|
|
3 |
get: {
|
4 |
'': async () => "pong"
|
5 |
}
|
|
|
1 |
export default {
|
2 |
+
// prefix: '/ping',
|
3 |
+
prefix: '/hf/ping',
|
4 |
get: {
|
5 |
'': async () => "pong"
|
6 |
}
|
src/api/routes/token.ts
CHANGED
@@ -7,7 +7,8 @@ import logger from '@/lib/logger.ts';
|
|
7 |
|
8 |
export default {
|
9 |
|
10 |
-
prefix: '/token',
|
|
|
11 |
|
12 |
post: {
|
13 |
|
|
|
7 |
|
8 |
export default {
|
9 |
|
10 |
+
// prefix: '/token',
|
11 |
+
prefix: '/hf/token',
|
12 |
|
13 |
post: {
|
14 |
|
src/lib/server.ts
CHANGED
@@ -17,7 +17,7 @@ class Server {
|
|
17 |
|
18 |
app;
|
19 |
router;
|
20 |
-
|
21 |
constructor() {
|
22 |
this.app = new Koa();
|
23 |
this.app.use(koaCors());
|
@@ -47,7 +47,7 @@ class Server {
|
|
47 |
|
48 |
/**
|
49 |
* 附加路由
|
50 |
-
*
|
51 |
* @param routes 路由列表
|
52 |
*/
|
53 |
attachRoutes(routes: any[]) {
|
@@ -61,6 +61,7 @@ class Server {
|
|
61 |
}
|
62 |
for (let uri in route[method]) {
|
63 |
this.router[method](`${prefix}${uri}`, async ctx => {
|
|
|
64 |
const { request, response } = await this.#requestProcessing(ctx, route[method][uri]);
|
65 |
if(response != null && config.system.requestLog)
|
66 |
logger.info(`<- ${request.method} ${request.url} ${response.time - request.time}ms`);
|
@@ -68,6 +69,7 @@ class Server {
|
|
68 |
}
|
69 |
}
|
70 |
logger.info(`Route ${config.service.urlPrefix || ""}${prefix} attached`);
|
|
|
71 |
});
|
72 |
this.app.use(this.router.routes());
|
73 |
this.app.use((ctx: any) => {
|
@@ -87,7 +89,7 @@ class Server {
|
|
87 |
|
88 |
/**
|
89 |
* 请求处理
|
90 |
-
*
|
91 |
* @param ctx 上下文
|
92 |
* @param routeFn 路由方法
|
93 |
*/
|
|
|
17 |
|
18 |
app;
|
19 |
router;
|
20 |
+
|
21 |
constructor() {
|
22 |
this.app = new Koa();
|
23 |
this.app.use(koaCors());
|
|
|
47 |
|
48 |
/**
|
49 |
* 附加路由
|
50 |
+
*
|
51 |
* @param routes 路由列表
|
52 |
*/
|
53 |
attachRoutes(routes: any[]) {
|
|
|
61 |
}
|
62 |
for (let uri in route[method]) {
|
63 |
this.router[method](`${prefix}${uri}`, async ctx => {
|
64 |
+
// this.router[method]("hf" + `${prefix}${uri}`, async ctx => {
|
65 |
const { request, response } = await this.#requestProcessing(ctx, route[method][uri]);
|
66 |
if(response != null && config.system.requestLog)
|
67 |
logger.info(`<- ${request.method} ${request.url} ${response.time - request.time}ms`);
|
|
|
69 |
}
|
70 |
}
|
71 |
logger.info(`Route ${config.service.urlPrefix || ""}${prefix} attached`);
|
72 |
+
// logger.info(`Route ${config.service.urlPrefix || ""}hf${prefix} attached`);
|
73 |
});
|
74 |
this.app.use(this.router.routes());
|
75 |
this.app.use((ctx: any) => {
|
|
|
89 |
|
90 |
/**
|
91 |
* 请求处理
|
92 |
+
*
|
93 |
* @param ctx 上下文
|
94 |
* @param routeFn 路由方法
|
95 |
*/
|