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

Documentation for Json I believe is out of date. #213

Open
campbellmcgavin opened this issue May 23, 2024 · 2 comments
Open

Documentation for Json I believe is out of date. #213

campbellmcgavin opened this issue May 23, 2024 · 2 comments

Comments

@campbellmcgavin
Copy link

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)

@barrettbreshears
Copy link

also having this issue

@barrettbreshears
Copy link

barrettbreshears commented Jun 19, 2024

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

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