runapi-grok-imagine 0.2.14 → 0.2.15
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/grok_imagine/client.rb +3 -0
- data/lib/runapi/grok_imagine/contract_gen.rb +60 -4
- data/lib/runapi/grok_imagine/resources/edit_image.rb +0 -1
- data/lib/runapi/grok_imagine/resources/segment_map.rb +42 -0
- data/lib/runapi/grok_imagine/types.rb +15 -0
- data/lib/runapi/grok_imagine.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9977ae570c6a5ffe4608e156f1f8f752a5ef8f1ad3153eb9995d50d8544d072c
|
|
4
|
+
data.tar.gz: 6e860ff0abebbbc3afca07b44df6eeb24bbef7ca3138470d1fc13d3448bf0f5c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 88353615d590fe3779b74fd8d13afcc8fbe41037f390bbb4dd60c8a1de343af0d72179723886f0178adcca1f5755ce63b05209b145d44bd7f32676b45268fcf2
|
|
7
|
+
data.tar.gz: 745f3f6e1af60ef8a3d273cf09e87586028cfe7a6d1d257a6fe9cc064f86d0b2edcccf06cfc12dbe178b726d7234c4087dcb9bd09beae78a4beee7d6bd2bf0e8
|
|
@@ -18,6 +18,8 @@ module RunApi
|
|
|
18
18
|
attr_reader :image_to_video
|
|
19
19
|
# @return [Resources::TextToImage] Text-to-image generation operations.
|
|
20
20
|
attr_reader :text_to_image
|
|
21
|
+
# @return [Resources::SegmentMap] Segmentation map generation operations.
|
|
22
|
+
attr_reader :segment_map
|
|
21
23
|
# @return [Resources::EditImage] Prompt-guided image editing operations.
|
|
22
24
|
attr_reader :edit_image
|
|
23
25
|
# @return [Resources::Extensions] Extend a previously generated video.
|
|
@@ -31,6 +33,7 @@ module RunApi
|
|
|
31
33
|
@text_to_video = Resources::TextToVideo.new(http)
|
|
32
34
|
@image_to_video = Resources::ImageToVideo.new(http)
|
|
33
35
|
@text_to_image = Resources::TextToImage.new(http)
|
|
36
|
+
@segment_map = Resources::SegmentMap.new(http)
|
|
34
37
|
@edit_image = Resources::EditImage.new(http)
|
|
35
38
|
@extensions = Resources::Extensions.new(http)
|
|
36
39
|
@upscales = Resources::Upscales.new(http)
|
|
@@ -4,7 +4,7 @@ module RunApi
|
|
|
4
4
|
module GrokImagine
|
|
5
5
|
CONTRACT = {
|
|
6
6
|
"edit-image" => {
|
|
7
|
-
"models" => ["grok-imagine-edit-image"],
|
|
7
|
+
"models" => ["grok-imagine-edit-image", "grok-imagine-image-2-0"],
|
|
8
8
|
"fields_by_model" => {
|
|
9
9
|
"grok-imagine-edit-image" => {
|
|
10
10
|
"model" => {
|
|
@@ -13,8 +13,33 @@ module RunApi
|
|
|
13
13
|
"source_image_url" => {
|
|
14
14
|
"required" => true
|
|
15
15
|
}
|
|
16
|
+
},
|
|
17
|
+
"grok-imagine-image-2-0" => {
|
|
18
|
+
"mask_indices" => {
|
|
19
|
+
"min_items" => 1
|
|
20
|
+
},
|
|
21
|
+
"model" => {
|
|
22
|
+
"required" => true
|
|
23
|
+
},
|
|
24
|
+
"prompt" => {
|
|
25
|
+
"required" => true
|
|
26
|
+
},
|
|
27
|
+
"source_task_id" => {
|
|
28
|
+
"required" => true
|
|
29
|
+
}
|
|
16
30
|
}
|
|
17
|
-
}
|
|
31
|
+
},
|
|
32
|
+
"rules" => [{
|
|
33
|
+
"when" => {
|
|
34
|
+
"model" => "grok-imagine-edit-image"
|
|
35
|
+
},
|
|
36
|
+
"forbidden" => ["source_task_id", "mask_indices"]
|
|
37
|
+
}, {
|
|
38
|
+
"when" => {
|
|
39
|
+
"model" => "grok-imagine-image-2-0"
|
|
40
|
+
},
|
|
41
|
+
"forbidden" => ["source_image_url", "enable_safety_checker"]
|
|
42
|
+
}]
|
|
18
43
|
},
|
|
19
44
|
"extend" => {
|
|
20
45
|
"models" => [],
|
|
@@ -146,9 +171,34 @@ module RunApi
|
|
|
146
171
|
"forbidden" => ["source_task_id", "index", "motion_style", "enable_safety_checker"]
|
|
147
172
|
}]
|
|
148
173
|
},
|
|
174
|
+
"segment-map" => {
|
|
175
|
+
"models" => ["grok-imagine-image-2-0"],
|
|
176
|
+
"fields_by_model" => {
|
|
177
|
+
"grok-imagine-image-2-0" => {
|
|
178
|
+
"model" => {
|
|
179
|
+
"required" => true
|
|
180
|
+
},
|
|
181
|
+
"source_task_id" => {
|
|
182
|
+
"required" => true
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
},
|
|
149
187
|
"text-to-image" => {
|
|
150
|
-
"models" => ["grok-imagine-text-to-image"],
|
|
188
|
+
"models" => ["grok-imagine-image-2-0", "grok-imagine-text-to-image"],
|
|
151
189
|
"fields_by_model" => {
|
|
190
|
+
"grok-imagine-image-2-0" => {
|
|
191
|
+
"aspect_ratio" => {
|
|
192
|
+
"enum" => ["1:1", "2:3", "3:2", "16:9", "9:16"],
|
|
193
|
+
"required" => true
|
|
194
|
+
},
|
|
195
|
+
"model" => {
|
|
196
|
+
"required" => true
|
|
197
|
+
},
|
|
198
|
+
"prompt" => {
|
|
199
|
+
"required" => true
|
|
200
|
+
}
|
|
201
|
+
},
|
|
152
202
|
"grok-imagine-text-to-image" => {
|
|
153
203
|
"aspect_ratio" => {
|
|
154
204
|
"enum" => ["2:3", "3:2", "1:1", "16:9", "9:16"]
|
|
@@ -162,7 +212,13 @@ module RunApi
|
|
|
162
212
|
"length" => true
|
|
163
213
|
}
|
|
164
214
|
}
|
|
165
|
-
}
|
|
215
|
+
},
|
|
216
|
+
"rules" => [{
|
|
217
|
+
"when" => {
|
|
218
|
+
"model" => "grok-imagine-image-2-0"
|
|
219
|
+
},
|
|
220
|
+
"forbidden" => ["enable_safety_checker", "enable_pro"]
|
|
221
|
+
}]
|
|
166
222
|
},
|
|
167
223
|
"text-to-video" => {
|
|
168
224
|
"models" => ["grok-imagine-text-to-video", "grok-imagine-video-1.5-fast", "grok-imagine-video-1.5-preview"],
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RunApi
|
|
4
|
+
module GrokImagine
|
|
5
|
+
module Resources
|
|
6
|
+
# Produces an editable segmentation map from an Image 2.0 text-to-image task.
|
|
7
|
+
class SegmentMap
|
|
8
|
+
include RunApi::Core::ResourceHelpers
|
|
9
|
+
|
|
10
|
+
ENDPOINT = "/api/v1/grok_imagine/segment_map"
|
|
11
|
+
|
|
12
|
+
RESPONSE_CLASS = Types::SegmentMapTaskResponse
|
|
13
|
+
COMPLETED_RESPONSE_CLASS = Types::CompletedSegmentMapTaskResponse
|
|
14
|
+
|
|
15
|
+
def initialize(http)
|
|
16
|
+
@http = http
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def run(options: nil, **params)
|
|
20
|
+
task = create(options: options, **params)
|
|
21
|
+
poll_until_complete { get(task.id, options: options) }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def create(options: nil, **params)
|
|
25
|
+
params = compact_params(params)
|
|
26
|
+
validate_params!(params)
|
|
27
|
+
request(:post, ENDPOINT, body: params, options: options)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def get(id, options: nil)
|
|
31
|
+
request(:get, "#{ENDPOINT}/#{id}", options: options)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def validate_params!(params)
|
|
37
|
+
validate_contract!(CONTRACT["segment-map"], params)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -37,6 +37,21 @@ module RunApi
|
|
|
37
37
|
class CompletedImageTaskResponse < ImageTaskResponse
|
|
38
38
|
required :images, [-> { MediaUrl }]
|
|
39
39
|
end
|
|
40
|
+
|
|
41
|
+
class Segment < RunApi::Core::BaseModel
|
|
42
|
+
required :url, String
|
|
43
|
+
optional :name, String
|
|
44
|
+
optional :index, Integer
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
class SegmentMapTaskResponse < AsyncTaskResponse
|
|
48
|
+
optional :segments, [-> { Segment }]
|
|
49
|
+
optional :error, String
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
class CompletedSegmentMapTaskResponse < SegmentMapTaskResponse
|
|
53
|
+
required :segments, [-> { Segment }]
|
|
54
|
+
end
|
|
40
55
|
end
|
|
41
56
|
end
|
|
42
57
|
end
|
data/lib/runapi/grok_imagine.rb
CHANGED
|
@@ -6,6 +6,7 @@ require_relative "grok_imagine/contract_gen"
|
|
|
6
6
|
require_relative "grok_imagine/resources/text_to_video"
|
|
7
7
|
require_relative "grok_imagine/resources/image_to_video"
|
|
8
8
|
require_relative "grok_imagine/resources/text_to_image"
|
|
9
|
+
require_relative "grok_imagine/resources/segment_map"
|
|
9
10
|
require_relative "grok_imagine/resources/edit_image"
|
|
10
11
|
require_relative "grok_imagine/resources/extensions"
|
|
11
12
|
require_relative "grok_imagine/resources/upscales"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: runapi-grok-imagine
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.15
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- RunAPI
|
|
@@ -43,6 +43,7 @@ files:
|
|
|
43
43
|
- lib/runapi/grok_imagine/resources/edit_image.rb
|
|
44
44
|
- lib/runapi/grok_imagine/resources/extensions.rb
|
|
45
45
|
- lib/runapi/grok_imagine/resources/image_to_video.rb
|
|
46
|
+
- lib/runapi/grok_imagine/resources/segment_map.rb
|
|
46
47
|
- lib/runapi/grok_imagine/resources/text_to_image.rb
|
|
47
48
|
- lib/runapi/grok_imagine/resources/text_to_video.rb
|
|
48
49
|
- lib/runapi/grok_imagine/resources/upscales.rb
|
|
@@ -71,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
71
72
|
- !ruby/object:Gem::Version
|
|
72
73
|
version: '0'
|
|
73
74
|
requirements: []
|
|
74
|
-
rubygems_version: 4.0.
|
|
75
|
+
rubygems_version: 4.0.17
|
|
75
76
|
specification_version: 4
|
|
76
77
|
summary: Grok Imagine Ruby SDK for RunAPI
|
|
77
78
|
test_files: []
|