go-openai
go-openai copied to clipboard
How to get JSON mode working for Open AI Vision
is there any support for JSON mode in vision preview? i've tried to get it working with GPT4Turbo1106
as well but it does not work. below is my example
resp, err := client.CreateChatCompletion(
context.Background(),
openai.ChatCompletionRequest{
Model: openai.GPT4Turbo1106,
MaxTokens: 1000,
Messages: []openai.ChatCompletionMessage{
{
Role: openai.ChatMessageRoleUser,
MultiContent: []openai.ChatMessagePart{
{
Type: openai.ChatMessagePartTypeText,
Text: text,
},
{
Type: openai.ChatMessagePartTypeImageURL,
ImageURL: &openai.ChatMessageImageURL{
URL: imgString2,
Detail: openai.ImageURLDetailLow,
},
},
},
},
},
Tools: []openai.Tool{t},
//ResponseFormat: &openai.ChatCompletionResponseFormat{
// Type: openai.ChatCompletionResponseFormatTypeJSONObject,
//},
},
)
has the error been fixed?
Working for me with the new GPT4o model and if I specify in the "text" that the output should be json.