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 +4 -4
- data/README.md +1 -1
- data/lib/llm/tool/param.rb +10 -12
- data/lib/llm/tool.rb +9 -0
- data/lib/llm/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c26db042940fc118505804bbec91d43dd39313b6625b4e3d7df51f43f01d58ae
|
|
4
|
+
data.tar.gz: 5780f3e3d0db3579772d4f7ba141052314d34b7fd0db06ba029e4b4fd6fd84dc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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.
|
|
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
|
data/lib/llm/tool/param.rb
CHANGED
|
@@ -21,7 +21,7 @@ class LLM::Tool
|
|
|
21
21
|
##
|
|
22
22
|
# @param name [Symbol]
|
|
23
23
|
# The name of a parameter
|
|
24
|
-
# @param type [
|
|
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
|
-
|
|
40
|
-
|
|
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
|
|
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