leoandruby 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/leoandruby/client.rb +9 -9
- data/lib/leoandruby/version.rb +1 -1
- data/lib/leoandruby.rb +2 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d4a487c7ba83376e79ce73f898ebe75378f2df1d3fbedb6668a5b51b3641ece
|
4
|
+
data.tar.gz: 954f1e0cb9f0f3ced2fc853059e77825693a1cf6f57cdf84f827049ddb862add
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46c3a77f0c5a3bd4970f9b137b64bbeda9595e3a454e71bf5aaa53784f578534feb5984867a9d97860d1a85234b2c6e1f2af80751ce3d649a9be64a84b088f54
|
7
|
+
data.tar.gz: dd969b602250d6eb442b465c483faf8a5be90d32178b9b83ee978493f4dd26418e3f8857bd71a76e3384010030b0340d7ce89c5aef0565bd5889d27567e10330
|
data/README.md
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
|
4
4
|
**LeoAndRuby** is a Ruby gem for generating images using the [Leonardo.ai API](https://docs.leonardo.ai/docs/generate-your-first-images). With this gem, you can easily integrate Leonardo.ai's powerful image generation capabilities into your Ruby applications.
|
5
5
|
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/leoandruby.svg)](https://badge.fury.io/rb/leoandruby)
|
7
|
+
|
8
|
+
|
6
9
|
---
|
7
10
|
|
8
11
|
## Features
|
data/lib/leoandruby/client.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "net/http"
|
2
|
+
require "json"
|
3
|
+
require "uri"
|
4
4
|
|
5
5
|
module LeoAndRuby
|
6
6
|
class Client
|
7
|
-
API_BASE_URL =
|
7
|
+
API_BASE_URL = "https://cloud.leonardo.ai/api/rest/v1".freeze
|
8
8
|
|
9
9
|
def initialize(api_key)
|
10
10
|
@api_key = api_key
|
@@ -13,9 +13,9 @@ module LeoAndRuby
|
|
13
13
|
def generate_image(prompt:, model_id:, width:, height:)
|
14
14
|
uri = URI("#{API_BASE_URL}/generations")
|
15
15
|
request = Net::HTTP::Post.new(uri)
|
16
|
-
request[
|
17
|
-
request[
|
18
|
-
request[
|
16
|
+
request["Accept"] = "application/json"
|
17
|
+
request["Authorization"] = "Bearer #{@api_key}"
|
18
|
+
request["Content-Type"] = "application/json"
|
19
19
|
|
20
20
|
request.body = {
|
21
21
|
prompt: prompt,
|
@@ -34,8 +34,8 @@ module LeoAndRuby
|
|
34
34
|
def get_generation(generation_id)
|
35
35
|
uri = URI("#{API_BASE_URL}/generations/#{generation_id}")
|
36
36
|
request = Net::HTTP::Get.new(uri)
|
37
|
-
request[
|
38
|
-
request[
|
37
|
+
request["Accept"] = "application/json"
|
38
|
+
request["Authorization"] = "Bearer #{@api_key}"
|
39
39
|
|
40
40
|
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
41
41
|
http.request(request)
|
data/lib/leoandruby/version.rb
CHANGED
data/lib/leoandruby.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leoandruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard HW Baldwin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: LeoAndRuby is a Ruby gem for integrating with the Leonardo.ai API, enabling
|
14
14
|
seamless image generation within Ruby applications. It provides a simple and intuitive
|