Skip to main content

Crate replysieve

Crate replysieve 

Source
Expand description

replysieve judges user comments: approve, reject or needs_review, with a reason, at light, medium or heavy strictness.

Free pre-checks (length, stock phrases, duplicates, injection markers) run first with no network call. Comments that pass go to a decision model on OpenRouter, tried model by model in the order you give.

use replysieve::{Checker, Comment, Decision, Level, Options, Reason};

let checker = Checker::new(
    Options { level: Level::Medium, ..Options::default() },
    std::env::var("OPENROUTER_API_KEY").ok(),
);

// Stock praise is rejected by a free pre-check, with no model call.
let verdict = checker.check(&Comment::new("Great product, love it!!"), &[]).await?;
assert_eq!(verdict.verdict, Decision::Reject);
assert_eq!(verdict.reason, Reason::StockPhrase);
assert_eq!(verdict.model, None);

// Anything that passes the pre-checks goes to the model.
let comment = Comment {
    title: Some("Taskly, a todo app with offline sync".into()),
    ..Comment::new("Does offline sync merge edits made on two phones?")
};
match checker.check(&comment, &[]).await {
    Ok(v) => println!("{}", serde_json::to_string(&v).unwrap()),
    Err(e) => eprintln!("{e}"), // no OPENROUTER_API_KEY set
}

Structs§

Checker
Judges comments with one set of options.
Comment
One comment to judge, with optional context about where it was posted.
Config
Contents of a replysieve config file. Every field is optional.
Options
How to judge comments.
Verdict
The judgement for one comment. Serialized as the verdict JSON.

Enums§

Decision
The outcome for one comment.
Error
Errors that stop a check before a verdict exists.
Level
How strict the built-in checks are. Custom rules apply at every level.
Preset
A built-in description of where comments are posted.
Reason
Why a verdict was reached.

Constants§

API_KEY_ENV
Environment variable holding the OpenRouter API key.
DEFAULT_BASE_URL
Default OpenRouter base URL.
DEFAULT_MODEL
The default OpenRouter decision model.

Functions§

normalize
Lower-case, keep letters and digits, collapse everything else to one space.