runapi-happyhorse 0.2.6 → 0.2.8

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: 8420f63d7f99ed90385490503c24de7fcb1057aafe9c7d2e707e0509df9daeb2
4
- data.tar.gz: 76648efbe65479f2c4c042ae4e5d11b2fc51e8f76c0fe113836f784e797c4f98
3
+ metadata.gz: e7d66e7f6bb1e4993244ffac318f0ea95a9a20d5b395588ed6f18d5a8a6dc7d3
4
+ data.tar.gz: 8559c1d3ee40b323fdc03a84b72cef7c076729089f8e00e3ff2e4e3e33c86442
5
5
  SHA512:
6
- metadata.gz: f7e08714a1d7b8ffb5f22ac49c0d652876eeedff7c8e0a460cb9114db6604d9a98c275cb56d8244b46a0602891f62bf2ab9af652afa824476de778dc9ef6acbf
7
- data.tar.gz: fefb8e30365b1d577314ef2de5dcda68bce75f85125fd0734128a5f648f255a5f2a3bdd26fc1078d637631662265ce7ab49ed197deb071cc1cfbbe5b6411c701
6
+ metadata.gz: 909f40ba4f68a5eb5f8fe5ceb6bf3ce42f2a30f05b1db001aa68b2da8f1e70f9aee8f79a427ec9db6adf3a24963b6ce5b92b142c2fda4c5f856f2a338132d166
7
+ data.tar.gz: 3633c1b80aecfff1c4f75dc930db62705415f6febcb35b37ddb156bb5f29c97444c8bd1268d87b33f089381ffc5a9a2716e447a66f042ccf34dbca29f6aa75b8
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # HappyHorse API Ruby SDK for RunAPI
2
2
 
3
- The happyhorse ai api Ruby SDK is the language-specific package for HappyHorse on RunAPI. Use this package for text, image, and edit-video workflows that need JSON request bodies, task status lookup, and consistent RunAPI errors in Ruby.
3
+ The HappyHorse Ruby SDK is the language-specific package for HappyHorse on RunAPI. Use this package for video generation, animation, and video editing workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in Ruby.
4
4
 
5
5
  ## Install
6
6
 
@@ -11,7 +11,7 @@ gem install runapi-happyhorse
11
11
  ## Quick start
12
12
 
13
13
  ```ruby
14
- require "runapi-happyhorse"
14
+ require "runapi/happyhorse"
15
15
 
16
16
  client = RunApi::HappyHorse::Client.new
17
17
  video = client.text_to_video.run(
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunApi
4
+ module HappyHorse
5
+ CONTRACT = {
6
+ "edit-video" => {
7
+ "models" => ["happyhorse-edit-video"],
8
+ "fields_by_model" => {
9
+ "happyhorse-edit-video" => {
10
+ "audio_setting" => {
11
+ "enum" => ["auto", "original"]
12
+ },
13
+ "output_resolution" => {
14
+ "enum" => ["720p", "1080p"]
15
+ },
16
+ "reference_image_urls" => {
17
+ "max_items" => 5
18
+ },
19
+ "seed" => {
20
+ "type" => "integer"
21
+ },
22
+ "source_video_url" => {
23
+ "required" => true
24
+ }
25
+ }
26
+ }
27
+ },
28
+ "image-to-video" => {
29
+ "models" => ["happyhorse-image-to-video"],
30
+ "fields_by_model" => {
31
+ "happyhorse-image-to-video" => {
32
+ "duration_seconds" => {
33
+ "type" => "integer"
34
+ },
35
+ "first_frame_image_url" => {
36
+ "required" => true
37
+ },
38
+ "output_resolution" => {
39
+ "enum" => ["720p", "1080p"]
40
+ },
41
+ "seed" => {
42
+ "type" => "integer"
43
+ }
44
+ }
45
+ }
46
+ },
47
+ "text-to-video" => {
48
+ "models" => ["happyhorse-character", "happyhorse-text-to-video"],
49
+ "fields_by_model" => {
50
+ "happyhorse-character" => {
51
+ "aspect_ratio" => {
52
+ "enum" => ["16:9", "9:16", "1:1", "4:3", "3:4"]
53
+ },
54
+ "duration_seconds" => {
55
+ "type" => "integer"
56
+ },
57
+ "output_resolution" => {
58
+ "enum" => ["720p", "1080p"]
59
+ },
60
+ "reference_image_urls" => {
61
+ "required" => true,
62
+ "min_items" => 1,
63
+ "max_items" => 9
64
+ },
65
+ "seed" => {
66
+ "type" => "integer"
67
+ }
68
+ },
69
+ "happyhorse-text-to-video" => {
70
+ "aspect_ratio" => {
71
+ "enum" => ["16:9", "9:16", "1:1", "4:3", "3:4"]
72
+ },
73
+ "duration_seconds" => {
74
+ "type" => "integer"
75
+ },
76
+ "output_resolution" => {
77
+ "enum" => ["720p", "1080p"]
78
+ },
79
+ "seed" => {
80
+ "type" => "integer"
81
+ }
82
+ }
83
+ }
84
+ }
85
+ }.freeze
86
+ end
87
+ end
@@ -12,7 +12,6 @@ module RunApi
12
12
 
13
13
  RESPONSE_CLASS = Types::EditVideoResponse
14
14
  COMPLETED_RESPONSE_CLASS = Types::CompletedEditVideoResponse
15
- REFERENCE_IMAGE_RANGE = (0..5)
16
15
 
17
16
  def initialize(http)
18
17
  @http = http
@@ -22,43 +21,36 @@ module RunApi
22
21
  #
23
22
  # @param params [Hash] edit-video parameters
24
23
  # @return [RunApi::HappyHorse::Types::CompletedEditVideoResponse] completed task with videos
25
- def run(**params)
26
- task = create(**params)
27
- poll_until_complete { get(task.id) }
24
+ def run(options: nil, **params)
25
+ task = create(options: options, **params)
26
+ poll_until_complete { get(task.id, options: options) }
28
27
  end
29
28
 
30
29
  # Create an edit-video task.
31
30
  #
32
31
  # @param params [Hash] edit-video parameters
33
32
  # @return [RunApi::HappyHorse::Types::EditVideoResponse] task creation result with id
34
- def create(**params)
33
+ def create(options: nil, **params)
35
34
  params = compact_params(params)
36
35
  validate_params!(params)
37
- request(:post, ENDPOINT, body: params)
36
+ request(:post, ENDPOINT, body: params, options: options)
38
37
  end
39
38
 
40
39
  # Get edit-video task status by task ID.
41
40
  #
42
41
  # @param id [String] task ID
43
42
  # @return [RunApi::HappyHorse::Types::EditVideoResponse] current task status
44
- def get(id)
45
- request(:get, "#{ENDPOINT}/#{id}")
43
+ def get(id, options: nil)
44
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
46
45
  end
47
46
 
48
47
  private
49
48
 
50
49
  def validate_params!(params)
51
- raise Core::ValidationError, "model is required" unless param(params, :model) == Types::EDIT_VIDEO_MODEL
52
- raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
53
- raise Core::ValidationError, "source_video_url is required" unless param(params, :source_video_url)
50
+ validate_contract!(CONTRACT["edit-video"], params)
54
51
 
55
- reference_image_urls = param(params, :reference_image_urls)
56
- if reference_image_urls && (!reference_image_urls.is_a?(Array) || !REFERENCE_IMAGE_RANGE.cover?(reference_image_urls.size))
57
- raise Core::ValidationError, "reference_image_urls must include at most #{REFERENCE_IMAGE_RANGE.max} entries"
58
- end
52
+ raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
59
53
 
60
- validate_optional!(params, :output_resolution, Types::OUTPUT_RESOLUTIONS)
61
- validate_optional!(params, :audio_setting, Types::AUDIO_SETTINGS)
62
54
  validate_integer_range!(params, :seed, Types::SEED_RANGE)
63
55
  end
64
56
 
@@ -21,36 +21,34 @@ module RunApi
21
21
  #
22
22
  # @param params [Hash] image-to-video parameters
23
23
  # @return [RunApi::HappyHorse::Types::CompletedImageToVideoResponse] completed task with videos
24
- def run(**params)
25
- task = create(**params)
26
- poll_until_complete { get(task.id) }
24
+ def run(options: nil, **params)
25
+ task = create(options: options, **params)
26
+ poll_until_complete { get(task.id, options: options) }
27
27
  end
28
28
 
29
29
  # Create an image-to-video task.
30
30
  #
31
31
  # @param params [Hash] image-to-video parameters
32
32
  # @return [RunApi::HappyHorse::Types::ImageToVideoResponse] task creation result with id
33
- def create(**params)
33
+ def create(options: nil, **params)
34
34
  params = compact_params(params)
35
35
  validate_params!(params)
36
- request(:post, ENDPOINT, body: params)
36
+ request(:post, ENDPOINT, body: params, options: options)
37
37
  end
38
38
 
39
39
  # Get image-to-video task status by task ID.
40
40
  #
41
41
  # @param id [String] task ID
42
42
  # @return [RunApi::HappyHorse::Types::ImageToVideoResponse] current task status
43
- def get(id)
44
- request(:get, "#{ENDPOINT}/#{id}")
43
+ def get(id, options: nil)
44
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
45
45
  end
46
46
 
47
47
  private
48
48
 
49
49
  def validate_params!(params)
50
- raise Core::ValidationError, "model is required" unless param(params, :model) == Types::IMAGE_TO_VIDEO_MODEL
51
- raise Core::ValidationError, "first_frame_image_url is required" unless param(params, :first_frame_image_url)
50
+ validate_contract!(CONTRACT["image-to-video"], params)
52
51
 
53
- validate_optional!(params, :output_resolution, Types::OUTPUT_RESOLUTIONS)
54
52
  validate_integer_range!(params, :duration_seconds, Types::DURATION_RANGE)
55
53
  validate_integer_range!(params, :seed, Types::SEED_RANGE)
56
54
  end
@@ -12,7 +12,6 @@ module RunApi
12
12
 
13
13
  RESPONSE_CLASS = Types::TextToVideoResponse
14
14
  COMPLETED_RESPONSE_CLASS = Types::CompletedTextToVideoResponse
15
- REFERENCE_IMAGE_URLS_RANGE = (1..9)
16
15
 
17
16
  def initialize(http)
18
17
  @http = http
@@ -22,47 +21,41 @@ module RunApi
22
21
  #
23
22
  # @param params [Hash] text-to-video parameters
24
23
  # @return [RunApi::HappyHorse::Types::CompletedTextToVideoResponse] completed task with videos
25
- def run(**params)
26
- task = create(**params)
27
- poll_until_complete { get(task.id) }
24
+ def run(options: nil, **params)
25
+ task = create(options: options, **params)
26
+ poll_until_complete { get(task.id, options: options) }
28
27
  end
29
28
 
30
29
  # Create a text-to-video task.
31
30
  #
32
31
  # @param params [Hash] text-to-video parameters
33
32
  # @return [RunApi::HappyHorse::Types::TextToVideoResponse] task creation result with id
34
- def create(**params)
33
+ def create(options: nil, **params)
35
34
  params = compact_params(params)
36
35
  validate_params!(params)
37
- request(:post, ENDPOINT, body: params)
36
+ request(:post, ENDPOINT, body: params, options: options)
38
37
  end
39
38
 
40
39
  # Get text-to-video task status by task ID.
41
40
  #
42
41
  # @param id [String] task ID
43
42
  # @return [RunApi::HappyHorse::Types::TextToVideoResponse] current task status
44
- def get(id)
45
- request(:get, "#{ENDPOINT}/#{id}")
43
+ def get(id, options: nil)
44
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
46
45
  end
47
46
 
48
47
  private
49
48
 
50
49
  def validate_params!(params)
51
- model = param(params, :model)
52
- raise Core::ValidationError, "model is required" unless Types::TEXT_TO_VIDEO_MODELS.include?(model)
50
+ validate_contract!(CONTRACT["text-to-video"], params)
51
+
53
52
  raise Core::ValidationError, "prompt is required" unless param(params, :prompt)
54
53
 
55
54
  reference_image_urls = param(params, :reference_image_urls)
56
- if model == Types::CHARACTER_MODEL
57
- unless reference_image_urls.is_a?(Array) && REFERENCE_IMAGE_URLS_RANGE.cover?(reference_image_urls.size)
58
- raise Core::ValidationError, "reference_image_urls must include between #{REFERENCE_IMAGE_URLS_RANGE.min} and #{REFERENCE_IMAGE_URLS_RANGE.max} entries"
59
- end
60
- elsif reference_image_urls
55
+ if param(params, :model) != Types::CHARACTER_MODEL && reference_image_urls
61
56
  raise Core::ValidationError, "reference_image_urls is only supported for #{Types::CHARACTER_MODEL}"
62
57
  end
63
58
 
64
- validate_optional!(params, :output_resolution, Types::OUTPUT_RESOLUTIONS)
65
- validate_optional!(params, :aspect_ratio, Types::ASPECT_RATIOS)
66
59
  validate_integer_range!(params, :duration_seconds, Types::DURATION_RANGE)
67
60
  validate_integer_range!(params, :seed, Types::SEED_RANGE)
68
61
  end
@@ -4,20 +4,8 @@ module RunApi
4
4
  module HappyHorse
5
5
  # Type definitions and constants for HappyHorse video generation and editing.
6
6
  module Types
7
- # Standard text-to-video model.
8
- TEXT_TO_VIDEO_MODEL = "happyhorse-text-to-video"
9
7
  # Character-consistent model; requires 1-9 reference_image_urls.
10
8
  CHARACTER_MODEL = "happyhorse-character"
11
- # All text-to-video model variants.
12
- TEXT_TO_VIDEO_MODELS = [TEXT_TO_VIDEO_MODEL, CHARACTER_MODEL].freeze
13
- IMAGE_TO_VIDEO_MODEL = "happyhorse-image-to-video"
14
- EDIT_VIDEO_MODEL = "happyhorse-edit-video"
15
- # Output resolution options. Defaults to 1080p.
16
- OUTPUT_RESOLUTIONS = %w[720p 1080p].freeze
17
- # Aspect ratio options. Defaults to 16:9.
18
- ASPECT_RATIOS = %w[16:9 9:16 1:1 4:3 3:4].freeze
19
- # Audio handling for video editing: "auto" lets the model decide, "original" preserves source audio.
20
- AUDIO_SETTINGS = %w[auto original].freeze
21
9
  # Duration range in seconds (3-15). Defaults to 5.
22
10
  DURATION_RANGE = (3..15)
23
11
  # Reproducibility seed range.
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "runapi/core"
4
4
  require_relative "happyhorse/types"
5
+ require_relative "happyhorse/contract_gen"
5
6
  require_relative "happyhorse/resources/edit_video"
6
7
  require_relative "happyhorse/resources/image_to_video"
7
8
  require_relative "happyhorse/resources/text_to_video"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-happyhorse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - RunAPI
@@ -15,17 +15,18 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.6
18
+ version: 0.2.14
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.6
26
- description: The happyhorse ai api Ruby SDK is the language-specific package for HappyHorse
27
- on RunAPI. Use this package for text, image, and edit-video workflows that need
28
- JSON request bodies, task status lookup, and consistent RunAPI errors in Ruby.
25
+ version: 0.2.14
26
+ description: The HappyHorse Ruby SDK is the language-specific package for HappyHorse
27
+ on RunAPI. Use this package for video generation, animation, and video editing workflows
28
+ when your application needs request bodies, task status lookup, and consistent RunAPI
29
+ errors in Ruby.
29
30
  email:
30
31
  - contact@runapi.ai
31
32
  executables: []
@@ -38,6 +39,7 @@ files:
38
39
  - lib/runapi-happyhorse.rb
39
40
  - lib/runapi/happyhorse.rb
40
41
  - lib/runapi/happyhorse/client.rb
42
+ - lib/runapi/happyhorse/contract_gen.rb
41
43
  - lib/runapi/happyhorse/resources/edit_video.rb
42
44
  - lib/runapi/happyhorse/resources/image_to_video.rb
43
45
  - lib/runapi/happyhorse/resources/text_to_video.rb
@@ -46,9 +48,11 @@ homepage: https://runapi.ai/models/happyhorse
46
48
  licenses:
47
49
  - Apache-2.0
48
50
  metadata:
51
+ runapi_slug: happyhorse
49
52
  homepage_uri: https://runapi.ai/models/happyhorse
50
53
  documentation_uri: https://github.com/runapi-ai/happyhorse-sdk/blob/main/ruby/README.md
51
54
  source_code_uri: https://github.com/runapi-ai/happyhorse-sdk
55
+ bug_tracker_uri: https://github.com/runapi-ai/happyhorse-sdk/issues
52
56
  changelog_uri: https://github.com/runapi-ai/happyhorse-sdk/blob/main/CHANGELOG.md
53
57
  rdoc_options: []
54
58
  require_paths: