sorbet-baml 0.1.0 → 0.3.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.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/CLAUDE.md +94 -0
  3. data/README.md +315 -122
  4. data/Rakefile +2 -2
  5. data/docs-site/.gitignore +48 -0
  6. data/docs-site/Gemfile +5 -0
  7. data/docs-site/Gemfile.lock +140 -0
  8. data/docs-site/Rakefile +3 -0
  9. data/docs-site/bridgetown.config.yml +15 -0
  10. data/docs-site/config/initializers.rb +9 -0
  11. data/docs-site/config/puma.rb +9 -0
  12. data/docs-site/config.ru +5 -0
  13. data/docs-site/esbuild.config.js +11 -0
  14. data/docs-site/frontend/javascript/index.js +22 -0
  15. data/docs-site/frontend/styles/index.css +61 -0
  16. data/docs-site/package.json +18 -0
  17. data/docs-site/postcss.config.js +6 -0
  18. data/docs-site/server/roda_app.rb +9 -0
  19. data/docs-site/src/_components/head.liquid +26 -0
  20. data/docs-site/src/_components/nav.liquid +68 -0
  21. data/docs-site/src/_layouts/default.liquid +27 -0
  22. data/docs-site/src/_layouts/doc.liquid +39 -0
  23. data/docs-site/src/advanced-usage.md +598 -0
  24. data/docs-site/src/getting-started.md +170 -0
  25. data/docs-site/src/index.md +183 -0
  26. data/docs-site/src/troubleshooting.md +317 -0
  27. data/docs-site/src/type-mapping.md +236 -0
  28. data/docs-site/tailwind.config.js +85 -0
  29. data/examples/description_parameters.rb +49 -0
  30. data/lib/sorbet_baml/comment_extractor.rb +51 -54
  31. data/lib/sorbet_baml/converter.rb +69 -35
  32. data/lib/sorbet_baml/dependency_resolver.rb +11 -11
  33. data/lib/sorbet_baml/description_extension.rb +34 -0
  34. data/lib/sorbet_baml/description_extractor.rb +34 -0
  35. data/lib/sorbet_baml/dspy_tool_converter.rb +97 -0
  36. data/lib/sorbet_baml/dspy_tool_extensions.rb +23 -0
  37. data/lib/sorbet_baml/enum_extensions.rb +2 -2
  38. data/lib/sorbet_baml/struct_extensions.rb +2 -2
  39. data/lib/sorbet_baml/tool_extensions.rb +23 -0
  40. data/lib/sorbet_baml/type_mapper.rb +35 -37
  41. data/lib/sorbet_baml/version.rb +1 -1
  42. data/lib/sorbet_baml.rb +41 -10
  43. data/sorbet/config +2 -0
  44. data/sorbet/rbi/gems/anthropic@1.5.0.rbi +21252 -0
  45. data/sorbet/rbi/gems/async@2.27.3.rbi +9 -0
  46. data/sorbet/rbi/gems/bigdecimal@3.2.2.rbi +9 -0
  47. data/sorbet/rbi/gems/concurrent-ruby@1.3.5.rbi +424 -0
  48. data/sorbet/rbi/gems/connection_pool@2.5.3.rbi +9 -0
  49. data/sorbet/rbi/gems/console@1.33.0.rbi +9 -0
  50. data/sorbet/rbi/gems/dry-configurable@1.3.0.rbi +672 -0
  51. data/sorbet/rbi/gems/dry-core@1.1.0.rbi +1729 -0
  52. data/sorbet/rbi/gems/dry-logger@1.1.0.rbi +1317 -0
  53. data/sorbet/rbi/gems/dspy@0.19.1.rbi +6677 -0
  54. data/sorbet/rbi/gems/ffi@1.17.2.rbi +2174 -0
  55. data/sorbet/rbi/gems/fiber-annotation@0.2.0.rbi +9 -0
  56. data/sorbet/rbi/gems/fiber-local@1.1.0.rbi +9 -0
  57. data/sorbet/rbi/gems/fiber-storage@1.0.1.rbi +9 -0
  58. data/sorbet/rbi/gems/google-protobuf@4.32.0.rbi +9 -0
  59. data/sorbet/rbi/gems/googleapis-common-protos-types@1.20.0.rbi +9 -0
  60. data/sorbet/rbi/gems/informers@1.2.1.rbi +1875 -0
  61. data/sorbet/rbi/gems/io-event@1.12.1.rbi +9 -0
  62. data/sorbet/rbi/gems/metrics@0.13.0.rbi +9 -0
  63. data/sorbet/rbi/gems/onnxruntime@0.10.0.rbi +304 -0
  64. data/sorbet/rbi/gems/openai@0.16.0.rbi +68055 -0
  65. data/sorbet/rbi/gems/opentelemetry-api@1.6.0.rbi +9 -0
  66. data/sorbet/rbi/gems/opentelemetry-common@0.22.0.rbi +9 -0
  67. data/sorbet/rbi/gems/opentelemetry-exporter-otlp@0.30.0.rbi +9 -0
  68. data/sorbet/rbi/gems/opentelemetry-registry@0.4.0.rbi +9 -0
  69. data/sorbet/rbi/gems/opentelemetry-sdk@1.8.1.rbi +9 -0
  70. data/sorbet/rbi/gems/opentelemetry-semantic_conventions@1.11.0.rbi +9 -0
  71. data/sorbet/rbi/gems/polars-df@0.20.0.rbi +9 -0
  72. data/sorbet/rbi/gems/sorbet-result@1.4.0.rbi +242 -0
  73. data/sorbet/rbi/gems/sorbet-schema@0.9.2.rbi +743 -0
  74. data/sorbet/rbi/gems/sorbet-struct-comparable@1.3.0.rbi +48 -0
  75. data/sorbet/rbi/gems/tokenizers@0.5.5.rbi +754 -0
  76. data/sorbet/rbi/gems/traces@0.17.0.rbi +9 -0
  77. data/sorbet/rbi/gems/zeitwerk@2.7.3.rbi +1429 -0
  78. metadata +67 -7
  79. data/docs/README.md +0 -117
  80. data/docs/advanced-usage.md +0 -427
  81. data/docs/getting-started.md +0 -91
  82. data/docs/troubleshooting.md +0 -291
  83. data/docs/type-mapping.md +0 -192
@@ -0,0 +1,9 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `io-event` gem.
5
+ # Please instead update this file by running `bin/tapioca gem io-event`.
6
+
7
+
8
+ # THIS IS AN EMPTY RBI FILE.
9
+ # see https://github.com/Shopify/tapioca#manually-requiring-parts-of-a-gem
@@ -0,0 +1,9 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `metrics` gem.
5
+ # Please instead update this file by running `bin/tapioca gem metrics`.
6
+
7
+
8
+ # THIS IS AN EMPTY RBI FILE.
9
+ # see https://github.com/Shopify/tapioca#manually-requiring-parts-of-a-gem
@@ -0,0 +1,304 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `onnxruntime` gem.
5
+ # Please instead update this file by running `bin/tapioca gem onnxruntime`.
6
+
7
+
8
+ # source://onnxruntime//lib/onnxruntime/datasets.rb#1
9
+ module OnnxRuntime
10
+ class << self
11
+ # Returns the value of attribute ffi_lib.
12
+ #
13
+ # source://onnxruntime//lib/onnxruntime.rb#16
14
+ def ffi_lib; end
15
+
16
+ # Sets the attribute ffi_lib
17
+ #
18
+ # @param value the value to set the attribute ffi_lib to.
19
+ #
20
+ # source://onnxruntime//lib/onnxruntime.rb#16
21
+ def ffi_lib=(_arg0); end
22
+
23
+ # source://onnxruntime//lib/onnxruntime.rb#37
24
+ def lib_version; end
25
+ end
26
+ end
27
+
28
+ # source://onnxruntime//lib/onnxruntime/datasets.rb#2
29
+ module OnnxRuntime::Datasets
30
+ class << self
31
+ # source://onnxruntime//lib/onnxruntime/datasets.rb#3
32
+ def example(name); end
33
+ end
34
+ end
35
+
36
+ # source://onnxruntime//lib/onnxruntime.rb#13
37
+ class OnnxRuntime::Error < ::StandardError; end
38
+
39
+ # source://onnxruntime//lib/onnxruntime/ffi.rb#2
40
+ module OnnxRuntime::FFI
41
+ extend ::FFI::Library
42
+
43
+ def OrtGetApiBase(*_arg0); end
44
+ def OrtSessionOptionsAppendExecutionProvider_CoreML(*_arg0); end
45
+
46
+ class << self
47
+ def OrtGetApiBase(*_arg0); end
48
+ def OrtSessionOptionsAppendExecutionProvider_CoreML(*_arg0); end
49
+
50
+ # source://onnxruntime//lib/onnxruntime/ffi.rb#249
51
+ def api; end
52
+ end
53
+ end
54
+
55
+ # source://onnxruntime//lib/onnxruntime/ffi.rb#16
56
+ class OnnxRuntime::FFI::Api < ::FFI::Struct; end
57
+
58
+ # source://onnxruntime//lib/onnxruntime/ffi.rb#239
59
+ class OnnxRuntime::FFI::ApiBase < ::FFI::Struct; end
60
+
61
+ # https://github.com/microsoft/onnxruntime/blob/master/include/onnxruntime/core/session/onnxruntime_c_api.h
62
+ # keep same order
63
+ #
64
+ # source://onnxruntime//lib/onnxruntime/ffi.rb#10
65
+ OnnxRuntime::FFI::ORT_API_VERSION = T.let(T.unsafe(nil), Integer)
66
+
67
+ # source://onnxruntime//lib/onnxruntime/ffi.rb#14
68
+ OnnxRuntime::FFI::OnnxType = T.let(T.unsafe(nil), FFI::Enum)
69
+
70
+ # enums
71
+ #
72
+ # source://onnxruntime//lib/onnxruntime/ffi.rb#13
73
+ OnnxRuntime::FFI::TensorElementDataType = T.let(T.unsafe(nil), FFI::Enum)
74
+
75
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#2
76
+ class OnnxRuntime::InferenceSession
77
+ # @return [InferenceSession] a new instance of InferenceSession
78
+ #
79
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#5
80
+ def initialize(path_or_bytes, enable_cpu_mem_arena: T.unsafe(nil), enable_mem_pattern: T.unsafe(nil), enable_profiling: T.unsafe(nil), execution_mode: T.unsafe(nil), free_dimension_overrides_by_denotation: T.unsafe(nil), free_dimension_overrides_by_name: T.unsafe(nil), graph_optimization_level: T.unsafe(nil), inter_op_num_threads: T.unsafe(nil), intra_op_num_threads: T.unsafe(nil), log_severity_level: T.unsafe(nil), log_verbosity_level: T.unsafe(nil), logid: T.unsafe(nil), optimized_model_filepath: T.unsafe(nil), profile_file_prefix: T.unsafe(nil), session_config_entries: T.unsafe(nil), providers: T.unsafe(nil)); end
81
+
82
+ # return value has double underscore like Python
83
+ #
84
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#191
85
+ def end_profiling; end
86
+
87
+ # Returns the value of attribute inputs.
88
+ #
89
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#3
90
+ def inputs; end
91
+
92
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#132
93
+ def modelmeta; end
94
+
95
+ # Returns the value of attribute outputs.
96
+ #
97
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#3
98
+ def outputs; end
99
+
100
+ # no way to set providers with C API yet
101
+ # so we can return all available providers
102
+ #
103
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#203
104
+ def providers; end
105
+
106
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#91
107
+ def run(output_names, input_feed, log_severity_level: T.unsafe(nil), log_verbosity_level: T.unsafe(nil), logid: T.unsafe(nil), terminate: T.unsafe(nil), output_type: T.unsafe(nil)); end
108
+
109
+ # TODO support logid
110
+ #
111
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#104
112
+ def run_with_ort_values(output_names, input_feed, log_severity_level: T.unsafe(nil), log_verbosity_level: T.unsafe(nil), logid: T.unsafe(nil), terminate: T.unsafe(nil)); end
113
+
114
+ private
115
+
116
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#309
117
+ def allocator_free(ptr); end
118
+
119
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#305
120
+ def api; end
121
+
122
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#297
123
+ def check_status(status); end
124
+
125
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#270
126
+ def create_input_tensor(input_feed); end
127
+
128
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#288
129
+ def create_node_names(names, refs); end
130
+
131
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#333
132
+ def env; end
133
+
134
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#234
135
+ def load_inputs; end
136
+
137
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#252
138
+ def load_outputs; end
139
+
140
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#215
141
+ def load_session(path_or_bytes, session_options); end
142
+
143
+ # wide string on Windows
144
+ # char string on Linux
145
+ # see ORTCHAR_T in onnxruntime_c_api.h
146
+ #
147
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#320
148
+ def ort_string(str); end
149
+
150
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#301
151
+ def tensor_types; end
152
+
153
+ class << self
154
+ # source://onnxruntime//lib/onnxruntime/inference_session.rb#313
155
+ def api; end
156
+ end
157
+ end
158
+
159
+ # source://onnxruntime//lib/onnxruntime/model.rb#2
160
+ class OnnxRuntime::Model
161
+ # @return [Model] a new instance of Model
162
+ #
163
+ # source://onnxruntime//lib/onnxruntime/model.rb#3
164
+ def initialize(path_or_bytes, **session_options); end
165
+
166
+ # source://onnxruntime//lib/onnxruntime/model.rb#18
167
+ def inputs; end
168
+
169
+ # source://onnxruntime//lib/onnxruntime/model.rb#26
170
+ def metadata; end
171
+
172
+ # source://onnxruntime//lib/onnxruntime/model.rb#22
173
+ def outputs; end
174
+
175
+ # source://onnxruntime//lib/onnxruntime/model.rb#7
176
+ def predict(input_feed, output_names: T.unsafe(nil), **run_options); end
177
+ end
178
+
179
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#2
180
+ class OnnxRuntime::OrtValue
181
+ # @return [OrtValue] a new instance of OrtValue
182
+ #
183
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#3
184
+ def initialize(ptr, ref = T.unsafe(nil)); end
185
+
186
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#119
187
+ def data_ptr; end
188
+
189
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#86
190
+ def data_type; end
191
+
192
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#103
193
+ def device_name; end
194
+
195
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#95
196
+ def element_type; end
197
+
198
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#107
199
+ def numo; end
200
+
201
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#99
202
+ def shape; end
203
+
204
+ # @return [Boolean]
205
+ #
206
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#82
207
+ def tensor?; end
208
+
209
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#115
210
+ def to_ptr; end
211
+
212
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#111
213
+ def to_ruby; end
214
+
215
+ private
216
+
217
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#144
218
+ def create_from_onnx_value(out_ptr, output_type); end
219
+
220
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#238
221
+ def create_strings_from_onnx_value(out_ptr, output_tensor_size, result); end
222
+
223
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#255
224
+ def reshape(arr, dims); end
225
+
226
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#135
227
+ def type_and_shape_info; end
228
+
229
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#127
230
+ def value_type; end
231
+
232
+ class << self
233
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#262
234
+ def allocator_info; end
235
+
236
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#15
237
+ def from_array(input, element_type:); end
238
+
239
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#8
240
+ def from_numo(numo_obj); end
241
+
242
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#39
243
+ def from_shape_and_type(shape, element_type); end
244
+
245
+ private
246
+
247
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#52
248
+ def create_input_data(input, tensor_type); end
249
+
250
+ # source://onnxruntime//lib/onnxruntime/ort_value.rb#68
251
+ def create_input_strings(input); end
252
+ end
253
+ end
254
+
255
+ # source://onnxruntime//lib/onnxruntime/utils.rb#2
256
+ module OnnxRuntime::Utils
257
+ class << self
258
+ # source://onnxruntime//lib/onnxruntime/utils.rb#133
259
+ def allocator; end
260
+
261
+ # source://onnxruntime//lib/onnxruntime/utils.rb#16
262
+ def api; end
263
+
264
+ # source://onnxruntime//lib/onnxruntime/utils.rb#8
265
+ def check_status(status); end
266
+
267
+ # source://onnxruntime//lib/onnxruntime/utils.rb#119
268
+ def input_shape(input); end
269
+
270
+ # Returns the value of attribute mutex.
271
+ #
272
+ # source://onnxruntime//lib/onnxruntime/utils.rb#4
273
+ def mutex; end
274
+
275
+ # Sets the attribute mutex
276
+ #
277
+ # @param value the value to set the attribute mutex to.
278
+ #
279
+ # source://onnxruntime//lib/onnxruntime/utils.rb#4
280
+ def mutex=(_arg0); end
281
+
282
+ # source://onnxruntime//lib/onnxruntime/utils.rb#44
283
+ def node_info(typeinfo); end
284
+
285
+ # @return [Boolean]
286
+ #
287
+ # source://onnxruntime//lib/onnxruntime/utils.rb#99
288
+ def numo_array?(obj); end
289
+
290
+ # source://onnxruntime//lib/onnxruntime/utils.rb#103
291
+ def numo_types; end
292
+
293
+ # source://onnxruntime//lib/onnxruntime/utils.rb#24
294
+ def tensor_type_and_shape(tensor_info); end
295
+
296
+ # @raise [Error]
297
+ #
298
+ # source://onnxruntime//lib/onnxruntime/utils.rb#20
299
+ def unsupported_type(name, type); end
300
+ end
301
+ end
302
+
303
+ # source://onnxruntime//lib/onnxruntime/version.rb#2
304
+ OnnxRuntime::VERSION = T.let(T.unsafe(nil), String)