leoandruby 0.5.2 → 0.5.3
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 +27 -0
- data/lib/leoandruby/client.rb +28 -10
- data/lib/leoandruby/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3108cca83586240d0b714c41e37b521f53505dedfd2410eb310cd53e81008a40
|
4
|
+
data.tar.gz: 5d4070cf2d3fe87c7ccdbd0b3faf80e4350bb1ef4c8e39f5256583585ab70fe3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a294f8fabede70c00c5af41614083b7263b31dd4d1fcf1bcdaa3f3f2c4c9dd6f5fd2d9aad291723a0147b51fc243af632217f5f1438586694de8de24cdebcabc
|
7
|
+
data.tar.gz: 8e5cac2eec85b83f2a2637c9e333c628ab7fa3731dc89ed43d9ec8e8d2e25225150dc603dbba6fb851408580fd4d4bcf8566e15e2bb8a5d0b794e9f40dcb9d0a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,32 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.5.3] - 2024-04-29
|
4
|
+
|
5
|
+
### Added
|
6
|
+
- Expanded `generate_image` method to support new parameters from Leonardo.ai's PhotoReal v2 API:
|
7
|
+
- `negative_prompt`
|
8
|
+
- `presetStyle`
|
9
|
+
- `photoRealVersion`
|
10
|
+
- Introduced intelligent default values for key generation parameters:
|
11
|
+
- Defaults to **Kino XL** model if no `model_id` is provided.
|
12
|
+
- Defaults `alchemy` to `true`.
|
13
|
+
- Defaults `photoReal` to `true`.
|
14
|
+
- Defaults `photoRealVersion` to `"v2"`.
|
15
|
+
- Defaults `presetStyle` to `"DYNAMIC"`.
|
16
|
+
- Added internal constant `DEFAULT_PHOTO_REAL_MODEL_ID` for clarity and maintainability.
|
17
|
+
|
18
|
+
### Changed
|
19
|
+
- Improved `handle_response` method to parse and log detailed Leonardo.ai error responses.
|
20
|
+
- Enhanced error reporting to Rails logs for faster and more accurate debugging.
|
21
|
+
- Introduced validation to raise informative `ArgumentError` if `prompt`, `height`, or `width` are missing when generating an image.
|
22
|
+
|
23
|
+
### Fixed
|
24
|
+
- Ensured `negative_prompt` is correctly handled as an optional parameter during image generation.
|
25
|
+
|
26
|
+
---
|
27
|
+
|
28
|
+
|
29
|
+
|
3
30
|
## [0.5.2] - 2025-04-29
|
4
31
|
|
5
32
|
### Added
|
data/lib/leoandruby/client.rb
CHANGED
@@ -1,16 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "net/http"
|
2
4
|
require "json"
|
3
5
|
require "uri"
|
4
6
|
|
5
7
|
module LeoAndRuby
|
6
8
|
class Client
|
7
|
-
API_BASE_URL = "https://cloud.leonardo.ai/api/rest/v1"
|
9
|
+
API_BASE_URL = "https://cloud.leonardo.ai/api/rest/v1"
|
10
|
+
DEFAULT_PHOTO_REAL_MODEL_ID = "aa77f04e-3eec-4034-9c07-d0f619684628"
|
8
11
|
|
9
12
|
def initialize(api_key)
|
10
13
|
@api_key = api_key
|
11
14
|
end
|
12
15
|
|
13
|
-
def generate_image(
|
16
|
+
def generate_image(
|
17
|
+
prompt:, height:, width:,
|
18
|
+
model_id: nil,
|
19
|
+
negative_prompt: nil,
|
20
|
+
alchemy: true,
|
21
|
+
preset_style: "DYNAMIC",
|
22
|
+
photo_real: true,
|
23
|
+
photo_real_version: "v2",
|
24
|
+
num_images: 1
|
25
|
+
)
|
26
|
+
raise ArgumentError, "Prompt must be provided" if prompt.nil? || prompt.strip.empty?
|
27
|
+
raise ArgumentError, "Height must be provided" if height.nil?
|
28
|
+
raise ArgumentError, "Width must be provided" if width.nil?
|
29
|
+
|
30
|
+
model_id ||= DEFAULT_PHOTO_REAL_MODEL_ID
|
31
|
+
|
14
32
|
uri = URI("#{API_BASE_URL}/generations")
|
15
33
|
request = Net::HTTP::Post.new(uri)
|
16
34
|
request["Accept"] = "application/json"
|
@@ -20,14 +38,16 @@ module LeoAndRuby
|
|
20
38
|
body = {
|
21
39
|
prompt: prompt,
|
22
40
|
modelId: model_id,
|
23
|
-
width: width,
|
24
41
|
height: height,
|
25
|
-
|
42
|
+
width: width,
|
43
|
+
num_images: num_images,
|
44
|
+
alchemy: alchemy,
|
45
|
+
presetStyle: preset_style,
|
46
|
+
photoReal: photo_real,
|
47
|
+
photoRealVersion: photo_real_version
|
26
48
|
}
|
27
|
-
|
28
|
-
body[:
|
29
|
-
body[:photoRealStrength] = photo_real_strength unless photo_real_strength.nil?
|
30
|
-
body[:presetStyle] = preset_style unless preset_style.nil?
|
49
|
+
|
50
|
+
body[:negative_prompt] = negative_prompt unless negative_prompt.nil?
|
31
51
|
|
32
52
|
request.body = body.to_json
|
33
53
|
|
@@ -88,9 +108,7 @@ module LeoAndRuby
|
|
88
108
|
Response Body: #{error_message}
|
89
109
|
ERROR
|
90
110
|
|
91
|
-
Rails.logger.error(full_error) if defined?(Rails)
|
92
111
|
raise full_error.strip
|
93
|
-
|
94
112
|
end
|
95
113
|
end
|
96
114
|
end
|
data/lib/leoandruby/version.rb
CHANGED