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
相关推荐
一只叫煤球的猫9 小时前
团队使用 Claude Code / Codex 的规范治理——献给所有全员 AI 开发的团队
人工智能·agent·ai编程
坚果派·白晓明10 小时前
【鸿蒙PC】SDL3 移植:AtomCode Skills 4 步速通多媒体库适配
c++·华为·ai编程·harmonyos·atomcode·c/c++三方库
忧云11 小时前
2026年最新 Cursor 国内使用 DeepSeek API等各模型使用完整教程
ai编程·策略模式·cursor·byok·cursor使用国内大模型
甘露s12 小时前
一文理解透MCP、Skill、Workflow的区别。
ai·ai编程
guyoung12 小时前
BoxAgnts 工具系统(7)——Skill 模板、Agent 代理与 Cron 调度
rust·agent·ai编程
自律懒人14 小时前
2026年4大AI编程CLI工具横评:Claude Code、Codex、Gemini CLI、OpenCode,实测30天差距有多大?
人工智能·ai编程
w32963627114 小时前
五、权限系统详解
ai编程·opencode
我不是外星人14 小时前
浅谈我对 AI 发展的看法
前端·ai编程·claude