Skip to content

Commit

Permalink
Fix ChatCompletionRequestMessage package (#532)
Browse files Browse the repository at this point in the history
  • Loading branch information
fedefernandez authored Nov 13, 2023
1 parent bd5d7da commit e498b5a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
}
}

Expand All @@ -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
Expand All @@ -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
}
}

Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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
}
}

Expand All @@ -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
) {

/**
Expand All @@ -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
}
}
}
2 changes: 1 addition & 1 deletion openai-client/generator/config/openai-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit e498b5a

Please sign in to comment.