stability_sdk 0.2.10 → 0.2.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b45f00aa32974424860512f59fb3c1745b6c3b8b08f359e95ccd603f637642d
4
- data.tar.gz: a67397bdc2b10b0bc49b7a508e3283c20fa4d7ea4ae4b4598b086b0ecc43b323
3
+ metadata.gz: d5aac33cb8d504aab26b515dc2fa6bd9d76c70829a0aa706eabc6be39043b143
4
+ data.tar.gz: ca6a3cd1cd24763a9f9427132a4e8fde4c688d9bc9d3409ef921139fa62fa232
5
5
  SHA512:
6
- metadata.gz: f2fe617756b1d720e1d3a5c63807a7dbde52b70df2eb7a3c11a2bde803245f0e00c25b29d0d1893359de2243d333cf82ce274e23e03f220dadcad1d6f661261c
7
- data.tar.gz: e50e38e2260d9e376581c03555468273c4378dea33cefdce1fb3e00e0d32db8aa592a63ba0e87f9685d0c89cdbd95c75af5093fc3e724711d862727d346028ba
6
+ metadata.gz: 95b76f6caf8e5a32af792cc0d284f81b76c7e38c682b24a5fc91204b3373096a47a98ab1ee6f0e32cbbd2039ad6b57c920c262661cda221c54eac529bd54e51a
7
+ data.tar.gz: f196c8b879b36e69c84d40c2528fd9fbf7f07e1ae6eec9c4a996a66a8a73841ea50d73d8ca941b7813ca9d5fbada94140143619bdb841de4ce9f71316af1303e
data/README.md CHANGED
@@ -61,9 +61,25 @@ Options:
61
61
  -m, --mask_image=VAL path to mask image
62
62
  --start_schedule=VAL start schedule for init image (must be greater than 0, 1 is full strength text prompt, no trace of image). default 1.0
63
63
  --end_schedule=VAL end schedule for init image. default 0.01
64
+ --guidance_preset=VAL Guidance preset to use. See generation.GuidancePreset for supported values. default `GUIDANCE_PRESET_NONE`
65
+ --guidance_cuts=VAL Number of cuts to use for guidance. default 0
66
+ --guidance_strength=VAL Strength of the guidance. We recommend values in range [0.0,1.0]. A good default is 0.25. default nil
67
+ --guidance_prompt=VAL Prompt to use for guidance, defaults to `YOUR_PROMPT_TEXT` argument (above) if not specified.
68
+ --guidance_models=VAL Models to use for guidance. default nil
64
69
  -v, --verbose
65
70
  ```
66
71
 
72
+ #### CLIP guidance
73
+
74
+ By specifying `--guidance_preset` and other `--guidance_*` options, you can use CLIP guidance, which is enabled by default on DreamStudio's web interface.
75
+ See also [this notebook](https://github.com/Stability-AI/stability-sdk/blob/c04381f960008f37c7392467cfaabfdf8f763e6a/nbs/demo_colab.ipynb) for more details.
76
+
77
+ ```sh
78
+ # example
79
+ # [note] --steps=35 is recommended. which is also the default value of the web interface
80
+ STABILITY_SDK_API_KEY=xxx stability-client --guidance_preset=GUIDANCE_PRESET_FAST_BLUE --guidance_strength=0.25 --steps=35 --sampler=k_dpm_2_ancestral "A dream of a distant galaxy, by Caspar David Friedrich, matte painting trending on artstation HQ"
81
+ ```
82
+
67
83
  ### SDK usage
68
84
 
69
85
  This sample code saves a generated image as `result.png`.
@@ -91,12 +107,57 @@ client.generate(prompt, options) do |answer|
91
107
  end
92
108
  ```
93
109
 
110
+ ### [Unstable] Dashboard API
111
+
112
+ **This feature is in a very early stage of development.**
113
+
114
+ Dashboard API is a way to interact with DreamStudio Web UIs, such as getting user info, payment info, etc.
115
+
116
+ Currently, there is no canonical way to get the API key for the Dashboard API. You can retrieve the key by logging in to the [DreamStudio Web page](https://beta.dreamstudio.ai/dream) and inspect request the authorization header with Chrome Developer Tool. Please be aware that how to refresh the key or an expiration period is unknown. See also https://github.com/Stability-AI/stability-sdk/issues/23
117
+
118
+ ```sh
119
+ # get user info
120
+ STABILITY_SDK_DASHBOARD_API_KEY=YOUR_API_KEY stability-dashboard-client-unstable get_me
121
+
122
+ # get organization info
123
+ STABILITY_SDK_DASHBOARD_API_KEY=YOUR_API_KEY stability-dashboard-client-unstable get_organization
124
+
125
+ # i.e, get remaining balance
126
+ STABILITY_SDK_DASHBOARD_API_KEY=YOUR_API_KEY stability-dashboard-client-unstable get_organization | jq .paymentInfo.balance
127
+ ```
128
+
94
129
  ## Development
95
130
 
96
131
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
97
132
 
98
133
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
99
134
 
135
+ ### update submodule to try a new feature on Stability-AI/api-interfaces
136
+
137
+ - update submodule
138
+
139
+ ```sh
140
+ git submodule update --init # if you haven't fetched the content of the submodule yet
141
+ cd api-interfaces
142
+
143
+ # checkout some branch/commit you need
144
+ git fetch
145
+ git reset --hard origin/some_branch
146
+
147
+ cd ..
148
+ ```
149
+
150
+ - build
151
+
152
+ ```sh
153
+ bundle exec rake protoc
154
+
155
+ git diff
156
+ # now you may be able to confirm that the diff is created in lib/generation_pb.rb
157
+ ```
158
+
159
+ - modify the `lib/stability_sdk/client.rb` to try some new features
160
+
100
161
  ## Contributing
101
162
 
102
163
  Bug reports and pull requests are welcome on GitHub at https://github.com/cou929/stability-sdk-ruby.
data/Rakefile CHANGED
@@ -13,3 +13,8 @@ desc "Parse proto file and generate output"
13
13
  task :protoc do
14
14
  sh "grpc_tools_ruby_protoc -I api-interfaces/src/proto/ --ruby_out=lib --grpc_out=lib api-interfaces/src/proto/generation.proto"
15
15
  end
16
+
17
+ desc "Compile a dashboard proto file"
18
+ task :protoc_dashboard do
19
+ sh "grpc_tools_ruby_protoc -I api-interfaces/src/proto/ --ruby_out=lib --grpc_out=lib api-interfaces/src/proto/dashboard.proto"
20
+ end
data/exe/stability-client CHANGED
@@ -18,20 +18,25 @@ opt.banner = "Usage: stability-client [options] YOUR_PROMPT_TEXT"
18
18
  opt.separator ""
19
19
  opt.separator "Options:"
20
20
  opt.on("--api_key=VAL", "api key of DreamStudio account. You can also specify by a STABILITY_SDK_API_KEY environment variable") {|v| options[:api_key] = v }
21
- opt.on("-H", "--height=VAL", "height of image in pixel. default 512") {|v| options[:height] = v }
22
- opt.on("-W", "--width=VAL", "width of image in pixel. default 512") {|v| options[:width] = v }
23
- opt.on("-C", "--cfg_scale=VAL", "CFG scale factor. default 7.0") {|v| options[:cfg_scale] = v }
24
- opt.on("-A", "--sampler=VAL", "ddim, plms, k_euler, k_euler_ancestral, k_heun, k_dpm_2, k_dpm_2_ancestral, k_lms. default k_lms") {|v| options[:sampler] = v }
25
- opt.on("-s", "--steps=VAL", "number of steps. default 50") {|v| options[:steps] = v }
26
- opt.on("-S", "--seed=VAL", "random seed to use in integer") {|v| options[:seed] = v }
27
- opt.on("-p", "--prefix=VAL", "output prefixes for artifacts. default `generation`") {|v| options[:prefix] = v }
21
+ opt.on("-H", "--height=VAL", Integer, "height of image in pixel. default 512") {|v| options[:height] = v }
22
+ opt.on("-W", "--width=VAL", Integer, "width of image in pixel. default 512") {|v| options[:width] = v }
23
+ opt.on("-C", "--cfg_scale=VAL", Float, "CFG scale factor. default 7.0") {|v| options[:cfg_scale] = v }
24
+ opt.on("-A", "--sampler=VAL", String, "ddim, plms, k_euler, k_euler_ancestral, k_heun, k_dpm_2, k_dpm_2_ancestral, k_lms. default k_lms") {|v| options[:sampler] = v }
25
+ opt.on("-s", "--steps=VAL", Integer, "number of steps. default 50") {|v| options[:steps] = v }
26
+ opt.on("-S", "--seed=VAL", Integer, "random seed to use in integer") {|v| options[:seed] = v }
27
+ opt.on("-p", "--prefix=VAL", String, "output prefixes for artifacts. default `generation`") {|v| options[:prefix] = v }
28
28
  opt.on("--no-store", "do not write out artifacts") {|v| options[:no_store] = v }
29
- opt.on("-n", "--num_samples=VAL", "number of samples to generate") {|v| options[:num_samples] = v }
30
- opt.on("-e", "--engine=VAL", "engine to use for inference. default `stable-diffusion-v1`") {|v| options[:engine_id] = v }
31
- opt.on("-i", "--init_image=VAL", "path to init image") {|v| options[:init_image] = v }
32
- opt.on("-m", "--mask_image=VAL", "path to mask image") {|v| options[:mask_image] = v }
33
- opt.on("--start_schedule=VAL", "start schedule for init image (must be greater than 0, 1 is full strength text prompt, no trace of image). default 1.0") {|v| options[:start_schedule] = v }
34
- opt.on("--end_schedule=VAL", "end schedule for init image. default 0.01") {|v| options[:end_schedule] = v }
29
+ opt.on("-n", "--num_samples=VAL", Integer, "number of samples to generate. default 1") {|v| options[:num_samples] = v }
30
+ opt.on("-e", "--engine=VAL", String, "engine to use for inference. default `stable-diffusion-v1-5`") {|v| options[:engine_id] = v }
31
+ opt.on("-i", "--init_image=VAL", String, "path to init image") {|v| options[:init_image] = v }
32
+ opt.on("-m", "--mask_image=VAL", String, "path to mask image") {|v| options[:mask_image] = v }
33
+ opt.on("--start_schedule=VAL", Float, "start schedule for init image (must be greater than 0, 1 is full strength text prompt, no trace of image). default 1.0") {|v| options[:start_schedule] = v }
34
+ opt.on("--end_schedule=VAL", Float, "end schedule for init image. default 0.01") {|v| options[:end_schedule] = v }
35
+ opt.on("--guidance_preset=VAL", String,"Guidance preset to use. See generation.GuidancePreset for supported values. default `GUIDANCE_PRESET_NONE`") {|v| options[:guidance_preset] = v }
36
+ opt.on("--guidance_cuts=VAL", Integer, "Number of cuts to use for guidance. default 0") {|v| options[:guidance_cuts] = v }
37
+ opt.on("--guidance_strength=VAL", Float, "Strength of the guidance. We recommend values in range [0.0,1.0]. A good default is 0.25. default nil") {|v| options[:guidance_strength] = v }
38
+ opt.on("--guidance_prompt=VAL", String, "Prompt to use for guidance, defaults to `YOUR_PROMPT_TEXT` argument (above) if not specified.") {|v| options[:guidance_prompt] = v }
39
+ opt.on("--guidance_models=VAL", Array, "Models to use for guidance. default nil") {|v| options[:guidance_models] = v }
35
40
  opt.on("-v", "--verbose") { logger.level = Logger::DEBUG }
36
41
  opt.parse!(ARGV)
37
42
 
@@ -48,7 +53,7 @@ if options.has_key?(:init_image)
48
53
  raise StabilitySDK::InvalidParameter, "width and height of init_image must be a multiple of 64" if size[0] % 64 != 0 || size[1] % 64 != 0
49
54
  end
50
55
 
51
- client = StabilitySDK::Client.new(api_key: options[:api_key])
56
+ client = StabilitySDK::Client.new(api_key: options[:api_key], logger: logger)
52
57
 
53
58
  client.generate(prompt, options) do |answer|
54
59
  StabilitySDK::CLI.save_answer(answer, options, logger)
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "thor"
4
+ require "logger"
5
+ require "stability_sdk"
6
+
7
+ logger = Logger.new(STDOUT)
8
+ logger.level = Logger::WARN
9
+
10
+ Version = StabilitySDK::VERSION
11
+
12
+ class CLI < Thor
13
+ class_option :api_key
14
+
15
+ desc "get_me", "get user info"
16
+ def get_me
17
+ client = self.client(options)
18
+ res = client.get_me
19
+ puts res.to_json
20
+ end
21
+
22
+ desc "get_organization", "get organization info"
23
+ def get_organization
24
+ client = self.client(options)
25
+ res = client.get_organization
26
+ puts res.to_json
27
+ end
28
+
29
+ private
30
+
31
+ def client(options)
32
+ api_key = options[:api_key]
33
+ api_key = ENV["STABILITY_SDK_DASHBOARD_API_KEY"] if ENV["STABILITY_SDK_DASHBOARD_API_KEY"]
34
+ raise StabilitySDK::InsufficientParameter, "api key is required" if api_key.nil?
35
+
36
+ return StabilitySDK::Unstable::DashboardClient.new(api_key: api_key)
37
+ end
38
+ end
39
+
40
+ CLI.start(ARGV)
@@ -0,0 +1,182 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: dashboard.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ Google::Protobuf::DescriptorPool.generated_pool.build do
7
+ add_file("dashboard.proto", :syntax => :proto3) do
8
+ add_message "gooseai.OrganizationMember" do
9
+ optional :organization, :message, 1, "gooseai.Organization"
10
+ proto3_optional :user, :message, 2, "gooseai.User"
11
+ optional :role, :enum, 3, "gooseai.OrganizationRole"
12
+ optional :is_default, :bool, 4
13
+ end
14
+ add_message "gooseai.OrganizationGrant" do
15
+ optional :amount_granted, :double, 1
16
+ optional :amount_used, :double, 2
17
+ optional :expires_at, :uint64, 3
18
+ optional :granted_at, :uint64, 4
19
+ end
20
+ add_message "gooseai.OrganizationPaymentInfo" do
21
+ optional :balance, :double, 1
22
+ repeated :grants, :message, 2, "gooseai.OrganizationGrant"
23
+ end
24
+ add_message "gooseai.OrganizationAutoCharge" do
25
+ optional :enabled, :bool, 1
26
+ optional :id, :string, 2
27
+ optional :created_at, :uint64, 3
28
+ end
29
+ add_message "gooseai.Organization" do
30
+ optional :id, :string, 1
31
+ optional :name, :string, 2
32
+ optional :description, :string, 3
33
+ repeated :members, :message, 4, "gooseai.OrganizationMember"
34
+ proto3_optional :payment_info, :message, 5, "gooseai.OrganizationPaymentInfo"
35
+ proto3_optional :stripe_customer_id, :string, 6
36
+ proto3_optional :auto_charge, :message, 7, "gooseai.OrganizationAutoCharge"
37
+ end
38
+ add_message "gooseai.APIKey" do
39
+ optional :key, :string, 1
40
+ optional :is_secret, :bool, 2
41
+ optional :created_at, :uint64, 3
42
+ end
43
+ add_message "gooseai.User" do
44
+ optional :id, :string, 1
45
+ proto3_optional :auth_id, :string, 2
46
+ optional :profile_picture, :string, 3
47
+ optional :email, :string, 4
48
+ repeated :organizations, :message, 5, "gooseai.OrganizationMember"
49
+ repeated :api_keys, :message, 7, "gooseai.APIKey"
50
+ optional :created_at, :uint64, 8
51
+ proto3_optional :email_verified, :bool, 9
52
+ end
53
+ add_message "gooseai.CostData" do
54
+ optional :amount_tokens, :uint32, 1
55
+ optional :amount_credits, :double, 2
56
+ end
57
+ add_message "gooseai.UsageMetric" do
58
+ optional :operation, :string, 1
59
+ optional :engine, :string, 2
60
+ optional :input_cost, :message, 3, "gooseai.CostData"
61
+ optional :output_cost, :message, 4, "gooseai.CostData"
62
+ proto3_optional :user, :string, 5
63
+ optional :aggregation_timestamp, :uint64, 6
64
+ end
65
+ add_message "gooseai.CostTotal" do
66
+ optional :amount_tokens, :uint32, 1
67
+ optional :amount_credits, :double, 2
68
+ end
69
+ add_message "gooseai.TotalMetricsData" do
70
+ optional :input_total, :message, 1, "gooseai.CostTotal"
71
+ optional :output_total, :message, 2, "gooseai.CostTotal"
72
+ end
73
+ add_message "gooseai.Metrics" do
74
+ repeated :metrics, :message, 1, "gooseai.UsageMetric"
75
+ optional :total, :message, 2, "gooseai.TotalMetricsData"
76
+ end
77
+ add_message "gooseai.EmptyRequest" do
78
+ end
79
+ add_message "gooseai.GetOrganizationRequest" do
80
+ optional :id, :string, 1
81
+ end
82
+ add_message "gooseai.GetMetricsRequest" do
83
+ optional :organization_id, :string, 1
84
+ proto3_optional :user_id, :string, 2
85
+ optional :range_from, :uint64, 3
86
+ optional :range_to, :uint64, 4
87
+ optional :include_per_request_metrics, :bool, 5
88
+ end
89
+ add_message "gooseai.APIKeyRequest" do
90
+ optional :is_secret, :bool, 1
91
+ end
92
+ add_message "gooseai.APIKeyFindRequest" do
93
+ optional :id, :string, 1
94
+ end
95
+ add_message "gooseai.UpdateDefaultOrganizationRequest" do
96
+ optional :organization_id, :string, 1
97
+ end
98
+ add_message "gooseai.ClientSettings" do
99
+ optional :settings, :bytes, 1
100
+ end
101
+ add_message "gooseai.CreateAutoChargeIntentRequest" do
102
+ optional :organization_id, :string, 1
103
+ optional :monthly_maximum, :uint64, 2
104
+ optional :minimum_value, :uint64, 3
105
+ optional :amount_credits, :uint64, 4
106
+ end
107
+ add_message "gooseai.CreateChargeRequest" do
108
+ optional :amount, :uint64, 1
109
+ optional :organization_id, :string, 2
110
+ end
111
+ add_message "gooseai.GetChargesRequest" do
112
+ optional :organization_id, :string, 1
113
+ optional :range_from, :uint64, 2
114
+ optional :range_to, :uint64, 3
115
+ end
116
+ add_message "gooseai.Charge" do
117
+ optional :id, :string, 1
118
+ optional :paid, :bool, 2
119
+ optional :receipt_link, :string, 3
120
+ optional :payment_link, :string, 4
121
+ optional :created_at, :uint64, 5
122
+ optional :amount_credits, :uint64, 6
123
+ end
124
+ add_message "gooseai.Charges" do
125
+ repeated :charges, :message, 1, "gooseai.Charge"
126
+ end
127
+ add_message "gooseai.GetAutoChargeRequest" do
128
+ optional :organization_id, :string, 1
129
+ end
130
+ add_message "gooseai.AutoChargeIntent" do
131
+ optional :id, :string, 1
132
+ optional :payment_link, :string, 2
133
+ optional :created_at, :uint64, 3
134
+ optional :monthly_maximum, :uint64, 4
135
+ optional :minimum_value, :uint64, 5
136
+ optional :amount_credits, :uint64, 6
137
+ end
138
+ add_message "gooseai.UpdateUserInfoRequest" do
139
+ proto3_optional :email, :string, 1
140
+ end
141
+ add_message "gooseai.UserPasswordChangeTicket" do
142
+ optional :ticket, :string, 1
143
+ end
144
+ add_enum "gooseai.OrganizationRole" do
145
+ value :MEMBER, 0
146
+ value :ACCOUNTANT, 1
147
+ value :OWNER, 2
148
+ end
149
+ end
150
+ end
151
+
152
+ module Gooseai
153
+ OrganizationMember = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.OrganizationMember").msgclass
154
+ OrganizationGrant = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.OrganizationGrant").msgclass
155
+ OrganizationPaymentInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.OrganizationPaymentInfo").msgclass
156
+ OrganizationAutoCharge = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.OrganizationAutoCharge").msgclass
157
+ Organization = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.Organization").msgclass
158
+ APIKey = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.APIKey").msgclass
159
+ User = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.User").msgclass
160
+ CostData = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.CostData").msgclass
161
+ UsageMetric = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.UsageMetric").msgclass
162
+ CostTotal = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.CostTotal").msgclass
163
+ TotalMetricsData = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.TotalMetricsData").msgclass
164
+ Metrics = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.Metrics").msgclass
165
+ EmptyRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.EmptyRequest").msgclass
166
+ GetOrganizationRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.GetOrganizationRequest").msgclass
167
+ GetMetricsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.GetMetricsRequest").msgclass
168
+ APIKeyRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.APIKeyRequest").msgclass
169
+ APIKeyFindRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.APIKeyFindRequest").msgclass
170
+ UpdateDefaultOrganizationRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.UpdateDefaultOrganizationRequest").msgclass
171
+ ClientSettings = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.ClientSettings").msgclass
172
+ CreateAutoChargeIntentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.CreateAutoChargeIntentRequest").msgclass
173
+ CreateChargeRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.CreateChargeRequest").msgclass
174
+ GetChargesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.GetChargesRequest").msgclass
175
+ Charge = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.Charge").msgclass
176
+ Charges = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.Charges").msgclass
177
+ GetAutoChargeRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.GetAutoChargeRequest").msgclass
178
+ AutoChargeIntent = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.AutoChargeIntent").msgclass
179
+ UpdateUserInfoRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.UpdateUserInfoRequest").msgclass
180
+ UserPasswordChangeTicket = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.UserPasswordChangeTicket").msgclass
181
+ OrganizationRole = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.OrganizationRole").enummodule
182
+ end
@@ -0,0 +1,41 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: dashboard.proto for package 'gooseai'
3
+
4
+ require 'grpc'
5
+ require 'dashboard_pb'
6
+
7
+ module Gooseai
8
+ module DashboardService
9
+ class Service
10
+
11
+ include ::GRPC::GenericService
12
+
13
+ self.marshal_class_method = :encode
14
+ self.unmarshal_class_method = :decode
15
+ self.service_name = 'gooseai.DashboardService'
16
+
17
+ # Get info
18
+ rpc :GetMe, ::Gooseai::EmptyRequest, ::Gooseai::User
19
+ rpc :GetOrganization, ::Gooseai::GetOrganizationRequest, ::Gooseai::Organization
20
+ rpc :GetMetrics, ::Gooseai::GetMetricsRequest, ::Gooseai::Metrics
21
+ # API key management
22
+ rpc :CreateAPIKey, ::Gooseai::APIKeyRequest, ::Gooseai::APIKey
23
+ rpc :DeleteAPIKey, ::Gooseai::APIKeyFindRequest, ::Gooseai::APIKey
24
+ # User settings
25
+ rpc :UpdateDefaultOrganization, ::Gooseai::UpdateDefaultOrganizationRequest, ::Gooseai::User
26
+ rpc :GetClientSettings, ::Gooseai::EmptyRequest, ::Gooseai::ClientSettings
27
+ rpc :SetClientSettings, ::Gooseai::ClientSettings, ::Gooseai::ClientSettings
28
+ rpc :UpdateUserInfo, ::Gooseai::UpdateUserInfoRequest, ::Gooseai::User
29
+ rpc :CreatePasswordChangeTicket, ::Gooseai::EmptyRequest, ::Gooseai::UserPasswordChangeTicket
30
+ rpc :DeleteAccount, ::Gooseai::EmptyRequest, ::Gooseai::User
31
+ # Payment functions
32
+ rpc :CreateCharge, ::Gooseai::CreateChargeRequest, ::Gooseai::Charge
33
+ rpc :GetCharges, ::Gooseai::GetChargesRequest, ::Gooseai::Charges
34
+ rpc :CreateAutoChargeIntent, ::Gooseai::CreateAutoChargeIntentRequest, ::Gooseai::AutoChargeIntent
35
+ rpc :UpdateAutoChargeIntent, ::Gooseai::CreateAutoChargeIntentRequest, ::Gooseai::AutoChargeIntent
36
+ rpc :GetAutoChargeIntent, ::Gooseai::GetAutoChargeRequest, ::Gooseai::AutoChargeIntent
37
+ end
38
+
39
+ Stub = Service.rpc_stub_class
40
+ end
41
+ end
data/lib/generation_pb.rb CHANGED
@@ -21,6 +21,8 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
21
21
  optional :index, :uint32, 8
22
22
  optional :finish_reason, :enum, 9, "gooseai.FinishReason"
23
23
  optional :seed, :uint32, 10
24
+ optional :uuid, :string, 12
25
+ optional :size, :uint64, 13
24
26
  oneof :data do
25
27
  optional :binary, :bytes, 5
26
28
  optional :text, :string, 6
@@ -40,20 +42,6 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
40
42
  optional :artifact, :message, 4, "gooseai.Artifact"
41
43
  end
42
44
  end
43
- add_message "gooseai.AnswerMeta" do
44
- proto3_optional :gpu_id, :string, 1
45
- proto3_optional :cpu_id, :string, 2
46
- proto3_optional :node_id, :string, 3
47
- proto3_optional :engine_id, :string, 4
48
- end
49
- add_message "gooseai.Answer" do
50
- optional :answer_id, :string, 1
51
- optional :request_id, :string, 2
52
- optional :received, :uint64, 3
53
- optional :created, :uint64, 4
54
- proto3_optional :meta, :message, 6, "gooseai.AnswerMeta"
55
- repeated :artifacts, :message, 7, "gooseai.Artifact"
56
- end
57
45
  add_message "gooseai.SamplerParameters" do
58
46
  proto3_optional :eta, :float, 1
59
47
  proto3_optional :sampling_steps, :uint64, 2
@@ -63,15 +51,48 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
63
51
  end
64
52
  add_message "gooseai.ConditionerParameters" do
65
53
  proto3_optional :vector_adjust_prior, :string, 1
54
+ proto3_optional :conditioner, :message, 2, "gooseai.Model"
66
55
  end
67
56
  add_message "gooseai.ScheduleParameters" do
68
57
  proto3_optional :start, :float, 1
69
58
  proto3_optional :end, :float, 2
59
+ proto3_optional :value, :float, 3
70
60
  end
71
61
  add_message "gooseai.StepParameter" do
72
62
  optional :scaled_step, :float, 1
73
63
  proto3_optional :sampler, :message, 2, "gooseai.SamplerParameters"
74
64
  proto3_optional :schedule, :message, 3, "gooseai.ScheduleParameters"
65
+ proto3_optional :guidance, :message, 4, "gooseai.GuidanceParameters"
66
+ end
67
+ add_message "gooseai.Model" do
68
+ optional :architecture, :enum, 1, "gooseai.ModelArchitecture"
69
+ optional :publisher, :string, 2
70
+ optional :dataset, :string, 3
71
+ optional :version, :float, 4
72
+ optional :semantic_version, :string, 5
73
+ optional :alias, :string, 6
74
+ end
75
+ add_message "gooseai.CutoutParameters" do
76
+ repeated :cutouts, :message, 1, "gooseai.CutoutParameters"
77
+ proto3_optional :count, :uint32, 2
78
+ proto3_optional :gray, :float, 3
79
+ proto3_optional :blur, :float, 4
80
+ proto3_optional :size_power, :float, 5
81
+ end
82
+ add_message "gooseai.GuidanceScheduleParameters" do
83
+ optional :duration, :float, 1
84
+ optional :value, :float, 2
85
+ end
86
+ add_message "gooseai.GuidanceInstanceParameters" do
87
+ repeated :models, :message, 2, "gooseai.Model"
88
+ proto3_optional :guidance_strength, :float, 3
89
+ repeated :schedule, :message, 4, "gooseai.GuidanceScheduleParameters"
90
+ proto3_optional :cutouts, :message, 5, "gooseai.CutoutParameters"
91
+ proto3_optional :prompt, :message, 6, "gooseai.Prompt"
92
+ end
93
+ add_message "gooseai.GuidanceParameters" do
94
+ optional :guidance_preset, :enum, 1, "gooseai.GuidancePreset"
95
+ repeated :instances, :message, 2, "gooseai.GuidanceInstanceParameters"
75
96
  end
76
97
  add_message "gooseai.TransformType" do
77
98
  oneof :type do
@@ -104,6 +125,25 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
104
125
  repeated :exceeds, :message, 2, "gooseai.ClassifierCategory"
105
126
  proto3_optional :realized_action, :enum, 3, "gooseai.Action"
106
127
  end
128
+ add_message "gooseai.AssetParameters" do
129
+ optional :action, :enum, 1, "gooseai.AssetAction"
130
+ optional :project_id, :string, 2
131
+ optional :use, :enum, 3, "gooseai.AssetUse"
132
+ end
133
+ add_message "gooseai.AnswerMeta" do
134
+ proto3_optional :gpu_id, :string, 1
135
+ proto3_optional :cpu_id, :string, 2
136
+ proto3_optional :node_id, :string, 3
137
+ proto3_optional :engine_id, :string, 4
138
+ end
139
+ add_message "gooseai.Answer" do
140
+ optional :answer_id, :string, 1
141
+ optional :request_id, :string, 2
142
+ optional :received, :uint64, 3
143
+ optional :created, :uint64, 4
144
+ proto3_optional :meta, :message, 6, "gooseai.AnswerMeta"
145
+ repeated :artifacts, :message, 7, "gooseai.Artifact"
146
+ end
107
147
  add_message "gooseai.Request" do
108
148
  optional :engine_id, :string, 1
109
149
  optional :request_id, :string, 2
@@ -113,6 +153,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
113
153
  oneof :params do
114
154
  optional :image, :message, 5, "gooseai.ImageParameters"
115
155
  optional :classifier, :message, 7, "gooseai.ClassifierParameters"
156
+ optional :asset, :message, 8, "gooseai.AssetParameters"
116
157
  end
117
158
  end
118
159
  add_message "gooseai.OnStatus" do
@@ -161,6 +202,21 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
161
202
  value :UPSCALER_GFPGAN, 1
162
203
  value :UPSCALER_ESRGAN, 2
163
204
  end
205
+ add_enum "gooseai.GuidancePreset" do
206
+ value :GUIDANCE_PRESET_NONE, 0
207
+ value :GUIDANCE_PRESET_SIMPLE, 1
208
+ value :GUIDANCE_PRESET_FAST_BLUE, 2
209
+ value :GUIDANCE_PRESET_FAST_GREEN, 3
210
+ value :GUIDANCE_PRESET_SLOW, 4
211
+ value :GUIDANCE_PRESET_SLOWER, 5
212
+ value :GUIDANCE_PRESET_SLOWEST, 6
213
+ end
214
+ add_enum "gooseai.ModelArchitecture" do
215
+ value :MODEL_ARCHITECTURE_NONE, 0
216
+ value :MODEL_ARCHITECTURE_CLIP_VIT, 1
217
+ value :MODEL_ARCHITECTURE_CLIP_RESNET, 2
218
+ value :MODEL_ARCHITECTURE_LDM, 3
219
+ end
164
220
  add_enum "gooseai.Action" do
165
221
  value :ACTION_PASSTHROUGH, 0
166
222
  value :ACTION_REGENERATE_DUPLICATE, 1
@@ -173,6 +229,18 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
173
229
  value :CLSFR_MODE_ZEROSHOT, 0
174
230
  value :CLSFR_MODE_MULTICLASS, 1
175
231
  end
232
+ add_enum "gooseai.AssetAction" do
233
+ value :ASSET_PUT, 0
234
+ value :ASSET_GET, 1
235
+ value :ASSET_DELETE, 2
236
+ end
237
+ add_enum "gooseai.AssetUse" do
238
+ value :ASSET_USE_UNDEFINED, 0
239
+ value :ASSET_USE_INPUT, 1
240
+ value :ASSET_USE_OUTPUT, 2
241
+ value :ASSET_USE_INTERMEDIATE, 3
242
+ value :ASSET_USE_PROJECT, 4
243
+ end
176
244
  add_enum "gooseai.StageAction" do
177
245
  value :STAGE_ACTION_PASS, 0
178
246
  value :STAGE_ACTION_DISCARD, 1
@@ -187,17 +255,23 @@ module Gooseai
187
255
  Artifact = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.Artifact").msgclass
188
256
  PromptParameters = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.PromptParameters").msgclass
189
257
  Prompt = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.Prompt").msgclass
190
- AnswerMeta = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.AnswerMeta").msgclass
191
- Answer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.Answer").msgclass
192
258
  SamplerParameters = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.SamplerParameters").msgclass
193
259
  ConditionerParameters = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.ConditionerParameters").msgclass
194
260
  ScheduleParameters = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.ScheduleParameters").msgclass
195
261
  StepParameter = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.StepParameter").msgclass
262
+ Model = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.Model").msgclass
263
+ CutoutParameters = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.CutoutParameters").msgclass
264
+ GuidanceScheduleParameters = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.GuidanceScheduleParameters").msgclass
265
+ GuidanceInstanceParameters = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.GuidanceInstanceParameters").msgclass
266
+ GuidanceParameters = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.GuidanceParameters").msgclass
196
267
  TransformType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.TransformType").msgclass
197
268
  ImageParameters = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.ImageParameters").msgclass
198
269
  ClassifierConcept = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.ClassifierConcept").msgclass
199
270
  ClassifierCategory = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.ClassifierCategory").msgclass
200
271
  ClassifierParameters = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.ClassifierParameters").msgclass
272
+ AssetParameters = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.AssetParameters").msgclass
273
+ AnswerMeta = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.AnswerMeta").msgclass
274
+ Answer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.Answer").msgclass
201
275
  Request = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.Request").msgclass
202
276
  OnStatus = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.OnStatus").msgclass
203
277
  Stage = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.Stage").msgclass
@@ -206,7 +280,11 @@ module Gooseai
206
280
  ArtifactType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.ArtifactType").enummodule
207
281
  DiffusionSampler = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.DiffusionSampler").enummodule
208
282
  Upscaler = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.Upscaler").enummodule
283
+ GuidancePreset = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.GuidancePreset").enummodule
284
+ ModelArchitecture = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.ModelArchitecture").enummodule
209
285
  Action = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.Action").enummodule
210
286
  ClassifierMode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.ClassifierMode").enummodule
287
+ AssetAction = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.AssetAction").enummodule
288
+ AssetUse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.AssetUse").enummodule
211
289
  StageAction = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.StageAction").enummodule
212
290
  end
@@ -6,6 +6,9 @@ require 'generation_pb'
6
6
 
7
7
  module Gooseai
8
8
  module GenerationService
9
+ #
10
+ # gRPC services
11
+ #
9
12
  class Service
10
13
 
11
14
  include ::GRPC::GenericService
@@ -23,10 +23,15 @@ module StabilitySDK
23
23
  logger.warn "not implemented for ArtifactType #{artifact.type}"
24
24
  end
25
25
 
26
+ if artifact.finish_reason == :FILTER
27
+ logger.debug "the generated image is filtered"
28
+ end
29
+
26
30
  next if filename == "" || contents == ""
27
31
 
28
32
  File.open(filename, "wb") do |f|
29
33
  f.write(contents)
34
+ logger.debug "wrote #{artifact.type} to #{filename}"
30
35
  end
31
36
  end
32
37
  end
@@ -1,5 +1,6 @@
1
1
  require "grpc"
2
2
  require "generation_services_pb"
3
+ require "logger"
3
4
 
4
5
  module StabilitySDK
5
6
  class Client
@@ -36,29 +37,37 @@ module StabilitySDK
36
37
  stub_params[kw] = options[kw] if options.has_key?(kw)
37
38
  end
38
39
 
40
+ if options.has_key?(:logger)
41
+ @logger = options[:logger]
42
+ else
43
+ logger = Logger.new(STDOUT)
44
+ logger.level = Logger::WARN
45
+ @logger = logger
46
+ end
47
+
39
48
  @stub = Gooseai::GenerationService::Stub.new(host, creds, **stub_params)
40
49
  end
41
50
 
42
51
  def generate(prompt, options, &block)
43
- width = options.has_key?(:width) ? options[:width].to_i : DEFAULT_IMAGE_WIDTH
44
- height = options.has_key?(:height) ? options[:height].to_i : DEFAULT_IMAGE_HEIGHT
52
+ width = options.has_key?(:width) ? options[:width] : DEFAULT_IMAGE_WIDTH
53
+ height = options.has_key?(:height) ? options[:height] : DEFAULT_IMAGE_HEIGHT
45
54
 
46
55
  if width % 64 != 0 || height % 64 != 0
47
56
  raise InvalidParameter, "width and height must be a multiple of 64"
48
57
  end
49
58
 
50
- samples = options.has_key?(:num_samples) ? options[:num_samples].to_i : DEFAULT_SAMPLE_SIZE
51
- steps = options.has_key?(:steps) ? options[:steps].to_i : DEFAULT_STEPS
52
- seed = options.has_key?(:seed) ? [options[:seed].to_i] : [rand(4294967295)]
59
+ samples = options.has_key?(:num_samples) ? options[:num_samples] : DEFAULT_SAMPLE_SIZE
60
+ steps = options.has_key?(:steps) ? options[:steps] : DEFAULT_STEPS
61
+ seed = options.has_key?(:seed) ? [options[:seed]] : [rand(4294967295)]
53
62
  transform = Gooseai::TransformType.new(
54
- diffusion: options.has_key?(:sampler) ? SAMPLER_ALGORITHMS[options[:sampler]] : DEFAULT_SAMPLER_ALGORITHM,
63
+ diffusion: options.has_key?(:sampler) ? SAMPLER_ALGORITHMS[options[:sampler].to_sym] : DEFAULT_SAMPLER_ALGORITHM,
55
64
  )
56
- parameters = [Gooseai::StepParameter.new(
65
+ step_parameter = Gooseai::StepParameter.new(
57
66
  scaled_step: 0,
58
67
  sampler: Gooseai::SamplerParameters.new(
59
- cfg_scale: options.has_key?(:cfg_scale) ? options[:cfg_scale].to_f : DEFAULT_CFG_SCALE,
68
+ cfg_scale: options.has_key?(:cfg_scale) ? options[:cfg_scale] : DEFAULT_CFG_SCALE,
60
69
  ),
61
- )]
70
+ )
62
71
 
63
72
  prompt_param = []
64
73
  if prompt != ""
@@ -66,21 +75,65 @@ module StabilitySDK
66
75
  end
67
76
  if options.has_key?(:init_image)
68
77
  prompt_param << init_image_to_prompt(options[:init_image])
69
- parameters = [Gooseai::StepParameter.new(
70
- scaled_step: 0,
71
- sampler: Gooseai::SamplerParameters.new(
72
- cfg_scale: options.has_key?(:cfg_scale) ? options[:cfg_scale].to_f : DEFAULT_CFG_SCALE,
73
- ),
74
- schedule: Gooseai::ScheduleParameters.new(
75
- start: options.has_key?(:start_schedule) ? options[:start_schedule].to_f : DEFAULT_START_SCHEDULE,
76
- end: options.has_key?(:end_schedule) ? options[:end_schedule].to_f : DEFAULT_END_SCHEDULE,
77
- ),
78
- )]
78
+ step_parameter.scaled_step = 0
79
+ step_parameter.sampler = Gooseai::SamplerParameters.new(
80
+ cfg_scale: options.has_key?(:cfg_scale) ? options[:cfg_scale] : DEFAULT_CFG_SCALE,
81
+ )
82
+ step_parameter.schedule = Gooseai::ScheduleParameters.new(
83
+ start: options.has_key?(:start_schedule) ? options[:start_schedule] : DEFAULT_START_SCHEDULE,
84
+ end: options.has_key?(:end_schedule) ? options[:end_schedule] : DEFAULT_END_SCHEDULE,
85
+ )
79
86
  end
80
87
  if options.has_key?(:mask_image)
81
88
  prompt_param << mask_image_to_prompt(options[:mask_image])
82
89
  end
83
90
 
91
+ # CLIP guidance
92
+ if options.has_key?(:guidance_preset) && options[:guidance_preset] != "GUIDANCE_PRESET_NONE"
93
+ step_parameter.sampler = nil
94
+
95
+ guidance_prompt =
96
+ if options.has_key?(:guidance_prompt)
97
+ Gooseai::Prompt.new(text: options[:guidance_prompt])
98
+ else
99
+ Gooseai::Prompt.new(text: prompt)
100
+ end
101
+
102
+ guidance_strength = nil
103
+ if options.has_key?(:guidance_strength) && options[:guidance_strength] != 0
104
+ guidance_strength = options[:guidance_strength]
105
+ end
106
+
107
+ models = nil
108
+ if options.has_key?(:guidance_models)
109
+ models = options[:guidance_models].map { |m| Gooseai::Model.new(alias: m) }
110
+ end
111
+
112
+ cutouts = nil
113
+ if options.has_key?(:guidance_cuts)
114
+ cutouts = Gooseai::CutoutParameters.new(count: options[:guidance_cuts])
115
+ end
116
+
117
+ step_parameter.guidance = Gooseai::GuidanceParameters.new(
118
+ guidance_preset: Gooseai::GuidancePreset.const_get(options[:guidance_preset].to_sym),
119
+ instances: [
120
+ Gooseai::GuidanceInstanceParameters.new(
121
+ guidance_strength: guidance_strength,
122
+ models: models,
123
+ cutouts: cutouts,
124
+ prompt: guidance_prompt,
125
+ ),
126
+ ],
127
+ )
128
+
129
+ if transform.diffusion != Gooseai::DiffusionSampler::SAMPLER_K_DPM_2_ANCESTRAL && transform.diffusion != Gooseai::DiffusionSampler::SAMPLER_K_EULER_ANCESTRAL
130
+ transform = Gooseai::TransformType.new(
131
+ diffusion: Gooseai::DiffusionSampler::SAMPLER_K_DPM_2_ANCESTRAL
132
+ )
133
+ @logger.warn "CLIP guidance is only supported with ancestral samplers. So override it with SAMPLER_K_DPM_2_ANCESTRAL."
134
+ end
135
+ end
136
+
84
137
  image_param = Gooseai::ImageParameters.new(
85
138
  width: width,
86
139
  height: height,
@@ -88,7 +141,7 @@ module StabilitySDK
88
141
  steps: steps,
89
142
  seed: seed,
90
143
  transform: transform,
91
- parameters: parameters,
144
+ parameters: [step_parameter],
92
145
  )
93
146
 
94
147
  req = Gooseai::Request.new(
@@ -97,8 +150,20 @@ module StabilitySDK
97
150
  image: image_param
98
151
  )
99
152
 
153
+ @logger.debug "sending request."
154
+ start = Time.now
100
155
  @stub.generate(req).each do |answer|
156
+ duration = Time.now - start
157
+ if answer.artifacts.size > 0
158
+ artifact_types = answer.artifacts.map { |a| a.type }
159
+ @logger.debug "got #{answer.answer_id} with #{artifact_types} in #{duration.round(2)}s"
160
+ else
161
+ @logger.debug "got keepalive #{answer.answer_id} in #{duration.round(2)}s"
162
+ end
163
+
101
164
  block.call(answer)
165
+
166
+ start = Time.now
102
167
  end
103
168
  end
104
169
 
@@ -0,0 +1,31 @@
1
+ require "grpc"
2
+ require "dashboard_services_pb"
3
+
4
+ module StabilitySDK::Unstable
5
+ class DashboardClient
6
+ DEFAULT_API_HOST = "grpc.stability.ai:443"
7
+
8
+ def initialize(options={})
9
+ host = options[:api_host] || DEFAULT_API_HOST
10
+ channel_creds = options.has_key?(:ca_cert) ? GRPC::Core::ChannelCredentials.new(options[:ca_cert]) : GRPC::Core::ChannelCredentials.new
11
+ call_creds = GRPC::Core::CallCredentials.new(proc { { "authorization" => "Bearer #{options[:api_key]}" } })
12
+ creds = channel_creds.compose(call_creds)
13
+
14
+ stub_params = {}
15
+ [:channel_override, :timeout, :propagate_mask, :channel_args, :interceptors].each do |kw|
16
+ stub_params[kw] = options[kw] if options.has_key?(kw)
17
+ end
18
+
19
+ @stub = Gooseai::DashboardService::Stub.new(host, creds, **stub_params)
20
+ end
21
+
22
+ def get_me
23
+ @stub.get_me(Gooseai::EmptyRequest.new)
24
+ end
25
+
26
+ def get_organization
27
+ me = self.get_me
28
+ @stub.get_organization(Gooseai::GetChargesRequest.new(organization_id: me.organizations[0].organization.id))
29
+ end
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module StabilitySDK
2
- VERSION = "0.2.10"
2
+ VERSION = "0.2.12"
3
3
  end
data/lib/stability_sdk.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "stability_sdk/version"
2
2
  require "stability_sdk/client"
3
3
  require "stability_sdk/cli"
4
+ require "stability_sdk/unstable/dashboard_client"
4
5
 
5
6
  module StabilitySDK
6
7
  class Error < StandardError; end
@@ -28,5 +28,6 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency "grpc", ">= 1.41.1"
29
29
  spec.add_dependency "mime-types", ">= 3.0.0"
30
30
  spec.add_dependency "fastimage", "~> 2.2", ">= 2.2.6"
31
+ spec.add_dependency "thor", ">= 1.2.1"
31
32
  spec.add_development_dependency "grpc-tools"
32
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stability_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kosei Moriyama
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-09 00:00:00.000000000 Z
11
+ date: 2022-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grpc
@@ -58,6 +58,20 @@ dependencies:
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
60
  version: 2.2.6
61
+ - !ruby/object:Gem::Dependency
62
+ name: thor
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 1.2.1
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 1.2.1
61
75
  - !ruby/object:Gem::Dependency
62
76
  name: grpc-tools
63
77
  requirement: !ruby/object:Gem::Requirement
@@ -78,6 +92,7 @@ email:
78
92
  - cou929@gmail.com
79
93
  executables:
80
94
  - stability-client
95
+ - stability-dashboard-client-unstable
81
96
  extensions: []
82
97
  extra_rdoc_files: []
83
98
  files:
@@ -91,11 +106,15 @@ files:
91
106
  - bin/console
92
107
  - bin/setup
93
108
  - exe/stability-client
109
+ - exe/stability-dashboard-client-unstable
110
+ - lib/dashboard_pb.rb
111
+ - lib/dashboard_services_pb.rb
94
112
  - lib/generation_pb.rb
95
113
  - lib/generation_services_pb.rb
96
114
  - lib/stability_sdk.rb
97
115
  - lib/stability_sdk/cli.rb
98
116
  - lib/stability_sdk/client.rb
117
+ - lib/stability_sdk/unstable/dashboard_client.rb
99
118
  - lib/stability_sdk/version.rb
100
119
  - stability_sdk.gemspec
101
120
  homepage: https://github.com/cou929/stability-sdk-ruby
@@ -120,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
139
  - !ruby/object:Gem::Version
121
140
  version: '0'
122
141
  requirements: []
123
- rubygems_version: 3.1.4
142
+ rubygems_version: 3.1.6
124
143
  signing_key:
125
144
  specification_version: 4
126
145
  summary: Ruby client for interacting with stability.ai APIs (e.g. stable diffusion