feat(captcha): self-consistency voting, optimized prompts, no-targets signal

- Add Samples to TextOptions/GridOptions; N>1 runs N solves at temp 0.5
  and majority-votes (text: most frequent; grid: tiles in strict majority).
  N<=1 keeps the single deterministic call path unchanged.
- Add NoTargets to GridResult so callers know to click Verify instead of
  looping; prompt instructs empty tiles + no_targets:true when nothing matches.
- Grid prompt: numbered cells 0..R*C-1, select any partial overlap.
- Text prompt: disambiguate similar glyphs (0/O 1/l/I 5/S 2/Z 8/B).
- Rotation prompt: reason step-by-step then emit final JSON.
This commit is contained in:
2026-06-07 17:37:18 +01:00
parent c8edd4aa06
commit edb655f590
5 changed files with 270 additions and 11 deletions
+2 -1
View File
@@ -21,7 +21,8 @@ func SolveRotation(ctx context.Context, c llm.Client, img []byte, mediaType, ins
"You are solving a rotation/choice puzzle captcha. Instruction: %q. "+
"If asked to pick one image, return its 0-based index as choice. "+
"If asked to rotate, return the number of clockwise steps as rotations. "+
`Respond ONLY with compact JSON: {"choice":<int>,"rotations":<int>,"confidence":<0..1>}.`,
"First reason step-by-step about the correct orientation/choice, then give the final answer "+
`as the last thing you output: compact JSON {"choice":<int>,"rotations":<int>,"confidence":<0..1>}.`,
instruction)
raw, err := c.Vision(ctx, prompt, []llm.Image{{MediaType: mediaType, Data: img}}, llm.Options{})
if err != nil {