leoandruby 0.4.3 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +49 -1
- data/README.md +23 -3
- data/Rakefile +101 -0
- data/lib/leoandruby/client.rb +29 -4
- data/lib/leoandruby/version.rb +2 -2
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b34c1559fe749345dcc2d19aaacbfc516f2f8331cd09ae1827e28e619cf77f96
|
4
|
+
data.tar.gz: bd88053ecbf601f70a18e69179cd115d0731d5cb245589a0e900211e136df60e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad61649bfe11f022c5e6be239bacc1474d2d86dc31cb995c8212d8b5180c4e185b6ac5c2e010ea9906c007bf77aa9755c7e9729de3a9370b7924472cfc329e20
|
7
|
+
data.tar.gz: c19db98f3abd4d3fe4f6bedd0a8cc66a8f2fda55b21f3cb3a2596cbe4078b06688d79c97e09cd1aae0ae0d8c6e96a6b40b5b7b75f9800607fd3ff0aba7380658
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,54 @@
|
|
1
|
-
|
2
1
|
# Changelog
|
3
2
|
|
3
|
+
## [0.5.2] - 2025-04-29
|
4
|
+
|
5
|
+
### Added
|
6
|
+
- Improved API error handling for Leonardo.ai failures.
|
7
|
+
- More detailed error logs to assist Rails diagnosis.
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
- Minor consistency improvements.
|
11
|
+
|
12
|
+
## [0.5.1] - 2025-04-28
|
13
|
+
|
14
|
+
### Added
|
15
|
+
- Enhanced error handling with detailed API response messages
|
16
|
+
- Improved documentation for troubleshooting common API errors
|
17
|
+
- Added support for model-specific parameter validation
|
18
|
+
|
19
|
+
### Changed
|
20
|
+
- Updated error handling to include API response body in error messages
|
21
|
+
- Improved parameter validation for model-specific requirements
|
22
|
+
|
23
|
+
### Fixed
|
24
|
+
- Resolved issues with model ID validation
|
25
|
+
- Fixed parameter handling for model-specific constraints
|
26
|
+
- Addressed compatibility issues with Leonardo.ai API updates
|
27
|
+
|
28
|
+
## [0.4.5] - 2025-04-28
|
29
|
+
### Added
|
30
|
+
- _Describe new features here._
|
31
|
+
|
32
|
+
### Changed
|
33
|
+
- _Describe changes here._
|
34
|
+
|
35
|
+
### Fixed
|
36
|
+
- _Describe fixes here._
|
37
|
+
|
38
|
+
|
39
|
+
## [0.4.4] - 2024-11-26
|
40
|
+
|
41
|
+
### Added
|
42
|
+
- **Enhanced Image Generation**: Added support for additional Leonardo.ai API parameters:
|
43
|
+
- `alchemy`: Enable/disable Alchemy feature
|
44
|
+
- `photoReal`: Enable/disable PhotoReal feature
|
45
|
+
- `photoRealStrength`: Control PhotoReal effect strength (0.0 to 1.0)
|
46
|
+
- `presetStyle`: Apply preset styles (e.g., "CINEMATIC")
|
47
|
+
|
48
|
+
### Improved
|
49
|
+
- Made new parameters optional to maintain backward compatibility
|
50
|
+
- Enhanced request body construction to only include provided parameters
|
51
|
+
|
4
52
|
## [0.4.3] - 2024-11-26
|
5
53
|
|
6
54
|
- Fixed an issue with the directory structure reference.
|
data/README.md
CHANGED
@@ -14,6 +14,7 @@
|
|
14
14
|
- Webhook support to handle asynchronous image generation results.
|
15
15
|
- Rails generator for setting up webhook integration effortlessly.
|
16
16
|
- Simple and intuitive Ruby interface for interacting with the Leonardo.ai API.
|
17
|
+
- Advanced image generation features including Alchemy, PhotoReal, and preset styles.
|
17
18
|
|
18
19
|
---
|
19
20
|
|
@@ -70,12 +71,27 @@ generation_response = client.generate_image(
|
|
70
71
|
model_id: '6bef9f1b-29cb-40c7-b9df-32b51c1f67d3',
|
71
72
|
width: 512,
|
72
73
|
height: 512,
|
73
|
-
num_images: 1 # Optional, defaults to 1 if not specified
|
74
|
+
num_images: 1, # Optional, defaults to 1 if not specified
|
75
|
+
alchemy: true, # Optional, enables Alchemy feature
|
76
|
+
photo_real: true, # Optional, enables PhotoReal feature
|
77
|
+
photo_real_strength: 0.5, # Optional, controls PhotoReal effect strength (0.0 to 1.0)
|
78
|
+
preset_style: 'CINEMATIC' # Optional, applies preset styles
|
74
79
|
)
|
75
80
|
|
76
81
|
generation_id = generation_response['sdGenerationJob']['generationId']
|
77
82
|
```
|
78
83
|
|
84
|
+
### Advanced Image Generation Options
|
85
|
+
|
86
|
+
The `generate_image` method supports several advanced options to enhance your image generation:
|
87
|
+
|
88
|
+
- `alchemy`: Enable/disable the Alchemy feature for enhanced image quality
|
89
|
+
- `photo_real`: Enable/disable the PhotoReal feature for photorealistic results
|
90
|
+
- `photo_real_strength`: Control the strength of the PhotoReal effect (0.0 to 1.0)
|
91
|
+
- `preset_style`: Apply preset styles like 'CINEMATIC', 'ANIME', 'CREATIVE', etc.
|
92
|
+
|
93
|
+
All advanced options are optional and can be used in combination to achieve the desired result.
|
94
|
+
|
79
95
|
### 3. List Available Models
|
80
96
|
|
81
97
|
You can fetch a list of all available platform models using the `list_models` method:
|
@@ -100,7 +116,7 @@ puts image_response
|
|
100
116
|
|
101
117
|
## Webhook Integration (Rails)
|
102
118
|
|
103
|
-
LeoAndRuby supports asynchronous image generation through Leonardo.ai
|
119
|
+
LeoAndRuby supports asynchronous image generation through Leonardo.ai's webhook feature. This allows your application to automatically process results when the image generation is complete.
|
104
120
|
|
105
121
|
### Generate a Webhook Controller
|
106
122
|
|
@@ -147,7 +163,11 @@ generation_response = client.generate_image(
|
|
147
163
|
model_id: '6bef9f1b-29cb-40c7-b9df-32b51c1f67d3',
|
148
164
|
width: 1024,
|
149
165
|
height: 768,
|
150
|
-
num_images: 1 # Optional, defaults to 1 if not specified
|
166
|
+
num_images: 1, # Optional, defaults to 1 if not specified
|
167
|
+
alchemy: true, # Enable Alchemy for enhanced quality
|
168
|
+
photo_real: true, # Enable PhotoReal for photorealistic results
|
169
|
+
photo_real_strength: 0.7, # Set PhotoReal strength
|
170
|
+
preset_style: 'CINEMATIC' # Apply cinematic style
|
151
171
|
)
|
152
172
|
|
153
173
|
generation_id = generation_response['sdGenerationJob']['generationId']
|
data/Rakefile
CHANGED
@@ -2,5 +2,106 @@
|
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
4
|
require "standard/rake"
|
5
|
+
require "fileutils"
|
5
6
|
|
7
|
+
desc "Run code formatting checks (StandardRB)"
|
6
8
|
task default: :standard
|
9
|
+
|
10
|
+
# Clean up old built gem files
|
11
|
+
desc "Clean up old built gem files"
|
12
|
+
task :clean do
|
13
|
+
rm_f Dir["leoandruby-*.gem"]
|
14
|
+
end
|
15
|
+
|
16
|
+
# Full release: bump version, commit, tag, push, build, release
|
17
|
+
desc "Full release: bump, commit, tag, push, build and release gem"
|
18
|
+
task :full_release, [:bump] => [:standard, :clean] do |t, args|
|
19
|
+
bump_type = args[:bump] || "patch" # default to patch bump
|
20
|
+
|
21
|
+
puts "🔧 Bumping #{bump_type} version..."
|
22
|
+
bump_version(bump_type)
|
23
|
+
|
24
|
+
version = current_version
|
25
|
+
puts "🔖 New version: #{version}"
|
26
|
+
|
27
|
+
puts "✅ Committing version bump..."
|
28
|
+
sh "git add lib/leoandruby/version.rb CHANGELOG.md"
|
29
|
+
sh "git commit -m 'Bump version to #{version}'"
|
30
|
+
|
31
|
+
puts "🏷️ Tagging release..."
|
32
|
+
sh "git tag v#{version}"
|
33
|
+
|
34
|
+
puts "📤 Pushing to GitHub..."
|
35
|
+
sh "git push"
|
36
|
+
sh "git push --tags"
|
37
|
+
|
38
|
+
puts "📦 Building gem..."
|
39
|
+
sh "gem build leoandruby.gemspec"
|
40
|
+
|
41
|
+
puts "🚀 Pushing gem to RubyGems..."
|
42
|
+
sh "gem push leoandruby-#{version}.gem"
|
43
|
+
|
44
|
+
puts "🎉 Release v#{version} complete!"
|
45
|
+
end
|
46
|
+
|
47
|
+
# Helpers
|
48
|
+
|
49
|
+
def current_version
|
50
|
+
File.read("lib/leoandruby/version.rb")[/VERSION\s*=\s*["'](.+)["']/, 1]
|
51
|
+
end
|
52
|
+
|
53
|
+
def bump_version(bump_type)
|
54
|
+
file = "lib/leoandruby/version.rb"
|
55
|
+
content = File.read(file)
|
56
|
+
|
57
|
+
major, minor, patch = current_version.split(".").map(&:to_i)
|
58
|
+
|
59
|
+
case bump_type
|
60
|
+
when "major"
|
61
|
+
major += 1
|
62
|
+
minor = 0
|
63
|
+
patch = 0
|
64
|
+
when "minor"
|
65
|
+
minor += 1
|
66
|
+
patch = 0
|
67
|
+
when "patch"
|
68
|
+
patch += 1
|
69
|
+
else
|
70
|
+
raise "Unknown bump type: #{bump_type}. Use major, minor, or patch."
|
71
|
+
end
|
72
|
+
|
73
|
+
new_version = "#{major}.#{minor}.#{patch}"
|
74
|
+
|
75
|
+
new_content = content.gsub(/VERSION\s*=\s*["'](.+)["']/, "VERSION = \"#{new_version}\"")
|
76
|
+
File.write(file, new_content)
|
77
|
+
|
78
|
+
# Also automatically update CHANGELOG.md
|
79
|
+
update_changelog(new_version)
|
80
|
+
end
|
81
|
+
|
82
|
+
def update_changelog(new_version)
|
83
|
+
changelog = "CHANGELOG.md"
|
84
|
+
timestamp = Time.now.strftime("%Y-%m-%d")
|
85
|
+
|
86
|
+
entry = <<~MARKDOWN
|
87
|
+
|
88
|
+
## [#{new_version}] - #{timestamp}
|
89
|
+
### Added
|
90
|
+
- _Describe new features here._
|
91
|
+
|
92
|
+
### Changed
|
93
|
+
- _Describe changes here._
|
94
|
+
|
95
|
+
### Fixed
|
96
|
+
- _Describe fixes here._
|
97
|
+
MARKDOWN
|
98
|
+
|
99
|
+
if File.exist?(changelog)
|
100
|
+
content = File.read(changelog)
|
101
|
+
updated_content = content.sub(/^# Changelog/, "# Changelog\n#{entry.strip}\n")
|
102
|
+
File.write(changelog, updated_content)
|
103
|
+
puts "📝 Updated CHANGELOG.md"
|
104
|
+
else
|
105
|
+
puts "⚠️ CHANGELOG.md not found. Skipping changelog update."
|
106
|
+
end
|
107
|
+
end
|
data/lib/leoandruby/client.rb
CHANGED
@@ -10,20 +10,26 @@ module LeoAndRuby
|
|
10
10
|
@api_key = api_key
|
11
11
|
end
|
12
12
|
|
13
|
-
def generate_image(prompt:, model_id:, width:, height:, num_images: 1)
|
13
|
+
def generate_image(prompt:, model_id:, width:, height:, num_images: 1, alchemy: nil, photo_real: nil, photo_real_strength: nil, preset_style: nil)
|
14
14
|
uri = URI("#{API_BASE_URL}/generations")
|
15
15
|
request = Net::HTTP::Post.new(uri)
|
16
16
|
request["Accept"] = "application/json"
|
17
17
|
request["Authorization"] = "Bearer #{@api_key}"
|
18
18
|
request["Content-Type"] = "application/json"
|
19
19
|
|
20
|
-
|
20
|
+
body = {
|
21
21
|
prompt: prompt,
|
22
22
|
modelId: model_id,
|
23
23
|
width: width,
|
24
24
|
height: height,
|
25
25
|
num_images: num_images
|
26
|
-
}
|
26
|
+
}
|
27
|
+
body[:alchemy] = alchemy unless alchemy.nil?
|
28
|
+
body[:photoReal] = photo_real unless photo_real.nil?
|
29
|
+
body[:photoRealStrength] = photo_real_strength unless photo_real_strength.nil?
|
30
|
+
body[:presetStyle] = preset_style unless preset_style.nil?
|
31
|
+
|
32
|
+
request.body = body.to_json
|
27
33
|
|
28
34
|
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
29
35
|
http.request(request)
|
@@ -65,7 +71,26 @@ module LeoAndRuby
|
|
65
71
|
when Net::HTTPSuccess
|
66
72
|
JSON.parse(response.body)
|
67
73
|
else
|
68
|
-
|
74
|
+
begin
|
75
|
+
error_body = JSON.parse(response.body)
|
76
|
+
error_message = if error_body.is_a?(Hash)
|
77
|
+
error_body["message"] || error_body["error"] || error_body.to_s
|
78
|
+
else
|
79
|
+
error_body.to_s
|
80
|
+
end
|
81
|
+
rescue JSON::ParserError
|
82
|
+
error_message = response.body
|
83
|
+
end
|
84
|
+
|
85
|
+
full_error = <<~ERROR
|
86
|
+
Leonardo.ai API Error:
|
87
|
+
HTTP Status: #{response.code} #{response.message}
|
88
|
+
Response Body: #{error_message}
|
89
|
+
ERROR
|
90
|
+
|
91
|
+
Rails.logger.error(full_error) if defined?(Rails)
|
92
|
+
raise full_error.strip
|
93
|
+
|
69
94
|
end
|
70
95
|
end
|
71
96
|
end
|
data/lib/leoandruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leoandruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard HW Baldwin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,9 +24,8 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '6.0'
|
27
|
-
description: LeoAndRuby
|
28
|
-
|
29
|
-
interface for creating, managing, and retrieving AI-generated images.
|
27
|
+
description: LeoAndRuby integrates with the Leonardo.ai API, enabling seamless AI-powered
|
28
|
+
image generation in Ruby and Rails applications with simple, intuitive interfaces.
|
30
29
|
email:
|
31
30
|
- richard@empireofaustralia.com
|
32
31
|
executables: []
|
@@ -54,13 +53,15 @@ metadata:
|
|
54
53
|
homepage_uri: https://github.com/RWKotulski/LeoAndRuby
|
55
54
|
source_code_uri: https://github.com/RWKotulski/LeoAndRuby
|
56
55
|
changelog_uri: https://github.com/RWKotulski/LeoAndRuby/CHANGELOG.md
|
56
|
+
documentation_uri: https://rubydoc.info/gems/leoandruby
|
57
|
+
bug_tracker_uri: https://github.com/RWKotulski/LeoAndRuby/issues
|
57
58
|
features: |
|
58
59
|
- Generate stunning AI-powered images with minimal configuration.
|
59
60
|
- Simple Ruby interface for interacting with the Leonardo.ai API.
|
60
|
-
- Supports asynchronous workflows with polling
|
61
|
-
- Fully configurable with
|
62
|
-
- Easily integrates into Ruby and Rails applications.
|
61
|
+
- Supports asynchronous workflows with polling or webhook callbacks.
|
62
|
+
- Fully configurable with API key environment variables.
|
63
63
|
- Webhook support with Rails generator for seamless integration.
|
64
|
+
- Rails 6+ compatible.
|
64
65
|
post_install_message:
|
65
66
|
rdoc_options: []
|
66
67
|
require_paths:
|