Skip to content

feat: character categories with filter#2

Merged
BH3GEI merged 1 commit into
mainfrom
feat/02-categories
May 21, 2026
Merged

feat: character categories with filter#2
BH3GEI merged 1 commit into
mainfrom
feat/02-categories

Conversation

@BH3GEI

@BH3GEI BH3GEI commented May 21, 2026

Copy link
Copy Markdown
Member

Summary

  • Add category field to all 34 avatar presets across 6 categories (医疗健康/教育/文化艺术/劳动者/商务科技/生活)
  • New GET /api/categories endpoint returns category list
  • Frontend filter chips above avatar grid for category filtering

Test plan

  • curl /api/categories returns 6 categories
  • Filter chips render and toggle correctly
  • Avatar grid updates on category selection

- Add category field to all avatar presets (6 categories)
- Add GET /api/categories endpoint
- Frontend filter chips above avatar grid to filter by category
- "全部" chip shows all avatars (default)
Copilot AI review requested due to automatic review settings May 21, 2026 14:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class “category” support for avatar presets and exposes it end-to-end (backend API → frontend filter UI) so users can quickly filter the avatar grid by scenario/persona.

Changes:

  • Backend: adds category to preset avatar metadata and introduces GET /api/categories.
  • Frontend: renders category filter chips and filters the avatar grid based on the selected category.
  • UI styling: adds chip styles and bumps static asset cache-busting versions.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
static/style.css Adds styles for category filter container and chip states.
static/index.html Inserts the category filter container above the avatar grid; bumps asset versions.
static/app.js Fetches categories, renders filter chips, and filters avatar rendering by category.
app.py Adds category data to presets, returns category in /api/avatars, and adds /api/categories.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread static/app.js
list.innerHTML = "";
const filtered = currentCategory
? allAvatars.filter((a) => a.category === currentCategory)
: allAvatars;
Comment thread static/app.js
Comment on lines +40 to +58
const allChip = document.createElement("button");
allChip.className = "category-chip active";
allChip.textContent = "全部";
allChip.addEventListener("click", () => {
currentCategory = null;
$$(".category-chip").forEach((c) => c.classList.remove("active"));
allChip.classList.add("active");
renderAvatars();
});
container.appendChild(allChip);

cats.forEach((cat) => {
const chip = document.createElement("button");
chip.className = "category-chip";
chip.textContent = cat;
chip.addEventListener("click", () => {
currentCategory = cat;
$$(".category-chip").forEach((c) => c.classList.remove("active"));
chip.classList.add("active");
Comment thread app.py
Comment on lines +27 to +31
CATEGORIES = ["医疗健康", "教育", "文化艺术", "劳动者", "商务科技", "生活"]

PRESETS = [
{"id": "lingnan_uncle", "name": "岭南大叔", "file": "lingnan_uncle.png", "voice": "onyx", "gender": "male",
"desc": "50 岁广东老街坊", "samples": ["今天带大家品品正宗广州早茶", "来来来,饮啖茶先"]},
"category": "生活", "desc": "50 岁广东老街坊", "samples": ["今天带大家品品正宗广州早茶", "来来来,饮啖茶先"]},
@BH3GEI BH3GEI merged commit 1b009f5 into main May 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants