runapi-midjourney 0.2.0 → 0.3.1

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: 06e85132c76348835ae96514c74883406ea74865d9d11525d7577e17c88f8e6f
4
- data.tar.gz: 84922384c8d30f48b9798a0b0299e6ff4be448f44819cd955fe3aba2b54ef398
3
+ metadata.gz: 4d95f63c07b630fb2078c85e3f41ae11a1485b73790c8de5c50a9e8412e51930
4
+ data.tar.gz: 571d993e64f17ea0da765284d3f0b7d82790c1dc060a2d17e24914d793799237
5
5
  SHA512:
6
- metadata.gz: 3e364a667e6b92db66d620c123d2fcf645d5a6c1af7342c8e209e5599129e720fb181603853158081cd4c45ebcfd26565a9ef11855c44b710b4cc0748c612572
7
- data.tar.gz: 9651d5a10d8eb4d6024dca341b307445bf57a4864e8ebdd62a9b43995a55eadb64a138f8363ff0ef6047b7518a9021e8accae2a90325c6296cfc2b3e48a58a28
6
+ metadata.gz: 11d53601405856537b50c13b5132de40f4ce91cd94258b347152dcce9b0905ba69eab26611b362c573a5ec9e79859e9411e0a3b1ad89c276dd7ef3163cb95a08
7
+ data.tar.gz: 8d7ff802f36621b71c98bff61fe2199098899229d4ffa9a01efa397a46e81845fb535c8be2edf5d65259c9060e966da6d92f13dcbe4b46b55034a565c764cc0f
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Midjourney Ruby SDK for RunAPI
2
2
 
3
- Use `runapi-midjourney` for Midjourney image generation, editing, image-to-video, image-to-prompt, prompt shortening, and seed lookup in Ruby applications and workers.
3
+ Use `runapi-midjourney` for Midjourney image generation, editing, image-to-video, first-video extension, image-to-prompt, prompt shortening, and seed lookup in Ruby applications and workers.
4
4
 
5
5
  ## Install
6
6
 
@@ -21,7 +21,7 @@ result = client.text_to_image.run(
21
21
  puts result.images.first.url
22
22
  ```
23
23
 
24
- Use `create`, `get`, and `run` for `text_to_image`, `edit_image`, and `image_to_video`. Use `run` directly for `image_to_prompt`, `shorten_prompt`, and `get_seed`. Generated media URLs are temporary and should be stored in durable storage.
24
+ Use `create`, `get`, and `run` for `text_to_image`, `edit_image`, `image_to_video`, and `extend_video`. `extend_video` accepts the task ID of an account-owned completed direct image-to-video task and continues its first video; extension tasks cannot be chained. Use `run` directly for `image_to_prompt`, `shorten_prompt`, and `get_seed`. Generated media URLs are temporary and should be stored in durable storage.
25
25
 
26
26
  ## Links
27
27
 
@@ -4,13 +4,14 @@ module RunApi
4
4
  module Midjourney
5
5
  # Midjourney image generation, editing, image-to-video, and helper client.
6
6
  class Client < RunApi::Core::Client
7
- attr_reader :text_to_image, :edit_image, :image_to_video, :image_to_prompt, :shorten_prompt, :get_seed
7
+ attr_reader :text_to_image, :edit_image, :image_to_video, :extend_video, :image_to_prompt, :shorten_prompt, :get_seed
8
8
 
9
9
  def initialize(api_key: nil, **options)
10
10
  super
11
11
  @text_to_image = Resources::TextToImage.new(http)
12
12
  @edit_image = Resources::EditImage.new(http)
13
13
  @image_to_video = Resources::ImageToVideo.new(http)
14
+ @extend_video = Resources::ExtendVideo.new(http)
14
15
  @image_to_prompt = Resources::ImageToPrompt.new(http)
15
16
  @shorten_prompt = Resources::ShortenPrompt.new(http)
16
17
  @get_seed = Resources::GetSeed.new(http)
@@ -16,6 +16,16 @@ module RunApi
16
16
  }
17
17
  }
18
18
  },
19
+ "extend-video" => {
20
+ "models" => ["midjourney-image-to-video"],
21
+ "fields_by_model" => {
22
+ "midjourney-image-to-video" => {
23
+ "source_task_id" => {
24
+ "required" => true
25
+ }
26
+ }
27
+ }
28
+ },
19
29
  "get-seed" => {
20
30
  "models" => [],
21
31
  "fields_by_model" => {
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunApi
4
+ module Midjourney
5
+ module Resources
6
+ # Extends the first video from a completed Midjourney image-to-video task.
7
+ class ExtendVideo
8
+ include RunApi::Core::ResourceHelpers
9
+
10
+ ENDPOINT = "/api/v1/midjourney/extend_video"
11
+ MODEL = "midjourney-image-to-video"
12
+ RESPONSE_CLASS = Types::VideoTaskResponse
13
+ COMPLETED_RESPONSE_CLASS = Types::CompletedVideoTaskResponse
14
+
15
+ def initialize(http) = (@http = http)
16
+
17
+ def run(options: nil, **params)
18
+ task = create(options: options, **params)
19
+ poll_until_complete { get(task.id, options: options) }
20
+ end
21
+
22
+ def create(options: nil, **params)
23
+ params = compact_params(params)
24
+ validate_contract!(CONTRACT["extend-video"], params.merge(model: MODEL))
25
+ request(:post, ENDPOINT, body: params, options: options)
26
+ end
27
+
28
+ def get(id, options: nil)
29
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -43,18 +43,21 @@ module RunApi
43
43
  class ImageToPromptResponse < RunApi::Core::BaseModel
44
44
  required :prompts, [String]
45
45
  optional :error, String
46
+ optional :billing, RunApi::Core::TaskBillingFacts
46
47
  end
47
48
 
48
49
  # Concise suggestions derived from a prompt.
49
50
  class ShortenPromptResponse < RunApi::Core::BaseModel
50
51
  required :prompts, [String]
51
52
  optional :error, String
53
+ optional :billing, RunApi::Core::TaskBillingFacts
52
54
  end
53
55
 
54
56
  # Seed associated with a generated image.
55
57
  class GetSeedResponse < RunApi::Core::BaseModel
56
58
  optional :seed, Integer
57
59
  optional :error, String
60
+ optional :billing, RunApi::Core::TaskBillingFacts
58
61
  end
59
62
  end
60
63
  end
@@ -6,6 +6,7 @@ require_relative "midjourney/contract_gen"
6
6
  require_relative "midjourney/resources/text_to_image"
7
7
  require_relative "midjourney/resources/edit_image"
8
8
  require_relative "midjourney/resources/image_to_video"
9
+ require_relative "midjourney/resources/extend_video"
9
10
  require_relative "midjourney/resources/image_to_prompt"
10
11
  require_relative "midjourney/resources/shorten_prompt"
11
12
  require_relative "midjourney/resources/get_seed"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-midjourney
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - RunAPI
@@ -15,16 +15,17 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.13
18
+ version: 0.3.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.2.13
25
+ version: 0.3.0
26
26
  description: Use `runapi-midjourney` for Midjourney image generation, editing, image-to-video,
27
- image-to-prompt, prompt shortening, and seed lookup in Ruby applications and workers.
27
+ first-video extension, image-to-prompt, prompt shortening, and seed lookup in Ruby
28
+ applications and workers.
28
29
  email:
29
30
  - contact@runapi.ai
30
31
  executables: []
@@ -39,6 +40,7 @@ files:
39
40
  - lib/runapi/midjourney/client.rb
40
41
  - lib/runapi/midjourney/contract_gen.rb
41
42
  - lib/runapi/midjourney/resources/edit_image.rb
43
+ - lib/runapi/midjourney/resources/extend_video.rb
42
44
  - lib/runapi/midjourney/resources/get_seed.rb
43
45
  - lib/runapi/midjourney/resources/image_to_prompt.rb
44
46
  - lib/runapi/midjourney/resources/image_to_video.rb
@@ -69,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
71
  - !ruby/object:Gem::Version
70
72
  version: '0'
71
73
  requirements: []
72
- rubygems_version: 4.0.10
74
+ rubygems_version: 4.0.17
73
75
  specification_version: 4
74
76
  summary: Midjourney Ruby SDK for RunAPI
75
77
  test_files: []