Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 38 additions & 17 deletions app/src/main/java/cn/lineai/model/ChatMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public String getProtocolName() {
private final String compactStatus;
private final String responseInputItemJson;
private final List<InputAttachment> attachments;
private final String modelSwitchNotification;

public ChatMessage(String id, Role role, String content, boolean streaming) {
this(id, role, content, "", streaming, false, false);
Expand Down Expand Up @@ -137,24 +138,28 @@ public ChatMessage(
}

public ChatMessage(
String id,
Role role,
String content,
String reasoningContent,
boolean streaming,
boolean hidden,
boolean excludeFromContext,
List<ToolCall> toolCalls,
List<ToolResult> toolResults,
String toolCallId,
String toolName,
boolean error,
String diffId,
String reviewState,
String reviewMessage,
String compactStatus,
String responseInputItemJson,
String id, Role role, String content, String reasoningContent,
boolean streaming, boolean hidden, boolean excludeFromContext,
List<ToolCall> toolCalls, List<ToolResult> toolResults,
String toolCallId, String toolName, boolean error,
String diffId, String reviewState, String reviewMessage,
String compactStatus, String responseInputItemJson,
List<InputAttachment> attachments
) {
this(id, role, content, reasoningContent, streaming, hidden, excludeFromContext,
toolCalls, toolResults, toolCallId, toolName, error, diffId, reviewState, reviewMessage,
compactStatus, responseInputItemJson, attachments, "");
}

public ChatMessage(
String id, Role role, String content, String reasoningContent,
boolean streaming, boolean hidden, boolean excludeFromContext,
List<ToolCall> toolCalls, List<ToolResult> toolResults,
String toolCallId, String toolName, boolean error,
String diffId, String reviewState, String reviewMessage,
String compactStatus, String responseInputItemJson,
List<InputAttachment> attachments,
String modelSwitchNotification
) {
this.id = id;
this.role = role == null ? Role.USER : role;
Expand All @@ -176,6 +181,7 @@ public ChatMessage(
this.attachments = attachments == null
? Collections.emptyList()
: Collections.unmodifiableList(new ArrayList<>(attachments));
this.modelSwitchNotification = modelSwitchNotification == null ? "" : modelSwitchNotification;
}

public String getId() {
Expand Down Expand Up @@ -274,6 +280,14 @@ public boolean hasAttachments() {
return !attachments.isEmpty();
}

public String getModelSwitchNotification() {
return modelSwitchNotification;
}

public boolean isModelSwitchNotification() {
return modelSwitchNotification.length() > 0;
}

public String getProtocolRole() {
return role.getProtocolName();
}
Expand Down Expand Up @@ -345,6 +359,13 @@ public static ChatMessage compactProgress(String id, String status) {
"", "", "", status, "");
}

public static ChatMessage modelSwitchNotice(String id, String fromModel, String toModel) {
String content = "\u6a21\u578b\u5df2\u4ece " + fromModel + " \u66f4\u6539\u4e3a " + toModel + "\u3002";
return new ChatMessage(id, Role.ASSISTANT, "", "", false, false, true,
Collections.emptyList(), Collections.emptyList(), "", "", false,
"", "", "", "", "", Collections.emptyList(), content);
}

private String normalizeCompactStatus(String value) {
if (COMPACT_STATUS_RUNNING.equals(value)
|| COMPACT_STATUS_DONE.equals(value)
Expand Down
Loading
Loading