npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

qwen-chat-cli

v1.4.0

Published

A command line interface for Qwen AI models

Downloads

77

Readme

Qwen Chat CLI

一个基于通义千问(Qwen)的命令行AI对话工具。

功能特性

  • 🚀 支持通义千问多种模型 (qwen-plus, qwen-max, qwen-turbo)
  • 💬 单次对话和交互式对话模式
  • 🌊 流式输出支持,实时显示AI回复
  • ⚙️ 灵活的配置管理
  • 🎨 美观的命令行界面
  • 📝 对话历史记录

安装

npm install -g qwen-chat-cli

快速开始

1. 配置API密钥

首先需要获取通义千问的API密钥,然后进行配置:

# 方法1:使用命令配置
qwen config --api-key YOUR_API_KEY

# 方法2:设置环境变量
export QWEN_API_KEY=YOUR_API_KEY

2. 基本使用

# 直接启动对话会话 (类似 Claude Code)
qwen

# 发送消息后进入对话会话
qwen "你好,介绍一下自己"

# 单次对话 (发送消息后退出)
qwen --single "你好"

# 使用流式输出
qwen -s

# 指定模型
qwen -m qwen-max

命令详解

基本命令

qwen [message] [options]

选项

  • -s, --stream: 使用流式输出
  • -m, --model <model>: 指定模型 (qwen-plus, qwen-max, qwen-turbo)
  • --single: 单次对话模式 (发送消息后退出)
  • -h, --help: 显示帮助信息
  • -V, --version: 显示版本号

配置命令

# 设置API密钥
qwen config --api-key YOUR_API_KEY

# 设置默认模型
qwen config --model qwen-max

# 查看当前配置
qwen config --show

配置方式

1. 环境变量

export QWEN_API_KEY=your_api_key_here
export QWEN_MODEL=qwen-plus
export QWEN_BASE_URL=https://dashscope.aliyuncs.com/api/v1

2. 配置文件

在用户目录下创建 .qwenrc.json

{
  "apiKey": "your_api_key_here",
  "model": "qwen-plus",
  "baseURL": "https://dashscope.aliyuncs.com/api/v1"
}

支持的模型

  • qwen-turbo: 响应速度最快
  • qwen-plus: 平衡性能和效果 (默认)
  • qwen-max: 效果最好

交互模式命令

在对话模式中,你可以使用以下斜杠命令:

  • /quit/exit: 退出程序
  • /clear: 清除对话历史
  • /help: 显示帮助信息

注意: 普通的 "exit" 或 "quit" 文本会正常发送给AI,只有以斜杠开头的命令才会触发特殊功能。

示例

直接启动对话

$ qwen
欢迎使用 Qwen AI!
输入 /quit 退出,/clear 清除历史,/help 查看帮助
当前模型: qwen-plus

You: 什么是人工智能?
Qwen: 人工智能(AI)是计算机科学的一个分支,旨在创建能够执行通常需要人类智能的任务的系统...

You: /quit
再见!

发送消息后继续对话

$ qwen "你好"
欢迎使用 Qwen AI!
当前模型: qwen-plus
You: 你好
Qwen: 您好!我是通义千问,很高兴为您服务。有什么我可以帮助您的吗?
输入 /quit 退出,/clear 清除历史,/help 查看帮助

You: 介绍一下自己
Qwen: 我是通义千问,由阿里云开发的AI助手...

You: /quit
再见!

流式输出

$ qwen -s
欢迎使用 Qwen AI!
输入 /quit 退出,/clear 清除历史,/help 查看帮助
当前模型: qwen-plus

You: 写一个Python函数计算斐波那契数列
Qwen: 好的,我来为您写一个计算斐波那契数列的Python函数:

```python
def fibonacci(n):
    """计算斐波那契数列的第n项"""
    if n <= 0:
        return 0
    elif n == 1:
        return 1
    else:
        return fibonacci(n-1) + fibonacci(n-2)

You: 我想讨论关于quit和exit的话题 Qwen: 当然可以!quit和exit都是编程中常见的退出命令...

You: /quit 再见!


## API密钥获取

1. 访问[阿里云百炼平台](https://bailian.console.aliyun.com/)
2. 注册并登录账号
3. 在控制台中创建应用
4. 获取API密钥

## 故障排除

### 常见问题

1. **API密钥无效**

错误: API密钥无效,请检查您的配置

解决方案:检查API密钥是否正确设置

2. **网络连接失败**

错误: 网络连接失败,请检查网络设置

解决方案:检查网络连接和代理设置

3. **请求频率限制**

错误: 请求过于频繁,请稍后再试

解决方案:降低请求频率,稍后重试

## 开发

```bash
# 克隆项目
git clone https://github.com/yourusername/qwen-chat-cli.git
cd qwen-chat-cli

# 安装依赖
npm install

# 开发模式运行
npm run dev

# 构建
npm run build

许可证

MIT License

贡献

欢迎提交Issue和Pull Request!

更新日志

1.2.0

  • 🎉 全新的斜杠命令系统
  • ✨ 使用 /quit 退出,避免与正常对话冲突
  • 🆕 新增 /help 命令显示帮助信息
  • 🔄 保持 /clear 清除历史功能
  • 📝 更新所有提示信息和文档

1.1.2

  • 🔧 修复API端点为正确的通义千问地址
  • 📡 更新为 compatible-mode/v1 端点

1.1.1

  • 🐛 修复chalk导入兼容性问题
  • 📦 降级到chalk v3.0.0确保稳定性

1.1.0

  • 🚀 实现Claude Code风格的默认交互模式
  • 💬 qwen 直接启动对话会话
  • 🎨 改进用户体验和界面

1.0.0

  • 🎊 初始版本发布
  • 💡 支持基本对话功能
  • 🌊 支持流式输出
  • 🔄 支持交互模式
  • ⚙️ 支持多模型切换