runapi-seedream 0.2.11 → 0.2.13

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: c18b722373785d38b9f50012f72d631079cb7e6969a5fcbe2478f540db2ef985
4
- data.tar.gz: 8da8e9cc24e5aef92bd396a29aa52d1eb2d79d96d24ecd073fd82c534ec45f0d
3
+ metadata.gz: c3c87b639ed82afc9c4f7d96106fcd9ee3ebfa322cfa20219bdd6d21e3d7c44c
4
+ data.tar.gz: 7a478828b7c2de132e32a280f6e1c8b4056eadb34c52f4092e712179bfa86a0c
5
5
  SHA512:
6
- metadata.gz: 989112c12aec51764f7c222088112d6f72847c9d0ebd75fc86a9c0c5ffebe7ebe1d7fef3727e3ad11dcb3824b55271431581f983e93ec4658162d2dc5a5a9aae
7
- data.tar.gz: 95a1ce3e40e62ea60daffd99569b57daaddc9561015a910a67b67e7446d8746247e415f6d88640c9960c2252acbb82f8fe5e2d4110a2aa580039e4a187c22e3e
6
+ metadata.gz: 47957fba900faba71a1b000d6f4808f60b1494732883e1f14fc291933aff99ea0423943148252801694f31e24915b826295a07e5d72fc598b07f836110ca2935
7
+ data.tar.gz: fd41da8643a0c7d487e829210972f2773fb5b804ae807596cb16e5807c628a9e7bddbf2c33e41850d04d621433558de3fae205ad24495e57428c46b12163b827
data/README.md CHANGED
@@ -32,11 +32,11 @@ RunAPI-generated file URLs are temporary. Download and store generated images, v
32
32
 
33
33
  ## Seedream 5 Pro
34
34
 
35
- Use `seedream-5-pro-text-to-image` for generation and `seedream-5-pro-edit` for image editing. Both accept `output_quality`, optional `output_format`, and optional content safety checking; editing accepts up to 10 source image URLs.
35
+ Use `seedream-5-pro-text-to-image` for generation, `seedream-5-pro-edit` for image editing, and `seedream-5-pro-layer-decomposition` to separate one image into a base image and ordered transparent layers.
36
36
 
37
37
  ## Language notes
38
38
 
39
- Use Ruby keyword arguments and the `RunApi::Seedream` error classes when building image jobs, Rails workers, or scripts. The package exposes `text_to_image` for text models and `edit_image` for editing models. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
39
+ Use Ruby keyword arguments and the `RunApi::Seedream` error classes when building image jobs, Rails workers, or scripts. The package exposes `text_to_image`, `edit_image`, and `decompose_layers`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
40
40
 
41
41
  ## Links
42
42
 
@@ -29,11 +29,14 @@ module RunApi
29
29
  attr_reader :text_to_image
30
30
  # @return [Resources::EditImage] Edit source images with a text prompt.
31
31
  attr_reader :edit_image
32
+ # @return [Resources::DecomposeLayers] Separate an image into editable layers.
33
+ attr_reader :decompose_layers
32
34
 
33
35
  def initialize(api_key: nil, **options)
34
36
  super
35
37
  @text_to_image = Resources::TextToImage.new(http)
36
38
  @edit_image = Resources::EditImage.new(http)
39
+ @decompose_layers = Resources::DecomposeLayers.new(http)
37
40
  end
38
41
  end
39
42
  end
@@ -3,6 +3,26 @@
3
3
  module RunApi
4
4
  module Seedream
5
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
+ },
6
26
  "edit-image" => {
7
27
  "models" => ["seedream-4.5-edit", "seedream-5-lite-edit", "seedream-5-pro-edit", "seedream-v4-edit"],
8
28
  "fields_by_model" => {
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunApi
4
+ module Seedream
5
+ module Resources
6
+ # Separates one image into a base image and independent layers.
7
+ class DecomposeLayers
8
+ include RunApi::Core::ResourceHelpers
9
+
10
+ ENDPOINT = "/api/v1/seedream/decompose_layers"
11
+ RESPONSE_CLASS = Types::DecomposeLayersResponse
12
+ COMPLETED_RESPONSE_CLASS = Types::CompletedDecomposeLayersResponse
13
+
14
+ def initialize(http)
15
+ @http = http
16
+ end
17
+
18
+ def run(options: nil, **params)
19
+ task = create(options: options, **params)
20
+ poll_until_complete { get(task.id, options: options) }
21
+ end
22
+
23
+ def create(options: nil, **params)
24
+ params = compact_params(params)
25
+ validate_contract!(CONTRACT["decompose-layers"], params)
26
+ request(:post, ENDPOINT, body: params, options: options)
27
+ end
28
+
29
+ def get(id, options: nil)
30
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -37,6 +37,19 @@ module RunApi
37
37
  end
38
38
 
39
39
  CompletedEditImageResponse = CompletedTextToImageResponse
40
+
41
+ class DecomposeLayersResponse < RunApi::Core::TaskResponse
42
+ required :id, String
43
+ optional :status, String, enum: -> { RunApi::Core::TaskResponse::Status::ALL }
44
+ optional :base_image, -> { Image }
45
+ optional :layers, [-> { Image }]
46
+ optional :error, String
47
+ end
48
+
49
+ class CompletedDecomposeLayersResponse < DecomposeLayersResponse
50
+ required :base_image, -> { Image }
51
+ required :layers, [-> { Image }]
52
+ end
40
53
  end
41
54
  end
42
55
  end
@@ -5,6 +5,7 @@ require_relative "seedream/types"
5
5
  require_relative "seedream/contract_gen"
6
6
  require_relative "seedream/resources/text_to_image"
7
7
  require_relative "seedream/resources/edit_image"
8
+ require_relative "seedream/resources/decompose_layers"
8
9
  require_relative "seedream/client"
9
10
 
10
11
  module RunApi
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.2.11
4
+ version: 0.2.13
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.3.4
18
+ version: 0.4.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.3.4
25
+ version: 0.4.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
@@ -40,6 +40,7 @@ files:
40
40
  - lib/runapi/seedream.rb
41
41
  - lib/runapi/seedream/client.rb
42
42
  - lib/runapi/seedream/contract_gen.rb
43
+ - lib/runapi/seedream/resources/decompose_layers.rb
43
44
  - lib/runapi/seedream/resources/edit_image.rb
44
45
  - lib/runapi/seedream/resources/text_to_image.rb
45
46
  - lib/runapi/seedream/types.rb