blackman_client 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +266 -0
- data/lib/blackman_client/api/completions_api.rb +89 -0
- data/lib/blackman_client/api/feedback_api.rb +88 -0
- data/lib/blackman_client/api/semantic_cache_api.rb +251 -0
- data/lib/blackman_client/api_client.rb +393 -0
- data/lib/blackman_client/api_error.rb +58 -0
- data/lib/blackman_client/configuration.rb +308 -0
- data/lib/blackman_client/models/choice.rb +282 -0
- data/lib/blackman_client/models/completion_options.rb +278 -0
- data/lib/blackman_client/models/completion_request.rb +380 -0
- data/lib/blackman_client/models/completion_response.rb +391 -0
- data/lib/blackman_client/models/invalidate_response.rb +238 -0
- data/lib/blackman_client/models/message.rb +264 -0
- data/lib/blackman_client/models/provider.rb +43 -0
- data/lib/blackman_client/models/semantic_cache_config.rb +292 -0
- data/lib/blackman_client/models/semantic_cache_stats.rb +400 -0
- data/lib/blackman_client/models/submit_feedback_request.rb +276 -0
- data/lib/blackman_client/models/submit_feedback_response.rb +263 -0
- data/lib/blackman_client/models/usage.rb +316 -0
- data/lib/blackman_client/version.rb +15 -0
- data/lib/blackman_client.rb +54 -0
- metadata +112 -0
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Blackman AI API
|
|
3
|
+
|
|
4
|
+
#A transparent AI API proxy that optimizes token usage to reduce costs. ## Authentication Blackman AI supports two authentication methods: ### 1. API Key (Recommended for integrations) Use the API key created from your dashboard: ```bash curl -X POST https://ap.useblackman.ai/v1/completions \\ -H \"Authorization: Bearer sk_your_api_key_here\" \\ -H \"Content-Type: application/json\" \\ -d '{\"provider\": \"OpenAI\", \"model\": \"gpt-4\", \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}]}' ``` ### 2. JWT Token (For web UI) Obtain a JWT token by logging in: ```bash curl -X POST https://ap.useblackman.ai/v1/auth/login \\ -H \"Content-Type: application/json\" \\ -d '{\"email\": \"user@example.com\", \"password\": \"yourpassword\"}' ``` Then use the token: ```bash curl -X POST https://ap.useblackman.ai/v1/completions \\ -H \"Authorization: Bearer your_jwt_token\" \\ -H \"Content-Type: application/json\" \\ -d '{...}' ``` ### Provider API Keys (Optional) You can optionally provide your own LLM provider API key via the `X-Provider-Api-Key` header, or store it in your account settings. ## Client SDKs Auto-generated SDKs are available for 10 languages: - **TypeScript**: [View Docs](/v1/sdks/typescript) - **Python**: [View Docs](/v1/sdks/python) - **Go**: [View Docs](/v1/sdks/go) - **Java**: [View Docs](/v1/sdks/java) - **Ruby**: [View Docs](/v1/sdks/ruby) - **PHP**: [View Docs](/v1/sdks/php) - **C#**: [View Docs](/v1/sdks/csharp) - **Rust**: [View Docs](/v1/sdks/rust) - **Swift**: [View Docs](/v1/sdks/swift) - **Kotlin**: [View Docs](/v1/sdks/kotlin) All SDKs are generated from this OpenAPI spec using [openapi-generator](https://openapi-generator.tech). ## Quick Start ```python # Python example with API key import blackman_client from blackman_client import CompletionRequest configuration = blackman_client.Configuration( host=\"http://localhost:8080\", access_token=\"sk_your_api_key_here\" # Your Blackman API key ) with blackman_client.ApiClient(configuration) as api_client: api = blackman_client.CompletionsApi(api_client) response = api.completions( CompletionRequest( provider=\"OpenAI\", model=\"gpt-4o\", messages=[{\"role\": \"user\", \"content\": \"Hello!\"}] ) ) ```
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 0.1.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.14.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module BlackmanClient
|
|
17
|
+
class SemanticCacheStats
|
|
18
|
+
# Average similarity score for cache hits
|
|
19
|
+
attr_accessor :avg_similarity_score
|
|
20
|
+
|
|
21
|
+
# Total cost saved from cache hits
|
|
22
|
+
attr_accessor :cost_saved
|
|
23
|
+
|
|
24
|
+
# Cache hit rate as a percentage
|
|
25
|
+
attr_accessor :hit_rate
|
|
26
|
+
|
|
27
|
+
# Total tokens saved from cache hits
|
|
28
|
+
attr_accessor :tokens_saved
|
|
29
|
+
|
|
30
|
+
# Total number of cache hits
|
|
31
|
+
attr_accessor :total_hits
|
|
32
|
+
|
|
33
|
+
# Total number of cache misses
|
|
34
|
+
attr_accessor :total_misses
|
|
35
|
+
|
|
36
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
37
|
+
def self.attribute_map
|
|
38
|
+
{
|
|
39
|
+
:'avg_similarity_score' => :'avg_similarity_score',
|
|
40
|
+
:'cost_saved' => :'cost_saved',
|
|
41
|
+
:'hit_rate' => :'hit_rate',
|
|
42
|
+
:'tokens_saved' => :'tokens_saved',
|
|
43
|
+
:'total_hits' => :'total_hits',
|
|
44
|
+
:'total_misses' => :'total_misses'
|
|
45
|
+
}
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Returns attribute mapping this model knows about
|
|
49
|
+
def self.acceptable_attribute_map
|
|
50
|
+
attribute_map
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Returns all the JSON keys this model knows about
|
|
54
|
+
def self.acceptable_attributes
|
|
55
|
+
acceptable_attribute_map.values
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Attribute type mapping.
|
|
59
|
+
def self.openapi_types
|
|
60
|
+
{
|
|
61
|
+
:'avg_similarity_score' => :'Float',
|
|
62
|
+
:'cost_saved' => :'Float',
|
|
63
|
+
:'hit_rate' => :'Float',
|
|
64
|
+
:'tokens_saved' => :'Integer',
|
|
65
|
+
:'total_hits' => :'Integer',
|
|
66
|
+
:'total_misses' => :'Integer'
|
|
67
|
+
}
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# List of attributes with nullable: true
|
|
71
|
+
def self.openapi_nullable
|
|
72
|
+
Set.new([
|
|
73
|
+
])
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Initializes the object
|
|
77
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
78
|
+
def initialize(attributes = {})
|
|
79
|
+
if (!attributes.is_a?(Hash))
|
|
80
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `BlackmanClient::SemanticCacheStats` initialize method"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
84
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
85
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
86
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
87
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `BlackmanClient::SemanticCacheStats`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
88
|
+
end
|
|
89
|
+
h[k.to_sym] = v
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if attributes.key?(:'avg_similarity_score')
|
|
93
|
+
self.avg_similarity_score = attributes[:'avg_similarity_score']
|
|
94
|
+
else
|
|
95
|
+
self.avg_similarity_score = nil
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
if attributes.key?(:'cost_saved')
|
|
99
|
+
self.cost_saved = attributes[:'cost_saved']
|
|
100
|
+
else
|
|
101
|
+
self.cost_saved = nil
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
if attributes.key?(:'hit_rate')
|
|
105
|
+
self.hit_rate = attributes[:'hit_rate']
|
|
106
|
+
else
|
|
107
|
+
self.hit_rate = nil
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
if attributes.key?(:'tokens_saved')
|
|
111
|
+
self.tokens_saved = attributes[:'tokens_saved']
|
|
112
|
+
else
|
|
113
|
+
self.tokens_saved = nil
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
if attributes.key?(:'total_hits')
|
|
117
|
+
self.total_hits = attributes[:'total_hits']
|
|
118
|
+
else
|
|
119
|
+
self.total_hits = nil
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
if attributes.key?(:'total_misses')
|
|
123
|
+
self.total_misses = attributes[:'total_misses']
|
|
124
|
+
else
|
|
125
|
+
self.total_misses = nil
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
130
|
+
# @return Array for valid properties with the reasons
|
|
131
|
+
def list_invalid_properties
|
|
132
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
133
|
+
invalid_properties = Array.new
|
|
134
|
+
if @avg_similarity_score.nil?
|
|
135
|
+
invalid_properties.push('invalid value for "avg_similarity_score", avg_similarity_score cannot be nil.')
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
if @cost_saved.nil?
|
|
139
|
+
invalid_properties.push('invalid value for "cost_saved", cost_saved cannot be nil.')
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
if @hit_rate.nil?
|
|
143
|
+
invalid_properties.push('invalid value for "hit_rate", hit_rate cannot be nil.')
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
if @tokens_saved.nil?
|
|
147
|
+
invalid_properties.push('invalid value for "tokens_saved", tokens_saved cannot be nil.')
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
if @tokens_saved < 0
|
|
151
|
+
invalid_properties.push('invalid value for "tokens_saved", must be greater than or equal to 0.')
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
if @total_hits.nil?
|
|
155
|
+
invalid_properties.push('invalid value for "total_hits", total_hits cannot be nil.')
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
if @total_hits < 0
|
|
159
|
+
invalid_properties.push('invalid value for "total_hits", must be greater than or equal to 0.')
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
if @total_misses.nil?
|
|
163
|
+
invalid_properties.push('invalid value for "total_misses", total_misses cannot be nil.')
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
if @total_misses < 0
|
|
167
|
+
invalid_properties.push('invalid value for "total_misses", must be greater than or equal to 0.')
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
invalid_properties
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# Check to see if the all the properties in the model are valid
|
|
174
|
+
# @return true if the model is valid
|
|
175
|
+
def valid?
|
|
176
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
177
|
+
return false if @avg_similarity_score.nil?
|
|
178
|
+
return false if @cost_saved.nil?
|
|
179
|
+
return false if @hit_rate.nil?
|
|
180
|
+
return false if @tokens_saved.nil?
|
|
181
|
+
return false if @tokens_saved < 0
|
|
182
|
+
return false if @total_hits.nil?
|
|
183
|
+
return false if @total_hits < 0
|
|
184
|
+
return false if @total_misses.nil?
|
|
185
|
+
return false if @total_misses < 0
|
|
186
|
+
true
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# Custom attribute writer method with validation
|
|
190
|
+
# @param [Object] avg_similarity_score Value to be assigned
|
|
191
|
+
def avg_similarity_score=(avg_similarity_score)
|
|
192
|
+
if avg_similarity_score.nil?
|
|
193
|
+
fail ArgumentError, 'avg_similarity_score cannot be nil'
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
@avg_similarity_score = avg_similarity_score
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# Custom attribute writer method with validation
|
|
200
|
+
# @param [Object] cost_saved Value to be assigned
|
|
201
|
+
def cost_saved=(cost_saved)
|
|
202
|
+
if cost_saved.nil?
|
|
203
|
+
fail ArgumentError, 'cost_saved cannot be nil'
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
@cost_saved = cost_saved
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Custom attribute writer method with validation
|
|
210
|
+
# @param [Object] hit_rate Value to be assigned
|
|
211
|
+
def hit_rate=(hit_rate)
|
|
212
|
+
if hit_rate.nil?
|
|
213
|
+
fail ArgumentError, 'hit_rate cannot be nil'
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
@hit_rate = hit_rate
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# Custom attribute writer method with validation
|
|
220
|
+
# @param [Object] tokens_saved Value to be assigned
|
|
221
|
+
def tokens_saved=(tokens_saved)
|
|
222
|
+
if tokens_saved.nil?
|
|
223
|
+
fail ArgumentError, 'tokens_saved cannot be nil'
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
if tokens_saved < 0
|
|
227
|
+
fail ArgumentError, 'invalid value for "tokens_saved", must be greater than or equal to 0.'
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
@tokens_saved = tokens_saved
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Custom attribute writer method with validation
|
|
234
|
+
# @param [Object] total_hits Value to be assigned
|
|
235
|
+
def total_hits=(total_hits)
|
|
236
|
+
if total_hits.nil?
|
|
237
|
+
fail ArgumentError, 'total_hits cannot be nil'
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
if total_hits < 0
|
|
241
|
+
fail ArgumentError, 'invalid value for "total_hits", must be greater than or equal to 0.'
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
@total_hits = total_hits
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
# Custom attribute writer method with validation
|
|
248
|
+
# @param [Object] total_misses Value to be assigned
|
|
249
|
+
def total_misses=(total_misses)
|
|
250
|
+
if total_misses.nil?
|
|
251
|
+
fail ArgumentError, 'total_misses cannot be nil'
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
if total_misses < 0
|
|
255
|
+
fail ArgumentError, 'invalid value for "total_misses", must be greater than or equal to 0.'
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
@total_misses = total_misses
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
# Checks equality by comparing each attribute.
|
|
262
|
+
# @param [Object] Object to be compared
|
|
263
|
+
def ==(o)
|
|
264
|
+
return true if self.equal?(o)
|
|
265
|
+
self.class == o.class &&
|
|
266
|
+
avg_similarity_score == o.avg_similarity_score &&
|
|
267
|
+
cost_saved == o.cost_saved &&
|
|
268
|
+
hit_rate == o.hit_rate &&
|
|
269
|
+
tokens_saved == o.tokens_saved &&
|
|
270
|
+
total_hits == o.total_hits &&
|
|
271
|
+
total_misses == o.total_misses
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
# @see the `==` method
|
|
275
|
+
# @param [Object] Object to be compared
|
|
276
|
+
def eql?(o)
|
|
277
|
+
self == o
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
# Calculates hash code according to all attributes.
|
|
281
|
+
# @return [Integer] Hash code
|
|
282
|
+
def hash
|
|
283
|
+
[avg_similarity_score, cost_saved, hit_rate, tokens_saved, total_hits, total_misses].hash
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
# Builds the object from hash
|
|
287
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
288
|
+
# @return [Object] Returns the model itself
|
|
289
|
+
def self.build_from_hash(attributes)
|
|
290
|
+
return nil unless attributes.is_a?(Hash)
|
|
291
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
292
|
+
transformed_hash = {}
|
|
293
|
+
openapi_types.each_pair do |key, type|
|
|
294
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
295
|
+
transformed_hash["#{key}"] = nil
|
|
296
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
297
|
+
# check to ensure the input is an array given that the attribute
|
|
298
|
+
# is documented as an array but the input is not
|
|
299
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
300
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
301
|
+
end
|
|
302
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
303
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
304
|
+
end
|
|
305
|
+
end
|
|
306
|
+
new(transformed_hash)
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
# Deserializes the data based on type
|
|
310
|
+
# @param string type Data type
|
|
311
|
+
# @param string value Value to be deserialized
|
|
312
|
+
# @return [Object] Deserialized data
|
|
313
|
+
def self._deserialize(type, value)
|
|
314
|
+
case type.to_sym
|
|
315
|
+
when :Time
|
|
316
|
+
Time.parse(value)
|
|
317
|
+
when :Date
|
|
318
|
+
Date.parse(value)
|
|
319
|
+
when :String
|
|
320
|
+
value.to_s
|
|
321
|
+
when :Integer
|
|
322
|
+
value.to_i
|
|
323
|
+
when :Float
|
|
324
|
+
value.to_f
|
|
325
|
+
when :Boolean
|
|
326
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
327
|
+
true
|
|
328
|
+
else
|
|
329
|
+
false
|
|
330
|
+
end
|
|
331
|
+
when :Object
|
|
332
|
+
# generic object (usually a Hash), return directly
|
|
333
|
+
value
|
|
334
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
335
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
336
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
337
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
338
|
+
k_type = Regexp.last_match[:k_type]
|
|
339
|
+
v_type = Regexp.last_match[:v_type]
|
|
340
|
+
{}.tap do |hash|
|
|
341
|
+
value.each do |k, v|
|
|
342
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
343
|
+
end
|
|
344
|
+
end
|
|
345
|
+
else # model
|
|
346
|
+
# models (e.g. Pet) or oneOf
|
|
347
|
+
klass = BlackmanClient.const_get(type)
|
|
348
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
349
|
+
end
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
# Returns the string representation of the object
|
|
353
|
+
# @return [String] String presentation of the object
|
|
354
|
+
def to_s
|
|
355
|
+
to_hash.to_s
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
359
|
+
# @return [Hash] Returns the object in the form of hash
|
|
360
|
+
def to_body
|
|
361
|
+
to_hash
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
# Returns the object in the form of hash
|
|
365
|
+
# @return [Hash] Returns the object in the form of hash
|
|
366
|
+
def to_hash
|
|
367
|
+
hash = {}
|
|
368
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
369
|
+
value = self.send(attr)
|
|
370
|
+
if value.nil?
|
|
371
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
372
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
hash[param] = _to_hash(value)
|
|
376
|
+
end
|
|
377
|
+
hash
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
# Outputs non-array value in the form of hash
|
|
381
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
382
|
+
# @param [Object] value Any valid value
|
|
383
|
+
# @return [Hash] Returns the value in the form of hash
|
|
384
|
+
def _to_hash(value)
|
|
385
|
+
if value.is_a?(Array)
|
|
386
|
+
value.compact.map { |v| _to_hash(v) }
|
|
387
|
+
elsif value.is_a?(Hash)
|
|
388
|
+
{}.tap do |hash|
|
|
389
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
390
|
+
end
|
|
391
|
+
elsif value.respond_to? :to_hash
|
|
392
|
+
value.to_hash
|
|
393
|
+
else
|
|
394
|
+
value
|
|
395
|
+
end
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
end
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Blackman AI API
|
|
3
|
+
|
|
4
|
+
#A transparent AI API proxy that optimizes token usage to reduce costs. ## Authentication Blackman AI supports two authentication methods: ### 1. API Key (Recommended for integrations) Use the API key created from your dashboard: ```bash curl -X POST https://ap.useblackman.ai/v1/completions \\ -H \"Authorization: Bearer sk_your_api_key_here\" \\ -H \"Content-Type: application/json\" \\ -d '{\"provider\": \"OpenAI\", \"model\": \"gpt-4\", \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}]}' ``` ### 2. JWT Token (For web UI) Obtain a JWT token by logging in: ```bash curl -X POST https://ap.useblackman.ai/v1/auth/login \\ -H \"Content-Type: application/json\" \\ -d '{\"email\": \"user@example.com\", \"password\": \"yourpassword\"}' ``` Then use the token: ```bash curl -X POST https://ap.useblackman.ai/v1/completions \\ -H \"Authorization: Bearer your_jwt_token\" \\ -H \"Content-Type: application/json\" \\ -d '{...}' ``` ### Provider API Keys (Optional) You can optionally provide your own LLM provider API key via the `X-Provider-Api-Key` header, or store it in your account settings. ## Client SDKs Auto-generated SDKs are available for 10 languages: - **TypeScript**: [View Docs](/v1/sdks/typescript) - **Python**: [View Docs](/v1/sdks/python) - **Go**: [View Docs](/v1/sdks/go) - **Java**: [View Docs](/v1/sdks/java) - **Ruby**: [View Docs](/v1/sdks/ruby) - **PHP**: [View Docs](/v1/sdks/php) - **C#**: [View Docs](/v1/sdks/csharp) - **Rust**: [View Docs](/v1/sdks/rust) - **Swift**: [View Docs](/v1/sdks/swift) - **Kotlin**: [View Docs](/v1/sdks/kotlin) All SDKs are generated from this OpenAPI spec using [openapi-generator](https://openapi-generator.tech). ## Quick Start ```python # Python example with API key import blackman_client from blackman_client import CompletionRequest configuration = blackman_client.Configuration( host=\"http://localhost:8080\", access_token=\"sk_your_api_key_here\" # Your Blackman API key ) with blackman_client.ApiClient(configuration) as api_client: api = blackman_client.CompletionsApi(api_client) response = api.completions( CompletionRequest( provider=\"OpenAI\", model=\"gpt-4o\", messages=[{\"role\": \"user\", \"content\": \"Hello!\"}] ) ) ```
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 0.1.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.14.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module BlackmanClient
|
|
17
|
+
class SubmitFeedbackRequest
|
|
18
|
+
# True for thumbs up, false for thumbs down
|
|
19
|
+
attr_accessor :is_positive
|
|
20
|
+
|
|
21
|
+
# Optional metadata (e.g., user_agent, session_id, etc.)
|
|
22
|
+
attr_accessor :metadata
|
|
23
|
+
|
|
24
|
+
# The response ID from the completion request
|
|
25
|
+
attr_accessor :response_id
|
|
26
|
+
|
|
27
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
28
|
+
def self.attribute_map
|
|
29
|
+
{
|
|
30
|
+
:'is_positive' => :'is_positive',
|
|
31
|
+
:'metadata' => :'metadata',
|
|
32
|
+
:'response_id' => :'response_id'
|
|
33
|
+
}
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Returns attribute mapping this model knows about
|
|
37
|
+
def self.acceptable_attribute_map
|
|
38
|
+
attribute_map
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Returns all the JSON keys this model knows about
|
|
42
|
+
def self.acceptable_attributes
|
|
43
|
+
acceptable_attribute_map.values
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Attribute type mapping.
|
|
47
|
+
def self.openapi_types
|
|
48
|
+
{
|
|
49
|
+
:'is_positive' => :'Boolean',
|
|
50
|
+
:'metadata' => :'Object',
|
|
51
|
+
:'response_id' => :'String'
|
|
52
|
+
}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# List of attributes with nullable: true
|
|
56
|
+
def self.openapi_nullable
|
|
57
|
+
Set.new([
|
|
58
|
+
:'metadata',
|
|
59
|
+
])
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Initializes the object
|
|
63
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
64
|
+
def initialize(attributes = {})
|
|
65
|
+
if (!attributes.is_a?(Hash))
|
|
66
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `BlackmanClient::SubmitFeedbackRequest` initialize method"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
70
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
71
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
72
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
73
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `BlackmanClient::SubmitFeedbackRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
74
|
+
end
|
|
75
|
+
h[k.to_sym] = v
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if attributes.key?(:'is_positive')
|
|
79
|
+
self.is_positive = attributes[:'is_positive']
|
|
80
|
+
else
|
|
81
|
+
self.is_positive = nil
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
if attributes.key?(:'metadata')
|
|
85
|
+
self.metadata = attributes[:'metadata']
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
if attributes.key?(:'response_id')
|
|
89
|
+
self.response_id = attributes[:'response_id']
|
|
90
|
+
else
|
|
91
|
+
self.response_id = nil
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
96
|
+
# @return Array for valid properties with the reasons
|
|
97
|
+
def list_invalid_properties
|
|
98
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
99
|
+
invalid_properties = Array.new
|
|
100
|
+
if @is_positive.nil?
|
|
101
|
+
invalid_properties.push('invalid value for "is_positive", is_positive cannot be nil.')
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
if @response_id.nil?
|
|
105
|
+
invalid_properties.push('invalid value for "response_id", response_id cannot be nil.')
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
invalid_properties
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Check to see if the all the properties in the model are valid
|
|
112
|
+
# @return true if the model is valid
|
|
113
|
+
def valid?
|
|
114
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
115
|
+
return false if @is_positive.nil?
|
|
116
|
+
return false if @response_id.nil?
|
|
117
|
+
true
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Custom attribute writer method with validation
|
|
121
|
+
# @param [Object] is_positive Value to be assigned
|
|
122
|
+
def is_positive=(is_positive)
|
|
123
|
+
if is_positive.nil?
|
|
124
|
+
fail ArgumentError, 'is_positive cannot be nil'
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
@is_positive = is_positive
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Custom attribute writer method with validation
|
|
131
|
+
# @param [Object] response_id Value to be assigned
|
|
132
|
+
def response_id=(response_id)
|
|
133
|
+
if response_id.nil?
|
|
134
|
+
fail ArgumentError, 'response_id cannot be nil'
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
@response_id = response_id
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Checks equality by comparing each attribute.
|
|
141
|
+
# @param [Object] Object to be compared
|
|
142
|
+
def ==(o)
|
|
143
|
+
return true if self.equal?(o)
|
|
144
|
+
self.class == o.class &&
|
|
145
|
+
is_positive == o.is_positive &&
|
|
146
|
+
metadata == o.metadata &&
|
|
147
|
+
response_id == o.response_id
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# @see the `==` method
|
|
151
|
+
# @param [Object] Object to be compared
|
|
152
|
+
def eql?(o)
|
|
153
|
+
self == o
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# Calculates hash code according to all attributes.
|
|
157
|
+
# @return [Integer] Hash code
|
|
158
|
+
def hash
|
|
159
|
+
[is_positive, metadata, response_id].hash
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Builds the object from hash
|
|
163
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
164
|
+
# @return [Object] Returns the model itself
|
|
165
|
+
def self.build_from_hash(attributes)
|
|
166
|
+
return nil unless attributes.is_a?(Hash)
|
|
167
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
168
|
+
transformed_hash = {}
|
|
169
|
+
openapi_types.each_pair do |key, type|
|
|
170
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
171
|
+
transformed_hash["#{key}"] = nil
|
|
172
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
173
|
+
# check to ensure the input is an array given that the attribute
|
|
174
|
+
# is documented as an array but the input is not
|
|
175
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
176
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
177
|
+
end
|
|
178
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
179
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
new(transformed_hash)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Deserializes the data based on type
|
|
186
|
+
# @param string type Data type
|
|
187
|
+
# @param string value Value to be deserialized
|
|
188
|
+
# @return [Object] Deserialized data
|
|
189
|
+
def self._deserialize(type, value)
|
|
190
|
+
case type.to_sym
|
|
191
|
+
when :Time
|
|
192
|
+
Time.parse(value)
|
|
193
|
+
when :Date
|
|
194
|
+
Date.parse(value)
|
|
195
|
+
when :String
|
|
196
|
+
value.to_s
|
|
197
|
+
when :Integer
|
|
198
|
+
value.to_i
|
|
199
|
+
when :Float
|
|
200
|
+
value.to_f
|
|
201
|
+
when :Boolean
|
|
202
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
203
|
+
true
|
|
204
|
+
else
|
|
205
|
+
false
|
|
206
|
+
end
|
|
207
|
+
when :Object
|
|
208
|
+
# generic object (usually a Hash), return directly
|
|
209
|
+
value
|
|
210
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
211
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
212
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
213
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
214
|
+
k_type = Regexp.last_match[:k_type]
|
|
215
|
+
v_type = Regexp.last_match[:v_type]
|
|
216
|
+
{}.tap do |hash|
|
|
217
|
+
value.each do |k, v|
|
|
218
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
else # model
|
|
222
|
+
# models (e.g. Pet) or oneOf
|
|
223
|
+
klass = BlackmanClient.const_get(type)
|
|
224
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
# Returns the string representation of the object
|
|
229
|
+
# @return [String] String presentation of the object
|
|
230
|
+
def to_s
|
|
231
|
+
to_hash.to_s
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
235
|
+
# @return [Hash] Returns the object in the form of hash
|
|
236
|
+
def to_body
|
|
237
|
+
to_hash
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# Returns the object in the form of hash
|
|
241
|
+
# @return [Hash] Returns the object in the form of hash
|
|
242
|
+
def to_hash
|
|
243
|
+
hash = {}
|
|
244
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
245
|
+
value = self.send(attr)
|
|
246
|
+
if value.nil?
|
|
247
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
248
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
hash[param] = _to_hash(value)
|
|
252
|
+
end
|
|
253
|
+
hash
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
# Outputs non-array value in the form of hash
|
|
257
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
258
|
+
# @param [Object] value Any valid value
|
|
259
|
+
# @return [Hash] Returns the value in the form of hash
|
|
260
|
+
def _to_hash(value)
|
|
261
|
+
if value.is_a?(Array)
|
|
262
|
+
value.compact.map { |v| _to_hash(v) }
|
|
263
|
+
elsif value.is_a?(Hash)
|
|
264
|
+
{}.tap do |hash|
|
|
265
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
266
|
+
end
|
|
267
|
+
elsif value.respond_to? :to_hash
|
|
268
|
+
value.to_hash
|
|
269
|
+
else
|
|
270
|
+
value
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
end
|