Hermes + Qwen 的配置方法

概述

由于 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
相关推荐
唐老板6 分钟前
一个 FDE 怎么干过一个项目组
ai编程
字节逆旅12 小时前
我在用什么Agent IDE
ai编程
北斗星_And15 小时前
七年后再看 Android 底层:机制没变,路变短了
android·ai编程
程序员老刘15 小时前
Flutter版本选择指南:尽早升级3.47.9 | 2026年11月
flutter·ai编程·客户端
孟健16 小时前
我用 Claude Code 一句话渲出 61 秒竖屏中文动画,不花视频生成费
开源·ai编程·claude
IT规划师17 小时前
热点速递 | Anthropic 推出 Claude Ship:智能体审代码、修代码、还能批合并
ai编程
ServBay17 小时前
Claude Ship 怎么用?我提了 GitHub PR,接下来能做什么?
ai编程·claude
Yongs_PRTS21 小时前
Codex CLI 上手避坑实录:Windows/Mac 配置、config.toml 模板与 6 个高频报错排查
ai编程
大侠Luffy1 天前
用 EmbeddingGemma 2 做一个本地照片与短视频搜索工具
开源·github·ai编程