stability_sdk 0.2.9 → 0.2.11

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: 27bb9b00352e1cf979dedd17438a5dc2a3dae93ed0d74a747e30f297152e81a2
4
- data.tar.gz: c125901e07cc2f6d0704a423e2dad2541c3e31efbeb1ff69993f65bf804dcabb
3
+ metadata.gz: 431d7a70dc0a5a538abdbe9a486bf5c632d1e6a8e7e58dd7fedf1fa89b15722b
4
+ data.tar.gz: a6d5c05cf4915e7c91ceeb92864b2cc84f852ec40a61ce174ba57b3a97ec0df9
5
5
  SHA512:
6
- metadata.gz: 4b79d8290c5c958f10a00f103efe6959b8e1f408d8ca3393453afb0a7433eda250252edab93195a1dd7885b9a3860aeffccd27833289f38ea373ff3bf1a274f0
7
- data.tar.gz: 4481b59d12990bf00e5b716611dbd8055df7d4d262a4f1647ea2b217c9122cd790b671e76d51f1c082e83f2a0cebb1d62e2a80d7cb08f1ae96755db299a89dcb
6
+ metadata.gz: 7c5ba5862fd6446e243cdf54760fe596a4298e2d2860183df4cef847cc75d4414e9ceb21e8bd927e71e0fbacca9ce742628107197ca1e7c380abbbabff1e7cdc
7
+ data.tar.gz: 69b3cef394cbd5bd784bfd8953b1bd8721e4921e96f3a7bda79c0de3a733692853005008e1946cad75b24889df5dc1c8f9479238baac488a37a64ef49dbe39b7
data/.gitignore CHANGED
@@ -6,3 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ Gemfile.lock
10
+ .DS_Store
data/README.md CHANGED
@@ -91,6 +91,25 @@ client.generate(prompt, options) do |answer|
91
91
  end
92
92
  ```
93
93
 
94
+ ### [Unstable] Dashboard API
95
+
96
+ **This feature is in a very early stage of development.**
97
+
98
+ Dashboard API is a way to interact with DreamStudio Web UIs, such as getting user info, payment info, etc.
99
+
100
+ 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
101
+
102
+ ```sh
103
+ # get user info
104
+ STABILITY_SDK_DASHBOARD_API_KEY=YOUR_API_KEY stability-dashboard-client-unstable get_me
105
+
106
+ # get organization info
107
+ STABILITY_SDK_DASHBOARD_API_KEY=YOUR_API_KEY stability-dashboard-client-unstable get_organization
108
+
109
+ # i.e, get remaining balance
110
+ STABILITY_SDK_DASHBOARD_API_KEY=YOUR_API_KEY stability-dashboard-client-unstable get_organization | jq .paymentInfo.balance
111
+ ```
112
+
94
113
  ## Development
95
114
 
96
115
  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.
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
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "optparse"
4
4
  require "mime/types"
5
+ require "fastimage"
5
6
  require "logger"
6
7
  require "stability_sdk"
7
8
 
@@ -42,6 +43,11 @@ raise StabilitySDK::InsufficientParameter, "api key is required" if !options.has
42
43
 
43
44
  raise StabilitySDK::InsufficientParameter, "init_image is required if mask_image is provided" if options.has_key?(:mask_image) && !options.has_key?(:init_image)
44
45
 
46
+ if options.has_key?(:init_image)
47
+ size = FastImage.size(options[:init_image])
48
+ 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
+ end
50
+
45
51
  client = StabilitySDK::Client.new(api_key: options[:api_key])
46
52
 
47
53
  client.generate(prompt, options) do |answer|
@@ -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
@@ -42,6 +42,11 @@ module StabilitySDK
42
42
  def generate(prompt, options, &block)
43
43
  width = options.has_key?(:width) ? options[:width].to_i : DEFAULT_IMAGE_WIDTH
44
44
  height = options.has_key?(:height) ? options[:height].to_i : DEFAULT_IMAGE_HEIGHT
45
+
46
+ if width % 64 != 0 || height % 64 != 0
47
+ raise InvalidParameter, "width and height must be a multiple of 64"
48
+ end
49
+
45
50
  samples = options.has_key?(:num_samples) ? options[:num_samples].to_i : DEFAULT_SAMPLE_SIZE
46
51
  steps = options.has_key?(:steps) ? options[:steps].to_i : DEFAULT_STEPS
47
52
  seed = options.has_key?(:seed) ? [options[:seed].to_i] : [rand(4294967295)]
@@ -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.9"
2
+ VERSION = "0.2.11"
3
3
  end
data/lib/stability_sdk.rb CHANGED
@@ -1,8 +1,10 @@
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
7
8
  class InsufficientParameter < StandardError; end
9
+ class InvalidParameter < StandardError; end
8
10
  end
@@ -27,5 +27,7 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_dependency "grpc", ">= 1.41.1"
29
29
  spec.add_dependency "mime-types", ">= 3.0.0"
30
+ spec.add_dependency "fastimage", "~> 2.2", ">= 2.2.6"
31
+ spec.add_dependency "thor", ">= 1.2.1"
30
32
  spec.add_development_dependency "grpc-tools"
31
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.9
4
+ version: 0.2.11
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-03 00:00:00.000000000 Z
11
+ date: 2022-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grpc
@@ -38,6 +38,40 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 3.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: fastimage
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.2'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 2.2.6
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '2.2'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
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
41
75
  - !ruby/object:Gem::Dependency
42
76
  name: grpc-tools
43
77
  requirement: !ruby/object:Gem::Requirement
@@ -58,6 +92,7 @@ email:
58
92
  - cou929@gmail.com
59
93
  executables:
60
94
  - stability-client
95
+ - stability-dashboard-client-unstable
61
96
  extensions: []
62
97
  extra_rdoc_files: []
63
98
  files:
@@ -65,18 +100,21 @@ files:
65
100
  - ".gitmodules"
66
101
  - ".travis.yml"
67
102
  - Gemfile
68
- - Gemfile.lock
69
103
  - LICENSE
70
104
  - README.md
71
105
  - Rakefile
72
106
  - bin/console
73
107
  - bin/setup
74
108
  - exe/stability-client
109
+ - exe/stability-dashboard-client-unstable
110
+ - lib/dashboard_pb.rb
111
+ - lib/dashboard_services_pb.rb
75
112
  - lib/generation_pb.rb
76
113
  - lib/generation_services_pb.rb
77
114
  - lib/stability_sdk.rb
78
115
  - lib/stability_sdk/cli.rb
79
116
  - lib/stability_sdk/client.rb
117
+ - lib/stability_sdk/unstable/dashboard_client.rb
80
118
  - lib/stability_sdk/version.rb
81
119
  - stability_sdk.gemspec
82
120
  homepage: https://github.com/cou929/stability-sdk-ruby
@@ -101,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
139
  - !ruby/object:Gem::Version
102
140
  version: '0'
103
141
  requirements: []
104
- rubygems_version: 3.1.4
142
+ rubygems_version: 3.1.6
105
143
  signing_key:
106
144
  specification_version: 4
107
145
  summary: Ruby client for interacting with stability.ai APIs (e.g. stable diffusion
data/Gemfile.lock DELETED
@@ -1,35 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- stability_sdk (0.2.9)
5
- grpc (>= 1.41.1)
6
- mime-types (>= 3.0.0)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- google-protobuf (3.21.7)
12
- googleapis-common-protos-types (1.4.0)
13
- google-protobuf (~> 3.14)
14
- grpc (1.49.1)
15
- google-protobuf (~> 3.21)
16
- googleapis-common-protos-types (~> 1.0)
17
- grpc-tools (1.48.0)
18
- mime-types (3.4.1)
19
- mime-types-data (~> 3.2015)
20
- mime-types-data (3.2022.0105)
21
- minitest (5.16.3)
22
- rake (12.3.3)
23
-
24
- PLATFORMS
25
- arm64-darwin-20
26
- ruby
27
-
28
- DEPENDENCIES
29
- grpc-tools
30
- minitest (~> 5.0)
31
- rake (~> 12.0)
32
- stability_sdk!
33
-
34
- BUNDLED WITH
35
- 2.2.2