File size: 1,280 Bytes
4e9208d
73921fc
4e9208d
 
 
 
 
 
 
73921fc
4e9208d
73921fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def generate_care_notes(plant_info: dict, plant_name: str | None = None, genus: str | None = None) -> str:
    """Build a short care note from CSV-derived plant metadata (rule-based, no model).

    Args:
        plant_info: Care metadata (watering_frequency_days, sunlight, soil, fertilization_type).
        plant_name: Common plant name, if known.
        genus: Genus name, if known.

    Returns:
        A short care note assembled from simple templates.
    """
    subject = plant_name or genus or "This plant"

    sentences = []

    sunlight = plant_info.get("sunlight")
    if sunlight:
        sentences.append(f"{subject} needs {sunlight}.")

    soil = plant_info.get("soil")
    if soil:
        sentences.append(f"It thrives in {soil} soil.")

    watering = plant_info.get("watering_frequency_days")
    if watering:
        sentences.append(f"{watering}.")

    fertilization = plant_info.get("fertilization_type")
    if fertilization and str(fertilization).strip().lower() not in ("no", "none", ""):
        sentences.append(f"Feed it with {str(fertilization).lower()} fertilizer.")
    else:
        sentences.append("No fertilizer is needed for this plant.")

    return " ".join(sentences) if sentences else f"No care information available for {subject}."