JSPM

glm4v-cli

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q32540F
  • License MIT

GLM-4V 视觉模型 CLI 工具 - 支持本地图片分析

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (glm4v-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    GLM-4V CLI

    GLM-4V 视觉模型命令行工具 - 支持本地图片分析

    功能特性

    • 本地图片分析(支持 jpg/png/gif/webp/bmp)
    • 配置文件管理 API 地址和 Key
    • 自定义提示词
    • JSON 格式输出
    • 自动 base64 编码

    安装

    # 克隆或下载项目
    cd glm4v-cli
    
    # 安装依赖
    npm install
    
    # 链接到全局(可选)
    npm link

    快速开始

    1. 初始化配置

    glm4v init

    2. 设置 API Key

    glm4v config --api-key your-api-key-here

    3. 分析图片

    glm4v analyze /path/to/image.jpg

    命令详解

    init - 初始化配置

    创建配置文件到 ~/.config/glm4v/config.json

    glm4v init

    config - 管理配置

    # 显示当前配置
    glm4v config --show
    
    # 设置 API Key
    glm4v config --api-key sk-xxxxxxxx
    
    # 设置自定义 API 地址
    glm4v config --api-url https://api.example.com/v1
    
    # 同时设置多个配置
    glm4v config --api-url https://api.example.com/v1 --api-key sk-xxxxxxxx

    analyze - 分析图片

    # 基本用法
    glm4v analyze ./photo.jpg
    
    # 自定义提示词
    glm4v analyze ./photo.jpg -p "这张图片里有什么文字?"
    
    # 使用不同模型
    glm4v analyze ./photo.jpg -m glm-4v-flash
    
    # 限制输出长度
    glm4v analyze ./photo.jpg -t 500
    
    # JSON 格式输出
    glm4v analyze ./photo.jpg --json
    
    # 组合选项
    glm4v analyze ./photo.png -p "描述图片风格" -t 800 --json

    配置说明

    配置文件位置: ~/.config/glm4v/config.json

    {
      "apiUrl": "https://ai.bytenote.net/v1",
      "apiKey": "your-api-key-here"
    }

    使用示例

    # 示例 1: 分析图标
    $ glm4v analyze ./icon.png
    📷 正在分析图片...
       文件: /Users/pan/Downloads/icon.png
       大小: 12.70 KB
       类型: image/png
       模型: glm-4v
    
    ✅ 分析完成
    
    🤖 GLM-4V 回答:
    这是一张应用图标,显示一个剪贴板图案...
    
    📊 Token 使用:
       - Prompt: 1674
       - Completion: 92
       - Total: 1766
    
    # 示例 2: JSON 输出
    $ glm4v analyze ./chart.png -p "分析这个图表的数据趋势" --json
    {
      "content": "该图表显示了...",
      "usage": {
        "prompt_tokens": 2156,
        "completion_tokens": 156,
        "total_tokens": 2312
      }
    }

    支持的图片格式

    • .jpg / .jpeg
    • .png
    • .gif
    • .webp
    • .bmp

    限制

    • 单张图片最大 10MB
    • 支持的图片格式见上表

    License

    MIT