runapi-seedream 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1cc01f0908e21b425000d28e19ce4ef4869d4002386c6aaa6f01b93ce57596ae
4
- data.tar.gz: cb79aba95acbeff5c089d4e4323494fe9bea27a7a5b54235059a2b2531405d2d
3
+ metadata.gz: f174aec9eb30f7457384baa78f50f0fe2978453a34a0b7a6a65766d3d4c5bb4e
4
+ data.tar.gz: a5f69b9d3d29123179a0f455688d7f8ab01fb6c9c3cc46ba862f9229dfcc38c7
5
5
  SHA512:
6
- metadata.gz: 169372426f905991d5a1d6aec5b79275dc3cd702aaa67157e90056555279860e8f9da01d78251a74205f9173f47d4bf2ec6c2d7387a882814da34c4bd8229ff0
7
- data.tar.gz: b7a21932f137ea256dd2d431e173c94400aaccdd885c2d5c2e97c6633ad8a2d738296dc87f046f60662ab5ab74ce270b46382791b423df5228220c08a16d7170
6
+ metadata.gz: 1471a52a9943aaa838592d7551f6d5600a08fd6db30da8da2d94f4cf9a54f77862c59c9ac7b5b46e3205e7cde25419515d07d9d3d7c98006f50808dc3bef1b71
7
+ data.tar.gz: 59c32983ddb1537f8b2c506af45050652f7b39c21fe9e0186c67f5233f0d314af5570b98aa59b794a0ca49bc4bd57484e6379c02cff96586928485456e98ad6f
@@ -22,7 +22,6 @@ module RunApi
22
22
 
23
23
  def create(options: nil, **params)
24
24
  params = compact_params(params)
25
- validate_contract!(CONTRACT["decompose-layers"], params)
26
25
  request(:post, ENDPOINT, body: params, options: options)
27
26
  end
28
27
 
@@ -12,9 +12,6 @@ module RunApi
12
12
  ENDPOINT = "/api/v1/seedream/edit_image"
13
13
  RESPONSE_CLASS = Types::EditImageResponse
14
14
  COMPLETED_RESPONSE_CLASS = Types::CompletedEditImageResponse
15
- PROMPT_MAX_LENGTH = 3000
16
- V4_PROMPT_MAX_LENGTH = 5000
17
- PROMPT_MIN_LENGTH_LITE = 3
18
15
 
19
16
  def initialize(http)
20
17
  @http = http
@@ -27,39 +24,12 @@ module RunApi
27
24
 
28
25
  def create(options: nil, **params)
29
26
  params = compact_params(params)
30
- validate_params!(params)
31
27
  request(:post, ENDPOINT, body: params, options: options)
32
28
  end
33
29
 
34
30
  def get(id, options: nil)
35
31
  request(:get, "#{ENDPOINT}/#{id}", options: options)
36
32
  end
37
-
38
- private
39
-
40
- def validate_params!(params)
41
- validate_contract!(CONTRACT["edit-image"], params)
42
-
43
- model = param(params, :model)
44
-
45
- prompt = param(params, :prompt)
46
- raise Core::ValidationError, "prompt is required" unless prompt.is_a?(String) && !prompt.empty?
47
- max_length = Types::LONG_PROMPT_MODELS.include?(model) ? V4_PROMPT_MAX_LENGTH : PROMPT_MAX_LENGTH
48
- raise Core::ValidationError, "prompt must be at most #{max_length} characters" if prompt.length > max_length
49
- if Types::MINIMUM_THREE_PROMPT_MODELS.include?(model) && prompt.length < PROMPT_MIN_LENGTH_LITE
50
- raise Core::ValidationError, "prompt must be between #{PROMPT_MIN_LENGTH_LITE} and #{max_length} characters"
51
- end
52
-
53
- validate_integer!(params, :seed) if Types::V4_MODELS.include?(model)
54
- end
55
-
56
- def validate_integer!(params, key)
57
- value = param(params, key)
58
- return if value.nil?
59
- return if value.is_a?(Integer)
60
-
61
- raise Core::ValidationError, "#{key} must be an integer"
62
- end
63
33
  end
64
34
  end
65
35
  end
@@ -12,9 +12,6 @@ module RunApi
12
12
  ENDPOINT = "/api/v1/seedream/text_to_image"
13
13
  RESPONSE_CLASS = Types::TextToImageResponse
14
14
  COMPLETED_RESPONSE_CLASS = Types::CompletedTextToImageResponse
15
- PROMPT_MAX_LENGTH = 3000
16
- V4_PROMPT_MAX_LENGTH = 5000
17
- PROMPT_MIN_LENGTH_LITE = 3
18
15
 
19
16
  def initialize(http)
20
17
  @http = http
@@ -27,43 +24,12 @@ module RunApi
27
24
 
28
25
  def create(options: nil, **params)
29
26
  params = compact_params(params)
30
- validate_params!(params)
31
27
  request(:post, ENDPOINT, body: params, options: options)
32
28
  end
33
29
 
34
30
  def get(id, options: nil)
35
31
  request(:get, "#{ENDPOINT}/#{id}", options: options)
36
32
  end
37
-
38
- private
39
-
40
- def validate_params!(params)
41
- validate_contract!(CONTRACT["text-to-image"], params)
42
-
43
- model = param(params, :model)
44
-
45
- prompt = param(params, :prompt)
46
- raise Core::ValidationError, "prompt is required" unless prompt.is_a?(String) && !prompt.empty?
47
- max_length = Types::LONG_PROMPT_MODELS.include?(model) ? V4_PROMPT_MAX_LENGTH : PROMPT_MAX_LENGTH
48
- raise Core::ValidationError, "prompt must be at most #{max_length} characters" if prompt.length > max_length
49
- if Types::MINIMUM_THREE_PROMPT_MODELS.include?(model) && prompt.length < PROMPT_MIN_LENGTH_LITE
50
- raise Core::ValidationError, "prompt must be between #{PROMPT_MIN_LENGTH_LITE} and #{max_length} characters"
51
- end
52
-
53
- validate_integer!(params, :seed) if Types::V4_MODELS.include?(model)
54
-
55
- if field_present?(params, :source_image_urls)
56
- raise Core::ValidationError, "source_image_urls is not supported for #{model}"
57
- end
58
- end
59
-
60
- def validate_integer!(params, key)
61
- value = param(params, key)
62
- return if value.nil?
63
- return if value.is_a?(Integer)
64
-
65
- raise Core::ValidationError, "#{key} must be an integer"
66
- end
67
33
  end
68
34
  end
69
35
  end
@@ -7,15 +7,6 @@ module RunApi
7
7
  # aspect_ratio and output_quality; 5-Lite/5 Pro also support output_format; V4 uses
8
8
  # output_resolution and supports seed/output_count.
9
9
  module Types
10
- # Model groupings used by bespoke prompt-length selection (a per-model rule
11
- # the contract cannot express). Model membership and field enums are
12
- # validated by the generated CONTRACT.
13
- LITE_MODELS = %w[seedream-5-lite-text-to-image seedream-5-lite-edit].freeze
14
- PRO_MODELS = %w[seedream-5-pro-text-to-image seedream-5-pro-edit].freeze
15
- V4_MODELS = %w[seedream-v4-text-to-image seedream-v4-edit].freeze
16
- LONG_PROMPT_MODELS = (PRO_MODELS + V4_MODELS).freeze
17
- MINIMUM_THREE_PROMPT_MODELS = (LITE_MODELS + PRO_MODELS).freeze
18
-
19
10
  class Image < RunApi::Core::BaseModel
20
11
  optional :url, String
21
12
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "runapi/core"
4
4
  require_relative "seedream/types"
5
- require_relative "seedream/contract_gen"
6
5
  require_relative "seedream/resources/text_to_image"
7
6
  require_relative "seedream/resources/edit_image"
8
7
  require_relative "seedream/resources/decompose_layers"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-seedream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.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.5.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.5.0
25
+ version: 0.6.0
26
26
  description: The Seedream Ruby SDK is the language-specific package for Seedream on
27
27
  RunAPI. Use this package for image generation, image editing, and creative production
28
28
  workflows when your application needs request bodies, task status lookup, and consistent
@@ -39,7 +39,6 @@ files:
39
39
  - lib/runapi-seedream.rb
40
40
  - lib/runapi/seedream.rb
41
41
  - lib/runapi/seedream/client.rb
42
- - lib/runapi/seedream/contract_gen.rb
43
42
  - lib/runapi/seedream/resources/decompose_layers.rb
44
43
  - lib/runapi/seedream/resources/edit_image.rb
45
44
  - lib/runapi/seedream/resources/text_to_image.rb
@@ -68,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
67
  - !ruby/object:Gem::Version
69
68
  version: '0'
70
69
  requirements: []
71
- rubygems_version: 4.0.17
70
+ rubygems_version: 4.0.10
72
71
  specification_version: 4
73
72
  summary: Seedream Ruby SDK for RunAPI
74
73
  test_files: []
@@ -1,228 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RunApi
4
- module Seedream
5
- CONTRACT = {
6
- "decompose-layers" => {
7
- "models" => ["seedream-5-pro-layer-decomposition"],
8
- "fields_by_model" => {
9
- "seedream-5-pro-layer-decomposition" => {
10
- "image_url" => {
11
- "required" => true
12
- },
13
- "output_format" => {
14
- "enum" => ["png", "jpeg"]
15
- },
16
- "prompt" => {
17
- "max" => 5000,
18
- "length" => true
19
- },
20
- "size" => {
21
- "enum" => ["auto", "1K", "1.5K", "2K"]
22
- }
23
- }
24
- }
25
- },
26
- "edit-image" => {
27
- "models" => ["seedream-4.5-edit", "seedream-5-lite-edit", "seedream-5-pro-edit", "seedream-v4-edit"],
28
- "fields_by_model" => {
29
- "seedream-4.5-edit" => {
30
- "aspect_ratio" => {
31
- "enum" => ["1:1", "4:3", "3:4", "16:9", "9:16", "2:3", "3:2", "21:9"],
32
- "required" => true
33
- },
34
- "output_count" => {
35
- "type" => "integer"
36
- },
37
- "output_quality" => {
38
- "enum" => ["basic", "high"],
39
- "required" => true
40
- },
41
- "seed" => {
42
- "type" => "integer"
43
- },
44
- "source_image_urls" => {
45
- "required" => true,
46
- "min_items" => 1,
47
- "max_items" => 14
48
- }
49
- },
50
- "seedream-5-lite-edit" => {
51
- "aspect_ratio" => {
52
- "enum" => ["1:1", "4:3", "3:4", "16:9", "9:16", "2:3", "3:2", "21:9"],
53
- "required" => true
54
- },
55
- "output_count" => {
56
- "type" => "integer"
57
- },
58
- "output_format" => {
59
- "enum" => ["png", "jpeg"]
60
- },
61
- "output_quality" => {
62
- "enum" => ["basic", "high", "ultra"],
63
- "required" => true
64
- },
65
- "seed" => {
66
- "type" => "integer"
67
- },
68
- "source_image_urls" => {
69
- "required" => true,
70
- "min_items" => 1,
71
- "max_items" => 14
72
- }
73
- },
74
- "seedream-5-pro-edit" => {
75
- "aspect_ratio" => {
76
- "enum" => ["1:1", "4:3", "3:4", "16:9", "9:16", "2:3", "3:2", "21:9"],
77
- "required" => true
78
- },
79
- "output_format" => {
80
- "enum" => ["png", "jpeg"]
81
- },
82
- "output_quality" => {
83
- "enum" => ["basic", "high"],
84
- "required" => true
85
- },
86
- "prompt" => {
87
- "required" => true,
88
- "min" => 3,
89
- "max" => 5000,
90
- "length" => true
91
- },
92
- "source_image_urls" => {
93
- "required" => true,
94
- "min_items" => 1,
95
- "max_items" => 10
96
- }
97
- },
98
- "seedream-v4-edit" => {
99
- "aspect_ratio" => {
100
- "enum" => ["1:1", "4:3", "3:4", "3:2", "2:3", "16:9", "9:16", "21:9"]
101
- },
102
- "output_count" => {
103
- "enum" => [1, 2, 3, 4, 5, 6],
104
- "type" => "integer"
105
- },
106
- "output_resolution" => {
107
- "enum" => ["1k", "2k", "4k"]
108
- },
109
- "seed" => {
110
- "type" => "integer"
111
- },
112
- "source_image_urls" => {
113
- "required" => true,
114
- "min_items" => 1,
115
- "max_items" => 10
116
- }
117
- }
118
- },
119
- "rules" => [{
120
- "when" => {
121
- "model" => "seedream-4.5-edit"
122
- },
123
- "forbidden" => ["output_format"]
124
- }, {
125
- "when" => {
126
- "model" => "seedream-5-pro-edit"
127
- },
128
- "forbidden" => ["output_resolution", "output_count", "seed"]
129
- }, {
130
- "when" => {
131
- "model" => "seedream-v4-edit"
132
- },
133
- "forbidden" => ["output_format"]
134
- }]
135
- },
136
- "text-to-image" => {
137
- "models" => ["seedream-4.5-text-to-image", "seedream-5-lite-text-to-image", "seedream-5-pro-text-to-image", "seedream-v4-text-to-image"],
138
- "fields_by_model" => {
139
- "seedream-4.5-text-to-image" => {
140
- "aspect_ratio" => {
141
- "enum" => ["1:1", "4:3", "3:4", "16:9", "9:16", "2:3", "3:2", "21:9"],
142
- "required" => true
143
- },
144
- "output_count" => {
145
- "type" => "integer"
146
- },
147
- "output_quality" => {
148
- "enum" => ["basic", "high"],
149
- "required" => true
150
- },
151
- "seed" => {
152
- "type" => "integer"
153
- }
154
- },
155
- "seedream-5-lite-text-to-image" => {
156
- "aspect_ratio" => {
157
- "enum" => ["1:1", "4:3", "3:4", "16:9", "9:16", "2:3", "3:2", "21:9"],
158
- "required" => true
159
- },
160
- "output_count" => {
161
- "type" => "integer"
162
- },
163
- "output_format" => {
164
- "enum" => ["png", "jpeg"]
165
- },
166
- "output_quality" => {
167
- "enum" => ["basic", "high", "ultra"],
168
- "required" => true
169
- },
170
- "seed" => {
171
- "type" => "integer"
172
- }
173
- },
174
- "seedream-5-pro-text-to-image" => {
175
- "aspect_ratio" => {
176
- "enum" => ["1:1", "4:3", "3:4", "16:9", "9:16", "2:3", "3:2", "21:9"],
177
- "required" => true
178
- },
179
- "output_format" => {
180
- "enum" => ["png", "jpeg"]
181
- },
182
- "output_quality" => {
183
- "enum" => ["basic", "high"],
184
- "required" => true
185
- },
186
- "prompt" => {
187
- "required" => true,
188
- "min" => 3,
189
- "max" => 5000,
190
- "length" => true
191
- }
192
- },
193
- "seedream-v4-text-to-image" => {
194
- "aspect_ratio" => {
195
- "enum" => ["1:1", "4:3", "3:4", "3:2", "2:3", "16:9", "9:16", "21:9"]
196
- },
197
- "output_count" => {
198
- "enum" => [1, 2, 3, 4, 5, 6],
199
- "type" => "integer"
200
- },
201
- "output_resolution" => {
202
- "enum" => ["1k", "2k", "4k"]
203
- },
204
- "seed" => {
205
- "type" => "integer"
206
- }
207
- }
208
- },
209
- "rules" => [{
210
- "when" => {
211
- "model" => "seedream-4.5-text-to-image"
212
- },
213
- "forbidden" => ["output_format"]
214
- }, {
215
- "when" => {
216
- "model" => "seedream-5-pro-text-to-image"
217
- },
218
- "forbidden" => ["output_resolution", "output_count", "seed"]
219
- }, {
220
- "when" => {
221
- "model" => "seedream-v4-text-to-image"
222
- },
223
- "forbidden" => ["output_format"]
224
- }]
225
- }
226
- }.freeze
227
- end
228
- end