baml 0.1.5-x86_64-linux → 0.1.7-x86_64-linux

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: 65da832e871a7ef0c9b7cadbd43553b6fe11922360027b88e62b071954b53ff1
4
- data.tar.gz: 70b361609230197c0420208b87c546961674a44e7a98ac8c7aeaf92a34fbe215
3
+ metadata.gz: 8bf825cfdd2d5f4221f7053e6e86e74b6944d3bb841065a012686a78307f0f77
4
+ data.tar.gz: 64a8108a0d1e1d260f91bd44120cbd7e5b32ac7ed250f4798563cd9584c94963
5
5
  SHA512:
6
- metadata.gz: f6948320bdf33d20138d0ce5f7dd3f1e234600f2a28202198fa5a35b51e81d4241184a0bf4ec6e9e779a5257b7c6034c589f6f1e8c682101c33f209c5c3e40ac
7
- data.tar.gz: 9ae881d1309c7758ddd492b038ca6a0869cb0b348881a81c10e31a008598685ce317e0d3e1e16a354220e3f9c3ba2179fed7aba909ef49dbbc16f7f58fe23d2d
6
+ metadata.gz: 8cc73697ea4e97881f13847e322ccdadebfdc5a6677e354d044bfa15a06db2a7bd82347c73d5c4bcbabbe0840baa393073623dd0ab5aa4a18cab70c4d9fb3586
7
+ data.tar.gz: 7352eb2fabb5adadb0eff49588f8515e3edb44c7e4c73ea1702937b957e25d8d4b667ecca8f0301e6db6739e51228ac99250d7f6bf7bc71a83b7831fca5ce356
Binary file
Binary file
Binary file
Binary file
Binary file
data/lib/baml.rb CHANGED
@@ -4,3 +4,46 @@ begin
4
4
  rescue LoadError
5
5
  require_relative "baml/ruby_ffi"
6
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
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.5
4
+ version: 0.1.7
5
5
  platform: x86_64-linux
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.so
23
23
  - lib/baml/3.0/ruby_ffi.so
24
+ - lib/baml/3.1/ruby_ffi.so
25
+ - lib/baml/3.2/ruby_ffi.so
26
+ - lib/baml/3.3/ruby_ffi.so
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
  - - ">="