From 395de033dda410c6374a476f2690800a864c0450 Mon Sep 17 00:00:00 2001 From: Werner Kok Date: Sun, 19 Nov 2023 11:01:43 +0000 Subject: [PATCH] Fixed issue #41 --- resources/openapi-README.md | 8 ++++++++ resources/openapi.yaml | 3 +-- test/wkok/openai_clojure/api_test.clj | 21 +++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/resources/openapi-README.md b/resources/openapi-README.md index fc52510..d06166c 100644 --- a/resources/openapi-README.md +++ b/resources/openapi-README.md @@ -8,6 +8,7 @@ Some changes are required in the hosted YAML spec to make it compatible with Mar * to: `16384` ## ChatCompletionFunctions/properties/parameters + later: (#/components/schemas/FunctionParameters) More info in this [PR](https://github.com/wkok/openai-clojure/pull/23#issuecomment-1595764611) @@ -15,6 +16,13 @@ More info in this [PR](https://github.com/wkok/openai-clojure/pull/23#issuecom * from: `ChatCompletionFunctionParameters` * to: `{}` +## FunctionObject + +More info in this [issue](https://github.com/wkok/openai-clojure/issues/41) + +* from "#/components/schemas/FunctionParameters" +* to {} + ## /threads/{thread_id}/runs/{run_id}/submit_tool_outputs Fix the typo: [PR](https://github.com/openai/openai-openapi/pull/114) diff --git a/resources/openapi.yaml b/resources/openapi.yaml index 1436991..aa754ef 100644 --- a/resources/openapi.yaml +++ b/resources/openapi.yaml @@ -5783,8 +5783,7 @@ components: name: type: string description: The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - parameters: - $ref: "#/components/schemas/FunctionParameters" + parameters: {} required: - name - parameters diff --git a/test/wkok/openai_clojure/api_test.clj b/test/wkok/openai_clojure/api_test.clj index 9a4bc86..61faa96 100644 --- a/test/wkok/openai_clojure/api_test.clj +++ b/test/wkok/openai_clojure/api_test.clj @@ -320,6 +320,27 @@ (is (= :success (api/create-thread-and-run {:assistant_id "----id----"})))))) +(deftest create-chat-completion-tools + + (with-stubbed-martians + + #(testing "Spec override for tools parameter. See https://github.com/wkok/openai-clojure/issues/41" + + (is (= :success + (api/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"})))))) (deftest stream-test