-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpromptfooconfig.predict.yaml
More file actions
250 lines (228 loc) · 9.13 KB
/
Copy pathpromptfooconfig.predict.yaml
File metadata and controls
250 lines (228 loc) · 9.13 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
description: |
/predict endpoint eval — full pipeline: categorize → blend → pools →
cache → personalization. Hits the running uvicorn server on :8900.
Per-case llm-rubric checks the surfaced `words` array makes sense for
an AAC kid (kid-safe, lowercase, single words, grammatically following).
Run:
# 1. Start the backend in another terminal: ./start.sh
# 2. Then:
OPENROUTER_KEY=<your_key> \
npx promptfoo@latest eval -c promptfooconfig.predict.yaml
prompts:
- id: predict-body
raw: |
{"sentence": {{sentence_json}}, "n": 8}
providers:
- id: http://localhost:8900/predict
config:
url: http://localhost:8900/predict
method: POST
headers:
Content-Type: application/json
body:
sentence: '{{sentence_json}}'
n: 8
transformResponse: |
json.words ? json.words.join(", ") : JSON.stringify(json)
defaultTest:
options:
provider:
id: openai:chat:gpt-4o-mini
config:
apiBaseUrl: https://openrouter.ai/api/v1
apiKeyEnvar: OPENROUTER_KEY
headers:
HTTP-Referer: http://localhost
X-Title: aac-rubric
assert:
- type: javascript
value: |
// Output is a comma-separated list of 8 lowercase single tokens.
const words = output.split(",").map(s => s.trim()).filter(Boolean);
if (words.length < 6) return { pass: false, reason: `only ${words.length} words returned` };
for (const w of words) {
if (w !== w.toLowerCase()) return { pass: false, reason: `non-lowercase: ${w}` };
if (!/^[a-z']+$/.test(w)) return { pass: false, reason: `non-alpha word: ${w}` };
}
const set = new Set(words);
if (set.size < words.length) return { pass: false, reason: "duplicates in output" };
return true;
tests:
- description: 'empty sentence — sentence-starters'
vars:
sentence_json: "[]"
assert:
- type: llm-rubric
value: |
The output is a comma-separated list of single lowercase words.
For an empty sentence, MOST words MUST be plausible sentence-starters
for an 11-year-old AAC user: things like "i", "you", "we", "let's",
"can", "where", "what", "the", "my", "hi", "yes", "no".
NO unusual or overly complex words.
- description: 'bare "i" — verbs and "am" / "want"'
vars:
sentence_json: '["i"]'
assert:
- type: llm-rubric
value: |
Each word MUST be one that can grammatically follow "i" in a kid sentence:
base verbs (want, need, like, love, hate, see, have, play, feel),
contractions/auxiliaries (am, will, can), or short connectors.
NO bare nouns ("i pizza" is wrong). NO -ing verbs without "am".
At least 4 of the 8 should be common kid verbs.
- description: 'sentence "i want"'
vars:
sentence_json: '["i", "want"]'
assert:
- type: llm-rubric
value: |
Each word MUST grammatically follow "i want": "to" (very common),
"a", "the", "my", "more", "some", or a noun (food/thing/game).
The list SHOULD include "to". MUST NOT include another verb in
base form (e.g. "play" without "to" first is awkward but acceptable
since AAC kids stack words; reject only if MAJORITY are bare verbs).
- description: 'sentence "i want to"'
vars:
sentence_json: '["i", "want", "to"]'
assert:
- type: llm-rubric
value: |
Every word MUST be a base-form verb that an 11-year-old says:
play, eat, go, see, have, build, watch, read, draw, sleep, etc.
NO -ing verbs. NO nouns. NO function words like "to"/"a"/"the".
- description: "sentence \"i'm super\""
vars:
sentence_json: "[\"i'm\", \"super\"]"
assert:
- type: llm-rubric
value: |
Every word MUST be an adjective Adrian could pair with "super":
tired, cool, hungry, scared, happy, mad, fast, strong, awesome,
excited, bored, etc. NO verbs. NO nouns. NO "super" itself.
- description: '"i''m super tired" — sentence-end / connectors'
vars:
sentence_json: "[\"i'm\", \"super\", \"tired\"]"
assert:
- type: llm-rubric
value: |
The list MUST be dominated by connectors/sentence-end markers:
"and", "but", "so", "now", "today", "too", or possibly an adverb.
MUST NOT include game names, food, or new objects (no second clause-content yet).
Reject if any word looks like a fresh subject/object.
- description: '"i love minecraft" — conjunction next, NOT another game'
vars:
sentence_json: '["i", "love", "minecraft"]'
assert:
- type: llm-rubric
value: |
The list MUST include "and" (very high priority for chaining).
The list MUST NOT include another game name (roblox, sonic, fortnite,
chess, etc) — that would be ungrammatical or unnatural after a
completed S-V-O.
Acceptable: and, but, so, with, too, now, today, please.
- description: '"i don''t like" — object slot'
vars:
sentence_json: "[\"i\", \"don't\", \"like\"]"
assert:
- type: llm-rubric
value: |
Each word MUST be something a kid could DISLIKE: a game, food,
activity, person, or demonstrative ("this", "that", "it").
MUST NOT include another negation ("not", "no", "don't").
MUST NOT be only verbs.
- description: 'sentence "the creeper is"'
vars:
sentence_json: '["the", "creeper", "is"]'
assert:
- type: llm-rubric
value: |
Each word MUST grammatically follow "is": -ing verbs (coming,
chasing, exploding, attacking), adjectives (scary, green, fast,
dangerous), or "super" / "really" intensifiers.
NO base-form verbs (no "run", "jump"). NO bare nouns.
- description: "sentence \"let's go to the\""
vars:
sentence_json: "[\"let's\", \"go\", \"to\", \"the\"]"
assert:
- type: llm-rubric
value: |
Each word MUST be a place or thing-as-destination an 11-year-old
might pick: park, beach, store, mall, library, school, kitchen,
bathroom, pool, game, movies, etc.
MUST NOT include verbs, "the" again, or "a".
- description: 'sentence "where is"'
vars:
sentence_json: '["where", "is"]'
assert:
- type: llm-rubric
value: |
Each word MUST be a noun/pronoun/determiner that fits "where is X":
mom, dad, the (+noun), my, it, that, this, your, our, plus people
/ things / places. NO verbs. NO conjunctions.
- description: 'sentence "can we"'
vars:
sentence_json: '["can", "we"]'
assert:
- type: llm-rubric
value: |
Each word MUST be a base verb a kid would request: play, go, eat,
watch, build, make, have, see, get, try.
NO past-tense or -ing forms. NO nouns.
- description: 'sentence "i feel"'
vars:
sentence_json: '["i", "feel"]'
assert:
- type: llm-rubric
value: |
Each word MUST be an adjective or feeling word: happy, sad, mad,
tired, hungry, sick, good, bad, scared, super (intensifier),
really, so. NO verbs. NO nouns.
- description: 'sentence "you are"'
vars:
sentence_json: '["you", "are"]'
assert:
- type: llm-rubric
value: |
Each word MUST follow "you are" naturally: adjectives (cool, mean,
funny, awesome, super), -ing verbs (going, coming, playing), or
role nouns (mom, dad, my, the +noun).
NO base verbs in raw form ("you are play" is wrong).
- description: '"and" mid-sentence — new clause start'
vars:
sentence_json: '["i", "love", "chess", "and"]'
assert:
- type: llm-rubric
value: |
A new clause is beginning. Words SHOULD be subjects ("i", "we",
"you", "it"), or another game/thing being added to the love-list,
or a new verb-phrase opener.
MUST NOT include another conjunction ("and", "but", "or", "so").
- description: 'question form "what do you"'
vars:
sentence_json: '["what", "do", "you"]'
assert:
- type: llm-rubric
value: |
Each word MUST be a base-form verb that completes a kid question:
want, like, need, see, have, do, think, mean, say.
NO nouns. NO -ing verbs.
- description: 'sentence "my mom is"'
vars:
sentence_json: '["my", "mom", "is"]'
assert:
- type: llm-rubric
value: |
Each word MUST be an adjective, -ing verb, or role noun that fits
after "is": cool, busy, sleeping, working, here, home, the +noun,
super (intensifier).
NO base verbs.
- description: 'empty followed by Adrian-favorite proper-noun bias'
vars:
sentence_json: '["i", "love"]'
assert:
- type: llm-rubric
value: |
The list MUST include at least one game or character Adrian likes:
minecraft, roblox, chess, sonic, batman, OR a noun like "you",
"mom", "dad", or food/animal.
NO bare verbs (the slot after "love" wants a thing, not an action).