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

Enable ChatCompletions to handle ToolCall streaming #109

Merged
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.sashirestela</groupId>
<artifactId>simple-openai</artifactId>
<version>2.3.1</version>
<version>2.3.2</version>
<packaging>jar</packaging>

<name>simple-openai</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import io.github.sashirestela.openai.domain.chat.message.ChatMsgResponse;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@NoArgsConstructor
@Getter
@Setter
@ToString
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class Choice {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ public Role getRole() {
return role;
}

public void setRole(Role role) {
this.role = role;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import io.github.sashirestela.openai.domain.chat.tool.ChatToolCall;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;

@NoArgsConstructor
@Getter
@Setter
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class ChatMsgResponse extends ChatMsg {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
public class ChatFunctionCall {

@Required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
public class ChatToolCall {

private Integer index;

@Required
private String id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ void testChatCompletionsCreateWithFunctionAnswer() throws IOException {
.message(new ChatMsgSystem("You are an expert in Mathematics"))
.message(new ChatMsgUser("What is the product of 123 and 456?"))
.message(new ChatMsgAssistant(null, List.of(new ChatToolCall(
0,
"call_tAoX6VHyjQVLnM9CZvEsTEwW",
ChatToolType.FUNCTION,
new ChatFunctionCall("product", "{\"multiplicand\":123,\"multiplier\":456}")))))
Expand Down