diff --git a/openai-client/client/src/commonMain/kotlin/com/xebia/functional/openai/models/CreateChatCompletionRequest.kt b/openai-client/client/src/commonMain/kotlin/com/xebia/functional/openai/models/CreateChatCompletionRequest.kt index 2b08e2ea9..0b54b2e6c 100644 --- a/openai-client/client/src/commonMain/kotlin/com/xebia/functional/openai/models/CreateChatCompletionRequest.kt +++ b/openai-client/client/src/commonMain/kotlin/com/xebia/functional/openai/models/CreateChatCompletionRequest.kt @@ -68,7 +68,7 @@ data class CreateChatCompletionRequest( @Required val messages: kotlin.collections.List< - com.xebia.functional.openai.apis.com.xebia.functional.openai.models.ext.chat.ChatCompletionRequestMessage + com.xebia.functional.openai.models.ext.chat.ChatCompletionRequestMessage >, @SerialName(value = "model") @Required diff --git a/openai-client/client/src/commonMain/kotlin/com/xebia/functional/openai/models/ext/chat/ChatCompletionRequestMessage.kt b/openai-client/client/src/commonMain/kotlin/com/xebia/functional/openai/models/ext/chat/ChatCompletionRequestMessage.kt index c30d5edb8..99d4ddef7 100644 --- a/openai-client/client/src/commonMain/kotlin/com/xebia/functional/openai/models/ext/chat/ChatCompletionRequestMessage.kt +++ b/openai-client/client/src/commonMain/kotlin/com/xebia/functional/openai/models/ext/chat/ChatCompletionRequestMessage.kt @@ -1,7 +1,8 @@ -package com.xebia.functional.openai.apis.com.xebia.functional.openai.models.ext.chat +package com.xebia.functional.openai.models.ext.chat import com.xebia.functional.openai.models.ChatCompletionMessageToolCall import com.xebia.functional.openai.models.ChatCompletionRequestAssistantMessageFunctionCall +import com.xebia.functional.openai.models.ChatCompletionRole import kotlinx.serialization.Required import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -30,7 +31,9 @@ sealed interface ChatCompletionRequestMessage { */ @Serializable enum class Role(val value: String) { - @SerialName(value = "system") system("system") + @SerialName(value = "system") system("system"); + + val asRole: ChatCompletionRole = ChatCompletionRole.system } } @@ -40,10 +43,7 @@ sealed interface ChatCompletionRequestMessage { */ @Serializable data class ChatCompletionRequestUserMessage( - @SerialName(value = "content") - @Required - val content: - com.xebia.functional.openai.models.ext.chat.ChatCompletionRequestUserMessageContent?, + @SerialName(value = "content") @Required val content: ChatCompletionRequestUserMessageContent?, /* The role of the messages author, in this case `user`. */ @SerialName(value = "role") @Required val role: ChatCompletionRequestUserMessage.Role @@ -56,7 +56,9 @@ sealed interface ChatCompletionRequestMessage { */ @Serializable enum class Role(val value: String) { - @SerialName(value = "user") user("user") + @SerialName(value = "user") user("user"); + + val asRole: ChatCompletionRole = ChatCompletionRole.user } } @@ -89,7 +91,9 @@ sealed interface ChatCompletionRequestMessage { */ @Serializable enum class Role(val value: String) { - @SerialName(value = "assistant") assistant("assistant") + @SerialName(value = "assistant") assistant("assistant"); + + val asRole: ChatCompletionRole = ChatCompletionRole.assistant } } @@ -118,7 +122,9 @@ sealed interface ChatCompletionRequestMessage { */ @Serializable enum class Role(val value: String) { - @SerialName(value = "tool") tool("tool") + @SerialName(value = "tool") tool("tool"); + + val asRole: ChatCompletionRole = ChatCompletionRole.tool } } @@ -135,10 +141,10 @@ sealed interface ChatCompletionRequestMessage { @SerialName(value = "role") @Required val role: ChatCompletionRequestFunctionMessage.Role, /* The return value from the function call, to return to the model. */ - @SerialName(value = "content") @Required val content: kotlin.String?, + @SerialName(value = "content") @Required val content: String?, /* The name of the function to call. */ - @SerialName(value = "name") @Required val name: kotlin.String + @SerialName(value = "name") @Required val name: String ) { /** @@ -147,8 +153,10 @@ sealed interface ChatCompletionRequestMessage { * Values: function */ @Serializable - enum class Role(val value: kotlin.String) { - @SerialName(value = "function") function("function") + enum class Role(val value: String) { + @SerialName(value = "function") function("function"); + + val asRole: ChatCompletionRole = ChatCompletionRole.function } } } diff --git a/openai-client/generator/config/openai-config.json b/openai-client/generator/config/openai-config.json index f2018dfb2..ae7caa6a2 100644 --- a/openai-client/generator/config/openai-config.json +++ b/openai-client/generator/config/openai-config.json @@ -7,7 +7,7 @@ }, "schemaMappings": { "FunctionParameters": "kotlinx.serialization.json.JsonObject", - "ChatCompletionRequestMessage": "com.xebia.functional.openai.apis.com.xebia.functional.openai.models.ext.chat.ChatCompletionRequestMessage", + "ChatCompletionRequestMessage": "com.xebia.functional.openai.models.ext.chat.ChatCompletionRequestMessage", "ChatCompletionRequestUserMessage_content": "com.xebia.functional.openai.models.ext.chat.ChatCompletionRequestUserMessageContent", "CreateChatCompletionRequest_model": "com.xebia.functional.openai.models.ext.chat.create.CreateChatCompletionRequestModel", "CreateChatCompletionRequest_stop": "com.xebia.functional.openai.models.ext.chat.create.CreateChatCompletionRequestStop",