Class ChatMessageConverter
java.lang.Object
io.agentscope.core.chat.completions.converter.ChatMessageConverter
Service for converting ChatMessage DTOs to framework internal Msg objects.
This converter handles the transformation from HTTP request DTOs (with String roles) to framework internal message objects (with MsgRole enum). Supported roles: user, assistant, system, tool.
Extended support for:
- Tool calls in assistant messages (tool_calls field)
- Tool results in tool messages (tool_call_id field)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList<io.agentscope.core.message.Msg>convertMessages(List<ChatMessage> chatMessages) Converts a list ofChatMessageDTOs to framework internalMsgobjects, supporting full conversation history including tool calls.
-
Constructor Details
-
ChatMessageConverter
public ChatMessageConverter()
-
-
Method Details
-
convertMessages
Converts a list ofChatMessageDTOs to framework internalMsgobjects, supporting full conversation history including tool calls.This method converts HTTP request DTOs (ChatMessage with String role) to framework internal objects (Msg with MsgRole enum). Supported roles: user, assistant, system, tool.
- Parameters:
chatMessages- The chat messages from the HTTP request to convert- Returns:
- A list of converted
Msgobjects; returns an empty list if input is null or empty - Throws:
IllegalArgumentException- if an unsupported role is encountered in any message
-