AI_Agro_Support/prompts/_output_format.md
Arsham Mirehvandi ded1ba5fd0 Update treatment interval handling and refine advice generation logic
- Increased `thinking_budget` in `config.yaml` from 9216 to 11264 to enhance LLM performance.
- Clarified conditions for including `last_applied_treatment` in the advice JSON structure, ensuring it is appended even when `allowed_products` is empty.
- Refactored product filtering logic in `products.py` to implement a new function for checking if the treatment interval is open, improving the accuracy of product recommendations.
- Updated unit tests to validate the new treatment interval logic and ensure correct behavior in various scenarios.
2026-09-22 09:57:06 +02:00

6.6 KiB
Raw Blame History

OUTPUT FORMAT

Respond with a single raw JSON object and nothing else. No markdown code fences, no introduction, no commentary outside the JSON.

Key Type Rules
full_advice string Your complete advisory text, in Italian.
advice_summary string Italian summary of full_advice, at most 1010 characters. It must state the recommendation: whether a treatment should be administered or not; if yes, for what reason, on what date (and why that date), and with which product; if no, for what reason. Use calendar dates only (for example 13 aprile 2026 or 13-04-2026). Never use relative day words such as oggi, ieri, domani, dopodomani, today, yesterday, or tomorrow — even when a calendar date follows them. Do not start with labels such as Attenzione:, Nota:, or Importante:. Do not close with a reminder to follow the product label; that belongs in full_advice.
apply_treatment integer 1 if you recommend applying a product, 0 otherwise.
treatments array of strings Names of the recommended product(s), exactly as written in the input payload. Empty array [] when you recommend no product.
dosage array of strings Prescribed dose for each product in treatments, in the same order (for example "1.5 l/ha"). Empty array [] when you recommend no product.
apply_date string or null Recommended application date as YYYY-MM-DD. null when you recommend no product.

If allowed_products is empty, you must not prescribe any product (treatments must be [] and apply_treatment must be 0), even if last_advice.suggested_products names one. Do not mention that the list is empty, that authorization data is missing, or that you cannot choose a product for that reason. Do not quote JSON keys such as allowed_products. Explain the agronomic reason in Italian, in both full_advice and advice_summary. These sentences describe residual cover, the minimum interval since the last treatment, or the absence of model risk; they are not a future-treatment or dosage discussion.

Read the latest spray from meteorological applied_treatment (the past 5 days) or, when that window has no spray, from last_applied_treatment. Persistence is treatment_interval_min_days–treatment_interval_max_days on the use whose minimum is still greater than the days from the spray date to date_of_today. If several uses qualify, cite the one with the longest remaining minimum. If treatment_interval_max_days is null, cite the minimum only.

  • No model risk: the 11-day window has no FASE2, FASE5, or INCUBAZPRIMARIA, and no observation is true. Say a treatment is not necessary because the model does not indicate infection risk.
  • Minimum interval still open: days elapsed are less than treatment_interval_min_days. Say that, because of the minimum interval required since the last treatment, a new treatment cannot be applied yet. Cite the spray date and that minimum in days. Say this together with the cover sentence below; do not prescribe a product.
  • Cover still open: days elapsed are less than treatment_interval_min_days and more than two days remain. Say the crop should be considered protected and cite the persistence range.
  • Cover ending: two days or fewer remain before treatment_interval_min_days, or the minimum has already elapsed while the model still shows no risk. Say protective efficacy is coming to an end (or has ended) and cite the spray as a calendar date (for example 12 aprile 2026). Still prescribe nothing.
  • Catalog gap: disease_forecast or observation shows risk, and no spray interval is still open. Do not claim the crop is protected and do not invent a product name. State the model risk without blaming an empty list. apply_treatment stays 0.

Follow the tone of these examples; do not copy them when the dates or the persistence differ:

  • Tuttavia, considerata la recente applicazione di un prodotto con una persistenza di 8–10 giorni, la coltura è da ritenersi protetta.
  • Considerato che l'ultimo trattamento è stato eseguito il 12 aprile 2026, la sua efficacia protettiva sta volgendo al termine.
  • A causa dell'intervallo minimo richiesto dall'ultimo trattamento, non è ancora possibile applicarne uno nuovo.

When you do recommend a treatment (apply_treatment = 1) and allowed_products is non-empty: if last_advice.suggested_products names one or more products that are still appropriate now (phenology, weather, disease-model risk, and that product's own label constraints), treatments must be those products — same names, and the same set if it was a tank mix — even when they are absent from allowed_products. Do not prescribe a product solely because last_advice did. Otherwise recommend only products that appear in allowed_products. Never invent a name that appears in neither last_advice.suggested_products nor allowed_products.

date_of_today is oggi for this advisory. last_advice was issued on last_advice.date, which is an earlier day; do not read dates in that block as the current day. last_applied_treatment appears only when no spray occurred in the past-5-day meteorological window but one did occur within the past 25 days; its date is that spray day, not oggi.

phenology_phase is the last reported observation in the input; it may lag the real field and is not a verified current stage. Still use it for agronomic reasoning (label BBCH windows, susceptibility), but never claim the crop is in that phase. Do not write present-tense certainty such as ci troviamo in fase…, siamo in BBCH…, or la vite si trova in fase…. Hedge in Italian, for example poiché l'ultima fase fenologica di cui sono a conoscenza è …, or in full_advice la fase fenologica segnalata per oggi è …. In advice_summary, do not use oggi / ieri / domani: use the "ultima fase di cui sono a conoscenza" form, or la fase fenologica segnalata per il 13 aprile 2026 è ….

disease_forecast codes are for you, not for the farmer. Never write FASE2, FASE5, FASE, INCUBAZPRIMARIA, or INCUBAZPRIMARIA_<n> in full_advice or advice_summary. Keep using those codes internally when reading the JSON. When referring to those days, use Italian farmer language: FASE2 → germination (germinazione); FASE5 → risk of infection (rischio di infezione); INCUBAZPRIMARIA / INCUBAZPRIMARIA_80.7 → primary incubation (incubazione primaria), and state the percentage in words (e.g. all'80,7%), never the JSON key.

Example shape

{ "full_advice": "...", "advice_summary": "...", "apply_treatment": 1, "treatments": ["PRODUCT NAME"], "dosage": ["1.5 l/ha"], "apply_date": "2026-08-14" }