refactor: clean up ai_service code formatting
- Adjust formatting for message parameters in the chat call - Eliminate unnecessary blank lines in generate_prompt_request method - Ensure consistent styles for arrays and block indentation These changes improve code readability and maintain consistency in formatting for better maintainability without altering functionality.
This commit is contained in:
parent
d728d7f50e
commit
853a1d03ce
@ -30,5 +30,4 @@ class BatchGenerateWeatherArtsJob < ApplicationJob
|
|||||||
# time = Time.current.in_time_zone(timezone)
|
# time = Time.current.in_time_zone(timezone)
|
||||||
# time.hour == 2
|
# time.hour == 2
|
||||||
# end
|
# end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -11,13 +11,13 @@ class AiService
|
|||||||
response = @client.chat(
|
response = @client.chat(
|
||||||
parameters: {
|
parameters: {
|
||||||
model: "gpt-4",
|
model: "gpt-4",
|
||||||
messages: [{
|
messages: [ {
|
||||||
role: "system",
|
role: "system",
|
||||||
content: "You are a professional artist creating prompts for DALL-E 3. Create realistic, artistic weather scenes featuring iconic landmarks."
|
content: "You are a professional artist creating prompts for DALL-E 3. Create realistic, artistic weather scenes featuring iconic landmarks."
|
||||||
}, {
|
}, {
|
||||||
role: "user",
|
role: "user",
|
||||||
content: generate_prompt_request(city, weather_data)
|
content: generate_prompt_request(city, weather_data)
|
||||||
}],
|
} ],
|
||||||
temperature: 0.7,
|
temperature: 0.7,
|
||||||
max_tokens: 300
|
max_tokens: 300
|
||||||
}
|
}
|
||||||
@ -45,20 +45,20 @@ class AiService
|
|||||||
def generate_prompt_request(city, weather_data)
|
def generate_prompt_request(city, weather_data)
|
||||||
<<~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}, #{city.country.name}.
|
||||||
|
|
||||||
Weather conditions:
|
Weather conditions:
|
||||||
- Temperature: #{weather_data[:temperature]}°C
|
- Temperature: #{weather_data[:temperature]}°C
|
||||||
- Weather: #{weather_data[:description]}
|
- Weather: #{weather_data[:description]}
|
||||||
- Cloud cover: #{weather_data[:cloud]}%
|
- Cloud cover: #{weather_data[:cloud]}%
|
||||||
- Time: Early morning
|
- Time: Early morning
|
||||||
|
|
||||||
Requirements:
|
Requirements:
|
||||||
- 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
|
||||||
- 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.
|
||||||
PROMPT
|
PROMPT
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
root "home#index"
|
root "home#index"
|
||||||
|
|
||||||
resources :cities, only: [:index, :show] do
|
resources :cities, only: [ :index, :show ] do
|
||||||
resources :weather_arts, path: 'weather', only: [:show], param: :slug
|
resources :weather_arts, path: "weather", only: [ :show ], param: :slug
|
||||||
end
|
end
|
||||||
|
|
||||||
# namespace :admin do
|
# namespace :admin do
|
||||||
|
Loading…
Reference in New Issue
Block a user