typesafe-ai-ruby 0.1.0 → 0.2.0

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.
data/sig/typesafe.rbs CHANGED
@@ -14,9 +14,16 @@ module TypeSafe
14
14
 
15
15
  type retry_policy_input = RetryPolicy | Hash[Symbol | String, untyped] | nil
16
16
 
17
+ # Experimental features: :images and :long_context, singly or as an Array.
18
+ type danger_zone_input = Symbol | String | Array[Symbol | String] | nil
19
+
20
+ # Images attached to a request: one image, an Array of images, or reference => Image.
21
+ type assets_input = Image | Array[Image] | Hash[String | Symbol, Image] | nil
22
+
17
23
  class Noul = Questions::Noul
18
24
  class Choice = Questions::Choice
19
25
  class Score = Questions::Score
26
+ class Box = Questions::Box
20
27
 
21
28
  def self.configuration: () -> Configuration
22
29
  def self.configure: () { (Configuration) -> void } -> Configuration
@@ -26,6 +33,7 @@ module TypeSafe
26
33
  def self.noul: (?json_input? instructions, ?Hash[untyped, untyped]? criteria, **untyped named) -> Questions::Noul
27
34
  def self.choice: (?json_input? instructions, ?Hash[untyped, untyped]? criteria, **untyped named) -> Questions::Choice
28
35
  def self.score: (?json_input? instructions, ?Array[untyped]? criteria) -> Questions::Score
36
+ def self.box: (?json_input? instructions) -> Questions::Box
29
37
 
30
38
  module Constants
31
39
  API_KEY_ENV: String
@@ -41,7 +49,11 @@ module TypeSafe
41
49
  SDK_NAME: String
42
50
  JSON_CONTENT_TYPE: String
43
51
 
52
+ DANGER_ZONES: Hash[Symbol, String]
53
+
44
54
  module Headers
55
+ DANGER_ZONE_IMAGES: String
56
+ DANGER_ZONE_LONG_CONTEXT: String
45
57
  AUTHORIZATION: String
46
58
  ACCEPT: String
47
59
  CONTENT_TYPE: String
@@ -89,6 +101,12 @@ module TypeSafe
89
101
  class NotFoundError < APIError
90
102
  end
91
103
 
104
+ class PayloadTooLargeError < APIError
105
+ end
106
+
107
+ class UnsupportedMediaTypeError < APIError
108
+ end
109
+
92
110
  class UnprocessableEntityError < APIError
93
111
  end
94
112
 
@@ -126,6 +144,34 @@ module TypeSafe
126
144
  def dig: (String | Symbol key, *untyped rest) -> untyped
127
145
  end
128
146
 
147
+ class Image
148
+ MAX_BYTES: Integer
149
+ REFERENCE_PATTERN: Regexp
150
+ SIGNATURES: Hash[String, String]
151
+
152
+ attr_reader reference: String
153
+ attr_reader path: String?
154
+
155
+ def self.open: (untyped path) -> Image
156
+ def self.from_base64: (String text) -> Image
157
+ def self.reference?: (untyped string) -> bool
158
+ def initialize: (?String? bytes, ?path: String?) -> void
159
+ def bytes: () -> String
160
+ def bytesize: () -> Integer
161
+ def content_type: () -> String
162
+ def format: () -> String
163
+ def validate!: () -> Image
164
+ def to_s: () -> String
165
+ def to_json: (*untyped args) -> String
166
+ end
167
+
168
+ module Assets
169
+ MAX_REFERENCE_BYTES: Integer
170
+
171
+ def self?.attach: (assets_input value) -> Hash[String, Image]
172
+ def self?.resolve: (Array[Image] collected, Hash[String, Image] attached, String json) -> Hash[String, Image]
173
+ end
174
+
129
175
  class Configuration
130
176
  LOG_LEVELS: Hash[Symbol, Integer]
131
177
 
@@ -138,10 +184,12 @@ module TypeSafe
138
184
  attr_accessor log_level: (Symbol | String)?
139
185
  attr_accessor retry_policy: retry_policy_input
140
186
  attr_accessor transport: HTTP::_Transport?
187
+ attr_accessor danger_zone: danger_zone_input
141
188
 
142
189
  def initialize: (?api_key: String?, ?base_url: String?, ?model: String?, ?timeout: Numeric?,
143
190
  ?headers: Hash[untyped, untyped]?, ?logger: Logger?, ?log_level: (Symbol | String)?,
144
- ?retry_policy: retry_policy_input, ?transport: HTTP::_Transport?) -> void
191
+ ?retry_policy: retry_policy_input, ?transport: HTTP::_Transport?,
192
+ ?danger_zone: danger_zone_input) -> void
145
193
  def to_h: () -> Hash[Symbol, untyped]
146
194
  def resolve: (?env: _Env) -> Configuration
147
195
  def logger_severity: () -> Integer
@@ -191,10 +239,12 @@ module TypeSafe
191
239
  attr_reader headers: Hash[String, String]
192
240
  attr_reader extra_body: Hash[String, untyped]?
193
241
  attr_reader retry_policy: retry_policy_input
242
+ attr_reader danger_zone: Array[Symbol]
194
243
 
195
- def self.from: (request_options_input options) -> RequestOptions
244
+ def self.from: (request_options_input options, ?danger_zone: danger_zone_input) -> RequestOptions
196
245
  def initialize: (?timeout: Numeric?, ?headers: Hash[untyped, untyped]?, ?extra_body: Hash[untyped, untyped]?,
197
- ?retry_policy: retry_policy_input) -> void
246
+ ?retry_policy: retry_policy_input, ?danger_zone: danger_zone_input) -> void
247
+ def with_danger_zone: (danger_zone_input zones) -> RequestOptions
198
248
  end
199
249
 
200
250
  class Client
@@ -203,8 +253,10 @@ module TypeSafe
203
253
 
204
254
  def initialize: (?api_key: String?, ?base_url: String?, ?model: String?, ?timeout: Numeric?,
205
255
  ?headers: Hash[untyped, untyped]?, ?logger: Logger?, ?log_level: (Symbol | String)?,
206
- ?retry_policy: retry_policy_input, ?transport: HTTP::_Transport?) -> void
207
- def system_one: (state: json_input, questions: Hash[String | Symbol, question_input], ?model: String?,
256
+ ?retry_policy: retry_policy_input, ?transport: HTTP::_Transport?,
257
+ ?danger_zone: danger_zone_input) -> void
258
+ def system_one: (state: json_input | Image, questions: Hash[String | Symbol, question_input], ?model: String?,
259
+ ?assets: assets_input, ?danger_zone: danger_zone_input,
208
260
  ?request_options: request_options_input) -> Responses::SystemOneResponse
209
261
  def close: () -> void
210
262
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typesafe-ai-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - hnegishi
@@ -37,18 +37,22 @@ files:
37
37
  - README.md
38
38
  - lib/typesafe-ai-ruby.rb
39
39
  - lib/typesafe.rb
40
+ - lib/typesafe/assets.rb
40
41
  - lib/typesafe/client.rb
41
42
  - lib/typesafe/configuration.rb
42
43
  - lib/typesafe/constants.rb
43
44
  - lib/typesafe/errors.rb
44
45
  - lib/typesafe/http/connection_manager.rb
46
+ - lib/typesafe/http/multipart_encoder.rb
45
47
  - lib/typesafe/http/net_http_transport.rb
46
48
  - lib/typesafe/http/request.rb
47
49
  - lib/typesafe/http/requestor.rb
48
50
  - lib/typesafe/http/response.rb
49
51
  - lib/typesafe/http/retrier.rb
52
+ - lib/typesafe/image.rb
50
53
  - lib/typesafe/instrumentation.rb
51
54
  - lib/typesafe/logging.rb
55
+ - lib/typesafe/questions/box.rb
52
56
  - lib/typesafe/questions/choice.rb
53
57
  - lib/typesafe/questions/normalizer.rb
54
58
  - lib/typesafe/questions/noul.rb