branch: externals/llm
commit 53337bed5af169bec7e8b469a131185da961606a
Author: Andrew Hyatt <ahy...@gmail.com>
Commit: GitHub <nore...@github.com>

    Fix README example of tool use (#156)
    
    This fixes https://github.com/ahyatt/llm/issues/155
---
 README.org | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/README.org b/README.org
index 0c42bcb703..4a3014fd15 100644
--- a/README.org
+++ b/README.org
@@ -213,21 +213,27 @@ This basic structure is useful because it can guarantee a 
well-structured output
 The way to call functions is to attach a list of functions to the =tools= slot 
in the prompt. This is a list of =llm-tool= structs, which is a tool that is an 
elisp function, with a name, a description, and a list of arguments. The 
docstrings give an explanation of the format.  An example is:
 
 #+begin_src emacs-lisp
-(llm-chat-async my-llm-provider (llm-make-chat-prompt
-   "What is the capital of France?"
-   :tools
-   (list (llm-make-tool
-          :function (lambda (callback result)
-                      ;; In this example function the assumption is that the
-                      ;; callback will be called after processing the result is
-                      ;; complete.
-                      (notify-user-of-capital result callback))
-          :name "capital_of_country"
-          :description "Get the capital of a country."
-          :args '((:name "country"
-                   :description "The country whose capital to look up."
-                   :type string))
-          :async t))))
+(llm-chat-async
+ my-llm-provider
+ (llm-make-chat-prompt
+  "What is the capital of France?"
+  :tools
+  (list (llm-make-tool
+         :function
+         (lambda (callback result)
+           ;; In this example function the assumption is that the
+           ;; callback will be called after processing the result is
+           ;; complete.
+           (notify-user-of-capital result callback))
+         :name "capital_of_country"
+         :description "Get the capital of a country."
+         :args '((:name "country"
+                        :description "The country whose capital to look up."
+                        :type string))
+         :async t)))
+ #'identity  ;; No need to process the result in this example.
+ (lambda (_ err)
+   (error "Error on getting capital: %s" err)))
 #+end_src
 
 Note that tools have the same arguments and structure as the tool definitions 
in [[https://github.com/karthink/gptel][GTPel]].

Reply via email to