baml 0.1.4-x86_64-darwin → 0.1.7-x86_64-darwin

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bdede7b3e8989ec52efc410b675a9c923c64931599292bc0be27953a4bafa5c2
4
- data.tar.gz: 4f70505ce12f20c1f5f369d602478e3c2f576aba90cc90b77637d8558480e688
3
+ metadata.gz: b4b6736efb17b9b2d160741f59f744dedb13d384d3ce0eca5eca5fd4604c2eed
4
+ data.tar.gz: ae910798753a6d0d8dfd8a5da271cbbdcf80faed76e0d72e6873aa29c1710245
5
5
  SHA512:
6
- metadata.gz: 292e7ef119de950451ce3d6ade741d10081a49673513728745fb2b84fc18e30b2f751244364003d086e1a5b8aa4539dc3dd2da8b8f14d990a157ab20c31ff114
7
- data.tar.gz: 89a8d908ae0a932eb094ea7df36ff0d396f23a3e6ecc1a07a49996f2e22349825713e60d04b4b99f828f78c394ce06e6e65e7f8f8506e3348c052c886a2e5f1d
6
+ metadata.gz: c5ae17b01a4203e7b47e914d12dd7f8e2377efb7ad25a00dd1da216d506a61a39affc565138ff5c83137ef3b65f6037cf6df68dc6390f582c81971eb3fdf1423
7
+ data.tar.gz: af75aa3015624134b0d8d29d861249df869ecf58248c43d93ddc1a5e2fac86dac200805b60baf986b0ae38c4f09e1f2184043f25fd9198008613710badd62ca6
Binary file
Binary file
Binary file
Binary file
Binary file
data/lib/baml.rb CHANGED
@@ -1,6 +1,49 @@
1
1
  begin
2
2
  ruby_version = /(\d+\.\d+)/.match(RUBY_VERSION)
3
- require_relative "#{ruby_version}/baml/ruby_ffi"
3
+ require_relative "baml/#{ruby_version}/ruby_ffi"
4
4
  rescue LoadError
5
5
  require_relative "baml/ruby_ffi"
6
+ end
7
+
8
+ module Baml
9
+ # Dynamically + idempotently define Baml::TypeConverter
10
+ # NB: this does not respect raise_coercion_error = false
11
+ def self.convert_to(type)
12
+ if !Baml.const_defined?(:TypeConverter)
13
+ Baml.const_set(:TypeConverter, Class.new(TypeCoerce::Converter) do
14
+ def initialize(type)
15
+ super(type)
16
+ end
17
+
18
+ def _convert(value, type, raise_coercion_error, coerce_empty_to_nil)
19
+ # make string handling more strict
20
+ if type == String
21
+ if value.is_a?(String)
22
+ return value
23
+ end
24
+
25
+ raise TypeCoerce::CoercionError.new(value, type)
26
+ end
27
+
28
+ # add unions
29
+ if type.is_a?(T::Types::Union)
30
+ type.types.each do |t|
31
+ # require raise_coercion_error on the recursive union call,
32
+ # so that we can suppress the error if it fails
33
+ converted = _convert(value, t, true, coerce_empty_to_nil)
34
+ return converted
35
+ rescue
36
+ # do nothing - try every instance of the union
37
+ end
38
+
39
+ raise TypeCoerce::CoercionError.new(value, type)
40
+ end
41
+
42
+ super(value, type, raise_coercion_error, coerce_empty_to_nil)
43
+ end
44
+ end)
45
+ end
46
+
47
+ Baml.const_get(:TypeConverter).new(type)
48
+ end
6
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.7
5
5
  platform: x86_64-darwin
6
6
  authors:
7
7
  - BoundaryML
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-29 00:00:00.000000000 Z
11
+ date: 2024-04-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A gem for users to interact with BoundaryML's Language Model clients
14
14
  (LLM) in Ruby.
@@ -21,6 +21,9 @@ files:
21
21
  - lib/baml.rb
22
22
  - lib/baml/2.7/ruby_ffi.bundle
23
23
  - lib/baml/3.0/ruby_ffi.bundle
24
+ - lib/baml/3.1/ruby_ffi.bundle
25
+ - lib/baml/3.2/ruby_ffi.bundle
26
+ - lib/baml/3.3/ruby_ffi.bundle
24
27
  homepage: https://github.com/BoundaryML/baml
25
28
  licenses:
26
29
  - MIT
@@ -36,7 +39,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
36
39
  version: '2.7'
37
40
  - - "<"
38
41
  - !ruby/object:Gem::Version
39
- version: 3.1.dev
42
+ version: 3.4.dev
40
43
  required_rubygems_version: !ruby/object:Gem::Requirement
41
44
  requirements:
42
45
  - - ">="