Open campbellmcgavin opened 6 months ago
also having this issue
if you take a look at line 152 the change here are drastic and cause breaking changes to anyone that implemented what their docs suggested as a solution for functions https://github.com/MacPaw/OpenAI/commit/905e31706d7ae6c9c3a851e6bf40bd36f41a87fb
Describe the bug I copied the block of code you had in the README.txt to set up functions, I pasted it into a swift file where I had "import OpenAI" and many of the constructs that the code relied upon failed to find references in the openai library.
Specifically, the "ChatFunctionDeclartion" and the JSNOSchema do not exist in the library.
let openAI = OpenAI(apiToken: "...") // Declare functions which GPT-3 might decide to call. let functions = [ ChatFunctionDeclaration( name: "get_current_weather", description: "Get the current weather in a given location", parameters: JSONSchema( type: .object, properties: [ "location": .init(type: .string, description: "The city and state, e.g. San Francisco, CA"), "unit": .init(type: .string, enumValues: ["celsius", "fahrenheit"]) ], required: ["location"] ) ) ] let query = ChatQuery( model: "gpt-3.5-turbo-0613", // 0613 is the earliest version with function calls support. messages: [ Chat(role: .user, content: "What's the weather like in Boston?") ], functions: functions ) let result = try await openAI.chats(query: query)