go-openai icon indicating copy to clipboard operation
go-openai copied to clipboard

[BREAKING_CHANGES] fix: support ThreadMessage.Content as an array

Open adamdecaf opened this issue 1 year ago • 2 comments

Describe the change FileIDs on ThreadMessage isn't supported anymore, but Content can be an array.

Provide OpenAI documentation link https://platform.openai.com/docs/api-reference/threads/createThread

Describe your solution Remove old fields and update existing ones to support current OpenAI endpoints.

Tests I've verified this allows me to upload an image and prompt in a thread (ran under an assistant).

Here's the snippet of code that creates the thread.

	thread, err := c.underlying.CreateThread(ctx, openaiclient.ThreadRequest{
		Messages: []openaiclient.ThreadMessage{
			{
				Role: openaiclient.ThreadMessageRoleUser,
				Content: []openaiclient.ThreadMessageContent{
					{
						Type: "image_file",
						ImageFile: &openaiclient.ThreadMessageImageFile{
							FileID: file.ID,
						},
					},
					{
						Type: "text",
						Text: &prompt,
					},
				},
			},
		},
	})

Fixes: https://github.com/sashabaranov/go-openai/issues/773

adamdecaf avatar Aug 08 '24 02:08 adamdecaf