@brizz/sdk 0.1.33 → 0.1.34

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/README.md CHANGED
@@ -536,12 +536,51 @@ await startSession(sessionId, async () => {
536
536
  });
537
537
  ```
538
538
 
539
- Only `type` is required; `score`, `reason`, `comment`, and `source` are optional, and `traits` adds free-form `brizz.feedback.<key>` entries. Feedback is anchored by `messageId` and/or `sessionId`, so you can send it later — even minutes or days after the reply — by passing the id(s) explicitly:
539
+ Only `type` is required; `score`, `reason`, `comment`, and `source` are optional, and `attributes` adds free-form `brizz.feedback.<key>` entries. Feedback is anchored by `messageId` and/or `sessionId`, so you can send it later — even minutes or days after the reply — by passing the id(s) explicitly:
540
540
 
541
541
  ```typescript
542
542
  recordFeedback('thumbs_down', { messageId: message.id, sessionId, reason: 'inaccurate' });
543
543
  ```
544
544
 
545
+ ### Recording Metrics
546
+
547
+ Report a number your own system already computes about an interaction — an eval score, a customer rating, a latency, a cost. It becomes a real Brizz metric you can filter and chart by, rather than an untyped bag of event attributes.
548
+
549
+ ```typescript
550
+ import { startSession, recordMetric } from '@brizz/sdk';
551
+
552
+ await startSession(sessionId, async () => {
553
+ const reply = await agent.run(prompt);
554
+
555
+ const score = await myEvaluator.score(prompt, reply);
556
+ recordMetric({
557
+ name: 'quality_score',
558
+ value: score,
559
+ unit: 'score',
560
+ minValue: 0,
561
+ maxValue: 1,
562
+ polarity: 'positive',
563
+ });
564
+ });
565
+ ```
566
+
567
+ `polarity` tells Brizz which direction is good — a rising `quality_score` is an improvement, a rising `hallucination_rate` is a regression. `minValue` / `maxValue` describe the scale, so a 4 out of 5 isn't read as a 4 out of 1.
568
+
569
+ Scoring often happens after the fact. Pass `sessionId` to attach a metric from anywhere, and `timestamp` to say *when the measured thing happened*, so a nightly job lands the score on the turn it describes rather than on the evaluation run:
570
+
571
+ ```typescript
572
+ recordMetric({
573
+ name: 'quality_score',
574
+ value: await judge.score(session),
575
+ sessionId: session.id,
576
+ timestamp: session.endedAt,
577
+ comment: 'graded by the nightly LLM judge',
578
+ attributes: { evaluator: 'gpt-4o', rubric: 'v2' },
579
+ });
580
+ ```
581
+
582
+ `attributes` are flat labels you can slice the metric by. Re-reporting the same metric supersedes the previous value, so a re-score wins over the original.
583
+
545
584
  ### Custom Properties
546
585
 
547
586
  Add custom properties to telemetry context:
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  INTERRUPT_TOOLS
3
- } from "./chunk-GRRKMMG6.js";
3
+ } from "./chunk-QY4VADPP.js";
4
4
 
5
5
  // src/internal/instrumentation/vercel-ai/interrupt.ts
6
6
  import { trace } from "@opentelemetry/api";