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
相关推荐
彭亚川Allen12 小时前
从零手搓 RAG 之检索全流程,给大模型接上自己的知识库
前端·后端·ai编程
桃西西呀14 小时前
LangGraph4j之四:运行引擎与流式
人工智能·llm·ai编程
桃西西呀14 小时前
LangGraph4j之五:持久化与断点续跑
人工智能·llm·ai编程
threerocks14 小时前
FDE 已死!从 FDE 到 FDU:重新定义 AI 交付
aigc·openai·ai编程
用户7217465882615 小时前
三条热词通道的机制拆解:bl speech 的参数面、生效模型范围与错配读数
llm·agent·ai编程
code_Bo15 小时前
从策划到上线:我和 AI 一起做了个微信记账小程序
前端·ai编程·cursor
星始流年16 小时前
AI 时代,软件程序员未来 10—15 年的职业前景
前端·后端·ai编程
Captaincc16 小时前
# 实习生A视角来了 | 2024 年字节跳动前实习生 (Tian Keyu) 模型训练攻击事件:受害者陈述与证据整理
ai编程
挖掘狂人16 小时前
AI 一天写的代码多了 30%,软件却没多出一个
人工智能·ai编程