Skip to content

Commit

Permalink
feat(messages): add assistant tools to attachements (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
aallam authored Jul 20, 2024
1 parent ebde0a2 commit 1a9bb01
Showing 1 changed file with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.aallam.openai.api.message

import com.aallam.openai.api.BetaOpenAI
import com.aallam.openai.api.assistant.AssistantTool
import com.aallam.openai.api.file.FileId
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand All @@ -8,9 +10,42 @@ import kotlinx.serialization.Serializable
* References an Attachment in the message request.
*/
@Serializable
@OptIn(BetaOpenAI::class)
public data class Attachment(
/**
* The ID of the file to attach to the message.
*/
@SerialName("file_id") val fileId: FileId
@SerialName("file_id") val fileId: FileId? = null,

/**
* The tools to add this file to.
*/
@SerialName("tools") val tools: List<AssistantTool>? = null,
)

/**
* A message attachment builder.
*/
public fun attachment(block: AttachmentBuilder.() -> Unit): Attachment = AttachmentBuilder().apply(block).build()

/**
* A message attachment builder.
*/
public class AttachmentBuilder {
/**
* The ID of the file to attach to the message.
*/
public var fileId: FileId? = null

/**
* The tools to add this file to.
*/
@OptIn(BetaOpenAI::class)
public var tools: List<AssistantTool>? = null

/**
* Build the attachment.
*/
@OptIn(BetaOpenAI::class)
public fun build(): Attachment = Attachment(fileId, tools)
}

0 comments on commit 1a9bb01

Please sign in to comment.