-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathforge-classify.test.js
More file actions
89 lines (78 loc) · 3.35 KB
/
Copy pathforge-classify.test.js
File metadata and controls
89 lines (78 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// api/_lib/forge-classify.js — prompt → model_category classifier.
//
// Pins the priority ordering (a humanoid subject wins over what it wears/rides)
// and representative coverage per category, plus the graceful 'other' fallback.
import { describe, it, expect } from 'vitest';
import { classifyModelCategory } from '../api/_lib/forge-classify.js';
describe('classifyModelCategory', () => {
it('classifies people/characters as avatar', () => {
for (const p of [
'a medieval knight in ornate armor',
'a cyberpunk woman with neon hair',
'a friendly astronaut character',
'a wizard holding a staff',
'portrait bust of an old king',
]) expect(classifyModelCategory(p)).toBe('avatar');
});
it('classifies animals/monsters as creature', () => {
for (const p of [
'a low-poly red fox, sitting',
'a fierce dragon with green scales',
'a cute cartoon octopus',
'a giant cave spider',
]) expect(classifyModelCategory(p)).toBe('creature');
});
it('classifies craft as vehicle', () => {
for (const p of [
'a sci-fi combat spaceship',
'a vintage red sports car',
'a wooden sailboat with a striped sail',
'a military tank, brushed metal',
]) expect(classifyModelCategory(p)).toBe('vehicle');
});
it('classifies places/architecture as scene', () => {
for (const p of [
'the gate of an ancient temple',
'a cozy medieval tavern interior',
'a small floating island in the clouds',
]) expect(classifyModelCategory(p)).toBe('scene');
});
it('classifies worn/wielded gear as accessory', () => {
for (const p of [
'a weathered bronze medieval helmet',
'an ornate golden crown with rubies',
'a glowing plasma sword',
'a round wooden shield with iron rim',
]) expect(classifyModelCategory(p)).toBe('accessory');
});
it('lets a person-word in a compound win for avatar (astronaut helmet → avatar)', () => {
// A prompt naming a character type is classified as that character even when
// it also names gear — a deliberate, documented priority, not a bug.
expect(classifyModelCategory('a weathered bronze astronaut helmet')).toBe('avatar');
});
it('classifies everyday objects as item', () => {
for (const p of [
'a glazed ceramic teapot',
'a small ceramic espresso cup, matte white',
'a carved wooden treasure chest',
]) expect(classifyModelCategory(p)).toBe('item');
});
it('prioritises the humanoid subject over what it holds or rides', () => {
expect(classifyModelCategory('a knight riding a horse')).toBe('avatar');
expect(classifyModelCategory('a soldier holding a rifle')).toBe('avatar');
// A creature wearing gear is still a creature (no avatar keyword present).
expect(classifyModelCategory('a dragon wearing a golden crown')).toBe('creature');
});
it('respects word boundaries (no substring false positives)', () => {
// "carpet"/"scarf" must not trip the vehicle "car" rule.
expect(classifyModelCategory('a persian carpet')).not.toBe('vehicle');
// "background" must not trip anything odd; unmatched → other.
expect(classifyModelCategory('an abstract swirl')).toBe('other');
});
it('falls back to other on empty or unmatched prompts', () => {
expect(classifyModelCategory('')).toBe('other');
expect(classifyModelCategory(null)).toBe('other');
expect(classifyModelCategory(' ')).toBe('other');
expect(classifyModelCategory('a mysterious glowing whatsit')).toBe('other');
});
});