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
相关推荐
Darling噜啦啦43 分钟前
RAG 语义搜索全栈实战:用 Node.js + Embedding 从零构建智能搜索引擎
llm·ai编程
aqi001 小时前
15天学会AI应用开发(十一)从TXT文件构建RAG知识库
人工智能·python·大模型·ai编程·ai应用
shhgdxbbb11ffff1 小时前
2026最新2款AI编程工具平替实测:vibe coding全维度深度对比
ai编程
吴bug2 小时前
认识 Open-ACE — AI 编程智能体的工作空间
人工智能·ai·ai编程
丹宇码农2 小时前
基于 Top-K Logits 的 LLM 知识蒸馏实战
人工智能·ai·ai编程
HjhIron2 小时前
从 RAG 乱象到统一标准:MCP 凭什么成为 Agentic AI 的底座?
ai编程·mcp
奔跑的犀牛先生3 小时前
【AI】第一步:安装 Claude Code +Deep Seek + VScode
ai编程
@realXuan3 小时前
人工智能AI编程 Agent 入门系列教程之 Claude Code 是什么
人工智能·python·ai编程
微信开发api-视频号协议4 小时前
DevEco Code的Plan+Build
ai编程·ai写作