baml 0.1.7-arm64-darwin → 0.1.8-arm64-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 +4 -4
- data/exe/baml-cli +4 -0
- data/lib/baml/2.7/ruby_ffi.bundle +0 -0
- data/lib/baml/3.0/ruby_ffi.bundle +0 -0
- data/lib/baml/3.1/ruby_ffi.bundle +0 -0
- data/lib/baml/3.2/ruby_ffi.bundle +0 -0
- data/lib/baml/3.3/ruby_ffi.bundle +0 -0
- data/lib/baml.rb +4 -0
- data/lib/stream.rb +73 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2d01cbd5ca6800a21ac72bb3f708ffb5b20ef86bd6e9102a5c9dcbf60874604
|
4
|
+
data.tar.gz: 2acb1f122149e41a10d95146c834ab34d264bb56a2028b8d50f8c7367b45bd0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a15a9e541d2d4de73737c72cc9ff443d8b07fee096dccf911337a547c2ce09b0b9658dc48893be76fff65ec1acfbd7ecc3d9a3698947f8b58b76c852a2722704
|
7
|
+
data.tar.gz: 67124711ac2be51312555d2593e9bcd87e48b1bb8dba1b6316c7e644bb7a82f51e85648b7bce9791b2e4eaac941989b8542717bca6986fa0e69a52948553e7f6
|
data/exe/baml-cli
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/baml.rb
CHANGED
@@ -4,8 +4,12 @@ begin
|
|
4
4
|
rescue LoadError
|
5
5
|
require_relative "baml/ruby_ffi"
|
6
6
|
end
|
7
|
+
require_relative "stream"
|
7
8
|
|
8
9
|
module Baml
|
10
|
+
# TODO: implement image support
|
11
|
+
class Image; end
|
12
|
+
|
9
13
|
# Dynamically + idempotently define Baml::TypeConverter
|
10
14
|
# NB: this does not respect raise_coercion_error = false
|
11
15
|
def self.convert_to(type)
|
data/lib/stream.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require "sorbet-runtime"
|
2
|
+
|
3
|
+
module Baml
|
4
|
+
# class BamlStream
|
5
|
+
# include Enumerable
|
6
|
+
|
7
|
+
# def initialize(raw_stream:)
|
8
|
+
# @raw_stream = raw_stream
|
9
|
+
# end
|
10
|
+
|
11
|
+
# def each(&block)
|
12
|
+
# @raw_stream.each do |raw_msg|
|
13
|
+
# yield Message.from(raw_msg)
|
14
|
+
# end
|
15
|
+
# end
|
16
|
+
# end
|
17
|
+
|
18
|
+
class BamlStream
|
19
|
+
extend T::Sig
|
20
|
+
extend T::Generic
|
21
|
+
|
22
|
+
include Enumerable
|
23
|
+
|
24
|
+
PartialType = type_member
|
25
|
+
FinalType = type_member
|
26
|
+
|
27
|
+
def initialize(
|
28
|
+
ffi_stream:,
|
29
|
+
partial_coerce:,
|
30
|
+
final_coerce:,
|
31
|
+
ctx_manager:
|
32
|
+
)
|
33
|
+
@ffi_stream = ffi_stream
|
34
|
+
@partial_coerce = partial_coerce
|
35
|
+
@final_coerce = final_coerce
|
36
|
+
@ctx_manager = ctx_manager
|
37
|
+
|
38
|
+
@final_response = nil
|
39
|
+
end
|
40
|
+
|
41
|
+
# Calls the given block once for each event in the stream, where event is a parsed
|
42
|
+
# partial response. Returns `self` to enable chaining `.get_final_response`.
|
43
|
+
#
|
44
|
+
# Must be called with a block.
|
45
|
+
#
|
46
|
+
# @yieldparam [PartialType] event the parsed partial response
|
47
|
+
# @return [BamlStream] self
|
48
|
+
def each(&block)
|
49
|
+
# Implementing this and include-ing Enumerable allows users to treat this as a Ruby
|
50
|
+
# collection: https://ruby-doc.org/3.1.6/Enumerable.html#module-Enumerable-label-Usage
|
51
|
+
if @final_response == nil
|
52
|
+
@final_response = @ffi_stream.done(@ctx_manager) do |event|
|
53
|
+
block.call @partial_coerce.new.from(event.parsed_using_types(Baml::PartialTypes))
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
self
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
# Gets the final response from the stream.
|
62
|
+
#
|
63
|
+
# @return [FinalType] the parsed final response
|
64
|
+
sig {returns(FinalType)}
|
65
|
+
def get_final_response
|
66
|
+
if @final_response == nil
|
67
|
+
@final_response = @ffi_stream.done(@ctx_manager)
|
68
|
+
end
|
69
|
+
|
70
|
+
@final_coerce.new.from(@final_response.parsed_using_types(Baml::Types))
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: arm64-darwin
|
6
6
|
authors:
|
7
7
|
- BoundaryML
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-07 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.
|
15
15
|
email:
|
16
16
|
- contact@boundaryml.com
|
17
|
-
executables:
|
17
|
+
executables:
|
18
|
+
- baml-cli
|
18
19
|
extensions: []
|
19
20
|
extra_rdoc_files: []
|
20
21
|
files:
|
22
|
+
- exe/baml-cli
|
21
23
|
- lib/baml.rb
|
22
24
|
- lib/baml/2.7/ruby_ffi.bundle
|
23
25
|
- lib/baml/3.0/ruby_ffi.bundle
|
24
26
|
- lib/baml/3.1/ruby_ffi.bundle
|
25
27
|
- lib/baml/3.2/ruby_ffi.bundle
|
26
28
|
- lib/baml/3.3/ruby_ffi.bundle
|
29
|
+
- lib/stream.rb
|
27
30
|
homepage: https://github.com/BoundaryML/baml
|
28
31
|
licenses:
|
29
32
|
- MIT
|