概述
由于 Hermes 和 Qwen 有点八字不合,所以需要加入代理去做请求的转换处理
代理脚本
js
const express = require('express');
const axios = require('axios');
const app = express();
const PORT = 8081;
const ALIBABA_API_KEY = 'sk-60cd20c34e2446c8a5985d1f86017333';
const ALIBABA_BASE_URL = 'https://dashscope.aliyuncs.com/compatible-mode/v1';
app.use(express.json());
app.post('/v1/chat/completions', async (req, res) => {
const isStream = req.body.stream === true;
try {
const alibabaRequest = {
model: req.body.model || 'qwen3.6-plus',
messages: req.body.messages,
temperature: req.body.temperature ?? 0.7,
max_tokens: req.body.max_tokens ?? 2000,
stream: isStream // 透传 stream 参数
};
const response = await axios({
method: 'POST',
url: `${ALIBABA_BASE_URL}/chat/completions`,
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${ALIBABA_API_KEY}`
},
data: alibabaRequest,
responseType: isStream ? 'stream' : 'json'
});
if (isStream) {
// 流式响应:直接转发
res.setHeader('Content-Type', 'text/event-stream');
res.setHeader('Cache-Control', 'no-cache');
res.setHeader('Connection', 'keep-alive');
response.data.pipe(res);
} else {
// 非流式响应
res.json(response.data);
}
} catch (error) {
console.error('Error:', error.message);
res.status(500).json({ error: error.message });
}
});
app.listen(PORT, () => {
console.log(`Proxy running on http://localhost:${PORT}`);
});
运行代理
node .\proxy.js
运行 hermes
hermes
Windows 下的特别处理
建议在 PowerShell 下执行
hermes chat -q "who are you"
hermes 常用指令
arduino
hermes config set model.base_url http://localhost:8080/v1
hermes config set model.provider custom
hermes config set model.api_key 你的apikey
hermes config set model.default qwen3.6-plus
hermes config set model.default qwen3-coder-next