forked from LiLittleCat/ChatGPT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatGPTTest.java
More file actions
50 lines (43 loc) · 1.25 KB
/
Copy pathChatGPTTest.java
File metadata and controls
50 lines (43 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import com.lilittlecat.chatgpt.offical.ChatGPT;
import okhttp3.OkHttpClient;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.net.InetSocketAddress;
import java.net.Proxy;
/**
* <p>
* Test with usage examples.
* </p>
*
* @author LiLittleCat
* @link <a href="https://github.com/LiLittleCat">https://github.com/LiLittleCat</a>
* @since 2022/12/8
*/
@Disabled
class ChatGPTTest {
@Test
void test() {
ChatGPT chatGPT = new ChatGPT("YOUR API KEY");
String hello = chatGPT.ask("Hello");
System.out.println(hello);
}
@Test
void testUseProxy() {
ChatGPT chatGPT = new ChatGPT("YOUR API KEY", "127.0.0.1", 7890);
String hello = chatGPT.ask("Hello");
System.out.println(hello);
}
@Test
void testUseProxy1() {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 7890));
ChatGPT chatGPT = new ChatGPT("YOUR API KEY", proxy);
String hello = chatGPT.ask("Hello");
System.out.println(hello);
}
@Test
void testUseOfferedClient() {
ChatGPT chatGPT = new ChatGPT("YOUR API KEY", new OkHttpClient());
String hello = chatGPT.ask("Hello");
System.out.println(hello);
}
}