| Crates.io | product-farm-llm-evaluator |
| lib.rs | product-farm-llm-evaluator |
| version | 0.2.0 |
| created_at | 2026-01-04 01:30:10.220672+00 |
| updated_at | 2026-01-04 01:30:10.220672+00 |
| description | LLM-based rule evaluation for Product-FARM |
| homepage | |
| repository | https://github.com/ayushmaanbhav/product-farm |
| max_upload_size | |
| id | 2021131 |
| size | 242,092 |
LLM-powered rule evaluation for complex business logic that's hard to express in traditional rules.
Some business rules are too complex or nuanced to express in traditional rule engines. product-farm-llm-evaluator bridges this gap by using Large Language Models to evaluate rules described in natural language.
Example use cases:
This crate is part of Product-FARM, an enterprise-grade rule engine featuring:
[dependencies]
product-farm-llm-evaluator = { version = "0.2", features = ["anthropic"] }
# or
product-farm-llm-evaluator = { version = "0.2", features = ["ollama"] }
# or both
product-farm-llm-evaluator = { version = "0.2", features = ["all-providers"] }
use product_farm_llm_evaluator::{ClaudeEvaluator, RuleEvaluationContext};
let evaluator = ClaudeEvaluator::new(
"your-api-key",
"claude-sonnet-4-20250514",
)?;
let context = RuleEvaluationContext {
rule_description: "Determine if the refund request is reasonable".into(),
input_data: serde_json::json!({
"purchase_date": "2024-01-15",
"request_date": "2024-01-20",
"reason": "Product arrived damaged, photos attached",
"amount": 49.99
}),
expected_output_type: OutputType::Boolean,
constraints: vec!["Consider standard 30-day return policy".into()],
};
let result = evaluator.evaluate(&context).await?;
// result.value = true (refund approved)
// result.confidence = 0.95
// result.reasoning = "Request is within policy window and damage is documented"
use product_farm_llm_evaluator::{OllamaEvaluator, RuleEvaluationContext};
let evaluator = OllamaEvaluator::new(
"http://localhost:11434",
"llama3.2",
)?;
let result = evaluator.evaluate(&context).await?;
# Anthropic
export RULE_ENGINE_LLM_PROVIDER=anthropic
export RULE_ENGINE_ANTHROPIC_API_KEY=your-key
export RULE_ENGINE_ANTHROPIC_MODEL=claude-sonnet-4-20250514
# Ollama
export RULE_ENGINE_LLM_PROVIDER=ollama
export RULE_ENGINE_OLLAMA_BASE_URL=http://localhost:11434
export RULE_ENGINE_OLLAMA_MODEL=llama3.2
# Shared settings
export RULE_ENGINE_LLM_MAX_CONCURRENCY=5
export RULE_ENGINE_LLM_TIMEOUT_SECS=30
| Type | Description | Example |
|---|---|---|
Boolean |
Yes/no decisions | Approve refund? |
Number |
Numeric scores | Risk score 0-100 |
String |
Categories/labels | Sentiment: positive |
Json |
Structured data | Extracted entities |
| Crate | Description |
|---|---|
| product-farm-core | Core domain types |
| product-farm-rule-engine | DAG executor |
| product-farm-yaml-loader | YAML definitions with LLM rules |
MIT License - see LICENSE for details.