Commit Graph

15 Commits

Author SHA1 Message Date
Arsham Mirehvandi
6b523820f6 Enhance advice generation logic with validation and retry mechanism
- Updated `advice.py` to implement a validation check for advice responses, ensuring compliance with defined rules before storing.
- Introduced a retry mechanism that provides feedback on rejected responses, allowing for corrective actions in subsequent attempts.
- Modified the `parse_advice` function to handle validation errors more effectively, raising appropriate exceptions when violations occur.
- Enhanced documentation in `README.md` to reflect the new validation rules and their implications for advice generation.
2026-10-13 10:25:42 +02:00
Arsham Mirehvandi
46cc17e5d5 Update LLM configuration and enhance vector search capabilities
- Changed `thinking_budget` to `thinking_level` in `config.yaml` for Gemini models, updating the logic to reflect the new parameter.
- Updated LLM models in `config.yaml` to `gemini-3.8-flash` and `gemini-3.1-pro-preview`, adjusting their respective `max_tokens` and `thinking_level`.
- Enhanced `docker-compose.yml` to include a new `reranker-transformers` service for improved product ranking.
- Modified vector search logic in `vector.py` to incorporate reranking with the local transformers model, improving the accuracy of product recommendations.
- Updated unit tests to validate the new reranking functionality and ensure correct behavior in product searches.
2026-10-07 16:25:54 +02:00
Arsham Mirehvandi
e45376fd4b Update concurrency settings in config.yaml and README.md
- Adjusted `thinking_budget` in `config.yaml` from 9216 to 8192 to optimize resource allocation.
- Increased `workers` from 8 to 12 in both `config.yaml` and `README.md` to enhance concurrency.
- Updated `gemini` limits from 4 to 12 in both files to improve request handling capacity.
2026-10-04 16:25:48 +02:00
Arsham Mirehvandi
d42fe18a52 Refactor advisory generation and update database schema
- Updated `config.yaml` to change the advice storage table from `advice` to `advisories` and adjusted the `thinking_budget` from 11264 to 9216.
- Modified `README.md` to reflect the new `advisories` table in the advisory generation process.
- Refactored SQL queries in `batch.py`, `job.py`, and `advice_context.py` to align with the new table structure.
- Enhanced the advice generation logic in `advice.py` to accommodate changes in the data model, including updates to the JSON structure for advice output.
- Updated relevant functions and documentation to ensure consistency across the codebase regarding the new advisory schema.
2026-09-30 14:43:08 +02:00
Arsham Mirehvandi
ae53961fd2 Enhance product filtering logic with legal state checks
- Updated README.md to clarify the product prefiltering process, emphasizing the importance of legal catalog state in determining product eligibility.
- Refactored products.py to implement checks for product registration against the government catalog, ensuring only permitted products are included in recommendations.
- Added new functions to handle registration normalization and state validation, improving the accuracy of product filtering.
- Expanded unit tests in test_products.py to validate the new legal state checks and ensure correct behavior in filtering products based on their registration status.
2026-09-22 10:57:08 +02:00
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
Arsham Mirehvandi
d1569a301f Refactor treatment history handling and enhance product filtering logic
- Updated README.md to clarify the conditions for `last_applied_treatment` and its integration into the advice JSON structure.
- Refactored job.py to utilize a new `TreatmentHistory` class for managing treatment data, improving clarity and efficiency in treatment retrieval.
- Enhanced advice_context.py to conditionally include `last_applied_treatment` based on the treatment history, ensuring no redundant queries are made.
- Modified products.py to implement logic for excluding active ingredients based on the latest treatment's interval, refining the product prefiltering process.
- Updated vector.py to ensure the SQL allowlist is applied correctly, improving the efficiency of product searches.
- Added unit tests to validate the new treatment history functionality and product filtering logic.
2026-09-20 23:38:25 +02:00
Arsham Mirehvandi
253a6d853d Update product retrieval limits in README and vector search logic
- Adjusted the maximum number of recommended products from 6 to 4 in README.md to reflect changes in the product retrieval process.
- Modified vector.py to limit the number of products retrieved per query to 4 for single queries and 2 for multiple queries, ensuring better deduplication and efficiency in product searches.
2026-09-16 23:18:23 +02:00
Arsham Mirehvandi
d8273b5cd1 Enhance advice context and treatment handling
- Updated README.md to clarify the conditions for including `last_applied_treatment` in the advice JSON structure.
- Modified job.py to pass `as_of` and `field_id` to the advice generation function.
- Enhanced advice_context.py to conditionally add `last_applied_treatment` based on recent treatment history and allowed products.
- Introduced new functions in treatments.py to group treatments by day and load the last treatment before the recent window.
- Updated _output_format.md to specify the conditions under which `last_applied_treatment` is included in the advisory.
2026-09-09 16:00:23 +02:00
Arsham Mirehvandi
8a6d48e5a1 Enhance advice generation and context handling
- Updated README.md to reflect changes in the `json_for_advice_generation` structure, including the addition of `date_of_today` and clarification of `last_advice` fields.
- Modified job.py to load and pass the issuance date of the last advice.
- Enhanced advice_context.py to include the issuance date in the last advice retrieval.
- Updated assemble.py to include `date_of_today` in the JSON assembly for advice generation.
- Improved advice.py to sanitize the `advice_summary` by removing relative date references and ensuring compliance with new guidelines.
2026-09-08 09:40:34 +02:00
Arsham Mirehvandi
28250d6608 Refactor disease prefiltering logic and update documentation
- Updated README.md to clarify the conditions for the `INCUBAZPRIMARIA` rule in the context of disease forecasting.
- Modified disease.py to adjust the order of prefilter rules, ensuring `INCUBAZPRIMARIA` is evaluated correctly.
- Enhanced product prefiltering logic in products.py to incorporate the new conditions for `incubazprimaria` while removing redundant checks.
2026-09-07 15:20:21 +02:00
Arsham Mirehvandi
98afec550d Enhance disease forecasting and product prefiltering logic
- Updated README.md to clarify the handling of historical/test dates and the conditions for generating advice.
- Modified job.py to incorporate observation data into risk assessment and product prefiltering.
- Introduced a new function in disease.py to select the appropriate prefilter rule based on observation and FASE data.
- Enhanced product filtering logic in products.py to accommodate new prefilter rules.
- Updated assemble.py to include observation data in JSON assembly for advice generation.
- Improved documentation in the grapevine downy mildew system prompt to explain the significance of INCUBAZPRIMARIA and observation data.
2026-09-05 23:02:39 +02:00
Arsham Mirehvandi
21927133a4 Enhance weather metrics handling and phenology logic
- Introduced a new function to round specific weather metric values to two decimal places in assemble.py.
- Updated the JSON entry construction in assemble.py to utilize the new rounding function for weather metrics.
- Modified the phenology loading logic in phenology.py to use yesterday's phase if today's phase is null after carry-forward.
- Clarified documentation in README.md regarding the phenology phase handling.
2026-09-05 14:11:45 +02:00
Arsham Mirehvandi
e588d97e0f Add observability support with OpenTelemetry tracing integration
- Updated .env.example and config.yaml to include observability settings.
- Added a new Phoenix service in docker-compose.yml for self-hosted tracing.
- Enhanced README.md with instructions on enabling and using observability features.
- Implemented tracing in the pipeline, including job spans and LLM stage spans.
- Introduced ObservabilitySettings class in config.py for better configuration management.
- Updated job.py and resources.py to support tracing without affecting fault isolation.
- Minor adjustments to other files for compatibility with the new observability features.
2026-08-25 22:06:54 +02:00
Arsham Mirehvandi
099d1e0af9 Initial commit 2026-08-22 08:47:56 +02:00