Skip to content

Commit 9f6e094

Browse files
committed
feat: update API proxy configuration and enhance model size limit
1 parent d8f92f3 commit 9f6e094

6 files changed

Lines changed: 63 additions & 39 deletions

File tree

frontend/vite.config.ts

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from "vite";
1+
import {defineConfig} from "vite";
22
import react from "@vitejs/plugin-react";
33
import tailwindcss from "@tailwindcss/vite";
44
import path from "path"; // 需要安装 Node.js 的类型声明(@types/node)
@@ -12,30 +12,55 @@ export default defineConfig({
1212
},
1313
},
1414
server: {
15-
// headers: {
16-
// "Access-Control-Allow-Origin": "*",
17-
// "access-control-allow-headers":
18-
// "Origin, X-Requested-With, Content-Type, Accept",
19-
// },
20-
proxy: {
21-
"^/api": {
22-
target: "http://localhost:8080", // 本地后端服务地址
15+
host: "0.0.0.0",
16+
proxy: (() => {
17+
const pythonProxyConfig = {
18+
target: "http://localhost:18000",
2319
changeOrigin: true,
2420
secure: false,
25-
rewrite: (path) => path.replace(/^\/api/, "/api"),
26-
configure: (proxy, options) => {
27-
// proxy 是 'http-proxy' 的实例
28-
proxy.on("proxyReq", (proxyReq, req, res) => {
29-
// 可以在这里修改请求头
30-
proxyReq.removeHeader("referer");
31-
proxyReq.removeHeader("origin");
21+
configure: (proxy: { on: (event: string, handler: (arg: unknown) => void) => void }) => {
22+
proxy.on("proxyReq", (proxyReq: unknown) => {
23+
(proxyReq as { removeHeader: (name: string) => void }).removeHeader("referer");
24+
(proxyReq as { removeHeader: (name: string) => void }).removeHeader("origin");
3225
});
33-
proxy.on("proxyRes", (proxyRes, req, res) => {
34-
delete proxyRes.headers["set-cookie"];
35-
proxyRes.headers["cookies"] = ""; // 清除 cookies 头
26+
proxy.on("proxyRes", (proxyRes: unknown) => {
27+
const res = proxyRes as { headers: Record<string, unknown> };
28+
delete res.headers["set-cookie"];
29+
res.headers["cookies"] = "";
3630
});
3731
},
38-
},
39-
},
32+
};
33+
34+
const javaProxyConfig = {
35+
target: "http://localhost:8080",
36+
changeOrigin: true,
37+
secure: false,
38+
configure: (proxy: { on: (event: string, handler: (arg: unknown) => void) => void }) => {
39+
proxy.on("proxyReq", (proxyReq: unknown) => {
40+
(proxyReq as { removeHeader: (name: string) => void }).removeHeader("referer");
41+
(proxyReq as { removeHeader: (name: string) => void }).removeHeader("origin");
42+
});
43+
proxy.on("proxyRes", (proxyRes: unknown) => {
44+
const res = proxyRes as { headers: Record<string, unknown> };
45+
delete res.headers["set-cookie"];
46+
res.headers["cookies"] = "";
47+
});
48+
},
49+
};
50+
51+
// Python 服务: rag, synthesis, annotation, evaluation, models
52+
const pythonPaths = ["rag", "synthesis", "annotation", "data-collection", "evaluation", "models"];
53+
// Java 服务: data-management, knowledge-base
54+
const javaPaths = ["data-management", "knowledge-base", "operators"];
55+
56+
const proxy: Record<string, object> = {};
57+
for (const p of pythonPaths) {
58+
proxy[`/api/${p}`] = pythonProxyConfig;
59+
}
60+
for (const p of javaPaths) {
61+
proxy[`/api/${p}`] = javaProxyConfig;
62+
}
63+
return proxy;
64+
})(),
4065
},
4166
});

runtime/datamate-python/app/db/models/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
class Models(BaseEntity):
7-
"""模型配置表,对应表 t_models
7+
"""模型配置表,对应表 t_models。模型为系统级配置,RAG/生成等按 ID 引用时不受数据权限过滤。
88
99
CREATE TABLE IF NOT EXISTS t_models (
1010
id VARCHAR(36) PRIMARY KEY COMMENT '主键ID',

runtime/datamate-python/app/module/system/interface/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def get_providers(svc: ModelsService = Depends()):
2323
@router.get("/list", response_model=StandardResponse[PaginatedData[ModelsResponse]])
2424
async def get_models(
2525
page: int = Query(0, ge=0, description="页码,从 0 开始"),
26-
size: int = Query(20, gt=0, le=500, description="每页大小"),
26+
size: int = Query(20, gt=0, le=2000, description="每页大小"),
2727
provider: str | None = Query(None, description="模型提供商"),
2828
type: ModelType | None = Query(None, description="模型类型"),
2929
isEnabled: bool | None = Query(None, description="是否启用"),

runtime/datamate-python/app/module/system/schema/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class QueryModelRequest(BaseModel):
3535
model_config = ConfigDict(str_strip_whitespace=True, extra="forbid")
3636

3737
page: int = Field(0, ge=0, description="页码,从 0 开始")
38-
size: int = Field(20, gt=0, le=500, description="每页大小")
38+
size: int = Field(20, gt=0, le=2000, description="每页大小")
3939
provider: Optional[str] = Field(None, description="模型提供商")
4040
type: Optional[ModelType] = Field(None, description="模型类型")
4141
isEnabled: Optional[bool] = Field(None, description="是否启用")

runtime/ops/README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class YourOperatorName(Mapper):
178178
"""
179179
算子类名建议使用驼峰命名法定义,例如 TestMapper
180180
"""
181-
181+
182182
def __init__(self, *args, **kwargs):
183183
super().__init__(*args, **kwargs)
184184
self.slider_param = float(kwargs.get("sliderParam", 0.5))
@@ -188,7 +188,7 @@ class YourOperatorName(Mapper):
188188
self.range_param = kwargs.get('rangeParam', [0, 0])
189189
self.checkbox_param = kwargs.get('checkboxParam', [])
190190
self.input_param = kwargs.get('inputParam', '').strip()
191-
191+
192192
def execute(self, sample: Dict[str, Any]) -> Dict[str, Any]:
193193
"""
194194
核心处理逻辑
@@ -199,7 +199,7 @@ class YourOperatorName(Mapper):
199199
# input_text = sample['text']
200200
# processed_text = do_something(input_text)
201201
# sample['text'] = processed_text
202-
202+
203203
return sample
204204
205205
```
@@ -208,14 +208,14 @@ class YourOperatorName(Mapper):
208208

209209
```json
210210
{
211-
"text": "文本内容",
212-
"data": "二进制数据",
213-
"fileName": "文件名",
214-
"fileType": "文件类型(扩展名)",
215-
"fileId": "文件ID",
216-
"filePath": "文件路径",
217-
"fileSize": "文件大小",
218-
"export_path": "导出路径信息",
211+
"text": "源文件读取的文本内容",
212+
"data": "源文件读取的二进制数据(针对图片等)",
213+
"fileName": "源文件名",
214+
"fileType": "源文件类型(扩展名)",
215+
"fileId": "源文件ID",
216+
"filePath": "源文件路径",
217+
"fileSize": "源文件大小",
218+
"export_path": "目标文件导出路径信息",
219219
"ext_params": "额外扩展参数",
220220
"target_type": "目标文件类型"
221221
}
@@ -242,7 +242,7 @@ from datamate.core.base_op import OPERATORS
242242
243243
# 假设 process.py 位于 operator_package 目录下
244244
OPERATORS.register_module(
245-
module_name='YourOperatorName',
245+
module_name='YourOperatorName',
246246
module_path="ops.user.operator_package.process"
247247
)
248248
@@ -273,7 +273,7 @@ OPERATORS.register_module(
273273

274274
```python
275275
OPERATORS.register_module(
276-
module_name='TestMapper',
276+
module_name='TestMapper',
277277
# 这里 ops.user.my_custom_op.process 中的 'my_custom_op' 为包目录名
278278
module_path="ops.user.my_custom_op.process"
279279
)

scripts/db/setting-management-init.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ BEGIN
5252
END;
5353
$$ language 'plpgsql';
5454

55-
DROP TRIGGER IF EXISTS update_t_model_config_updated_at ON t_models;
56-
CREATE TRIGGER update_t_model_config_updated_at
55+
CREATE TRIGGER update_t_models_updated_at
5756
BEFORE UPDATE ON t_models
5857
FOR EACH ROW
5958
EXECUTE FUNCTION update_updated_at_column();

0 commit comments

Comments
 (0)