Skip to content

Commit

Permalink
- 1.10.4
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiteMagic2014 committed Jun 13, 2024
1 parent 85eb424 commit c84cd3d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,30 @@ new CreateChatCompletionRequest()

## Version

### 1.10.4

- Update: DefaultGptHttpUtil Class Changed to Singleton Pattern

```
Old
DefaultGptHttpUtil util = new DefaultGptHttpUtil();
New
DefaultGptHttpUtil util = DefaultGptHttpUtil.getInstance();
Old
DefaultGptHttpUtil util = new DefaultGptHttpUtil(true, 20000, 50000);
New
DefaultGptHttpUtil util = DefaultGptHttpUtil.getInstance();
util.init(true, 20000, 50000);
```

#### Additional Notes

- This change ensures that `DefaultGptHttpUtil` has only one instance throughout the application lifecycle, thereby
reducing memory usage and potential thread safety issues.
- The `init` method provides flexibility to set the instance parameters, but it should be called before the first use of
the `DefaultGptHttpUtil` instance.

### 1.10.3

- Fixed Bug:Fixed a bug where CreateChatCompletionRequest, CreateRunRequest, and CreateThreadAndRunRequest could not be
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<url>https://github.com/WhiteMagic2014/gpt-magic.git</url>
<groupId>io.github.whitemagic2014</groupId>
<artifactId>gpt-magic</artifactId>
<version>1.10.3</version>
<version>1.10.4</version>

<developers>
<developer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public abstract class GptRequest {
*/
protected String org = System.getProperty("OPENAI_API_ORG");

protected GptHttpUtil gptHttpUtil = new DefaultGptHttpUtil();
protected GptHttpUtil gptHttpUtil = DefaultGptHttpUtil.getInstance();

/**
* @return origin json data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,20 @@
**/
public class DefaultGptHttpUtil implements GptHttpUtil {

boolean useCaches = false;
int connectTimeOut = 30000;// default 30s
int readTimeout = 60000;// default 60s
private boolean useCaches = false;
private int connectTimeOut = 30000;// default 30s
private int readTimeout = 60000;// default 60s

private static final DefaultGptHttpUtil INSTANCE = new DefaultGptHttpUtil();

public DefaultGptHttpUtil() {
private DefaultGptHttpUtil() {
}

public DefaultGptHttpUtil(boolean useCaches, int connectTimeOut, int readTimeout) {
public static DefaultGptHttpUtil getInstance() {
return INSTANCE;
}

public void init(boolean useCaches, int connectTimeOut, int readTimeout) {
this.useCaches = useCaches;
this.connectTimeOut = connectTimeOut;
this.readTimeout = readTimeout;
Expand Down

0 comments on commit c84cd3d

Please sign in to comment.