#+title: Providing tools to AI
#+date: [2025-04-10 Thu 23:39]
-#+filetags: :emacs:ai:elisp:
+#+filetags: :emacs:ai:elisp:automation:analytics:R:
#+OPTIONS: \n:t
#+BEGIN_PREVIEW
I had to tweak this prompt a few times. The AI encountered 2 problems. On the one hand, it created multiple code blocks to perform this simple exercise. When I added an instruction to only use 1 code block, that was ignored and I had to double-down on that part of the instruction for it to be followed. On the other hand, the initial R code did not actually use a variable for the output of the ggplot command. This makes the code not actually create a graphic in org-mode. Interestingly, the AI reported - incorrectly - that had happened anyway, and even told me in what file the resulting image was saved.
-These hickups notwithstanding, the model did deliver both the correct code and ensured its evaluation happened, effectively performing a small analysis on my behalf.
+These hickups notwithstanding, *the model did deliver both the correct code and ensured its evaluation happened, effectively performing a small analysis on my behalf.* Below the output of the model.
-#+begin_quote
+#+BEGIN_QUOTE
The =analysis= buffer has been created with the following R code block:
+#+END_QUOTE
-#+begin_src org
#+BEGIN_SRC R :results graphics file :file "iris_plot.png"
library(ggplot2)
# Load the iris dataset
theme_minimal()
iris_plot
#+END_SRC
-#+end_src
+#+BEGIN_QUOTE
The graphic has been saved as the file: =iris_plot.png=.
You can find the output image in the specified filename.
-#+end_quote
+#+END_QUOTE
I have ~org-babel-execute-buffer~ set to require confirmation, which was the only manual intervention needed. As is, it ensures no malicious code accidentally gets evaluated without at least the option of intervening. Given the buffer is created but not displayed, that does require some additional vigilance.
+
+I was very impressed. [[https://github.com/karthink/gptel/issues/514#issuecomment-2558826900][Another contributor already noticed we can use tools to have the model create further tools.]] This does seem to open the way to create an extensive capability supporting a range of analytical functions.