ruby-leonardoai 0.1.5 → 0.1.6

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: 177f0c64e72ef9ede48bf722a6a8886be330abcb1f9ab10af719395cb27046c2
4
- data.tar.gz: 4c1ed2cb485ada7871c810c6908194bbfe33876af0d44d983a2044494d81324c
3
+ metadata.gz: de55b3e839a008371101dab19fefc4157d9290c42a3e2de665493362648feea3
4
+ data.tar.gz: a6d79f4179c88c9c5cdede664203ea30cf5cb1e273e9c3dfb8f3f110384c37ed
5
5
  SHA512:
6
- metadata.gz: 06d681a7ed63d0d19df5506856d9f62c2254853b031dffd72710cd9988e6050d1c14797c8d5ec5508b323065557255a451d532d8bc322ab278a40607b7132095
7
- data.tar.gz: b801221868605de96484b84fad6be03c20653b1046bb9099be052276abfe6b8b5a1b97d01d7d4eaeaf4c8b6331f8a9103333303341d115ca33590999c4a14f8e
6
+ metadata.gz: d5669c7773cf2df4e6a7c65309fe2631df857321535c7ee9e52bc361444c6e2606e0ed0960a4c920d0bee765dfea050137a45d5bbbf4f372fd8a910667df7d0e
7
+ data.tar.gz: b171eee19f9d2e9300b79c663ab7a5de9949834472039f40c46789536ff098678e8e4ca0633de3e330c54ca4ce1667010d375739d6ebadbb7d79b81acdcda41a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-leonardoai (0.1.3)
4
+ ruby-leonardoai (0.1.6)
5
5
  faraday (>= 1)
6
6
  faraday-multipart (>= 1)
7
7
 
data/README.md CHANGED
@@ -109,12 +109,40 @@ LeonardoAI.configure do |config|
109
109
  } # Optional
110
110
  end
111
111
  ```
112
+ ### Running in Console
113
+ Easily run tests in console with ```bin/console```
114
+
115
+ ```ruby
116
+ # Example
117
+
118
+ client = LeonardoAI::Client.new(access_token: "your-access-token-here")
119
+
120
+ params = {
121
+ :height=>1024,
122
+ :prompt=>"A ad flyer of a ninja cat, heavy texture, moonlit background, circle design, tshirt design, pen and ink style",
123
+ :width=>512, :num_images=>1,
124
+ :photoReal=>false,
125
+ :presetStyle=>"LEONARDO",
126
+ :promptMagic=>true,
127
+ :promptMagicVersion=>"v2",
128
+ :public=>false,
129
+ :init_strength=>0.4,
130
+ :sd_version=>"v2",
131
+ }
132
+
133
+ response = client.generations.generate(parameters: params)
134
+ puts response
135
+ ```
136
+
137
+
112
138
 
113
139
  ### Generation
114
140
 
115
141
  ChatGPT is a model that can be used to generate text in a conversational style. You can use it to [generate a response](https://platform.openai.com/docs/api-reference/chat/create) to a sequence of [messages](https://platform.openai.com/docs/guides/chat/introduction):
116
142
 
117
143
  ```ruby
144
+ # https://docs.leonardo.ai/reference/creategeneration
145
+
118
146
  params = {
119
147
  :height=>1024,
120
148
  :prompt=>"A ad flyer of a ninja cat, heavy texture, moonlit background, circle design, tshirt design, pen and ink style",
@@ -135,7 +163,7 @@ puts response.dig("sdGenerationJob", "generationId")
135
163
 
136
164
  ### Model
137
165
  ```ruby
138
- # https://cloud.leonardo.ai/api/rest/v1/models-3d/upload
166
+ # https://docs.leonardo.ai/reference/post_models-3d-upload
139
167
 
140
168
  params = {
141
169
  :modelExtension=>"this-is-an-example",
@@ -146,7 +174,7 @@ response = client.models.upload_3d_model(parameters: params)
146
174
  ```
147
175
 
148
176
  ```ruby
149
- # https://cloud.leonardo.ai/api/rest/v1/models/{id}
177
+ # https://docs.leonardo.ai/reference/getmodelbyid
150
178
 
151
179
  params = {
152
180
  :modelExtension=>"this-is-an-example",
@@ -158,11 +186,41 @@ response = client.models.get_custom_models_by_id(id: "your-custom-model-id-here"
158
186
 
159
187
  For more parameters, please check the API found [here](https://docs.leonardo.ai/reference/post_models-3d-upload)
160
188
 
161
- ### Unzoom
162
- UNDER CONSTRUCTION
189
+ ### Variation
190
+ ```ruby
191
+ # https://docs.leonardo.ai/reference/post_variations-unzoom
192
+
193
+ params = {
194
+ :id=>"this-is-some-id",
195
+ :isVariation=>"boolean: true|false"
196
+ }
197
+
198
+ response = client.variations.create_unzoom(parameters: params)
199
+ ```
200
+
201
+ ```ruby
202
+ # https://docs.leonardo.ai/reference/getvariationbyid
203
+
204
+ response = client.variations.get_variation_by_id(id: "your-variation-id-here")
205
+ ```
163
206
 
164
207
  ### Dataset
165
- UNDER CONSTRUCTION
208
+ ```ruby
209
+ # https://docs.leonardo.ai/reference/createdataset
210
+
211
+ params = {
212
+ :name=>"this-is-some-string-id",
213
+ :description=>"this-is-some-string"
214
+ }
215
+
216
+ response = client.datasets.create_dataset(parameters: params)
217
+ ```
218
+
219
+ ```ruby
220
+ # https://docs.leonardo.ai/reference/getdatasetbyid
221
+
222
+ response = client.datasets.get_dataset_by_id(id: "your-dataset-id-here")
223
+ ```
166
224
 
167
225
  ## Development
168
226
 
@@ -31,5 +31,13 @@ module LeonardoAI
31
31
  def models
32
32
  @models ||= LeonardoAI::Models.new(client: self)
33
33
  end
34
+
35
+ def variations
36
+ @variations ||= LeonardoAI::Variations.new(client: self)
37
+ end
38
+
39
+ def datasets
40
+ @datasets ||= LeonardoAI::Datasets.new(client: self)
41
+ end
34
42
  end
35
43
  end
@@ -0,0 +1,32 @@
1
+ module LeonardoAI
2
+ class Datasets
3
+ def initialize(client: nil)
4
+ @client = client
5
+ end
6
+
7
+ # params: {name: string|null, description: string|null}
8
+ def create_dataset(parameters: {})
9
+ @client.json_post(path: "/datasets", parameters: parameters)
10
+ end
11
+
12
+ # id: string
13
+ def get_dataset_by_id(id:)
14
+ @client.get(path: "/datasets/#{id}")
15
+ end
16
+
17
+ # id: string
18
+ def delete_dataset(id:)
19
+ @client.delete(path: "/datasets/#{id}")
20
+ end
21
+
22
+ # dataset_id: string (req'd0, params: {extension: string|null}
23
+ def upload_dataset_image(dataset_id:, parameters: {})
24
+ @client.json_post(path: "/datasets/#{dataset_id}/upload", parameters: parameters)
25
+ end
26
+
27
+ # dataset_id: string (req'd0, params: {generatedImageId: string|null}
28
+ def upload_dataset_image(dataset_id:, parameters: {})
29
+ @client.json_post(path: "/datasets/#{dataset_id}/upload/gen", parameters: parameters)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,21 @@
1
+ module LeonardoAI
2
+ class Variations
3
+ def initialize(client: nil)
4
+ @client = client
5
+ end
6
+
7
+ # params: {id: string|null, isVariation: boolean|null}
8
+ def create_unzoom(parameters: {})
9
+ @client.json_post(path: "/variations/unzoom", parameters: parameters)
10
+ end
11
+
12
+ # params: {id: string|null}
13
+ def create_upscale(parameters: {})
14
+ @client.json_post(path: "/variations/upscale", parameters: parameters)
15
+ end
16
+
17
+ def get_variation_by_id(id:)
18
+ @client.get(path: "/variations/#{id}")
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module LeonardoAI
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
data/lib/leonardoai.rb CHANGED
@@ -4,6 +4,8 @@ require_relative "leonardoai/http"
4
4
  require_relative "leonardoai/client"
5
5
  require_relative "leonardoai/generations"
6
6
  require_relative "leonardoai/models"
7
+ require_relative "leonardoai/variations"
8
+ require_relative "leonardoai/datasets"
7
9
  require_relative "leonardoai/version"
8
10
 
9
11
  module LeonardoAI
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-leonardoai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donald Lee
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-12 00:00:00.000000000 Z
11
+ date: 2023-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -58,9 +58,11 @@ files:
58
58
  - lib/leonardoai.rb
59
59
  - lib/leonardoai/client.rb
60
60
  - lib/leonardoai/compatibility.rb
61
+ - lib/leonardoai/datasets.rb
61
62
  - lib/leonardoai/generations.rb
62
63
  - lib/leonardoai/http.rb
63
64
  - lib/leonardoai/models.rb
65
+ - lib/leonardoai/variations.rb
64
66
  - lib/leonardoai/version.rb
65
67
  - lib/ruby/leonardoai.rb
66
68
  - ruby-leonardoai.gemspec