You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(let ((completer (make-instance 'ollama-completer :model "mistral:latest")))
(get-completion completer "It's a beautiful day for " 100))
To use the OpenAI API:
(let ((completer (make-instance 'openai-completer :api-key (uiop:getenv "OPENAI_API_KEY"))))
(get-completion completer "It's a beautiful day for " 100))
To use the Anthropic API:
(let ((completer (make-instance 'anthropic-completer :api-key (uiop:getenv "ANTHROPIC_API_KEY"))))
(get-completion completer "It's a beautiful day for " 100))
In addition, the OpenAI completer supports callback functions, like so:
(defun-tool time-of-day ()
"Useful if you want to know what time it is."
(let ((decoded-time (multiple-value-list (get-decoded-time))))
(format nil "Current time: ~2,'0D:~2,'0D:~2,'0D~%"
(third decoded-time)
(second decoded-time)
(first decoded-time))))
(defun-tool get-temperature ((location string "Where to get the temperature for."))
"Get the temperature for a specific location"
(cond
((equal location "Toronto")
"cold")
(t "warm")))
(let ((c (make-instance 'openai-completer
:api-key (uiop:getenv "OPENAI_API_KEY")
:tools '(time-of-day get-temperature))))
(get-completion c "I'm in Toronto. What's the time and temperature here?" 20))
This code generates output like:
The current time in Toronto is 20:01:22 and it's cold there right now
The default read timeout for a response from the completer is 120
seconds. You can modify this by setting completions:*read-timeout*
to a new value.