Resolve cultivar from free-text input
resolve_cultivar(
cultivar_input,
crop,
cultivar_db = get_cached_cultivars(crop),
use_ai = TRUE,
use_cache = TRUE
)Character string. The cultivar description to resolve.
Character string. The crop for which to resolve the cultivar.
Data frame. The database of supported cultivars. This is typically retrieved using get_cached_cultivars(crop) or a data.frame with a "name" column to specify cultivar names.
Logical. Whether to use AI fallback if no deterministic match is found
Logical. Whether to use caching for AI responses.
A list with fields: cultivar, source, raw_input, assumptions. If not resolvable, cultivar is "unknown".
This function attempts to interpret a farmer's free-text description of a cultivar using an LLM. It returns a structured representation with the best matching cultivar. If the input cannot be resolved, it returns "unknown".
The function first checks for direct matches against a list of supported cultivars for the specified crop. If no deterministic match is found and AI fallback is enabled, it uses an LLM to attempt resolution. The output includes the resolved cultivar, the source of the resolution (direct match, AI, or unresolvable), the raw input, and any assumptions made during resolution.
The output is a list with the following fields:
list( cultivar = "cultivar_name" | "unknown", source = "direct_match" | "ai_resolution" | "unresolvable", raw_input = "farmer_input", assumptions = NULL )
# Example with AI backend configured:
if (FALSE) { # \dontrun{
resolve_cultivar("PAWC about 100mm, full profile", "wheat")
resolve_cultivar("profile about half full", "wheat")
resolve_cultivar("not sure", "wheat")
} # }