leoandruby 0.4.5 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1367cd52f309343a6083ed35dceace0d85491460b0a4e89c61c013bc39b2cf5
4
- data.tar.gz: 4424b97d4adf3b674eaa76f23d7c8047f2b4973c317835935dc2f520bf650c66
3
+ metadata.gz: b34c1559fe749345dcc2d19aaacbfc516f2f8331cd09ae1827e28e619cf77f96
4
+ data.tar.gz: bd88053ecbf601f70a18e69179cd115d0731d5cb245589a0e900211e136df60e
5
5
  SHA512:
6
- metadata.gz: '09ba19275cccfcc57783db80e855e1a4284b54f67f02ba88872541ffeb160a92fc6cce69e176c8e1f7c860c47e4224b4ac306da5bc88c0d95451eea8ab017b5b'
7
- data.tar.gz: 20a7213cc2b2308918569b1d7c02922dcb1d7194409c25c3554bfc1a2aa54a70bd992813c9877b565a9f8aea9edbacd603e1e6384d3360d9c44215d3dea8772d
6
+ metadata.gz: ad61649bfe11f022c5e6be239bacc1474d2d86dc31cb995c8212d8b5180c4e185b6ac5c2e010ea9906c007bf77aa9755c7e9729de3a9370b7924472cfc329e20
7
+ data.tar.gz: c19db98f3abd4d3fe4f6bedd0a8cc66a8f2fda55b21f3cb3a2596cbe4078b06688d79c97e09cd1aae0ae0d8c6e96a6b40b5b7b75f9800607fd3ff0aba7380658
data/CHANGELOG.md CHANGED
@@ -1,4 +1,30 @@
1
1
  # Changelog
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
+
2
28
  ## [0.4.5] - 2025-04-28
3
29
  ### Added
4
30
  - _Describe new features here._
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.ais webhook feature. This allows your application to automatically process results when the image generation is complete.
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']
@@ -71,7 +71,26 @@ module LeoAndRuby
71
71
  when Net::HTTPSuccess
72
72
  JSON.parse(response.body)
73
73
  else
74
- raise "HTTP Error: #{response.code} - #{response.message}"
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
+
75
94
  end
76
95
  end
77
96
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LeoAndRuby
4
- VERSION = "0.4.5"
4
+ VERSION = "0.5.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leoandruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard HW Baldwin
@@ -24,9 +24,8 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '6.0'
27
- description: LeoAndRuby is a Ruby gem for integrating with the Leonardo.ai API, enabling
28
- seamless image generation within Ruby applications. It provides a simple and intuitive
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 for image generation results.
61
- - Fully configurable with support for API keys via environment variables.
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: