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

@ai-rpg-engine/image-gen

v2.0.7

Published

Headless image generation pipeline — portrait prompts, provider abstraction, and asset storage for AI RPG Engine

Readme

@ai-rpg-engine/image-gen

npm License: MIT

用于 AI RPG Engine 的无头人物肖像生成流水线,具有提供商抽象功能。

安装

npm install @ai-rpg-engine/image-gen

功能

将角色元数据(原型、背景、特征、专长)转换为生成提示,将其发送到可插拔的图像提供商,并将结果存储在资源注册表中。 包含一个零依赖的占位符提供商和一个用于本地 GPU 生成的 ComfyUI 提供商。

用法

生成肖像(占位符)

import { PlaceholderProvider, generatePortrait, buildPortraitPrompt } from '@ai-rpg-engine/image-gen';
import { MemoryAssetStore } from '@ai-rpg-engine/asset-registry';

const provider = new PlaceholderProvider();
const store = new MemoryAssetStore();

const meta = await generatePortrait({
  characterName: 'Aldric',
  archetypeName: 'Penitent Knight',
  backgroundName: 'Oath-Breaker',
  traits: ['Iron Frame', 'Cursed Blood'],
  title: 'Grave Warden',
  tags: ['martial', 'oath-broken', 'curse-touched'],
  genre: 'fantasy',
}, provider, store);

// meta.hash is the portraitRef for CharacterBuild
console.log(meta.hash);  // SHA-256 content address

使用 ComfyUI(本地 GPU)生成

import { ComfyUIProvider, generatePortrait } from '@ai-rpg-engine/image-gen';
import { FileAssetStore } from '@ai-rpg-engine/asset-registry';

const provider = new ComfyUIProvider({
  baseUrl: 'http://localhost:8188',
  checkpoint: 'sd_xl_base_1.0.safetensors',
});

if (await provider.isAvailable()) {
  const store = new FileAssetStore('./assets');
  const meta = await generatePortrait(request, provider, store, {
    generation: { width: 512, height: 512, steps: 20, cfgScale: 7 },
  });
}

手动构建提示

import { buildPortraitPrompt, buildNegativePrompt } from '@ai-rpg-engine/image-gen';

const prompt = buildPortraitPrompt(request);
// "Portrait of Aldric, Grave Warden, Penitent Knight and Occultist, Oath-Breaker origin, known for being Iron Frame and Cursed Blood, dark fantasy oil painting, dramatic lighting..."

const negative = buildNegativePrompt(request);
// "modern clothing, technology, cartoon, anime, blurry, deformed"

确保肖像(去重)

import { ensurePortrait } from '@ai-rpg-engine/image-gen';

// Generates only if no matching portrait exists in the store
const meta = await ensurePortrait(request, provider, store);

提供商

| 提供商 | 后端 | 依赖项 | 使用场景 | |----------|---------|------|----------| | PlaceholderProvider | 带有首字母的 SVG | 无 | 测试、开发 | | ComfyUIProvider | ComfyUI HTTP API | ComfyUI 服务器 | 本地 GPU 生成 |

自定义提供商

实现 ImageProvider 接口:

import type { ImageProvider, GenerationResult, GenerationOptions } from '@ai-rpg-engine/image-gen';

class MyProvider implements ImageProvider {
  readonly name = 'my-provider';

  async generate(prompt: string, opts?: GenerationOptions): Promise<GenerationResult> {
    // Your generation logic here
  }

  async isAvailable(): Promise<boolean> {
    return true;
  }
}

风格预设

内置 9 个类型的风格预设:

| 类型 | 风格 | |-------|-------| | 奇幻 | 黑暗奇幻油画,戏剧性光照 | | 赛博朋克 | 霓虹灯,铬合金和皮革,高对比度 | | 神秘 | 维多利亚时代黑色电影,煤气灯氛围,雾气和阴影 | | 海盗 | 黄金时代的航海,风化的纹理 | | 恐怖 | 黑暗插图,柔和的、饱和度低的调色板 | | 西部 | 怪异西部油画,尘土飞扬的边境 | | 科幻 | 概念艺术,未来主义的场景,电影感 | | 后末日 | 废弃的城市,生存装备,粗糙的纹理 | | 历史 | 符合时代,经典的构图 |

集成

comfy-headless 配合使用,可增强提示智能,并在您的本地 GPU 上进行视频生成。

AI RPG Engine 的一部分

此软件包是 AI RPG Engine 单一代码仓库的一部分。 依赖于 @ai-rpg-engine/asset-registry 进行存储。

许可证

MIT