Skip to content

Commit 654caf4

Browse files
authored
feat(assistants): add attachments.fileId field to MessageRequest (#367)
1 parent ec5dfee commit 654caf4

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.aallam.openai.api.message
2+
3+
import com.aallam.openai.api.file.FileId
4+
import kotlinx.serialization.SerialName
5+
import kotlinx.serialization.Serializable
6+
7+
/**
8+
* References an Attachment in the message request.
9+
*/
10+
@Serializable
11+
public data class Attachment(
12+
/**
13+
* The ID of the file to attach to the message.
14+
*/
15+
@SerialName("file_id") val fileId: FileId
16+
)

openai-core/src/commonMain/kotlin/com.aallam.openai.api/message/MessageRequest.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.aallam.openai.api.message
22

33
import com.aallam.openai.api.BetaOpenAI
44
import com.aallam.openai.api.core.Role
5-
import com.aallam.openai.api.file.FileId
65
import kotlinx.serialization.SerialName
76
import kotlinx.serialization.Serializable
87

@@ -22,6 +21,11 @@ public class MessageRequest(
2221
*/
2322
@SerialName("content") public val content: String,
2423

24+
/**
25+
* A list of files attached to the message.
26+
*/
27+
@SerialName("attachments") public val attachments: List<Attachment>? = null,
28+
2529
/**
2630
* Set of 16 key-value pairs that can be attached to an object.
2731
* This can be useful for storing additional information about the object in a structured format.
@@ -52,6 +56,11 @@ public class MessageRequestBuilder {
5256
*/
5357
public var content: String? = null
5458

59+
/**
60+
* A list of files attached to the message.
61+
*/
62+
public var attachments: List<Attachment>? = null
63+
5564
/**
5665
* Set of 16 key-value pairs that can be attached to an object.
5766
* This can be useful for storing additional information about the object in a structured format.
@@ -62,6 +71,7 @@ public class MessageRequestBuilder {
6271
public fun build(): MessageRequest = MessageRequest(
6372
role = requireNotNull(role) { "role is required" },
6473
content = requireNotNull(content) { "content is required" },
74+
attachments = attachments,
6575
metadata = metadata
6676
)
6777
}

0 commit comments

Comments
 (0)