Merge branch 'dev'
This commit is contained in:
commit
8fce45e1d0
@ -8,22 +8,24 @@ class AiService
|
|||||||
end
|
end
|
||||||
|
|
||||||
def generate_prompt(city, weather_data)
|
def generate_prompt(city, weather_data)
|
||||||
response = @client.chat(
|
city_desc = generate_location_desc(city)
|
||||||
parameters: {
|
|
||||||
model: "gpt-4",
|
|
||||||
messages: [ {
|
|
||||||
role: "system",
|
|
||||||
content: "You are a professional artist creating prompts for DALL-E 3. Create realistic, artistic weather scenes featuring iconic landmarks."
|
|
||||||
}, {
|
|
||||||
role: "user",
|
|
||||||
content: generate_prompt_request(city, weather_data)
|
|
||||||
} ],
|
|
||||||
temperature: 0.7,
|
|
||||||
max_tokens: 300
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
response.dig("choices", 0, "message", "content")
|
system_message =
|
||||||
|
"You are a professional artist creating prompts for DALL-E 3. Create realistic, artistic weather scenes featuring iconic landmarks."
|
||||||
|
user_message = generate_dall_e_3_prompt_request(city, weather_data, city_desc)
|
||||||
|
ask_ai(system_message, user_message)
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_location_desc(city)
|
||||||
|
region = city.country.region&.name || ""
|
||||||
|
country = city.country.name || ""
|
||||||
|
state = city.state&.name || ""
|
||||||
|
|
||||||
|
system_message =
|
||||||
|
"You are a global geography master, you understand the culture, geography, architecture, customs and other information of all cities around the world. Describe this city based on the city I gave you. Include details about its culture, climate, landmarks, and any unique features that make this place special. Condense the keyword into a description of about 50 words"
|
||||||
|
user_message =
|
||||||
|
"Describe the characteristics of the city of #{city.name}, located in the #{state}, #{country}, #{region}"
|
||||||
|
ask_ai(system_message, user_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_image(prompt)
|
def generate_image(prompt)
|
||||||
@ -42,7 +44,26 @@ class AiService
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def generate_prompt_request(city, weather_data)
|
def ask_ai(system_message, user_message)
|
||||||
|
response = @client.chat(
|
||||||
|
parameters: {
|
||||||
|
model: "gpt-4",
|
||||||
|
message:
|
||||||
|
[ {
|
||||||
|
role: "System",
|
||||||
|
content: system_message
|
||||||
|
}, {
|
||||||
|
role: "User",
|
||||||
|
content: user_message
|
||||||
|
} ],
|
||||||
|
temperature: 0.7,
|
||||||
|
max_tokens: 300
|
||||||
|
}
|
||||||
|
)
|
||||||
|
response.dig("choices", 0, "message", "content")
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_dall_e_3_prompt_request(city, weather_data, city_desc)
|
||||||
region = city.country.region&.name || ""
|
region = city.country.region&.name || ""
|
||||||
country = city.country.name || ""
|
country = city.country.name || ""
|
||||||
state = city.state&.name || ""
|
state = city.state&.name || ""
|
||||||
@ -50,6 +71,8 @@ class AiService
|
|||||||
<<~PROMPT
|
<<~PROMPT
|
||||||
Create a DALL-E 3 prompt for a weather scene in #{city.name}, #{state}, #{country}, #{region}.
|
Create a DALL-E 3 prompt for a weather scene in #{city.name}, #{state}, #{country}, #{region}.
|
||||||
|
|
||||||
|
Location Desc: #{city_desc}
|
||||||
|
|
||||||
Weather conditions:
|
Weather conditions:
|
||||||
- Temperature: #{weather_data[:temperature]}°C
|
- Temperature: #{weather_data[:temperature]}°C
|
||||||
- Weather: #{weather_data[:description]}
|
- Weather: #{weather_data[:description]}
|
||||||
@ -60,9 +83,12 @@ class AiService
|
|||||||
- Feature iconic landmarks or architecture from #{city.name}
|
- Feature iconic landmarks or architecture from #{city.name}
|
||||||
- Realistic style
|
- Realistic style
|
||||||
- Weather conditions should be clearly visible
|
- Weather conditions should be clearly visible
|
||||||
|
- Keep the picture clear and bright and avoid blurring
|
||||||
|
- Ensure the overall brightness is maintained, even in overcast conditions, by incorporating vibrant colors and soft lighting effects.
|
||||||
|
- If it’s a sunny day, enhance the brightness and warmth of the scene.
|
||||||
- Atmospheric and artistic composition
|
- Atmospheric and artistic composition
|
||||||
|
|
||||||
Generate a detailed, creative prompt that will produce a beautiful and realistic image.
|
Generate a detailed, creative prompt that will produce a beautiful and realistic image. Directly output prompt words, no prefix and suffix words
|
||||||
PROMPT
|
PROMPT
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user