11package com.aallam.openai.api.message
22
3+ import com.aallam.openai.api.BetaOpenAI
4+ import com.aallam.openai.api.assistant.AssistantTool
35import com.aallam.openai.api.file.FileId
46import kotlinx.serialization.SerialName
57import kotlinx.serialization.Serializable
@@ -8,9 +10,42 @@ import kotlinx.serialization.Serializable
810 * References an Attachment in the message request.
911 */
1012@Serializable
13+ @OptIn(BetaOpenAI ::class )
1114public data class Attachment (
1215 /* *
1316 * The ID of the file to attach to the message.
1417 */
15- @SerialName(" file_id" ) val fileId : FileId
18+ @SerialName(" file_id" ) val fileId : FileId ? = null ,
19+
20+ /* *
21+ * The tools to add this file to.
22+ */
23+ @SerialName(" tools" ) val tools : List <AssistantTool >? = null ,
1624)
25+
26+ /* *
27+ * A message attachment builder.
28+ */
29+ public fun attachment (block : AttachmentBuilder .() -> Unit ): Attachment = AttachmentBuilder ().apply (block).build()
30+
31+ /* *
32+ * A message attachment builder.
33+ */
34+ public class AttachmentBuilder {
35+ /* *
36+ * The ID of the file to attach to the message.
37+ */
38+ public var fileId: FileId ? = null
39+
40+ /* *
41+ * The tools to add this file to.
42+ */
43+ @OptIn(BetaOpenAI ::class )
44+ public var tools: List <AssistantTool >? = null
45+
46+ /* *
47+ * Build the attachment.
48+ */
49+ @OptIn(BetaOpenAI ::class )
50+ public fun build (): Attachment = Attachment (fileId, tools)
51+ }
0 commit comments