Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with "tools" parameter #41

Closed
aamedina opened this issue Nov 17, 2023 · 1 comment
Closed

Issue with "tools" parameter #41

aamedina opened this issue Nov 17, 2023 · 1 comment

Comments

@aamedina
Copy link

I think this may be related to or similarly dealt with: #37

The parameters for tools should be "Any", to workaround the same issue, I think?

Thanks for your work on this library.

To reproduce provide a function using the tools parameter. Here's the same example modified from the issue to use tools:

(create-chat-completion {:model       "gpt-3.5-turbo"
                         :messages    [{:role    "user"
                                        :content "Wikipedia page about foxes"}]
                         :tools
                         [{:type     "function"
                           :function {: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"]}}}}}]
                         :tool_choice "auto"})

Which throws an exception:
"Execution error (ExceptionInfo) at schema-tools.coerce/coerce-or-error! (coerce.cljc:24).
Could not coerce value to schema: {:body {:tools [{:function {:parameters {:type disallowed-key, :properties disallowed-key}}}]}}"

{:type :schema-tools.coerce/error,
    :schema
    {:body
     {{:k :function_call} Any,
      {:k :stop} Any,
      {:k :n} (maybe (default Int 1)),
      {:k :presence_penalty} (maybe (default Num 0)),
      {:k :seed} (maybe Int),
      {:k :stream} (maybe (default Bool false)),
      {:k :temperature} (maybe (default Num 1)),
      {:k :functions}
      [{{:k :description} java.lang.String,
        :name java.lang.String,
        :parameters Any}],
      {:k :max_tokens} (maybe (default Int 16384)),
      {:k :response_format}
      {{:k :type} (default (enum "json_object" "text") "text")},
      :messages [Any],
      {:k :tools}
      [{:type (enum "function"),
        :function
        {{:k :description} java.lang.String,
         :name java.lang.String,
         :parameters {}}}],
      {:k :tool_choice} Any,
      {:k :frequency_penalty} (maybe (default Num 0)),
      {:k :logit_bias} (maybe {}),
      {:k :top_p} (maybe (default Num 1)),
      {:k :user} java.lang.String,
      :model Any}},
    :value
    {:body
     {:model "gpt-3.5-turbo",
      :messages [{:role "user", :content "Wikipedia page about foxes"}],
      :tools
      [{:type "function",
        :function
        {:name "get_current_weather",
         :description "Get the current weather in a given location",
         :parameters
         {:type "object",
          :properties {:location {#, #}, :unit {#, #}}}}}],
      :tool_choice "auto",
      :wkok.openai-clojure.core/options nil}},
    :error
    {:body
     {:tools
      [{:function
        {:parameters
         {:type disallowed-key, :properties disallowed-key}}}]}}}
wkok added a commit that referenced this issue Nov 19, 2023
@wkok
Copy link
Owner

wkok commented Nov 19, 2023

Thanks for reporting, fixed accordingly

395de03

@wkok wkok closed this as completed Nov 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants