vue2server7 7.0.59 → 7.0.61

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2server7",
3
- "version": "7.0.59",
3
+ "version": "7.0.61",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "nodemon --watch src --ext ts --exec \"ts-node src/app.ts\"",
package/test/2.txt CHANGED
@@ -1,38 +1,107 @@
1
+ import express from "express";
2
+ import axios from "axios";
3
+
4
+ const app = express();
5
+ app.use(express.json());
6
+
7
+ // 👉 你的真实接口
8
+ const TARGET_URL =
9
+ "http://maasapp.aip.bj.bob.test:8080/apis/ais-v2/chat/completions";
10
+
11
+ // 👉 公共请求头
12
+ const BASE_HEADERS = {
13
+ Authorization: "Bearer sk-xxx",
14
+ "X-LLM-Application-Tag": "proxyai",
15
+ "Content-Type": "application/json"
16
+ };
17
+
18
+ app.post("/v1/chat/completions", async (req, res) => {
19
+ const { stream = false } = req.body;
20
+
21
+ try {
22
+ // =========================
23
+ // 🚀 流式模式(SSE)
24
+ // =========================
25
+ if (stream) {
26
+ const response = await axios({
27
+ method: "post",
28
+ url: TARGET_URL,
29
+ data: {
30
+ ...req.body,
31
+ stream: true
32
+ },
33
+ headers: BASE_HEADERS,
34
+ responseType: "stream"
35
+ });
36
+
37
+ // 👉 设置 SSE 头
38
+ res.setHeader("Content-Type", "text/event-stream");
39
+ res.setHeader("Cache-Control", "no-cache");
40
+ res.setHeader("Connection", "keep-alive");
41
+
42
+ // 👉 直接透传
43
+ response.data.on("data", (chunk) => {
44
+ res.write(chunk);
45
+ });
46
+
47
+ response.data.on("end", () => {
48
+ res.end();
49
+ });
50
+
51
+ response.data.on("error", (err) => {
52
+ console.error("❌ Stream Error:", err.message);
53
+ res.end();
54
+ });
55
+
56
+ return;
57
+ }
58
+
59
+ // =========================
60
+ // 📦 非流式
61
+ // =========================
62
+ const response = await axios.post(
63
+ TARGET_URL,
64
+ {
65
+ ...req.body,
66
+ stream: false
67
+ },
68
+ {
69
+ headers: BASE_HEADERS
70
+ }
71
+ );
72
+
73
+ res.json(response.data);
74
+ } catch (err) {
75
+ console.error("❌ Gateway Error:", err.response?.data || err.message);
76
+
77
+ res.status(500).json({
78
+ error: err.response?.data || err.message
79
+ });
80
+ }
81
+ });
82
+
83
+ app.listen(3000, () => {
84
+ console.log("✅ AI Gateway running at http://localhost:3000");
85
+ });
86
+
87
+
1
88
  name: Local Config
2
89
  version: 1.0.0
3
90
  schema: v1
4
91
 
5
92
  models:
6
- # ===== QWEN =====
7
93
  - name: qwen-chat
8
94
  provider: openai
9
- model: qwen1.5
10
- apiBase: http://127.0.0.1:8000/v1
11
- apiKey: sk-xxx
95
+ model: qwen15-32b
96
+ apiBase: http://localhost:3000/v1
97
+ apiKey: sk-dummy
12
98
  roles:
13
99
  - chat
14
100
 
15
101
  - name: qwen-autocomplete
16
102
  provider: openai
17
- model: qwen-coder
18
- apiBase: http://127.0.0.1:8000/v1
19
- apiKey: sk-xxx
20
- roles:
21
- - autocomplete
22
-
23
- # ===== DEEPSEEK =====
24
- - name: deepseek-chat
25
- provider: openai
26
- model: deepseek-chat
27
- apiBase: https://api.deepseek.com/v1
28
- apiKey: 1
29
- roles:
30
- - chat
31
-
32
- - name: deepseek-coder
33
- provider: openai
34
- model: deepseek-coder
35
- apiBase: https://api.deepseek.com/v1
36
- apiKey: 1
103
+ model: qwen15-32b
104
+ apiBase: http://localhost:3000/v1
105
+ apiKey: sk-dummy
37
106
  roles:
38
107
  - autocomplete
Binary file
Binary file