You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
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 905e317
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)
The text was updated successfully, but these errors were encountered: