SwiftOpenAI
SwiftOpenAI copied to clipboard
Responses API
When trying to convert to using the new Responses API, whilst the input does accept an array of items, it is not possible afaict to pass an array of items that include user/assistant messages.
I've since refactored the code I had back to ChatCompletions, but it was using InputItems and the error was:
OpenAI chat error: responseUnsuccessful(description: "status code 400 Invalid value: \'input_text\'. Supported values are: \'output_text\' and \'refusal\'.", statusCode: 400)
I also printed out the input array it was sending:
[
SwiftOpenAI.InputItem(role: "user", content: [SwiftOpenAI.ContentItem.text(SwiftOpenAI.TextContent(text: "just wanted to test this works. tell me 3 dad jokes.", type: "input_text"))]),
SwiftOpenAI.InputItem(role: "assistant", content: [SwiftOpenAI.ContentItem.text(SwiftOpenAI.TextContent(text: "Sure thing! Here are three dad jokes for you:\n\n1. Why don\'t skeletons fight each other? \n They don\'t have the guts!\n\n2. What do you call cheese that isn\'t yours? \n Nacho cheese!\n\n3. Why did the scarecrow win an award? \n Because he was outstanding in his field!", type: "input_text"))]),
SwiftOpenAI.InputItem(role: "user", content: [SwiftOpenAI.ContentItem.text(SwiftOpenAI.TextContent(text: "ok, this is promising. I mean, not funny, but its good to see u can chat.", type: "input_text"))])
]
It might be the way I am working, but I feel like its more related to the library not setting the content type correctly for non-user messages.