Closed zmedelis closed 1 year ago
OpenAI hasn't defined the spec for FunctionParameters fully:
FunctionParameters:
type: object
description: "The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/gpt/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.\n\nTo describe a function that accepts no parameters, provide the value `{\"type\": \"object\", \"properties\": {}}`."
and because of this, if we keep the $ref: "#/components/schemas/FunctionParameters"
then the spec validation fails when sending a request like this one
(create-chat-completion {:model "gpt-3.5-turbo-0613"
:messages [{:role "user"
:content "Wikipedia page about foxes"}]
: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"]}}}}]})
error:
error: clojure.lang.ExceptionInfo: Interceptor Exception: Could not coerce value to schema: {:body {:functions [{:parameters {:type disallowed-key, :properties disallowed-key}}]}}
So unforunately we still need to override the spec to parameters: {}
I'm updating to the latest spec anyway as there's a few other small changes. Will make a release containing that soon
Released https://github.com/wkok/openai-clojure/releases/tag/0.12.3 with latest spec (for the other updates)
There was an update on OAI
openapi.yaml
with the notable change specifying FunctionParametersopenai-clojure
versionOAI
latest version