feat(divergence): Jev noul restatement check -> harness review nudge (#25)
This commit is contained in:
1 parent
b04aace26b
commit
dfe50da320
3 files changed
+121
No files matched your search
@@ -252,6 +252,61 @@ func (j *JevClient) ClassifyKind(ctx context.Context, text string) (string, map[
|
||||
return a.Choice, a.Probabilities, true
|
||||
}
|
||||
|
||||
// divergenceQuestions asks whether a message restates an earlier point. It is
|
||||
// a noul: JEV_STRATEGIES strategy 3 (crisp yes/no) and noul has no confidence,
|
||||
// so the probability itself is thresholded (band = threshold).
|
||||
var divergenceQuestions = map[string]any{
|
||||
"restates_earlier": map[string]any{
|
||||
"type": "noul",
|
||||
"instructions": "Does `this` make a point already made in `earlier`, adding no new angle?",
|
||||
"criteria": map[string]string{
|
||||
"true": "It repeats an earlier point without a genuinely new angle.",
|
||||
"false": "It adds something different from what `earlier` already said.",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// ClassifyDivergence returns the probability that a message restates earlier
|
||||
// ones, and ok when a value came back (noul always carries one; ok is false
|
||||
// only on transport error or a missing answer).
|
||||
func (j *JevClient) ClassifyDivergence(ctx context.Context, state any) (float64, bool) {
|
||||
if j == nil {
|
||||
return 0, false
|
||||
}
|
||||
answers, _, _, err := j.SystemOne(ctx, state, divergenceQuestions)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
a := answers["restates_earlier"]
|
||||
if a.Noul == nil {
|
||||
return 0, false
|
||||
}
|
||||
return *a.Noul, true
|
||||
}
|
||||
|
||||
// ClassifyDivergence runs the restatement check under the flock guardrails
|
||||
// (cap, timeout, flight log with the probability recorded).
|
||||
func (f *Flock) ClassifyDivergence(ctx context.Context, state any, budgets ...*Budget) (float64, bool) {
|
||||
if f.jev == nil {
|
||||
return 0, false
|
||||
}
|
||||
for _, b := range budgets {
|
||||
if err := b.Check(); err != nil {
|
||||
return 0, false
|
||||
}
|
||||
}
|
||||
f.sem <- struct{}{}
|
||||
defer func() { <-f.sem }()
|
||||
cctx, cancel := context.WithTimeout(ctx, f.g.CrowTimeout)
|
||||
defer cancel()
|
||||
start := time.Now()
|
||||
p, ok := f.jev.ClassifyDivergence(cctx, state)
|
||||
if f.log != nil {
|
||||
f.log.Write(Event{Kind: "divergence", Crow: "Sentry", Model: f.jev.model, Ms: time.Since(start).Milliseconds(), Prob: map[string]float64{"restates_earlier": p}, Note: fmt.Sprint(ok && p >= f.jev.threshold)})
|
||||
}
|
||||
return p, ok
|
||||
}
|
||||
|
||||
// ClassifyKind tags a nest message under the same guardrails as any call:
|
||||
// flock cap, timeout and flight log, with the probabilities recorded.
|
||||
func (f *Flock) ClassifyKind(ctx context.Context, text string, budgets ...*Budget) (string, map[string]float64, bool) {
|
||||
|
||||
Reference in new issue
Block a user