A tutorial architecture that enables any chatbot to automatically select and send stickers by pre-processing images with a vision model once and storing text descriptions for zero-cost retrieval at runtime.

Stars

21

7-day growth

No data

Forks

4

Open issues

0

License

MIT

Last updated

2026-06-29

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

It solves the token cost and latency problem of having a vision model analyze every sticker candidate per message, while providing a flexible, platform-agnostic blueprint that includes practical pitfalls and fixes from real implementation.

Who it is for

  • Chatbot developers integrating sticker support
  • AI assistant builders on platforms like Telegram or Discord
  • Developers of customer service auto-reply systems
  • Hobbyists building AI companion applications

Use cases

  • Adding contextual sticker replies to a webchat AI assistant
  • Building a Telegram bot that sends the right meme based on conversation mood
  • Creating an AI companion that reacts with appropriate emotes without vision costs
  • Enabling a customer service bot to send friendly stickers in support chats

Strengths

  • Drastically reduces token usage by never re-scanning images after initial storage
  • Clear, modular architecture that works with any vision model and any platform
  • Includes detailed, real-world pitfalls (e.g., Telegram public URL requirement, multi-byte chunking) that save implementation time
  • Open-source MIT license allows free use and modification

Considerations

  • Not a plug-and-play product; requires manual backend integration and adaptation to specific platforms
  • Depends on an external vision model API for initial description generation (costs still apply once per upload)
  • Sticker image URLs must be publicly accessible without authentication, which may conflict with private storage or security policies

README quick start

ai-sticker-pack · 让聊天机器人「自己会挑表情包发」

给任意聊天机器人(bot / AI 助手 / 自动回复)加一套会按场景自己挑、自己发的表情包能力。 核心只有一句:

上传那一刻让视觉模型看一眼图、自动写好「名字 + 描述」存起来;之后机器人只读这段文字来挑表情,永远不再看图。

这样"挑表情"几乎不花 token(不走视觉),而你扩充表情库无痛——传张图、AI 自动配描述、入库,完事。

这是一份「思路」教程,不是即插即用的成品。 能搬走的是这套架构踩过的坑。你的后端用什么语言、机器人在哪个平台(网页 / Telegram / Discord…)、用哪个视觉模型——都按你自己的来。下面的代码片段全是示例,照着改成你自己的就行。当灵感看,别当模板。


为什么这么做

想让机器人会发表情包,有两个天然难点:

  1. 机器人"看不懂"图。 一堆抽象梗图(尤其带文字的中文表情包),机器人不知道每张啥意思、啥时候该发。
  2. 每次都让它"看图"太贵也太慢。 如果每条消息都把候选表情图喂给视觉模型判断,token 烧得飞起,还慢。

这个项目的办法:把"理解图"和"使用图"拆开——

  • 理解只做一次:上传时,视觉模型看一眼,写出「短名 + 一句话描述(图上文字 / 情绪 / 啥场景发)」,连同图 URL 存进库。
  • 使用零成本:之后把库里的「名字 + 描述」(纯文字、很短)注进机器人的 prompt;它想发就在回复里写个标记 [sticker:名字];后端拦下标记 → 换成图发出去。机器人从不重新看图
  上传一张图
      │
      ▼
 视觉模型看一次 ──► 「名字|描述」── 连同图URL ──► 表情库(表/JSON)
                                                      │
              ┌───────────────────────────────────────┘
              ▼  (只把 名字+描述 这段文字注进 prompt,很省)
        机器人生成回复: "哈哈哈 [sticker:得意]"
              │
              ▼  后端拦标记
     网页前端 → 渲染 
     Telegram → sendPhoto(图URL)

四块拼图

1) 表情库(一张表就够)

CREATE TABLE stickers (
  id    TEXT PRIMARY KEY,
  name  TEXT NOT NULL,   -- 机器人引用名,如「得意」
  url   TEXT NOT NULL,   -- 图片直链(自己图床 / 公开 URL)
  descr TEXT             -- AI 自动写的:图上文字 + 情绪/梗 + 啥时候发
);

2) 上传即「自动描述」(一次性视觉)

上传后,把图(base64 data URL)发给任意 OpenAI 兼容的视觉模型,让它返回「名字|描述」:

// 伪代码 / 示例:上传后调一次视觉模型
async function describeSticker(imageBase64) {
  const prompt =
    '这是一张表情包。先起个3-6字短名(梗/情绪关键词,好记、能当引用名),' +
    '再写一句话描述(图上文字 + 表达的情绪/梗 + 什么场景下适合发)。' +
    '严格用这一行格式回复:名字|描述';

  const r = await fetch(YOUR_OPENAI_COMPATIBLE_ENDPOINT, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', Authorization: 'Bearer ' + YOUR_KEY },
    body: JSON.stringify({
      model: YOUR_VISION_MODEL,                 // 任意能看图的便宜模型即可
      messages: [{
        role: 'user',
        content: [
          { type: 'text', text: prompt },
          { type: 'image_url', image_url: { url: 'data:image/png;base64,' + imageBase64 } },
        ],
      }],
      max_tokens: 200,
    }),
  }).then((x) => x.json());

  const line = r.choices?.[0]?.message?.content?.trim() || '';
  const i = line.indexOf('|');
  return i > 0 ? { name: line.slice(0, i).trim(), desc: line.slice(i + 1).trim() } : { name: '', desc: line };
}

关键:**这步只在上传时跑一

Description

上传表情包 → AI 自动写描述 → 聊天机器人按场景自己挑着发(含双向发送 / 多端渲染 / 踩坑思路)

Related repositories

Similar projects matched by category, topics, and programming language.

MoonshotAI
Featured
MoonshotAI GitHub avatar

Kimi-K3

Kimi K3 is an open-weight, 2.8T-parameter native multimodal agentic model with a 1M-token context window, designed for frontier coding, knowledge work, and reasoning tasks.

AI & Machine LearningAI Agents
3,348
xuchonglang
Featured
xuchonglang GitHub avatar

investing-for-beginners

A structured investing guide for Chinese beginners covering US stocks, options, and cryptocurrency, with focus on foundational concepts and risk awareness.

Blockchain & Web3
2,739
Krishnagangwal
Featured
Krishnagangwal GitHub avatar

CS-Fundamentals

A curated collection of Computer Science fundamentals (PDFs, notes, cheatsheets, interview question banks) for placement preparation, covering seven core subjects plus general resources.

Data & DatabasesDatabases & Storage
2,326