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
相关推荐
必须会一定会1 小时前
DeepSeek API 峰谷定价实战:计算 8 月 17 日后的 Agent 成本,并启动 Harness 预览版
人工智能·ai编程
canonical_entropy1 小时前
关于《Mission Driver:Loop Engineering 的一种通用参考实现》的补充说明
后端·agent·ai编程
leeyi1 小时前
Agent 调了删库工具怎么办:5 层防线——DeepFlux 工具安全纵深防御(第84篇-E70)
aigc·agent·ai编程
plainGeekDev2 小时前
Loop —— 文档还是脚本?让 AI 自动干活的完整指南
ai编程·claude
Awna2 小时前
Superpowers 实战教程:单体服务 vs 微服务多仓库
ai编程
岛雨QA3 小时前
Claude Code接入本地大模型指南
ai编程·claude·ollama
程序员黑豆5 小时前
Java字符串常量池完全指南:原理、intern()方法与性能优化最佳实践
java·前端·ai编程
Canace5 小时前
笔记本都合上了,Claude 为什么还能在手机上执行电脑上装的技能?
前端·人工智能·ai编程
不吃辣49017 小时前
vibe coding | 如何做一个AI制图小程序?
人工智能·小程序·ai编程
kyriewen18 小时前
DeepSeek Harness开源第一天我就上手了——和Claude Code的差距比想象中大
前端·ai编程·deepseek