Open princepride opened 10 months ago
chatgpt-spring-boot-starter-1.0.4.zip
implementation files('chatgpt-spring-boot-starter-1.0.4.jar')
I have only updated the multichat component for now, but I've built one myself while waiting for the author to update the codes.
Minor adjustments include using ChatRole
for defining roles, such as ChatRole.SYSTEM
, ChatRole.USER
, and ChatRole.ASSISTANT
.
public String generate(String yay) {
var multiChatRequest = MultiChatRequest.builder()
.maxTokens(128)
.model("gpt-3.5-turbo-1106")
.responseFormat("json_object")
.build();
var messages = List.of(
new MultiChatMessage(ChatRole.SYSTEM, "Return as json, bark"),
new MultiChatMessage(ChatRole.ASSISTANT, "woof?"),
new MultiChatMessage(ChatRole.USER, yay));
return chatgptService.multiChat(messages, multiChatRequest);
}
For example: `@Autowired private ChatgptService chatgptService;
public void testMultiChat(){ List messages = Arrays.asList(
new MultiChatMessage("system","You are a helpful assistant."),
new MultiChatMessage("user","Who won the world series in 2020?"),
new MultiChatMessage("assistant","The Los Angeles Dodgers won the World Series in 2020."),
new MultiChatMessage("user","Where was it played?"));
String model = "gpt-4";
String responseMessage = chatgptService.multiChat(messages, model);
System.out.print(responseMessage); //The 2020 World Series was played at Globe Life Field in Arlington, Texas.
}`