llm.rb 4.5.0 → 4.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8252114d7ab58f00fd2d14389e932cfa9b2f0a71d96d9ea2c261f1f8b67d721
4
- data.tar.gz: 8c00745ba750d0e271d8a4e5d5d9418a13556847c181e912aa8a8a1e7a9344b5
3
+ metadata.gz: c26db042940fc118505804bbec91d43dd39313b6625b4e3d7df51f43f01d58ae
4
+ data.tar.gz: 5780f3e3d0db3579772d4f7ba141052314d34b7fd0db06ba029e4b4fd6fd84dc
5
5
  SHA512:
6
- metadata.gz: 9b45173644a3803db844c1cad679a14ec647e058bd4517ce0160b7f2f352480877375748a4abb727007d3c76e7b977a6c106a5bfa438575f69ef8cd60a5612d2
7
- data.tar.gz: bebdb107819b1410bc6644529ad0f56544deadbae9661ab8ed2c84a420c74097b357113650de7ed7da1d0b388c601a9b7e60e30d887b62d72e7cfb84f3f0dd1a
6
+ metadata.gz: 864ba517e81d8fb4d248d754c5a9fc4bdcbf162f9ac4fb7691a54c015006ed40035300fd19c2057f755678676534a568204b0e0bc29b8e058cf2334b8625465e
7
+ data.tar.gz: cd8b18c4e780a26c83201ea39f81077ad2535db966efcb5fe860f4af55808f96a8bd8a6bdd4c25f38a9012b3092eb2611bbfd31552969b00b15579af5e95354a
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  <p align="center">
5
5
  <a href="https://0x1eef.github.io/x/llm.rb?rebuild=1"><img src="https://img.shields.io/badge/docs-0x1eef.github.io-blue.svg" alt="RubyDoc"></a>
6
6
  <a href="https://opensource.org/license/0bsd"><img src="https://img.shields.io/badge/License-0BSD-orange.svg?" alt="License"></a>
7
- <a href="https://github.com/llmrb/llm.rb/tags"><img src="https://img.shields.io/badge/version-4.5.0-green.svg?" alt="Version"></a>
7
+ <a href="https://github.com/llmrb/llm.rb/tags"><img src="https://img.shields.io/badge/version-4.6.0-green.svg?" alt="Version"></a>
8
8
  </p>
9
9
 
10
10
  ## About
@@ -21,7 +21,7 @@ class LLM::Tool
21
21
  ##
22
22
  # @param name [Symbol]
23
23
  # The name of a parameter
24
- # @param type [Class, Symbol]
24
+ # @param type [LLM::Schema::Leaf, Class]
25
25
  # The parameter type (eg String)
26
26
  # @param description [String]
27
27
  # The description of a property
@@ -36,9 +36,8 @@ class LLM::Tool
36
36
  def param(name, type, description, options = {})
37
37
  lock do
38
38
  function.params do |schema|
39
- leaf = schema.public_send(Utils.resolve(type))
40
- leaf = Utils.setup(leaf, description, options)
41
- schema.object(name => leaf)
39
+ resolved = Utils.resolve(schema, type)
40
+ schema.object(name => Utils.setup(resolved, description, options))
42
41
  end
43
42
  end
44
43
  end
@@ -48,15 +47,14 @@ class LLM::Tool
48
47
  module Utils
49
48
  extend self
50
49
 
51
- def resolve(type)
52
- if type == String
53
- :string
54
- elsif type == Integer
55
- :integer
56
- elsif type == Float
57
- :number
58
- else
50
+ def resolve(schema, type)
51
+ if LLM::Schema::Leaf === type
59
52
  type
53
+ elsif Class === type && type.respond_to?(:object)
54
+ type.object
55
+ else
56
+ target = type.name.split("::").last.downcase
57
+ schema.public_send(target)
60
58
  end
61
59
  end
62
60
 
data/lib/llm/tool.rb CHANGED
@@ -21,6 +21,15 @@ class LLM::Tool
21
21
  require_relative "tool/param"
22
22
  extend LLM::Tool::Param
23
23
 
24
+ types = [
25
+ :Leaf, :String, :Array,
26
+ :Object, :Integer, :Number,
27
+ :Boolean, :Null
28
+ ]
29
+ types.each do |constant|
30
+ const_set constant, LLM::Schema.const_get(constant)
31
+ end
32
+
24
33
  ##
25
34
  # Registers the tool as a function when inherited
26
35
  # @param [Class] klass The subclass
data/lib/llm/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LLM
4
- VERSION = "4.5.0"
4
+ VERSION = "4.6.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llm.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.0
4
+ version: 4.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antar Azri