@chai-ui/react 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/DESIGN.md CHANGED
@@ -170,7 +170,7 @@ Rules:
170
170
  | Try again | `ResultCard`'s retry fires `onAction("retry", result)` | Re-run the **same** model call, not a different one |
171
171
  | Feedback | Like/dislike fire `onAction`, and the displayed vote comes from `getVote` | Store votes yourself |
172
172
  | Details | The flip side shows prompt, model, tokens, cost and duration | Supply `models` so ids resolve to labels |
173
- | Quality checks | Each result's `evaluations` render on the flip side: green with a check if it passed, red with a cross if it failed | Run your checks in your backend proxy and add a top-level `evaluations: [{ id, label, passed }]` field to the JSON it returns (for a stream, send it as its own `data:` chunk). The built-in Fal and OpenRouter engines read that field, a custom engine returns it from `generate`, and `useComposer` puts it on the matching `Result`. CHAI never runs or scores anything itself, and there are no confidence scores. |
173
+ | Quality checks | Each result's `evaluations` render on the flip side: green with a check if it passed, red with a cross if it failed | Run your checks in your backend proxy and add a top-level `evaluations: [{ id, label, passed }]` field to the JSON it returns (for a stream, send it as its own `data:` chunk). The built-in Fal and OpenRouter engines read that field, a custom engine returns it from `generate`, and `useComposer` puts it on the matching `Result`. Or turn on the opt-in judge: `useComposer({ judgeModel, judgeChecks })` has a model you name check each text or image result against your criteria, one tag per check, after your backend's. It's off by default, with no default model, and there are no confidence scores. |
174
174
 
175
175
  `ResultCard` is where a run ends. Don't add a "use as input" action that
176
176
  feeds a result back into a `Composer`. Chaining steps like that is
package/README.md CHANGED
@@ -206,6 +206,36 @@ with black bars:
206
206
  const { submit } = useComposer({ engine, startImageFit: "pad" }); // default "crop"
207
207
  ```
208
208
 
209
+ ### Quality checks: `evaluations`
210
+
211
+ Each result can carry pass or fail tags, shown on the ResultCard's flip
212
+ side. They come from two places, and you can use either or both:
213
+
214
+ - **Your backend:** add a top-level `evaluations: [{ id, label, passed }]`
215
+ field to the JSON your route returns (for a stream, send it as its own
216
+ `data:` chunk). The Fal and OpenRouter engines read it.
217
+ - **The opt-in judge:** a model you name checks each text or image result
218
+ against your criteria, one tag per check. It runs on the reasoning engine
219
+ (`ChaiProvider`). It's off by default, with no default model. Without
220
+ `judgeChecks` it runs one general "Matches prompt" check. What else counts
221
+ as good is up to your app.
222
+
223
+ ```tsx
224
+ const { submit } = useComposer({
225
+ engine,
226
+ judgeModel: "google/gemini-3.5-flash",
227
+ judgeChecks: [
228
+ // Your criteria, in your words. This one is an example for a marketing app's images.
229
+ { id: "on-brand", label: "On brand", criterion: "Photographic and polished, never cartoonish.", kind: "image" },
230
+ ...DEFAULT_EVALUATION_CHECKS,
231
+ ],
232
+ });
233
+ ```
234
+
235
+ The judge's prompt is `buildJudgePrompt` (exported, so you can read it).
236
+ Pass `judgePrompt` to replace it, calling `buildJudgePrompt` to add to it
237
+ rather than rewrite it.
238
+
209
239
  ### Where the bar sits: `menuPlacement`
210
240
 
211
241
  Every menu in the bar (the `+` menu, Model, Aspect ratio, Voice, Genre,
package/dist/index.d.ts CHANGED
@@ -6,6 +6,6 @@ export * from "./EditCard.js";
6
6
  export * from "./useComposer.js";
7
7
  export * from "./ChaiProvider.js";
8
8
  export * from "./useMediaAnalyzer.js";
9
- export { createFalEngine, createFalTranscriber, createOpenRouterEngine, createMockEngine, mockEngine, buildRegionEditPrompt, DEFAULT_MAX_REGIONS, PRECISE_EDIT_MODELS, ROUTING_MODEL_ID, GenerationError, DEFAULT_MEDIA_ANALYSIS_PROMPT_LENGTH, MEDIA_ANALYSIS_PROMPTS, MEDIA_ANALYSIS_PROMPT_LENGTHS, SUGGESTED_IMAGE_MODELS, SUGGESTED_TEXT_TO_VIDEO_MODELS, SUGGESTED_IMAGE_TO_VIDEO_MODELS, SUGGESTED_EDIT_MODELS, SUGGESTED_ANALYSIS_MODELS, suggestedModels, promptWithGenres, checkSuggestedModels, nextUseCases, combinesWithOthers, } from "@chai-ui/core";
10
- export type { DroppedMedia, EditRegion, Evaluation, GenerationEngine, GenerationUseCase, MediaAnalysisKind, MediaAnalysisPromptLength, MediaKind, MenuPlacement, ModelOption, OutputKind, Transcribe, VoiceClip, VoiceInputConfig, VoiceOption, ParameterOption, RegionBox, RegionFormat, Request, Result, ResultStatus, Run, SuggestedModelProblem, SuggestedModelsCheck, FalInputFormat, Usage, } from "@chai-ui/core";
9
+ export { createFalEngine, createFalTranscriber, createOpenRouterEngine, createMockEngine, mockEngine, buildRegionEditPrompt, DEFAULT_MAX_REGIONS, PRECISE_EDIT_MODELS, ROUTING_MODEL_ID, GenerationError, DEFAULT_MEDIA_ANALYSIS_PROMPT_LENGTH, MEDIA_ANALYSIS_PROMPTS, MEDIA_ANALYSIS_PROMPT_LENGTHS, SUGGESTED_IMAGE_MODELS, SUGGESTED_TEXT_TO_VIDEO_MODELS, SUGGESTED_IMAGE_TO_VIDEO_MODELS, SUGGESTED_EDIT_MODELS, SUGGESTED_ANALYSIS_MODELS, suggestedModels, promptWithGenres, checkSuggestedModels, nextUseCases, combinesWithOthers, buildJudgePrompt, DEFAULT_EVALUATION_CHECKS, } from "@chai-ui/core";
10
+ export type { DroppedMedia, EditRegion, Evaluation, EvaluationCheck, JudgePromptInput, GenerationEngine, GenerationUseCase, MediaAnalysisKind, MediaAnalysisPromptLength, MediaKind, MenuPlacement, ModelOption, OutputKind, Transcribe, VoiceClip, VoiceInputConfig, VoiceOption, ParameterOption, RegionBox, RegionFormat, Request, Result, ResultStatus, Run, SuggestedModelProblem, SuggestedModelsCheck, FalInputFormat, Usage, } from "@chai-ui/core";
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AAItC,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,oCAAoC,EACpC,sBAAsB,EACtB,6BAA6B,EAC7B,sBAAsB,EACtB,8BAA8B,EAC9B,+BAA+B,EAC/B,qBAAqB,EACrB,yBAAyB,EACzB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,EACzB,SAAS,EACT,aAAa,EACb,WAAW,EACX,UAAU,EACV,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,SAAS,EACT,YAAY,EACZ,OAAO,EACP,MAAM,EACN,YAAY,EACZ,GAAG,EACH,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,KAAK,GACN,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AAItC,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,oCAAoC,EACpC,sBAAsB,EACtB,6BAA6B,EAC7B,sBAAsB,EACtB,8BAA8B,EAC9B,+BAA+B,EAC/B,qBAAqB,EACrB,yBAAyB,EACzB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,EACzB,SAAS,EACT,aAAa,EACb,WAAW,EACX,UAAU,EACV,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,SAAS,EACT,YAAY,EACZ,OAAO,EACP,MAAM,EACN,YAAY,EACZ,GAAG,EACH,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,KAAK,GACN,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -8,5 +8,5 @@ export * from "./ChaiProvider.js";
8
8
  export * from "./useMediaAnalyzer.js";
9
9
  // Re-export the core engines and types so a consumer typically only needs
10
10
  // to import from @chai-ui/react.
11
- export { createFalEngine, createFalTranscriber, createOpenRouterEngine, createMockEngine, mockEngine, buildRegionEditPrompt, DEFAULT_MAX_REGIONS, PRECISE_EDIT_MODELS, ROUTING_MODEL_ID, GenerationError, DEFAULT_MEDIA_ANALYSIS_PROMPT_LENGTH, MEDIA_ANALYSIS_PROMPTS, MEDIA_ANALYSIS_PROMPT_LENGTHS, SUGGESTED_IMAGE_MODELS, SUGGESTED_TEXT_TO_VIDEO_MODELS, SUGGESTED_IMAGE_TO_VIDEO_MODELS, SUGGESTED_EDIT_MODELS, SUGGESTED_ANALYSIS_MODELS, suggestedModels, promptWithGenres, checkSuggestedModels, nextUseCases, combinesWithOthers, } from "@chai-ui/core";
11
+ export { createFalEngine, createFalTranscriber, createOpenRouterEngine, createMockEngine, mockEngine, buildRegionEditPrompt, DEFAULT_MAX_REGIONS, PRECISE_EDIT_MODELS, ROUTING_MODEL_ID, GenerationError, DEFAULT_MEDIA_ANALYSIS_PROMPT_LENGTH, MEDIA_ANALYSIS_PROMPTS, MEDIA_ANALYSIS_PROMPT_LENGTHS, SUGGESTED_IMAGE_MODELS, SUGGESTED_TEXT_TO_VIDEO_MODELS, SUGGESTED_IMAGE_TO_VIDEO_MODELS, SUGGESTED_EDIT_MODELS, SUGGESTED_ANALYSIS_MODELS, suggestedModels, promptWithGenres, checkSuggestedModels, nextUseCases, combinesWithOthers, buildJudgePrompt, DEFAULT_EVALUATION_CHECKS, } from "@chai-ui/core";
12
12
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AAEtC,0EAA0E;AAC1E,iCAAiC;AACjC,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,oCAAoC,EACpC,sBAAsB,EACtB,6BAA6B,EAC7B,sBAAsB,EACtB,8BAA8B,EAC9B,+BAA+B,EAC/B,qBAAqB,EACrB,yBAAyB,EACzB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,GACnB,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AAEtC,0EAA0E;AAC1E,iCAAiC;AACjC,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,oCAAoC,EACpC,sBAAsB,EACtB,6BAA6B,EAC7B,sBAAsB,EACtB,8BAA8B,EAC9B,+BAA+B,EAC/B,qBAAqB,EACrB,yBAAyB,EACzB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chai-ui/react",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Chai UI React components — smart, drop-in UI for AI apps: Composer, Media Analyzer, Result Card, and the useComposer hook.",
5
5
  "license": "MIT",
6
6
  "author": "kazarazat",
@@ -49,8 +49,8 @@
49
49
  "@fontsource/roboto": "^5.3.0",
50
50
  "@lit/react": "^1.0.8",
51
51
  "@material/web": "^2.5.0",
52
- "@chai-ui/core": "0.12.0",
53
- "@chai-ui/tokens": "0.12.0"
52
+ "@chai-ui/core": "0.13.0",
53
+ "@chai-ui/tokens": "0.13.0"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@material-symbols/svg-400": "^0.47.5",
package/src/index.ts CHANGED
@@ -33,11 +33,15 @@ export {
33
33
  checkSuggestedModels,
34
34
  nextUseCases,
35
35
  combinesWithOthers,
36
+ buildJudgePrompt,
37
+ DEFAULT_EVALUATION_CHECKS,
36
38
  } from "@chai-ui/core";
37
39
  export type {
38
40
  DroppedMedia,
39
41
  EditRegion,
40
42
  Evaluation,
43
+ EvaluationCheck,
44
+ JudgePromptInput,
41
45
  GenerationEngine,
42
46
  GenerationUseCase,
43
47
  MediaAnalysisKind,