@@ -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.
5555DESCRIPTION is the tool's documentation string.
56+
5657SPECS 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)
5960will be used by default.
6061
6162SPECS 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
6768ARGS 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
74114BODY contains the function body.
75115
0 commit comments