Skip to content

Commit

Permalink
fix: serialization of Tool
Browse files Browse the repository at this point in the history
  • Loading branch information
morisil committed Sep 30, 2024
1 parent 35100a3 commit e0abae6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/commonMain/kotlin/message/Messages.kt
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ data class Tool(
val name: String,
val description: String,
@SerialName("input_schema")
val inputSchema: JsonObject,
val inputSchema: JsonObject, // soon it will be a generic type
val cacheControl: CacheControl?
)

@OptIn(ExperimentalSerializationApi::class)
@Serializable
@JsonClassDiscriminator("type")
@OptIn(ExperimentalSerializationApi::class)
sealed class Content {

abstract val cacheControl: CacheControl?
Expand Down Expand Up @@ -268,15 +268,20 @@ data class CacheControl(
}

@Serializable
@JsonClassDiscriminator("type")
@OptIn(ExperimentalSerializationApi::class)
sealed class ToolChoice {

@Serializable
@SerialName("auto")
class Auto : ToolChoice()

@Serializable
@SerialName("any")
class Any : ToolChoice()

@Serializable
@SerialName("tool")
class Tool(
val name: String
) : ToolChoice()
Expand Down

0 comments on commit e0abae6

Please sign in to comment.