Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add customViewState field to conversation api #599

Merged
merged 4 commits into from
Dec 4, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.Data;

import java.util.List;
import java.util.Map;
import java.util.Set;

@Data
Expand All @@ -32,6 +33,7 @@ public class Conversation {
ModelId model;
Set<String> selectedAddons;
List<Message> messages;
Map<String, Object> customViewState;

@JsonCreator
public Conversation(@JsonProperty(value = "id", required = true) String id,
Expand All @@ -42,7 +44,8 @@ public Conversation(@JsonProperty(value = "id", required = true) String id,
@JsonProperty(value = "lastActivityDate", required = true) long lastActivityDate,
@JsonProperty(value = "model", required = true) ModelId model,
@JsonProperty(value = "selectedAddons", required = true) Set<String> selectedAddons,
@JsonProperty(value = "messages", required = true) List<Message> messages) {
@JsonProperty(value = "messages", required = true) List<Message> messages,
@JsonProperty(value = "customViewState") Map<String, Object> customViewState) {
this.id = id;
this.folderId = folderId;
this.name = name;
Expand All @@ -52,6 +55,7 @@ public Conversation(@JsonProperty(value = "id", required = true) String id,
this.model = model;
this.selectedAddons = selectedAddons;
this.messages = messages;
this.customViewState = customViewState;
}

@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,4 +461,51 @@ public void testCollectAttachmentsFromResponse_ChatStreamingResponse() throws Js

}

@Test
public void testCustomViewStateValidation() {
String validConversationJson = """
{
"id": "conversation_id",
"name": "display_name",
"model": {
"id": "model_id"
},
"prompt": "system prompt",
"temperature": 1,
"folderId": "folder1",
"messages": [
{
"role": "user",
"content": "content",
"custom_content": {"attachment_url": "some_url"},
"model": {"id": "model_id"},
"settings":
{
"prompt": "sysPrompt",
"temperature": 5,
"selectedAddons": ["A", "B", "C"],
"assistantModelId": "assistantId"
}
}
],
"replay": {
"isReplay": true,
"replayUserMessagesStack": [],
"activeReplayIndex": 0
},
"selectedAddons": ["R", "T", "G"],
"assistantModelId": "assistantId",
"lastActivityDate": 4848683153,
"customViewState": {
"a": ["A"],
"b": {
"c": ["C"],
"d": 5.12
}
}
}
""";

assertDoesNotThrow(() -> ProxyUtil.convertToObject(validConversationJson, Conversation.class));
}
}
Loading