ruby-stabilityai 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.rubocop.yml +23 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +80 -0
- data/LICENSE.txt +21 -0
- data/README.md +209 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/ruby/stabilityai.rb +2 -0
- data/lib/stabilityai/client.rb +83 -0
- data/lib/stabilityai/compatibility.rb +9 -0
- data/lib/stabilityai/version.rb +3 -0
- data/lib/stabilityai.rb +49 -0
- data/ruby-stabilityai.gemspec +31 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 17277edf17941172cadec0db6163696718b1a39968f9495df13a621bc8e8f171
|
4
|
+
data.tar.gz: dde322e316056c9082e8929552a9818d0651b640894b494cb91381bc83def143
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bfd2a44b14b3c5ddfa7a8eae1711551fd114229460938e9d33ffa12cffe6ca1631a45dc11d5be1ae94561f06efbf681dac6d6cb8c319879f10bde1ac842884e1
|
7
|
+
data.tar.gz: 5b013585ad4d464a6ff4ca54895bbc4042d5fb72f1eb39ab27b69cc3306079d26f42e5cb7315d0db2ad4d799f16201fe1c07640dddccaec7603c14e6c98553fc
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.6
|
3
|
+
NewCops: enable
|
4
|
+
SuggestExtensions: false
|
5
|
+
|
6
|
+
Style/Documentation:
|
7
|
+
# Skips checking to make sure top level modules / classes have a comment.
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Layout/LineLength:
|
11
|
+
Max: 100
|
12
|
+
Exclude:
|
13
|
+
- "**/*.gemspec"
|
14
|
+
|
15
|
+
Metrics/BlockLength:
|
16
|
+
Exclude:
|
17
|
+
- "spec/**/*"
|
18
|
+
|
19
|
+
Style/StringLiterals:
|
20
|
+
EnforcedStyle: double_quotes
|
21
|
+
|
22
|
+
Style/FrozenStringLiteralComment:
|
23
|
+
Enabled: false
|
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Include gem dependencies from ruby-stabilityai.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem "byebug", "~> 11.1.3"
|
7
|
+
gem "dotenv", "~> 2.8.1"
|
8
|
+
gem "rake", "~> 13.0"
|
9
|
+
gem "rspec", "~> 3.12"
|
10
|
+
gem "rubocop", "~> 1.50.2"
|
11
|
+
gem "vcr", "~> 6.1.0"
|
12
|
+
gem "webmock", "~> 3.18.1"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ruby-stabilityai (0.0.1)
|
5
|
+
httparty (>= 0.18.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.8.4)
|
11
|
+
public_suffix (>= 2.0.2, < 6.0)
|
12
|
+
ast (2.4.2)
|
13
|
+
byebug (11.1.3)
|
14
|
+
crack (0.4.5)
|
15
|
+
rexml
|
16
|
+
diff-lcs (1.5.0)
|
17
|
+
dotenv (2.8.1)
|
18
|
+
hashdiff (1.0.1)
|
19
|
+
httparty (0.21.0)
|
20
|
+
mini_mime (>= 1.0.0)
|
21
|
+
multi_xml (>= 0.5.2)
|
22
|
+
json (2.6.3)
|
23
|
+
mini_mime (1.1.2)
|
24
|
+
multi_xml (0.6.0)
|
25
|
+
parallel (1.23.0)
|
26
|
+
parser (3.2.2.1)
|
27
|
+
ast (~> 2.4.1)
|
28
|
+
public_suffix (5.0.1)
|
29
|
+
rainbow (3.1.1)
|
30
|
+
rake (13.0.6)
|
31
|
+
regexp_parser (2.8.0)
|
32
|
+
rexml (3.2.5)
|
33
|
+
rspec (3.12.0)
|
34
|
+
rspec-core (~> 3.12.0)
|
35
|
+
rspec-expectations (~> 3.12.0)
|
36
|
+
rspec-mocks (~> 3.12.0)
|
37
|
+
rspec-core (3.12.2)
|
38
|
+
rspec-support (~> 3.12.0)
|
39
|
+
rspec-expectations (3.12.3)
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
+
rspec-support (~> 3.12.0)
|
42
|
+
rspec-mocks (3.12.5)
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
+
rspec-support (~> 3.12.0)
|
45
|
+
rspec-support (3.12.0)
|
46
|
+
rubocop (1.50.2)
|
47
|
+
json (~> 2.3)
|
48
|
+
parallel (~> 1.10)
|
49
|
+
parser (>= 3.2.0.0)
|
50
|
+
rainbow (>= 2.2.2, < 4.0)
|
51
|
+
regexp_parser (>= 1.8, < 3.0)
|
52
|
+
rexml (>= 3.2.5, < 4.0)
|
53
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
54
|
+
ruby-progressbar (~> 1.7)
|
55
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
56
|
+
rubocop-ast (1.28.0)
|
57
|
+
parser (>= 3.2.1.0)
|
58
|
+
ruby-progressbar (1.13.0)
|
59
|
+
unicode-display_width (2.4.2)
|
60
|
+
vcr (6.1.0)
|
61
|
+
webmock (3.18.1)
|
62
|
+
addressable (>= 2.8.0)
|
63
|
+
crack (>= 0.3.2)
|
64
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
65
|
+
|
66
|
+
PLATFORMS
|
67
|
+
x86_64-darwin-22
|
68
|
+
|
69
|
+
DEPENDENCIES
|
70
|
+
byebug (~> 11.1.3)
|
71
|
+
dotenv (~> 2.8.1)
|
72
|
+
rake (~> 13.0)
|
73
|
+
rspec (~> 3.12)
|
74
|
+
rubocop (~> 1.50.2)
|
75
|
+
ruby-stabilityai!
|
76
|
+
vcr (~> 6.1.0)
|
77
|
+
webmock (~> 3.18.1)
|
78
|
+
|
79
|
+
BUNDLED WITH
|
80
|
+
2.4.8
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 Kevin
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
# Ruby Stability.ai
|
2
|
+
|
3
|
+
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/kurbm/ruby-stabilityai/blob/main/LICENSE.txt)
|
4
|
+
|
5
|
+
Use the [Stability.ai API](https://platform.stability.ai/) with Ruby! 🤖❤️
|
6
|
+
|
7
|
+
Generate images with Stability AI, get engines, accounts and balance
|
8
|
+
|
9
|
+
[Ruby AI Builders Discord](https://discord.gg/k4Uc224xVD)
|
10
|
+
|
11
|
+
### Bundler
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem "ruby-stabilityai"
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle install
|
22
|
+
|
23
|
+
### Gem install
|
24
|
+
|
25
|
+
Or install with:
|
26
|
+
|
27
|
+
$ gem install ruby-stabilityai
|
28
|
+
|
29
|
+
and require with:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
require "stabilityai"
|
33
|
+
```
|
34
|
+
|
35
|
+
|
36
|
+
## Usage
|
37
|
+
|
38
|
+
- Get your API key from [https://beta.dreamstudio.ai/account](https://beta.dreamstudio.ai/account)
|
39
|
+
|
40
|
+
|
41
|
+
### Quickstart
|
42
|
+
|
43
|
+
For a quick test you can pass your token directly to a new client:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
client = StabilityAI::Client.new(access_token: "access_token_goes_here")
|
47
|
+
```
|
48
|
+
|
49
|
+
### With Config
|
50
|
+
|
51
|
+
For a more robust setup, you can configure the gem with your API keys, for example in an `stabilityai.rb` initializer file. Never hardcode secrets into your codebase - instead use something like [dotenv](https://github.com/motdotla/dotenv) to pass the keys safely into your environments.
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
StabilityAI.configure do |config|
|
55
|
+
config.access_token = ENV.fetch('STABILITYAI_ACCESS_TOKEN')
|
56
|
+
config.organization_id = ENV.fetch('STABILITYAI_ORGANIZATION_ID') # Optional.
|
57
|
+
end
|
58
|
+
```
|
59
|
+
|
60
|
+
Then you can create a client like this:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
client = StabilityAI::Client.new
|
64
|
+
```
|
65
|
+
|
66
|
+
#### Custom timeout and engine
|
67
|
+
|
68
|
+
The default timeout for any Stability.ai request is 120 seconds. You can change that passing the `request_timeout` when initializing the client.
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
client = StabilityAI::Client.new(
|
72
|
+
access_token: "access_token_goes_here",
|
73
|
+
request_timeout: 240,
|
74
|
+
engine_id: "/stable-diffusion-v1-5"
|
75
|
+
)
|
76
|
+
```
|
77
|
+
|
78
|
+
or when configuring the gem:
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
OpenAI.configure do |config|
|
82
|
+
config.access_token = ENV.fetch("STABILITYAI_ACCESS_TOKEN")
|
83
|
+
config.organization_id = ENV.fetch("STABILITYAI_ORGANIZATION_ID") # Optional
|
84
|
+
config.engine_id = "/stable-diffusion-v1-5"
|
85
|
+
config.request_timeout = 240 # Optional
|
86
|
+
end
|
87
|
+
```
|
88
|
+
|
89
|
+
### Engines
|
90
|
+
|
91
|
+
There are different engines that can be used to generate images. For a full list:
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
client.engines
|
95
|
+
```
|
96
|
+
|
97
|
+
#### Examples
|
98
|
+
|
99
|
+
- V1
|
100
|
+
- stable-diffusion-v1
|
101
|
+
- stable-diffusion-v1-5
|
102
|
+
- V2
|
103
|
+
- stable-diffusion-512-v2-0
|
104
|
+
- stable-diffusion-768-v2-0
|
105
|
+
|
106
|
+
### Account
|
107
|
+
|
108
|
+
Get an overview of accounts connected to your user:
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
response = client.account
|
112
|
+
puts response
|
113
|
+
# => "{"email":"email@email.com","id":"user-abcdefghijklmn","organizations":[{"id":"org-abcdefghijklmn","is_default":true,"name":"Personal","role":"OWNER"}],"profile_picture":"https://lh3.googleusercontent.com/a/abcdefghijklmn"}"
|
114
|
+
```
|
115
|
+
|
116
|
+
### Balance
|
117
|
+
|
118
|
+
Get feedback, how much balance is left in your account:
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
response = client.balance
|
122
|
+
puts response
|
123
|
+
# => {"credits":1001.73012}
|
124
|
+
```
|
125
|
+
|
126
|
+
### Text To Image
|
127
|
+
|
128
|
+
Send a string and additional settings to create your image:
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
response = client.text_to_image(
|
132
|
+
parameters: {
|
133
|
+
text_prompts: [
|
134
|
+
{
|
135
|
+
text: "A red candle"
|
136
|
+
}
|
137
|
+
],
|
138
|
+
cfg_scale: 7,
|
139
|
+
clip_guidance_preset: "FAST_BLUE",
|
140
|
+
height: 512,
|
141
|
+
width: 512,
|
142
|
+
samples: 1,
|
143
|
+
steps: 30
|
144
|
+
}
|
145
|
+
)
|
146
|
+
data = response.dig("artifacts", 0, "base64")
|
147
|
+
# => Outputs base64 string, which can be used in an image tag like this <img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAACEmVYSWZNTQAq..."">
|
148
|
+
```
|
149
|
+
|
150
|
+
![Ruby](https://i.ibb.co/4mvDFG3/flamingo.png)
|
151
|
+
|
152
|
+
### Parameters, which can be set
|
153
|
+
|
154
|
+
- height
|
155
|
+
- width
|
156
|
+
- text_prompts (required)
|
157
|
+
- cfg_scale
|
158
|
+
- Default: 7
|
159
|
+
- Between 0 and 35
|
160
|
+
- clip_guidance_preset
|
161
|
+
- Default: None
|
162
|
+
- FAST_BLUE
|
163
|
+
- FAST_GREEN
|
164
|
+
- NONE
|
165
|
+
- SIMPLE
|
166
|
+
- SLOW
|
167
|
+
- SLOWER
|
168
|
+
- SLOWEST
|
169
|
+
- sampler
|
170
|
+
- DDIM
|
171
|
+
- DDPM
|
172
|
+
- K_DPMPP_2M
|
173
|
+
- K_DPMPP_2S_ANCESTRAL
|
174
|
+
- K_DPM_2
|
175
|
+
- K_DPM_2_ANCESTRAL
|
176
|
+
- K_EULER
|
177
|
+
- K_EULER_ANCESTRAL
|
178
|
+
- K_HEUN
|
179
|
+
- K_LMS
|
180
|
+
- samples (Number of images to generate)
|
181
|
+
- Default: 1
|
182
|
+
- Between 1 and 10
|
183
|
+
- seed
|
184
|
+
- Default: 0
|
185
|
+
- Random noise seed (omit this option or use 0 for a random seed)
|
186
|
+
- steps
|
187
|
+
- Default: 50
|
188
|
+
- Between: 10 and 150
|
189
|
+
- Number of diffusion steps to run
|
190
|
+
- style_preset
|
191
|
+
- 3d-model
|
192
|
+
- analog-film
|
193
|
+
- anime
|
194
|
+
- cinematic
|
195
|
+
- comic-book
|
196
|
+
- digital-art
|
197
|
+
- enhance
|
198
|
+
- fantasy-art
|
199
|
+
- isometric
|
200
|
+
- line-art
|
201
|
+
- low-poly
|
202
|
+
- modeling-compound
|
203
|
+
- neon-punk
|
204
|
+
- origami
|
205
|
+
- photographic
|
206
|
+
- pixel-art
|
207
|
+
- tile-texture
|
208
|
+
|
209
|
+
More information can be found here: [Stability AI Text to Image](https://platform.stability.ai/rest-api#tag/v1generation/operation/textToImage)
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "stabilityai"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
module StabilityAI
|
2
|
+
class Client
|
3
|
+
def initialize(access_token: nil, organization_id: nil, folder: nil, engine_id: nil, uri_base: nil,
|
4
|
+
request_timeout: nil)
|
5
|
+
StabilityAI.configuration.access_token = access_token if access_token
|
6
|
+
StabilityAI.configuration.organization_id = organization_id if organization_id
|
7
|
+
StabilityAI.configuration.engine_id = engine_id if engine_id
|
8
|
+
StabilityAI.configuration.folder = folder if folder
|
9
|
+
StabilityAI.configuration.uri_base = uri_base if uri_base
|
10
|
+
StabilityAI.configuration.request_timeout = request_timeout if request_timeout
|
11
|
+
end
|
12
|
+
|
13
|
+
def text_to_image(parameters: {})
|
14
|
+
StabilityAI::Client.json_post(path: "/text-to-image", parameters: parameters)
|
15
|
+
end
|
16
|
+
|
17
|
+
def engines
|
18
|
+
StabilityAI::Client.get(path: "/engines/list")
|
19
|
+
end
|
20
|
+
|
21
|
+
def account
|
22
|
+
StabilityAI::Client.get(path: "/user/account")
|
23
|
+
end
|
24
|
+
|
25
|
+
def balance
|
26
|
+
StabilityAI::Client.get(path: "/user/balance")
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.get(path:)
|
30
|
+
HTTParty.get(
|
31
|
+
get_uri(path: path),
|
32
|
+
headers: headers,
|
33
|
+
timeout: request_timeout
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.json_post(path:, parameters:)
|
38
|
+
HTTParty.post(
|
39
|
+
uri(path: path),
|
40
|
+
headers: headers,
|
41
|
+
body: parameters&.to_json,
|
42
|
+
timeout: request_timeout
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.multipart_post(path:, parameters: nil)
|
47
|
+
HTTParty.post(
|
48
|
+
uri(path: path),
|
49
|
+
headers: headers.merge({ "Content-Type" => "multipart/form-data" }),
|
50
|
+
body: parameters,
|
51
|
+
timeout: request_timeout
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.delete(path:)
|
56
|
+
HTTParty.delete(
|
57
|
+
uri(path: path),
|
58
|
+
headers: headers,
|
59
|
+
timeout: request_timeout
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
private_class_method def self.uri(path:)
|
64
|
+
StabilityAI.configuration.uri_base + StabilityAI.configuration.api_version + StabilityAI.configuration.folder + StabilityAI.configuration.engine_id + path
|
65
|
+
end
|
66
|
+
|
67
|
+
private_class_method def self.get_uri(path:)
|
68
|
+
StabilityAI.configuration.uri_base + StabilityAI.configuration.api_version + path
|
69
|
+
end
|
70
|
+
|
71
|
+
private_class_method def self.headers
|
72
|
+
{
|
73
|
+
"Content-Type" => "application/json",
|
74
|
+
"Authorization" => "Bearer #{StabilityAI.configuration.access_token}",
|
75
|
+
"Organization" => StabilityAI.configuration.organization_id
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
private_class_method def self.request_timeout
|
80
|
+
StabilityAI.configuration.request_timeout
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/stabilityai.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require "httparty"
|
2
|
+
|
3
|
+
require_relative "stabilityai/client"
|
4
|
+
require_relative "stabilityai/version"
|
5
|
+
|
6
|
+
module StabilityAI
|
7
|
+
class Error < StandardError; end
|
8
|
+
class ConfigurationError < Error; end
|
9
|
+
|
10
|
+
class Configuration
|
11
|
+
attr_writer :access_token
|
12
|
+
attr_accessor :api_version, :organization_id, :folder, :uri_base, :engine_id, :request_timeout
|
13
|
+
|
14
|
+
DEFAULT_API_VERSION = "/v1".freeze
|
15
|
+
DEFAULT_ENGINE_ID = "/stable-diffusion-v1-5".freeze
|
16
|
+
DEFAULT_FOLDER = "/generation".freeze
|
17
|
+
DEFAULT_URI_BASE = "https://api.stability.ai".freeze
|
18
|
+
DEFAULT_REQUEST_TIMEOUT = 120
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
@access_token = nil
|
22
|
+
@organization_id = nil
|
23
|
+
@api_version = DEFAULT_API_VERSION
|
24
|
+
@engine_id = DEFAULT_ENGINE_ID
|
25
|
+
@folder = DEFAULT_FOLDER
|
26
|
+
@uri_base = DEFAULT_URI_BASE
|
27
|
+
@request_timeout = DEFAULT_REQUEST_TIMEOUT
|
28
|
+
end
|
29
|
+
|
30
|
+
def access_token
|
31
|
+
return @access_token if @access_token
|
32
|
+
|
33
|
+
error_text = "StabilityAI access token missing! See https://github.com/kurbm/ruby-stabilityai#usage"
|
34
|
+
raise ConfigurationError, error_text
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class << self
|
39
|
+
attr_writer :configuration
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.configuration
|
43
|
+
@configuration ||= StabilityAI::Configuration.new
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.configure
|
47
|
+
yield(configuration)
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative "lib/stabilityai/version"
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "ruby-stabilityai"
|
5
|
+
spec.version = StabilityAI::VERSION
|
6
|
+
spec.authors = ["Kevin"]
|
7
|
+
spec.email = ["kurbm@users.noreply.github.com"]
|
8
|
+
|
9
|
+
spec.summary = "StabilityAI API + Ruby! 🤖❤️"
|
10
|
+
spec.homepage = "https://github.com/kurbm/ruby-stabilityai"
|
11
|
+
spec.license = "MIT"
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
13
|
+
|
14
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
15
|
+
spec.metadata["source_code_uri"] = "https://github.com/kurbm/ruby-stabilityai"
|
16
|
+
spec.metadata["changelog_uri"] = "https://github.com/kurbm/ruby-stabilityai/blob/main/CHANGELOG.md"
|
17
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
18
|
+
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
end
|
24
|
+
spec.bindir = "exe"
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
spec.add_dependency "httparty", ">= 0.18.1"
|
29
|
+
|
30
|
+
spec.post_install_message = "Note if upgrading: The `::Ruby::StabilityAI` module has been removed and all classes have been moved under the top level `::StabilityAI` module. To upgrade, change `require 'ruby/stabilityai'` to `require 'stabilityai'` and change all references to `Ruby::StabilityAI` to `StabilityAI`."
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-stabilityai
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kevin
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-04-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.18.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.18.1
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
- kurbm@users.noreply.github.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- ".rspec"
|
36
|
+
- ".rubocop.yml"
|
37
|
+
- Gemfile
|
38
|
+
- Gemfile.lock
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- bin/console
|
43
|
+
- bin/setup
|
44
|
+
- lib/ruby/stabilityai.rb
|
45
|
+
- lib/stabilityai.rb
|
46
|
+
- lib/stabilityai/client.rb
|
47
|
+
- lib/stabilityai/compatibility.rb
|
48
|
+
- lib/stabilityai/version.rb
|
49
|
+
- ruby-stabilityai.gemspec
|
50
|
+
homepage: https://github.com/kurbm/ruby-stabilityai
|
51
|
+
licenses:
|
52
|
+
- MIT
|
53
|
+
metadata:
|
54
|
+
homepage_uri: https://github.com/kurbm/ruby-stabilityai
|
55
|
+
source_code_uri: https://github.com/kurbm/ruby-stabilityai
|
56
|
+
changelog_uri: https://github.com/kurbm/ruby-stabilityai/blob/main/CHANGELOG.md
|
57
|
+
rubygems_mfa_required: 'true'
|
58
|
+
post_install_message: 'Note if upgrading: The `::Ruby::StabilityAI` module has been
|
59
|
+
removed and all classes have been moved under the top level `::StabilityAI` module.
|
60
|
+
To upgrade, change `require ''ruby/stabilityai''` to `require ''stabilityai''` and
|
61
|
+
change all references to `Ruby::StabilityAI` to `StabilityAI`.'
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.6.0
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubygems_version: 3.3.7
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: "StabilityAI API + Ruby! \U0001F916❤️"
|
80
|
+
test_files: []
|