Skip to content

Commit 99337b1

Browse files
authored
fix(messages): content as image file (#313)
1 parent 6527123 commit 99337b1

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
- **Audio**: add `timestampGranularities` (thanks @mxwell)
66

7+
### Fixed
8+
9+
- **Messages**: nullable field `MessageContent.Image#fileId` (#313)
10+
711
## 3.7.0
812

913
### Added
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 image File in the content of a message.
9+
*/
10+
@Serializable
11+
public data class ImageFile(
12+
/**
13+
* The File ID of the image in the message content.
14+
*/
15+
@SerialName("file_id") val fileId: FileId
16+
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public sealed interface MessageContent {
3535
/**
3636
* The File ID of the image in the message content.
3737
*/
38-
@SerialName("file_id") val fileId: FileId
38+
@SerialName("image_file") val imageFile: ImageFile
3939
) : MessageContent
4040

4141
}

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

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

33
import com.aallam.openai.api.BetaOpenAI
44
import com.aallam.openai.api.file.FileId
5+
import kotlinx.serialization.SerialName
56
import kotlinx.serialization.Serializable
67

78
/**
@@ -13,13 +14,13 @@ public data class MessageFile(
1314
/**
1415
* The identifier, which can be referenced in API endpoints.
1516
*/
16-
val id: FileId,
17+
@SerialName("id") val id: FileId,
1718
/**
1819
* The Unix timestamp (in seconds) for when the message file was created.
1920
*/
20-
val createdAt: Int? = null,
21+
@SerialName("created_at") val createdAt: Int? = null,
2122
/**
2223
* The ID of the message that the File is attached to.
2324
*/
24-
val messageId: MessageId? = null,
25+
@SerialName("message_id") val messageId: MessageId? = null,
2526
)

0 commit comments

Comments
 (0)