File tree Expand file tree Collapse file tree 4 files changed +198
-1
lines changed
Expand file tree Collapse file tree 4 files changed +198
-1
lines changed Original file line number Diff line number Diff line change @@ -142,7 +142,7 @@ client.assistantsFiles("asst_xv9N9dNXstuV8OVLElLqgV7U"));
142142client. retrieveAssistant(" asst_xv9N9dNXstuV8OVLElLqgV7U" );
143143```
144144
145- Returns :
145+ 返回 :
146146
147147``` json
148148{
Original file line number Diff line number Diff line change 1+ ---
2+ title : Threads <span style="font-weight:bold; margin-left:10px; color:red;">Beta</span>
3+ ---
4+
5+ !!! Note
6+
7+ Please build the client before calling, the build code is as follows:
8+
9+ ```java
10+ OpenAiClient client = OpenAiClient.builder()
11+ .apiHost("https://api.openai.com")
12+ .apiKey(System.getProperty("openai.token"))
13+ .build();
14+ ```
15+
16+ `System.getProperty("openai.token")` is the key to access the API authorization.
17+
18+ ### Create thread
19+
20+ ---
21+
22+ ``` java
23+ ThreadEntity configure = ThreadEntity . builder()
24+ .build();
25+ client. createThread(configure);
26+ ```
27+
28+ Returns:
29+
30+ ``` json
31+ {
32+ "id" : " thread_abc123" ,
33+ "object" : " thread" ,
34+ "created_at" : 1699012949 ,
35+ "metadata" : {}
36+ }
37+ ```
38+
39+ ### Retrieve thread
40+
41+ ---
42+
43+ ``` java
44+ String threadId = " thread_lsfBRIATCECds5WYLVXnVcpU" ;
45+ client. retrieveThread(threadId);
46+ ```
47+
48+ Returns:
49+
50+ ``` json
51+ {
52+ "id" : " thread_abc123" ,
53+ "object" : " thread" ,
54+ "created_at" : 1699014083 ,
55+ "metadata" : {}
56+ }
57+ ```
58+
59+ ### Modify thread
60+
61+ ---
62+
63+ ``` java
64+ String threadId = " thread_lsfBRIATCECds5WYLVXnVcpU" ;
65+ ThreadEntity configure = ThreadEntity . builder()
66+ .build();
67+ client. updateThread(threadId, configure);
68+ ```
69+
70+ Returns:
71+
72+ ``` json
73+ {
74+ "id" : " thread_abc123" ,
75+ "object" : " thread" ,
76+ "created_at" : 1699014083 ,
77+ "metadata" : {}
78+ }
79+ ```
80+
81+ ### Delete thread
82+
83+ ---
84+
85+ ``` java
86+ String threadId = " thread_lsfBRIATCECds5WYLVXnVcpU" ;
87+ client. deleteThread(threadId);
88+ ```
89+
90+ Returns:
91+
92+ ``` json
93+ {
94+ "id" : " thread_abc123" ,
95+ "object" : " thread.deleted" ,
96+ "deleted" : true
97+ }
98+ ```
Original file line number Diff line number Diff line change 1+ ---
2+ title : Threads <span style="font-weight:bold; margin-left:10px; color:red;">Beta</span>
3+ ---
4+
5+ !!! Note
6+
7+ 调用前请先构建客户端,构建代码如下:
8+
9+ ```java
10+ OpenAiClient client = OpenAiClient.builder()
11+ .apiHost("https://api.openai.com")
12+ .apiKey(System.getProperty("openai.token"))
13+ .build();
14+ ```
15+
16+ `System.getProperty("openai.token")` 是访问 API 授权的关键。
17+
18+ ### 创建线程
19+
20+ ---
21+
22+ ``` java
23+ ThreadEntity configure = ThreadEntity . builder()
24+ .build();
25+ client. createThread(configure);
26+ ```
27+
28+ 返回:
29+
30+ ``` json
31+ {
32+ "id" : " thread_abc123" ,
33+ "object" : " thread" ,
34+ "created_at" : 1699012949 ,
35+ "metadata" : {}
36+ }
37+ ```
38+
39+ ### 检索线程
40+
41+ ---
42+
43+ ``` java
44+ String threadId = " thread_lsfBRIATCECds5WYLVXnVcpU" ;
45+ client. retrieveThread(threadId);
46+ ```
47+
48+ 返回:
49+
50+ ``` json
51+ {
52+ "id" : " thread_abc123" ,
53+ "object" : " thread" ,
54+ "created_at" : 1699014083 ,
55+ "metadata" : {}
56+ }
57+ ```
58+
59+ ### 修改线程
60+
61+ ---
62+
63+ ``` java
64+ String threadId = " thread_lsfBRIATCECds5WYLVXnVcpU" ;
65+ ThreadEntity configure = ThreadEntity . builder()
66+ .build();
67+ client. updateThread(threadId, configure);
68+ ```
69+
70+ 返回:
71+
72+ ``` json
73+ {
74+ "id" : " thread_abc123" ,
75+ "object" : " thread" ,
76+ "created_at" : 1699014083 ,
77+ "metadata" : {}
78+ }
79+ ```
80+
81+ ### 删除线程
82+
83+ ---
84+
85+ ``` java
86+ String threadId = " thread_lsfBRIATCECds5WYLVXnVcpU" ;
87+ client. deleteThread(threadId);
88+ ```
89+
90+ 返回:
91+
92+ ``` json
93+ {
94+ "id" : " thread_abc123" ,
95+ "object" : " thread.deleted" ,
96+ "deleted" : true
97+ }
98+ ```
Original file line number Diff line number Diff line change 103103 - reference/openai/files.md
104104 - reference/openai/fine_tunes.md
105105 - reference/openai/assistants.md
106+ - reference/openai/threads.md
106107 - Azure Open Ai :
107108 - reference/azure/completions.md
108109 - reference/azure/completions_chat.md
You can’t perform that action at this time.
0 commit comments