runapi-ideogram-v3 0.2.9 → 0.3.0
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/lib/runapi/ideogram_v3/resources/edit_image.rb +0 -28
- data/lib/runapi/ideogram_v3/resources/reframe_image.rb +0 -9
- data/lib/runapi/ideogram_v3/resources/remix_image.rb +0 -37
- data/lib/runapi/ideogram_v3/resources/text_to_image.rb +0 -26
- data/lib/runapi/ideogram_v3.rb +0 -1
- metadata +3 -4
- data/lib/runapi/ideogram_v3/contract_gen.rb +0 -175
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '09325b56b41b50dd473bf72de55b628cef1a8a9ad1c0bd59bf9e4ad6e3a0bcce'
|
|
4
|
+
data.tar.gz: 0f389ee9495bda089d06f35ee1caa2aac1a9f4fa4314339b08f34ceb0ab600c2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4ed8811c85f7b00f05ebf6a71435193b98ac1355dc3e8406cf90787fee5c213d6028ba9924832ca572c700e2adcdf71c524f4080fcb27c975bc8836bc011bf72
|
|
7
|
+
data.tar.gz: dc11b0c56071a11c2464373813554afabbc89396889957bbbf156ca9e7c2ecb8adab6c92fe031d6d14a600a93089c80c202b3ad174043cde9820ed952156660d
|
|
@@ -10,7 +10,6 @@ module RunApi
|
|
|
10
10
|
ENDPOINT = "/api/v1/ideogram_v3/edit_image"
|
|
11
11
|
RESPONSE_CLASS = Types::IdeogramResponse
|
|
12
12
|
COMPLETED_RESPONSE_CLASS = Types::CompletedIdeogramResponse
|
|
13
|
-
PROMPT_MAX_LENGTH = 5000
|
|
14
13
|
|
|
15
14
|
def initialize(http)
|
|
16
15
|
@http = http
|
|
@@ -23,39 +22,12 @@ module RunApi
|
|
|
23
22
|
|
|
24
23
|
def create(options: nil, **params)
|
|
25
24
|
params = compact_params(params)
|
|
26
|
-
validate_params!(params)
|
|
27
25
|
request(:post, ENDPOINT, body: params, options: options)
|
|
28
26
|
end
|
|
29
27
|
|
|
30
28
|
def get(id, options: nil)
|
|
31
29
|
request(:get, "#{ENDPOINT}/#{id}", options: options)
|
|
32
30
|
end
|
|
33
|
-
|
|
34
|
-
private
|
|
35
|
-
|
|
36
|
-
def validate_params!(params)
|
|
37
|
-
validate_contract!(CONTRACT["edit-image"], params)
|
|
38
|
-
model = param(params, :model)
|
|
39
|
-
|
|
40
|
-
prompt = param(params, :prompt)
|
|
41
|
-
raise Core::ValidationError, "prompt is required" unless prompt.is_a?(String) && !prompt.empty?
|
|
42
|
-
if prompt.length > PROMPT_MAX_LENGTH
|
|
43
|
-
raise Core::ValidationError, "prompt must be at most #{PROMPT_MAX_LENGTH} characters"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
raise Core::ValidationError, "mask_url is required" unless param(params, :mask_url)
|
|
47
|
-
|
|
48
|
-
validate_character_fields!(params, model)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def validate_character_fields!(params, model)
|
|
52
|
-
refs = param(params, :reference_image_urls)
|
|
53
|
-
if model == Types::CHARACTER_EDIT_MODEL
|
|
54
|
-
raise Core::ValidationError, "reference_image_urls is required" unless refs.is_a?(Array) && refs.any?
|
|
55
|
-
elsif refs || param(params, :style)
|
|
56
|
-
raise Core::ValidationError, "character edit fields are not supported for #{model}"
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
31
|
end
|
|
60
32
|
end
|
|
61
33
|
end
|
|
@@ -22,21 +22,12 @@ module RunApi
|
|
|
22
22
|
|
|
23
23
|
def create(options: nil, **params)
|
|
24
24
|
params = compact_params(params)
|
|
25
|
-
validate_params!(params)
|
|
26
25
|
request(:post, ENDPOINT, body: params, options: options)
|
|
27
26
|
end
|
|
28
27
|
|
|
29
28
|
def get(id, options: nil)
|
|
30
29
|
request(:get, "#{ENDPOINT}/#{id}", options: options)
|
|
31
30
|
end
|
|
32
|
-
|
|
33
|
-
private
|
|
34
|
-
|
|
35
|
-
def validate_params!(params)
|
|
36
|
-
validate_contract!(CONTRACT["reframe-image"], params)
|
|
37
|
-
|
|
38
|
-
raise Core::ValidationError, "aspect_ratio is required" unless param(params, :aspect_ratio)
|
|
39
|
-
end
|
|
40
31
|
end
|
|
41
32
|
end
|
|
42
33
|
end
|
|
@@ -10,10 +10,6 @@ module RunApi
|
|
|
10
10
|
ENDPOINT = "/api/v1/ideogram_v3/remix_image"
|
|
11
11
|
RESPONSE_CLASS = Types::IdeogramResponse
|
|
12
12
|
COMPLETED_RESPONSE_CLASS = Types::CompletedIdeogramResponse
|
|
13
|
-
PROMPT_MAX_LENGTH = 5000
|
|
14
|
-
STRENGTH_MIN = 0.01
|
|
15
|
-
CHARACTER_REMIX_STRENGTH_MIN = 0.1
|
|
16
|
-
STRENGTH_MAX = 1.0
|
|
17
13
|
|
|
18
14
|
def initialize(http)
|
|
19
15
|
@http = http
|
|
@@ -26,45 +22,12 @@ module RunApi
|
|
|
26
22
|
|
|
27
23
|
def create(options: nil, **params)
|
|
28
24
|
params = compact_params(params)
|
|
29
|
-
validate_params!(params)
|
|
30
25
|
request(:post, ENDPOINT, body: params, options: options)
|
|
31
26
|
end
|
|
32
27
|
|
|
33
28
|
def get(id, options: nil)
|
|
34
29
|
request(:get, "#{ENDPOINT}/#{id}", options: options)
|
|
35
30
|
end
|
|
36
|
-
|
|
37
|
-
private
|
|
38
|
-
|
|
39
|
-
def validate_params!(params)
|
|
40
|
-
validate_contract!(CONTRACT["remix-image"], params)
|
|
41
|
-
model = param(params, :model)
|
|
42
|
-
|
|
43
|
-
prompt = param(params, :prompt)
|
|
44
|
-
raise Core::ValidationError, "prompt is required" unless prompt.is_a?(String) && !prompt.empty?
|
|
45
|
-
if prompt.length > PROMPT_MAX_LENGTH
|
|
46
|
-
raise Core::ValidationError, "prompt must be at most #{PROMPT_MAX_LENGTH} characters"
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
validate_character_fields!(params, model)
|
|
50
|
-
|
|
51
|
-
if (strength = param(params, :strength))
|
|
52
|
-
numeric = Float(strength, exception: false)
|
|
53
|
-
min = (model == Types::CHARACTER_REMIX_MODEL) ? CHARACTER_REMIX_STRENGTH_MIN : STRENGTH_MIN
|
|
54
|
-
if numeric.nil? || numeric < min || numeric > STRENGTH_MAX
|
|
55
|
-
raise Core::ValidationError, "strength must be between #{min} and #{STRENGTH_MAX}"
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def validate_character_fields!(params, model)
|
|
61
|
-
refs = param(params, :reference_image_urls)
|
|
62
|
-
if model == Types::CHARACTER_REMIX_MODEL
|
|
63
|
-
raise Core::ValidationError, "reference_image_urls is required" unless refs.is_a?(Array) && refs.any?
|
|
64
|
-
elsif refs || param(params, :style_reference_image_urls) || param(params, :reference_mask_urls)
|
|
65
|
-
raise Core::ValidationError, "character remix fields are not supported for #{model}"
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
31
|
end
|
|
69
32
|
end
|
|
70
33
|
end
|
|
@@ -10,7 +10,6 @@ module RunApi
|
|
|
10
10
|
ENDPOINT = "/api/v1/ideogram_v3/text_to_image"
|
|
11
11
|
RESPONSE_CLASS = Types::IdeogramResponse
|
|
12
12
|
COMPLETED_RESPONSE_CLASS = Types::CompletedIdeogramResponse
|
|
13
|
-
PROMPT_MAX_LENGTH = 5000
|
|
14
13
|
|
|
15
14
|
def initialize(http)
|
|
16
15
|
@http = http
|
|
@@ -23,37 +22,12 @@ module RunApi
|
|
|
23
22
|
|
|
24
23
|
def create(options: nil, **params)
|
|
25
24
|
params = compact_params(params)
|
|
26
|
-
validate_params!(params)
|
|
27
25
|
request(:post, ENDPOINT, body: params, options: options)
|
|
28
26
|
end
|
|
29
27
|
|
|
30
28
|
def get(id, options: nil)
|
|
31
29
|
request(:get, "#{ENDPOINT}/#{id}", options: options)
|
|
32
30
|
end
|
|
33
|
-
|
|
34
|
-
private
|
|
35
|
-
|
|
36
|
-
def validate_params!(params)
|
|
37
|
-
validate_contract!(CONTRACT["text-to-image"], params)
|
|
38
|
-
model = param(params, :model)
|
|
39
|
-
|
|
40
|
-
prompt = param(params, :prompt)
|
|
41
|
-
raise Core::ValidationError, "prompt is required" unless prompt.is_a?(String) && !prompt.empty?
|
|
42
|
-
if prompt.length > PROMPT_MAX_LENGTH
|
|
43
|
-
raise Core::ValidationError, "prompt must be at most #{PROMPT_MAX_LENGTH} characters"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
validate_character_refs!(params, model)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def validate_character_refs!(params, model)
|
|
50
|
-
refs = param(params, :reference_image_urls)
|
|
51
|
-
if model == Types::CHARACTER_MODEL
|
|
52
|
-
raise Core::ValidationError, "reference_image_urls is required" unless refs.is_a?(Array) && refs.any?
|
|
53
|
-
elsif refs
|
|
54
|
-
raise Core::ValidationError, "reference_image_urls is not supported for #{model}"
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
31
|
end
|
|
58
32
|
end
|
|
59
33
|
end
|
data/lib/runapi/ideogram_v3.rb
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
require "runapi/core"
|
|
4
4
|
require_relative "ideogram_v3/types"
|
|
5
|
-
require_relative "ideogram_v3/contract_gen"
|
|
6
5
|
require_relative "ideogram_v3/resources/text_to_image"
|
|
7
6
|
require_relative "ideogram_v3/resources/edit_image"
|
|
8
7
|
require_relative "ideogram_v3/resources/remix_image"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: runapi-ideogram-v3
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- RunAPI
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
18
|
+
version: 0.6.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.
|
|
25
|
+
version: 0.6.0
|
|
26
26
|
description: The Ideogram V3 Ruby SDK is the language-specific package for Ideogram
|
|
27
27
|
V3 on RunAPI. Use this package for image generation, image editing, and creative
|
|
28
28
|
production workflows when your application needs request bodies, task status lookup,
|
|
@@ -39,7 +39,6 @@ files:
|
|
|
39
39
|
- lib/runapi-ideogram_v3.rb
|
|
40
40
|
- lib/runapi/ideogram_v3.rb
|
|
41
41
|
- lib/runapi/ideogram_v3/client.rb
|
|
42
|
-
- lib/runapi/ideogram_v3/contract_gen.rb
|
|
43
42
|
- lib/runapi/ideogram_v3/resources/edit_image.rb
|
|
44
43
|
- lib/runapi/ideogram_v3/resources/reframe_image.rb
|
|
45
44
|
- lib/runapi/ideogram_v3/resources/remix_image.rb
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RunApi
|
|
4
|
-
module IdeogramV3
|
|
5
|
-
CONTRACT = {
|
|
6
|
-
"edit-image" => {
|
|
7
|
-
"models" => ["ideogram-v3-character-edit", "ideogram-v3-edit"],
|
|
8
|
-
"fields_by_model" => {
|
|
9
|
-
"ideogram-v3-character-edit" => {
|
|
10
|
-
"mask_url" => {
|
|
11
|
-
"required" => true
|
|
12
|
-
},
|
|
13
|
-
"output_count" => {
|
|
14
|
-
"enum" => [1, 2, 3, 4],
|
|
15
|
-
"type" => "integer"
|
|
16
|
-
},
|
|
17
|
-
"reference_image_urls" => {
|
|
18
|
-
"required" => true
|
|
19
|
-
},
|
|
20
|
-
"rendering_speed" => {
|
|
21
|
-
"enum" => ["turbo", "balanced", "quality"]
|
|
22
|
-
},
|
|
23
|
-
"seed" => {
|
|
24
|
-
"type" => "integer"
|
|
25
|
-
},
|
|
26
|
-
"source_image_url" => {
|
|
27
|
-
"required" => true
|
|
28
|
-
},
|
|
29
|
-
"style" => {
|
|
30
|
-
"enum" => ["auto", "realistic", "fiction"]
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
"ideogram-v3-edit" => {
|
|
34
|
-
"mask_url" => {
|
|
35
|
-
"required" => true
|
|
36
|
-
},
|
|
37
|
-
"output_count" => {
|
|
38
|
-
"enum" => [1, 2, 3, 4],
|
|
39
|
-
"type" => "integer"
|
|
40
|
-
},
|
|
41
|
-
"rendering_speed" => {
|
|
42
|
-
"enum" => ["turbo", "balanced", "quality"]
|
|
43
|
-
},
|
|
44
|
-
"seed" => {
|
|
45
|
-
"type" => "integer"
|
|
46
|
-
},
|
|
47
|
-
"source_image_url" => {
|
|
48
|
-
"required" => true
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
"reframe-image" => {
|
|
54
|
-
"models" => ["ideogram-v3-reframe"],
|
|
55
|
-
"fields_by_model" => {
|
|
56
|
-
"ideogram-v3-reframe" => {
|
|
57
|
-
"aspect_ratio" => {
|
|
58
|
-
"enum" => ["1:1", "3:4", "9:16", "4:3", "16:9"]
|
|
59
|
-
},
|
|
60
|
-
"output_count" => {
|
|
61
|
-
"enum" => [1, 2, 3, 4],
|
|
62
|
-
"type" => "integer"
|
|
63
|
-
},
|
|
64
|
-
"rendering_speed" => {
|
|
65
|
-
"enum" => ["turbo", "balanced", "quality"]
|
|
66
|
-
},
|
|
67
|
-
"seed" => {
|
|
68
|
-
"type" => "integer"
|
|
69
|
-
},
|
|
70
|
-
"source_image_url" => {
|
|
71
|
-
"required" => true
|
|
72
|
-
},
|
|
73
|
-
"style" => {
|
|
74
|
-
"enum" => ["auto", "general", "realistic", "design"]
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
"remix-image" => {
|
|
80
|
-
"models" => ["ideogram-v3-character-remix", "ideogram-v3-remix"],
|
|
81
|
-
"fields_by_model" => {
|
|
82
|
-
"ideogram-v3-character-remix" => {
|
|
83
|
-
"aspect_ratio" => {
|
|
84
|
-
"enum" => ["1:1", "3:4", "9:16", "4:3", "16:9"]
|
|
85
|
-
},
|
|
86
|
-
"output_count" => {
|
|
87
|
-
"enum" => [1, 2, 3, 4],
|
|
88
|
-
"type" => "integer"
|
|
89
|
-
},
|
|
90
|
-
"reference_image_urls" => {
|
|
91
|
-
"required" => true
|
|
92
|
-
},
|
|
93
|
-
"rendering_speed" => {
|
|
94
|
-
"enum" => ["turbo", "balanced", "quality"]
|
|
95
|
-
},
|
|
96
|
-
"seed" => {
|
|
97
|
-
"type" => "integer"
|
|
98
|
-
},
|
|
99
|
-
"source_image_url" => {
|
|
100
|
-
"required" => true
|
|
101
|
-
},
|
|
102
|
-
"style" => {
|
|
103
|
-
"enum" => ["auto", "realistic", "fiction"]
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
"ideogram-v3-remix" => {
|
|
107
|
-
"aspect_ratio" => {
|
|
108
|
-
"enum" => ["1:1", "3:4", "9:16", "4:3", "16:9"]
|
|
109
|
-
},
|
|
110
|
-
"output_count" => {
|
|
111
|
-
"enum" => [1, 2, 3, 4],
|
|
112
|
-
"type" => "integer"
|
|
113
|
-
},
|
|
114
|
-
"rendering_speed" => {
|
|
115
|
-
"enum" => ["turbo", "balanced", "quality"]
|
|
116
|
-
},
|
|
117
|
-
"seed" => {
|
|
118
|
-
"type" => "integer"
|
|
119
|
-
},
|
|
120
|
-
"source_image_url" => {
|
|
121
|
-
"required" => true
|
|
122
|
-
},
|
|
123
|
-
"style" => {
|
|
124
|
-
"enum" => ["auto", "general", "realistic", "design"]
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
"text-to-image" => {
|
|
130
|
-
"models" => ["ideogram-v3-character", "ideogram-v3-text-to-image"],
|
|
131
|
-
"fields_by_model" => {
|
|
132
|
-
"ideogram-v3-character" => {
|
|
133
|
-
"aspect_ratio" => {
|
|
134
|
-
"enum" => ["1:1", "3:4", "9:16", "4:3", "16:9"]
|
|
135
|
-
},
|
|
136
|
-
"output_count" => {
|
|
137
|
-
"enum" => [1, 2, 3, 4],
|
|
138
|
-
"type" => "integer"
|
|
139
|
-
},
|
|
140
|
-
"reference_image_urls" => {
|
|
141
|
-
"required" => true
|
|
142
|
-
},
|
|
143
|
-
"rendering_speed" => {
|
|
144
|
-
"enum" => ["turbo", "balanced", "quality"]
|
|
145
|
-
},
|
|
146
|
-
"seed" => {
|
|
147
|
-
"type" => "integer"
|
|
148
|
-
},
|
|
149
|
-
"style" => {
|
|
150
|
-
"enum" => ["auto", "realistic", "fiction"]
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
"ideogram-v3-text-to-image" => {
|
|
154
|
-
"aspect_ratio" => {
|
|
155
|
-
"enum" => ["1:1", "3:4", "9:16", "4:3", "16:9"]
|
|
156
|
-
},
|
|
157
|
-
"output_count" => {
|
|
158
|
-
"enum" => [1, 2, 3, 4],
|
|
159
|
-
"type" => "integer"
|
|
160
|
-
},
|
|
161
|
-
"rendering_speed" => {
|
|
162
|
-
"enum" => ["turbo", "balanced", "quality"]
|
|
163
|
-
},
|
|
164
|
-
"seed" => {
|
|
165
|
-
"type" => "integer"
|
|
166
|
-
},
|
|
167
|
-
"style" => {
|
|
168
|
-
"enum" => ["auto", "general", "realistic", "design"]
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}.freeze
|
|
174
|
-
end
|
|
175
|
-
end
|