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
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 10646256d97ec239d7195c3317a38e5b3ec3278ab26921646139d71c8e379b89
|
|
4
|
+
data.tar.gz: 79daba76e677e18d10568db4d238401c11500663150df8736b2caa9ca04fdd22
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4ea08108aa027a9074214052d7c7c5bd76ac45ff3a3646e887b90c3edf681bc0897c7a28775dcb8f56eacab98bf47714dd4d52187e81ef543e50275125fba54a
|
|
7
|
+
data.tar.gz: dc1a6977997ddbb1b4f18016fe570051d11422085746b5f22db4699221c90bd41606313ff71f352e05cc597f3751713b52cc6eb5c497e3834c6f8cc06746c407
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Blackman AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# Blackman AI Ruby SDK
|
|
2
|
+
|
|
3
|
+
Official Ruby client for [Blackman AI](https://www.useblackman.ai) - The AI API proxy that optimizes token usage to reduce costs.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🚀 Drop-in replacement for OpenAI, Anthropic, and other LLM APIs
|
|
8
|
+
- 💰 Automatic token optimization (save 20-40% on costs)
|
|
9
|
+
- 📊 Built-in analytics and cost tracking
|
|
10
|
+
- 🔒 Enterprise-grade security with SSO support
|
|
11
|
+
- ⚡ Low latency overhead (<50ms)
|
|
12
|
+
- 🎯 Semantic caching for repeated queries
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
Add this line to your application's Gemfile:
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
gem 'blackman_client', '~> 0.0.5'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
And then execute:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
bundle install
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Or install it yourself:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
gem install blackman_client
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
```ruby
|
|
37
|
+
require 'blackman_client'
|
|
38
|
+
|
|
39
|
+
# Configure client
|
|
40
|
+
BlackmanClient.configure do |config|
|
|
41
|
+
config.host = 'app.useblackman.ai'
|
|
42
|
+
config.scheme = 'https'
|
|
43
|
+
config.api_key['Authorization'] = 'Bearer sk_your_blackman_api_key'
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
api = BlackmanClient::CompletionsApi.new
|
|
47
|
+
|
|
48
|
+
# Create completion request
|
|
49
|
+
request = BlackmanClient::CompletionRequest.new(
|
|
50
|
+
provider: 'OpenAI',
|
|
51
|
+
model: 'gpt-4o',
|
|
52
|
+
messages: [
|
|
53
|
+
BlackmanClient::Message.new(
|
|
54
|
+
role: 'user',
|
|
55
|
+
content: 'Explain quantum computing in simple terms'
|
|
56
|
+
)
|
|
57
|
+
]
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
# Send request
|
|
61
|
+
begin
|
|
62
|
+
response = api.completions(request)
|
|
63
|
+
puts response.choices[0].message.content
|
|
64
|
+
puts "Tokens used: #{response.usage.total_tokens}"
|
|
65
|
+
rescue BlackmanClient::ApiError => e
|
|
66
|
+
puts "Error: #{e}"
|
|
67
|
+
end
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Authentication
|
|
71
|
+
|
|
72
|
+
Get your API key from the [Blackman AI Dashboard](https://app.useblackman.ai/settings/api-keys).
|
|
73
|
+
|
|
74
|
+
```ruby
|
|
75
|
+
BlackmanClient.configure do |config|
|
|
76
|
+
config.host = 'app.useblackman.ai'
|
|
77
|
+
config.scheme = 'https'
|
|
78
|
+
config.api_key['Authorization'] = 'Bearer sk_your_blackman_api_key'
|
|
79
|
+
end
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Framework Integration
|
|
83
|
+
|
|
84
|
+
### Ruby on Rails
|
|
85
|
+
|
|
86
|
+
Create an initializer `config/initializers/blackman.rb`:
|
|
87
|
+
|
|
88
|
+
```ruby
|
|
89
|
+
require 'blackman_client'
|
|
90
|
+
|
|
91
|
+
BlackmanClient.configure do |config|
|
|
92
|
+
config.host = 'app.useblackman.ai'
|
|
93
|
+
config.scheme = 'https'
|
|
94
|
+
config.api_key['Authorization'] = "Bearer #{ENV['BLACKMAN_API_KEY']}"
|
|
95
|
+
end
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Create a service class `app/services/chat_service.rb`:
|
|
99
|
+
|
|
100
|
+
```ruby
|
|
101
|
+
class ChatService
|
|
102
|
+
def initialize
|
|
103
|
+
@api = BlackmanClient::CompletionsApi.new
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def chat(message)
|
|
107
|
+
request = BlackmanClient::CompletionRequest.new(
|
|
108
|
+
provider: 'OpenAI',
|
|
109
|
+
model: 'gpt-4o',
|
|
110
|
+
messages: [
|
|
111
|
+
BlackmanClient::Message.new(
|
|
112
|
+
role: 'user',
|
|
113
|
+
content: message
|
|
114
|
+
)
|
|
115
|
+
]
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
response = @api.completions(request)
|
|
119
|
+
response.choices[0].message.content
|
|
120
|
+
rescue BlackmanClient::ApiError => e
|
|
121
|
+
Rails.logger.error "Blackman API error: #{e}"
|
|
122
|
+
raise
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Use in a controller:
|
|
128
|
+
|
|
129
|
+
```ruby
|
|
130
|
+
class ChatsController < ApplicationController
|
|
131
|
+
def create
|
|
132
|
+
service = ChatService.new
|
|
133
|
+
response = service.chat(params[:message])
|
|
134
|
+
render json: { response: response }
|
|
135
|
+
rescue BlackmanClient::ApiError => e
|
|
136
|
+
render json: { error: e.message }, status: :bad_request
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Sinatra
|
|
142
|
+
|
|
143
|
+
```ruby
|
|
144
|
+
require 'sinatra'
|
|
145
|
+
require 'blackman_client'
|
|
146
|
+
require 'json'
|
|
147
|
+
|
|
148
|
+
# Configure Blackman
|
|
149
|
+
BlackmanClient.configure do |config|
|
|
150
|
+
config.host = 'app.useblackman.ai'
|
|
151
|
+
config.scheme = 'https'
|
|
152
|
+
config.api_key['Authorization'] = "Bearer #{ENV['BLACKMAN_API_KEY']}"
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
post '/chat' do
|
|
156
|
+
content_type :json
|
|
157
|
+
|
|
158
|
+
data = JSON.parse(request.body.read)
|
|
159
|
+
|
|
160
|
+
api = BlackmanClient::CompletionsApi.new
|
|
161
|
+
request = BlackmanClient::CompletionRequest.new(
|
|
162
|
+
provider: 'OpenAI',
|
|
163
|
+
model: 'gpt-4o',
|
|
164
|
+
messages: [
|
|
165
|
+
BlackmanClient::Message.new(
|
|
166
|
+
role: 'user',
|
|
167
|
+
content: data['message']
|
|
168
|
+
)
|
|
169
|
+
]
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
begin
|
|
173
|
+
response = api.completions(request)
|
|
174
|
+
{ response: response.choices[0].message.content }.to_json
|
|
175
|
+
rescue BlackmanClient::ApiError => e
|
|
176
|
+
status 400
|
|
177
|
+
{ error: e.message }.to_json
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Advanced Usage
|
|
183
|
+
|
|
184
|
+
### Custom Timeouts
|
|
185
|
+
|
|
186
|
+
```ruby
|
|
187
|
+
BlackmanClient.configure do |config|
|
|
188
|
+
config.host = 'app.useblackman.ai'
|
|
189
|
+
config.scheme = 'https'
|
|
190
|
+
config.api_key['Authorization'] = 'Bearer sk_your_blackman_api_key'
|
|
191
|
+
config.timeout = 60 # seconds
|
|
192
|
+
end
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Error Handling
|
|
196
|
+
|
|
197
|
+
```ruby
|
|
198
|
+
begin
|
|
199
|
+
response = api.completions(request)
|
|
200
|
+
puts response.choices[0].message.content
|
|
201
|
+
rescue BlackmanClient::ApiError => e
|
|
202
|
+
puts "HTTP Status Code: #{e.code}"
|
|
203
|
+
puts "Response Headers: #{e.response_headers}"
|
|
204
|
+
puts "Response Body: #{e.response_body}"
|
|
205
|
+
rescue StandardError => e
|
|
206
|
+
puts "Unexpected error: #{e.message}"
|
|
207
|
+
end
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Streaming Responses
|
|
211
|
+
|
|
212
|
+
```ruby
|
|
213
|
+
# For streaming, use a custom approach with Faraday
|
|
214
|
+
require 'faraday'
|
|
215
|
+
|
|
216
|
+
conn = Faraday.new(url: 'https://app.useblackman.ai') do |f|
|
|
217
|
+
f.headers['Authorization'] = 'Bearer sk_your_blackman_api_key'
|
|
218
|
+
f.adapter Faraday.default_adapter
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
response = conn.post('/v1/completions') do |req|
|
|
222
|
+
req.headers['Content-Type'] = 'application/json'
|
|
223
|
+
req.body = {
|
|
224
|
+
provider: 'OpenAI',
|
|
225
|
+
model: 'gpt-4o',
|
|
226
|
+
messages: [{ role: 'user', content: 'Hello!' }],
|
|
227
|
+
stream: true
|
|
228
|
+
}.to_json
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
response.body.each_line do |line|
|
|
232
|
+
puts line if line.start_with?('data:')
|
|
233
|
+
end
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Retry Logic
|
|
237
|
+
|
|
238
|
+
```ruby
|
|
239
|
+
require 'retriable'
|
|
240
|
+
|
|
241
|
+
Retriable.retriable(tries: 3, base_interval: 1, multiplier: 2) do
|
|
242
|
+
response = api.completions(request)
|
|
243
|
+
puts response.choices[0].message.content
|
|
244
|
+
end
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Documentation
|
|
248
|
+
|
|
249
|
+
- [Full API Reference](https://app.useblackman.ai/docs)
|
|
250
|
+
- [Getting Started Guide](https://app.useblackman.ai/docs/getting-started)
|
|
251
|
+
- [Ruby Examples](https://github.com/blackman-ai/ruby-sdk/tree/main/examples)
|
|
252
|
+
- [RubyDoc](https://rubydoc.info/gems/blackman_client)
|
|
253
|
+
|
|
254
|
+
## Requirements
|
|
255
|
+
|
|
256
|
+
- Ruby 2.7 or higher
|
|
257
|
+
|
|
258
|
+
## Support
|
|
259
|
+
|
|
260
|
+
- 📧 Email: [support@blackman.ai](mailto:support@blackman.ai)
|
|
261
|
+
- 💬 Discord: [Join our community](https://discord.gg/blackman-ai)
|
|
262
|
+
- 🐛 Issues: [GitHub Issues](https://github.com/blackman-ai/ruby-sdk/issues)
|
|
263
|
+
|
|
264
|
+
## License
|
|
265
|
+
|
|
266
|
+
MIT © Blackman AI
|
|
@@ -0,0 +1,89 @@
|
|
|
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 'cgi'
|
|
14
|
+
|
|
15
|
+
module BlackmanClient
|
|
16
|
+
class CompletionsApi
|
|
17
|
+
attr_accessor :api_client
|
|
18
|
+
|
|
19
|
+
def initialize(api_client = ApiClient.default)
|
|
20
|
+
@api_client = api_client
|
|
21
|
+
end
|
|
22
|
+
# @param completion_request [CompletionRequest]
|
|
23
|
+
# @param [Hash] opts the optional parameters
|
|
24
|
+
# @option opts [String] :x_provider_api_key Optional provider API key to override stored or system keys
|
|
25
|
+
# @return [CompletionResponse]
|
|
26
|
+
def completions(completion_request, opts = {})
|
|
27
|
+
data, _status_code, _headers = completions_with_http_info(completion_request, opts)
|
|
28
|
+
data
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# @param completion_request [CompletionRequest]
|
|
32
|
+
# @param [Hash] opts the optional parameters
|
|
33
|
+
# @option opts [String] :x_provider_api_key Optional provider API key to override stored or system keys
|
|
34
|
+
# @return [Array<(CompletionResponse, Integer, Hash)>] CompletionResponse data, response status code and response headers
|
|
35
|
+
def completions_with_http_info(completion_request, opts = {})
|
|
36
|
+
if @api_client.config.debugging
|
|
37
|
+
@api_client.config.logger.debug 'Calling API: CompletionsApi.completions ...'
|
|
38
|
+
end
|
|
39
|
+
# verify the required parameter 'completion_request' is set
|
|
40
|
+
if @api_client.config.client_side_validation && completion_request.nil?
|
|
41
|
+
fail ArgumentError, "Missing the required parameter 'completion_request' when calling CompletionsApi.completions"
|
|
42
|
+
end
|
|
43
|
+
# resource path
|
|
44
|
+
local_var_path = '/v1/completions'
|
|
45
|
+
|
|
46
|
+
# query parameters
|
|
47
|
+
query_params = opts[:query_params] || {}
|
|
48
|
+
|
|
49
|
+
# header parameters
|
|
50
|
+
header_params = opts[:header_params] || {}
|
|
51
|
+
# HTTP header 'Accept' (if needed)
|
|
52
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
53
|
+
# HTTP header 'Content-Type'
|
|
54
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
|
55
|
+
if !content_type.nil?
|
|
56
|
+
header_params['Content-Type'] = content_type
|
|
57
|
+
end
|
|
58
|
+
header_params[:'X-Provider-Api-Key'] = opts[:'x_provider_api_key'] if !opts[:'x_provider_api_key'].nil?
|
|
59
|
+
|
|
60
|
+
# form parameters
|
|
61
|
+
form_params = opts[:form_params] || {}
|
|
62
|
+
|
|
63
|
+
# http body (model)
|
|
64
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(completion_request)
|
|
65
|
+
|
|
66
|
+
# return_type
|
|
67
|
+
return_type = opts[:debug_return_type] || 'CompletionResponse'
|
|
68
|
+
|
|
69
|
+
# auth_names
|
|
70
|
+
auth_names = opts[:debug_auth_names] || ['BearerAuth']
|
|
71
|
+
|
|
72
|
+
new_options = opts.merge(
|
|
73
|
+
:operation => :"CompletionsApi.completions",
|
|
74
|
+
:header_params => header_params,
|
|
75
|
+
:query_params => query_params,
|
|
76
|
+
:form_params => form_params,
|
|
77
|
+
:body => post_body,
|
|
78
|
+
:auth_names => auth_names,
|
|
79
|
+
:return_type => return_type
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
|
83
|
+
if @api_client.config.debugging
|
|
84
|
+
@api_client.config.logger.debug "API called: CompletionsApi#completions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
85
|
+
end
|
|
86
|
+
return data, status_code, headers
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
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 'cgi'
|
|
14
|
+
|
|
15
|
+
module BlackmanClient
|
|
16
|
+
class FeedbackApi
|
|
17
|
+
attr_accessor :api_client
|
|
18
|
+
|
|
19
|
+
def initialize(api_client = ApiClient.default)
|
|
20
|
+
@api_client = api_client
|
|
21
|
+
end
|
|
22
|
+
# Submit feedback for a completion response
|
|
23
|
+
# @param submit_feedback_request [SubmitFeedbackRequest]
|
|
24
|
+
# @param [Hash] opts the optional parameters
|
|
25
|
+
# @return [SubmitFeedbackResponse]
|
|
26
|
+
def submit_feedback(submit_feedback_request, opts = {})
|
|
27
|
+
data, _status_code, _headers = submit_feedback_with_http_info(submit_feedback_request, opts)
|
|
28
|
+
data
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Submit feedback for a completion response
|
|
32
|
+
# @param submit_feedback_request [SubmitFeedbackRequest]
|
|
33
|
+
# @param [Hash] opts the optional parameters
|
|
34
|
+
# @return [Array<(SubmitFeedbackResponse, Integer, Hash)>] SubmitFeedbackResponse data, response status code and response headers
|
|
35
|
+
def submit_feedback_with_http_info(submit_feedback_request, opts = {})
|
|
36
|
+
if @api_client.config.debugging
|
|
37
|
+
@api_client.config.logger.debug 'Calling API: FeedbackApi.submit_feedback ...'
|
|
38
|
+
end
|
|
39
|
+
# verify the required parameter 'submit_feedback_request' is set
|
|
40
|
+
if @api_client.config.client_side_validation && submit_feedback_request.nil?
|
|
41
|
+
fail ArgumentError, "Missing the required parameter 'submit_feedback_request' when calling FeedbackApi.submit_feedback"
|
|
42
|
+
end
|
|
43
|
+
# resource path
|
|
44
|
+
local_var_path = '/v1/feedback'
|
|
45
|
+
|
|
46
|
+
# query parameters
|
|
47
|
+
query_params = opts[:query_params] || {}
|
|
48
|
+
|
|
49
|
+
# header parameters
|
|
50
|
+
header_params = opts[:header_params] || {}
|
|
51
|
+
# HTTP header 'Accept' (if needed)
|
|
52
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
53
|
+
# HTTP header 'Content-Type'
|
|
54
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
|
55
|
+
if !content_type.nil?
|
|
56
|
+
header_params['Content-Type'] = content_type
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# form parameters
|
|
60
|
+
form_params = opts[:form_params] || {}
|
|
61
|
+
|
|
62
|
+
# http body (model)
|
|
63
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(submit_feedback_request)
|
|
64
|
+
|
|
65
|
+
# return_type
|
|
66
|
+
return_type = opts[:debug_return_type] || 'SubmitFeedbackResponse'
|
|
67
|
+
|
|
68
|
+
# auth_names
|
|
69
|
+
auth_names = opts[:debug_auth_names] || ['BearerAuth']
|
|
70
|
+
|
|
71
|
+
new_options = opts.merge(
|
|
72
|
+
:operation => :"FeedbackApi.submit_feedback",
|
|
73
|
+
:header_params => header_params,
|
|
74
|
+
:query_params => query_params,
|
|
75
|
+
:form_params => form_params,
|
|
76
|
+
:body => post_body,
|
|
77
|
+
:auth_names => auth_names,
|
|
78
|
+
:return_type => return_type
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
|
82
|
+
if @api_client.config.debugging
|
|
83
|
+
@api_client.config.logger.debug "API called: FeedbackApi#submit_feedback\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
84
|
+
end
|
|
85
|
+
return data, status_code, headers
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|