File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed
api/src/main/java/com/theokanning/openai/completion/chat Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change 1818 */
1919@ Data
2020@ NoArgsConstructor (force = true )
21- @ RequiredArgsConstructor
2221@ AllArgsConstructor
2322public class ChatMessage {
2423
2524 /**
2625 * Must be either 'system', 'user', 'assistant' or 'function'.<br>
26+ * If it's set to null, it will be set to 'assistant' by default.<br>
2727 * You may use {@link ChatMessageRole} enum.
2828 */
29- @ NonNull
3029 String role ;
3130 @ JsonInclude () // content should always exist in the call, even if it is null
3231 String content ;
@@ -40,12 +39,12 @@ public class ChatMessage {
4039 ChatFunctionCall functionCall ;
4140
4241 public ChatMessage (String role , String content ) {
43- this .role = role ;
42+ this .role = role == null ? "assistant" : role ;
4443 this .content = content ;
4544 }
4645
4746 public ChatMessage (String role , String content , String name ) {
48- this .role = role ;
47+ this .role = role == null ? "assistant" : role ;
4948 this .content = content ;
5049 this .name = name ;
5150 }
You can’t perform that action at this time.
0 commit comments