io.cequence.cohereapi.model.ChatMessage.scala Maven / Gradle / Ivy
The newest version!
package io.cequence.cohereapi.model
import io.cequence.wsclient.domain.EnumValue
sealed trait ChatMessage {
def role: Role
def message: String
}
case class ChatbotMessage(
// Contents of the chat message.
override val message: String,
// Contains the tool calls generated by the model. Use it to invoke your tools.
tool_calls: Seq[ToolCall] = Nil
) extends ChatMessage {
override def role: Role = Role.CHATBOT
}
case class SystemMessage(
// Contents of the chat message.
override val message: String,
// Contains the tool calls generated by the model. Use it to invoke your tools.
tool_calls: Seq[ToolCall] = Nil
) extends ChatMessage {
override def role: Role = Role.SYSTEM
}
case class UserMessage(
// Contents of the chat message.
override val message: String,
// Contains the tool calls generated by the model. Use it to invoke your tools.
tool_calls: Seq[ToolCall] = Nil
) extends ChatMessage {
override def role: Role = Role.USER
}
case class ToolMessage(
tool_results: Seq[ToolResult] = Nil
) extends ChatMessage {
override def role: Role = Role.TOOL
override def message: String = "" // Tool messages don't have a message field
}
case class ToolCall(
// Name of the tool to call.
name: String,
// The name and value of the parameters to use when invoking a tool.
parameters: Map[String, Any]
)
case class ToolResult(
// Contains the tool calls generated by the model. Use it to invoke your tools.
call: ToolCallResult,
// list of maps from strings to any
outputs: Seq[Map[String, Any]]
)
case class ToolCallResult(
// Name of the tool to call.
name: String,
// The name and value of the parameters to use when invoking a tool.
parameters: Map[String, Any]
)
sealed trait Role extends EnumValue
object Role {
case object CHATBOT extends Role
case object SYSTEM extends Role
case object USER extends Role
case object TOOL extends Role
}