From e39c87ac5c9ea324ff5a95fc3a9c3f3a50697f07 Mon Sep 17 00:00:00 2001 From: songtianlun Date: Wed, 12 Feb 2025 10:02:09 +0800 Subject: [PATCH] feat: improve prompt generation with location details - Include state, country, and region in the DALL-E prompt - Enhance context for the generated weather scene This change improves the specificity of the prompts generated for the AI, providing more contextual information such as state, country, and region alongside the city name. This enhancement can lead to more accurate and relevant outputs from the DALL-E 3 model for weather scenes. --- app/services/ai_service.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/services/ai_service.rb b/app/services/ai_service.rb index a9abdfa..9f86b40 100644 --- a/app/services/ai_service.rb +++ b/app/services/ai_service.rb @@ -43,8 +43,12 @@ class AiService private def generate_prompt_request(city, weather_data) + region = city.country.region&.name || "" + country = city.country.name || "" + state = city.state&.name || "" + <<~PROMPT - Create a DALL-E 3 prompt for a weather scene in #{city.name}, #{city.country.name}. + Create a DALL-E 3 prompt for a weather scene in #{city.name}, #{state}, #{country}, #{region}. Weather conditions: - Temperature: #{weather_data[:temperature]}°C