Skip to content

Commit 53cb57f

Browse files
committed
proxy
1 parent 0dd0d47 commit 53cb57f

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: maven
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 100
8+

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ maven
6767
<dependency>
6868
<groupId>com.github.plexpt</groupId>
6969
<artifactId>chatgpt</artifactId>
70-
<version>1.1.2</version>
70+
<version>1.2.0</version>
7171
</dependency>
7272
```
7373

7474
gradle
7575
```
76-
implementation group: 'com.github.plexpt', name: 'chatgpt', version: '1.1.2'
76+
implementation group: 'com.github.plexpt', name: 'chatgpt', version: '1.2.0'
7777
```
7878

7979

README_en.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ maven
2626
<dependency>
2727
<groupId>com.github.plexpt</groupId>
2828
<artifactId>chatgpt</artifactId>
29-
<version>1.1.2</version>
29+
<version>1.2.0</version>
3030
</dependency>
3131
```
3232

3333
gradle
3434
```
35-
implementation group: 'com.github.plexpt', name: 'chatgpt', version: '1.1.2'
35+
implementation group: 'com.github.plexpt', name: 'chatgpt', version: '1.2.0'
3636
```
3737

3838

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.github.plexpt</groupId>
77
<artifactId>chatgpt</artifactId>
8-
<version>1.1.2</version>
8+
<version>1.2.0</version>
99
<name>chatgpt-java</name>
1010
<description>chatgpt-java</description>
1111

@@ -70,7 +70,7 @@
7070
<dependency>
7171
<groupId>com.alibaba.fastjson2</groupId>
7272
<artifactId>fastjson2</artifactId>
73-
<version>2.0.20</version>
73+
<version>2.0.23</version>
7474
</dependency>
7575
<!-- <dependency>-->
7676
<!-- <groupId>com.squareup.okhttp3</groupId>-->

src/main/java/com/github/plexpt/chatgpt/Chatbot.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public class Chatbot {
2828
private String parentId;
2929
private Map<String, String> headers = new HashMap<>();
3030

31+
private String host = "https://chat.openai.com";
32+
3133
private String conversationIdPrev;
3234
private String parentIdPrev;
3335

@@ -91,7 +93,7 @@ public void refreshHeaders() {
9193

9294

9395
Map<String, Object> getChatStream(Map<String, Object> data) {
94-
String url = "https://chat.openai.com/backend-api/conversation";
96+
String url = host + "/backend-api/conversation";
9597

9698
String body = HttpUtil.createPost(url)
9799
.headerMap(headers, true)
@@ -157,7 +159,7 @@ public Map<String, Object> getChatText(Map<String, Object> data) {
157159
// Set proxies
158160
setupProxy(session);
159161

160-
HttpResponse response = session.post2("https://chat.openai.com/backend-api/conversation",
162+
HttpResponse response = session.post2(host + "/backend-api/conversation",
161163
data);
162164
String body = response.body();
163165

@@ -266,7 +268,7 @@ public void refreshSession() {
266268
map.put("cookie", cookiesString);
267269
map.put("Cookie", cookiesString);
268270
session.setHeaders(map);
269-
String urlSession = "https://chat.openai.com/api/auth/session";
271+
String urlSession = host + "/api/auth/session";
270272
HttpResponse response = session.get2(urlSession);
271273

272274
if (response.getStatus() != 200) {
@@ -275,8 +277,10 @@ public void refreshSession() {
275277
System.err.println("token: " + sessionToken);
276278
System.err.println("userAgent: " + userAgent);
277279

278-
System.err.println("请检查以上参数是否正确,是否过期。并且获取以上参数的浏览器要和本程序在同一IP地址" );
279-
System.err.println("Please check whether the above parameters are correct or expired. And the browser that obtains the above parameters must be at the same IP address as this program" );
280+
System.err.println("请检查以上参数是否正确,是否过期。并且获取以上参数的浏览器要和本程序在同一IP地址");
281+
System.err.println("Please check whether the above parameters are correct or expired." +
282+
" And the browser that obtains the above parameters must be at the same IP " +
283+
"address as this program");
280284

281285
return;
282286
}

0 commit comments

Comments
 (0)