vue2server7 7.0.61 → 7.0.63
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 +1 -1
- package/test/2.txt +12 -105
package/package.json
CHANGED
package/test/2.txt
CHANGED
|
@@ -1,107 +1,14 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
88
|
-
name: Local Config
|
|
89
|
-
version: 1.0.0
|
|
90
|
-
schema: v1
|
|
1
|
+
# ~/.continue/config.yaml
|
|
91
2
|
|
|
3
|
+
name: Internal Qwen15-32B
|
|
92
4
|
models:
|
|
93
|
-
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
apiBase: http://
|
|
97
|
-
apiKey:
|
|
98
|
-
|
|
99
|
-
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
model: qwen15-32b
|
|
104
|
-
apiBase: http://localhost:3000/v1
|
|
105
|
-
apiKey: sk-dummy
|
|
106
|
-
roles:
|
|
107
|
-
- autocomplete
|
|
5
|
+
- title: "Qwen15-32B (Internal)"
|
|
6
|
+
model: "qwen15-32b"
|
|
7
|
+
provider: "openai"
|
|
8
|
+
apiBase: "http://maasapp.aip.bj.bob.test:8080/apis/ais-v2"
|
|
9
|
+
apiKey: "你的实际API密钥" # 替换为 $CUSTOM_SERVICE_API_KEY 的真实值
|
|
10
|
+
headers:
|
|
11
|
+
X-LLM-Application-Tag: "proxyai"
|
|
12
|
+
enableCaching: false
|
|
13
|
+
maxTokens: 8192 # 建议先不要设太高,避免服务端 OOM
|
|
14
|
+
temperature: 0.1
|