Skip to content

Commit cf39aeb

Browse files
committed
Expand documentation concerning tool specs
* llm-tool-collection.el (llm-tool-collection-deftool): Expand docs. Clarify that optional arguments are specified via the &optional keyword, rather than with `:optional t'. Add link to the tool spec.
1 parent 3858b89 commit cf39aeb

File tree

1 file changed

+48
-8
lines changed

1 file changed

+48
-8
lines changed

llm-tool-collection.el

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,63 @@ Each function is called with one argument, the tool's plist definition.")
5353
(defmacro llm-tool-collection-deftool (name description specs args &rest body)
5454
"Declare a generic LLM tool named NAME.
5555
DESCRIPTION is the tool's documentation string.
56+
5657
SPECS should be a plist specifying the standard attributes of an LLM
57-
tool. The `:name' attribute should be set to an LLM-friendly name. If
58-
it is not set, the NAME argument (with dashes replaced with underscores)
58+
tool. The :name attribute should be set to an LLM-friendly name. If it
59+
is not set, the NAME argument (with dashes replaced with underscores)
5960
will be used by default.
6061
6162
SPECS may also contain extra keywords used by certain clients, such as
62-
`:include' and `:confirm' for gptel. Conformant clients should ignore
63-
all unsupported keywords. Tool definitions should contain a `:category'
64-
value and a list of symbols for `:tags' to make it convenient for users
65-
to select tools.
63+
:include and :confirm for gptel. Conformant clients should ignore all
64+
unsupported keywords. Tool definitions should contain a :category value
65+
and a list of symbols for :tags to make it convenient for users to
66+
select tools.
6667
6768
ARGS is a list where each element is of the form
6869
6970
(ARGNAME \"DESCRIPTION\" :type TYPE [...]).
7071
71-
Arguments after the special symbol `&optional' are marked with
72-
`:optional t`.
72+
Arguments after the special symbol `&optional' are marked as optional.
73+
TYPE and further properties [...] can include:
74+
75+
- :type. Required. One of the symbols string, number, integer,
76+
boolean, array, object, or null.
77+
78+
- :enum. For enumerated types, a vector of strings representing allowed
79+
values. Note that :type is still required even with enums.
80+
81+
- :items. Required if :type is array. Must be a plist including at
82+
least the item's :type.
83+
84+
- :properties. Required if :type is object. Must be a plist that can
85+
be serialized into a JSON object specification via `json-serialize',
86+
with the exception that :type specifications in this plist must be
87+
symbols.
88+
89+
- :required. For object types, a vector of strings listing required
90+
object keys.
91+
92+
For example, a weather tool might have ARGS defined as:
93+
94+
((location \"The city and state, e.g. San Francisco, CA\" :type string)
95+
&optional
96+
(unit \"The unit of temperature, either 'celsius' or 'fahrenheit'\"
97+
:type string
98+
:enum [\"celsius\" \"fahrenheit\"]))
99+
100+
This would translate to a tool specification, in the sense described at
101+
URL
102+
`https://github.com/ahyatt/llm/discussions/124#discussioncomment-11877109',
103+
with args:
104+
105+
((:name \"location\"
106+
:type string
107+
:description \"The city and state, e.g. San Francisco, CA\")
108+
(:name \"unit\"
109+
:type string
110+
:enum [\"celsius\" \"fahrenheit\"]
111+
:description \"The unit of temperature, either 'celsius' or 'fahrenheit'\"
112+
:optional t))
73113
74114
BODY contains the function body.
75115

0 commit comments

Comments
 (0)