lib/gen_ai/image/stability_ai.rb in gen-ai-0.2.3 vs lib/gen_ai/image/stability_ai.rb in gen-ai-0.3.0
- old
+ new
@@ -21,11 +21,11 @@
response = client.post url, build_generation_body(prompt, options)
build_result(
raw: response,
model: model,
- parsed: response['artifacts'].map { |artifact| artifact['base64'] }
+ parsed: parse_response_data(response['artifacts'])
)
end
def edit(image, prompt, options = {})
model = options[:model] || DEFAULT_MODEL
@@ -34,11 +34,11 @@
response = client.post url, build_edit_body(image, prompt, options), multipart: true
build_result(
raw: response,
model: model,
- parsed: response['artifacts'].map { |artifact| artifact['base64'] }
+ parsed: parse_response_data(response['artifacts'])
)
end
def upscale(image, options = {})
model = options[:model] || UPSCALE_MODEL
@@ -47,11 +47,11 @@
response = client.post url, build_upscale_body(image, options), multipart: true
build_result(
raw: response,
model: model,
- parsed: response['artifacts'].map { |artifact| artifact['base64'] }
+ parsed: parse_response_data(response['artifacts'])
)
end
private
@@ -88,9 +88,13 @@
end
def size(options)
size = options.delete(:size) || DEFAULT_SIZE
size.split('x').map(&:to_i)
+ end
+
+ def parse_response_data(data)
+ data.map { |artifact| Base64.decode64(artifact['base64']) }
end
end
end
end