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.
This commit is contained in:
songtianlun 2025-02-12 10:02:09 +08:00
parent 6f21fe001e
commit e39c87ac5c

View File

@ -43,8 +43,12 @@ class AiService
private private
def generate_prompt_request(city, weather_data) def generate_prompt_request(city, weather_data)
region = city.country.region&.name || ""
country = city.country.name || ""
state = city.state&.name || ""
<<~PROMPT <<~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: Weather conditions:
- Temperature: #{weather_data[:temperature]}°C - Temperature: #{weather_data[:temperature]}°C