wkok / openai-clojure

Clojure functions to drive the OpenAI API
https://cljdoc.org/d/net.clojars.wkok/openai-clojure
MIT License
208 stars 28 forks source link

Is it possible to use the "functions" feature? #27

Closed jave closed 1 year ago

jave commented 1 year ago

I tried the following, but it didnt seem to work, its adapted from https://platform.openai.com/docs/guides/gpt/function-calling

(api/create-chat-completion {:model "gpt-3.5-turbo-0613" :messages [ {:role "user" :content "Whats the weather like in Boston?"}] :functions [ { :name "get_current_weather" :description "Get the current weather in a given location" :parameters { :type "object", :properties { :location { :type "string", :description "The city and state, e.g. San Francisco, CA" } :unit {:type "string" :enum ["celsius", "fahrenheit"]} } :required ["location"] } }] :function-call "auto" } {:api-key KEY})

jave commented 1 year ago

... or maybe it actually works, if I make sure the 0.7.0 version is loaded? seems cider stubbornly loaded 0.5.1 instead. I will try some more and get back

wkok commented 1 year ago

Hi there. Yes, support for functions was added in v0.7.0

jave commented 1 year ago

then this can be closed. tnx