From 99194b32f14df7ea86b288f15eadf172e639fe5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edin=20=C4=86orali=C4=87?= Date: Mon, 15 Jul 2024 20:46:04 +0200 Subject: [PATCH 1/2] fix: Updated ThreadMessage struct with latest fields based on OpenAI docs --- thread.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/thread.go b/thread.go index 6f752145..88776f1c 100644 --- a/thread.go +++ b/thread.go @@ -83,14 +83,24 @@ type ModifyThreadRequest struct { type ThreadMessageRole string const ( - ThreadMessageRoleUser ThreadMessageRole = "user" + ThreadMessageRoleAssistant ThreadMessageRole = "assistant" + ThreadMessageRoleUser ThreadMessageRole = "user" ) type ThreadMessage struct { - Role ThreadMessageRole `json:"role"` - Content string `json:"content"` - FileIDs []string `json:"file_ids,omitempty"` - Metadata map[string]any `json:"metadata,omitempty"` + Role ThreadMessageRole `json:"role"` + Content string `json:"content"` + Attachments []ThreadAttachment `json:"attachments,omitempty"` + Metadata map[string]any `json:"metadata,omitempty"` +} + +type ThreadAttachment struct { + FileID string `json:"file_id"` + Tools []ThreadAttachmentTool `json:"tools"` +} + +type ThreadAttachmentTool struct { + Type string `json:"type"` } type ThreadDeleteResponse struct { From 460bd138b54cea7b1805b1b658410e0f7c7d1a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edin=20=C4=86orali=C4=87?= Date: Tue, 16 Jul 2024 15:48:47 +0200 Subject: [PATCH 2/2] fix: Reverted FileIDs for backward compatibility of v1 --- thread.go | 1 + 1 file changed, 1 insertion(+) diff --git a/thread.go b/thread.go index 88776f1c..bc08e2bc 100644 --- a/thread.go +++ b/thread.go @@ -90,6 +90,7 @@ const ( type ThreadMessage struct { Role ThreadMessageRole `json:"role"` Content string `json:"content"` + FileIDs []string `json:"file_ids,omitempty"` Attachments []ThreadAttachment `json:"attachments,omitempty"` Metadata map[string]any `json:"metadata,omitempty"` }