Skip to content

Commit b094da4

Browse files
committed
[Release] Released for 2024.01.1
1 parent e2d2914 commit b094da4

File tree

5 files changed

+259
-30
lines changed

5 files changed

+259
-30
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
```java
4545
<properties>
46-
<openai.version>2023.12.1</openai.version>
46+
<openai.version>2024.01.1</openai.version>
4747
</properties>
4848

4949
<dependencies>

README.zh_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
```java
4545
<properties>
46-
<openai.version>2023.12.1</openai.version>
46+
<openai.version>2024.01.1</openai.version>
4747
</properties>
4848

4949
<dependencies>

docs/docs/reference/openai/assistants.md

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,13 @@ title: Assistants <span style="font-weight:bold; margin-left:10px; color:red;">B
1919

2020
---
2121

22-
Create an assistant with a model and instructions.
23-
2422
```java
2523
AssistantsEntity entity = AssistantsEntity.builder()
2624
.name("Math Tutor")
2725
.model(CompletionModel.GPT_35_TURBO)
2826
.instructions("You are a personal math tutor. When asked a question, write and run Python code to answer the question.")
2927
.build();
30-
client.
31-
32-
createAssistants(entity);
28+
client.createAssistants(entity);
3329
```
3430

3531
Returns:
@@ -57,8 +53,6 @@ Returns:
5753

5854
---
5955

60-
Create an assistant file by attaching a File to an assistant.
61-
6256
```java
6357
client.createAssistantsFile("file-jNuKdx61rNQ0FUhuPFpMNmGZ","asst_xv9N9dNXstuV8OVLElLqgV7U")
6458
```
@@ -78,18 +72,14 @@ Returns:
7872

7973
---
8074

81-
Returns a list of assistants.
82-
8375
```java
8476
client.listAssistants(null);
8577

8678
// With query params
8779
QueryEntity configure = QueryEntity.builder()
8880
.limit(2)
8981
.build();
90-
client.
91-
92-
assistants(configure);
82+
client.assistants(configure);
9383
```
9484

9585
Returns:
@@ -121,8 +111,6 @@ Returns:
121111

122112
---
123113

124-
Returns a list of assistant files.
125-
126114
```java
127115
client.assistantsFiles("asst_xv9N9dNXstuV8OVLElLqgV7U"));
128116
```
@@ -150,8 +138,6 @@ Returns:
150138

151139
---
152140

153-
Retrieves an assistant.
154-
155141
```java
156142
client.retrieveAssistant("asst_xv9N9dNXstuV8OVLElLqgV7U");
157143
```
@@ -181,8 +167,6 @@ Returns:
181167

182168
---
183169

184-
Retrieves an assistant file.
185-
186170
```java
187171
client.retrieveAssistantFile("asst_xv9N9dNXstuV8OVLElLqgV7U","file-jNuKdx61rNQ0FUhuPFpMNmGZ");
188172
```
@@ -202,17 +186,13 @@ Returns:
202186

203187
---
204188

205-
Modifies an assistant.
206-
207189
```java
208190
AssistantsEntity entity = AssistantsEntity.builder()
209191
.name("Math Tutor 1")
210192
.model(CompletionModel.GPT_35_TURBO)
211193
.instructions("You are a personal math tutor. When asked a question, write and run Python code to answer the question.")
212194
.build();
213-
client.
214-
215-
updateAssistant("asst_xv9N9dNXstuV8OVLElLqgV7U",entity);
195+
client.updateAssistant("asst_xv9N9dNXstuV8OVLElLqgV7U",entity);
216196
```
217197

218198
Returns:
@@ -240,8 +220,6 @@ Returns:
240220

241221
---
242222

243-
Deletes an assistant.
244-
245223
```java
246224
client.deleteAssistant("asst_xv9N9dNXstuV8OVLElLqgV7U");
247225
```
@@ -260,8 +238,6 @@ Returns:
260238

261239
---
262240

263-
Deletes an assistant file.
264-
265241
```java
266242
client.deleteAssistantFile("asst_xv9N9dNXstuV8OVLElLqgV7U","file-jNuKdx61rNQ0FUhuPFpMNmGZ");
267243
```
Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
---
2+
title: Assistants <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+
AssistantsEntity entity = AssistantsEntity.builder()
24+
.name("Math Tutor")
25+
.model(CompletionModel.GPT_35_TURBO)
26+
.instructions("You are a personal math tutor. When asked a question, write and run Python code to answer the question.")
27+
.build();
28+
client.createAssistants(entity);
29+
```
30+
31+
返回:
32+
33+
```json
34+
{
35+
"id": "asst_abc123",
36+
"object": "assistant",
37+
"created_at": 1698984975,
38+
"name": "Math Tutor",
39+
"description": null,
40+
"model": "gpt-4",
41+
"instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
42+
"tools": [
43+
{
44+
"type": "code_interpreter"
45+
}
46+
],
47+
"file_ids": [],
48+
"metadata": {}
49+
}
50+
```
51+
52+
### 创建助手文件
53+
54+
---
55+
56+
```java
57+
client.createAssistantsFile("file-jNuKdx61rNQ0FUhuPFpMNmGZ","asst_xv9N9dNXstuV8OVLElLqgV7U")
58+
```
59+
60+
返回:
61+
62+
```json
63+
{
64+
"id": "file-abc123",
65+
"object": "assistant.file",
66+
"created_at": 1699055364,
67+
"assistant_id": "asst_abc123"
68+
}
69+
```
70+
71+
### 列出助手
72+
73+
---
74+
75+
```java
76+
client.listAssistants(null);
77+
78+
// With query params
79+
QueryEntity configure = QueryEntity.builder()
80+
.limit(2)
81+
.build();
82+
client.assistants(configure);
83+
```
84+
85+
返回:
86+
87+
```json
88+
{
89+
"object": "list",
90+
"data": [
91+
{
92+
"id": "asst_abc123",
93+
"object": "assistant",
94+
"created_at": 1698982736,
95+
"name": "Coding Tutor",
96+
"description": null,
97+
"model": "gpt-4",
98+
"instructions": "You are a helpful assistant designed to make me better at coding!",
99+
"tools": [],
100+
"file_ids": [],
101+
"metadata": {}
102+
}
103+
],
104+
"first_id": "asst_abc123",
105+
"last_id": "asst_abc789",
106+
"has_more": false
107+
}
108+
```
109+
110+
### 列出助手文件
111+
112+
---
113+
114+
```java
115+
client.assistantsFiles("asst_xv9N9dNXstuV8OVLElLqgV7U"));
116+
```
117+
118+
返回:
119+
120+
```json
121+
{
122+
"object": "list",
123+
"data": [
124+
{
125+
"id": "file-abc123",
126+
"object": "assistant.file",
127+
"created_at": 1699060412,
128+
"assistant_id": "asst_abc123"
129+
}
130+
],
131+
"first_id": "file-abc123",
132+
"last_id": "file-abc456",
133+
"has_more": false
134+
}
135+
```
136+
137+
### 检索助手
138+
139+
---
140+
141+
```java
142+
client.retrieveAssistant("asst_xv9N9dNXstuV8OVLElLqgV7U");
143+
```
144+
145+
Returns:
146+
147+
```json
148+
{
149+
"id": "asst_abc123",
150+
"object": "assistant",
151+
"created_at": 1698984975,
152+
"name": "Math Tutor",
153+
"description": null,
154+
"model": "gpt-4",
155+
"instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
156+
"tools": [
157+
{
158+
"type": "code_interpreter"
159+
}
160+
],
161+
"file_ids": [],
162+
"metadata": {}
163+
}
164+
```
165+
166+
### 检索助手文件
167+
168+
---
169+
170+
```java
171+
client.retrieveAssistantFile("asst_xv9N9dNXstuV8OVLElLqgV7U","file-jNuKdx61rNQ0FUhuPFpMNmGZ");
172+
```
173+
174+
返回:
175+
176+
```json
177+
{
178+
"id": "file-abc123",
179+
"object": "assistant.file",
180+
"created_at": 1699055364,
181+
"assistant_id": "asst_abc123"
182+
}
183+
```
184+
185+
### 修改助手
186+
187+
---
188+
189+
```java
190+
AssistantsEntity entity = AssistantsEntity.builder()
191+
.name("Math Tutor 1")
192+
.model(CompletionModel.GPT_35_TURBO)
193+
.instructions("You are a personal math tutor. When asked a question, write and run Python code to answer the question.")
194+
.build();
195+
client.updateAssistant("asst_xv9N9dNXstuV8OVLElLqgV7U",entity);
196+
```
197+
198+
返回:
199+
200+
```json
201+
{
202+
"id": "asst_abc123",
203+
"object": "assistant",
204+
"created_at": 1698984975,
205+
"name": "Math Tutor 1",
206+
"description": null,
207+
"model": "gpt-4",
208+
"instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
209+
"tools": [
210+
{
211+
"type": "code_interpreter"
212+
}
213+
],
214+
"file_ids": [],
215+
"metadata": {}
216+
}
217+
```
218+
219+
### 删除助手
220+
221+
---
222+
223+
```java
224+
client.deleteAssistant("asst_xv9N9dNXstuV8OVLElLqgV7U");
225+
```
226+
227+
返回:
228+
229+
```json
230+
{
231+
"id": "asst_abc123",
232+
"object": "assistant.deleted",
233+
"deleted": true
234+
}
235+
```
236+
237+
### 删除助手文件
238+
239+
---
240+
241+
```java
242+
client.deleteAssistantFile("asst_xv9N9dNXstuV8OVLElLqgV7U","file-jNuKdx61rNQ0FUhuPFpMNmGZ");
243+
```
244+
245+
返回:
246+
247+
```json
248+
{
249+
"id": "file-abc123",
250+
"object": "assistant.file.deleted",
251+
"deleted": true
252+
}
253+
```

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>org.devlive.sdk</groupId>
77
<artifactId>openai-java-sdk</artifactId>
8-
<version>2024.01.1-SNAPSHOT</version>
8+
<version>2024.01.1</version>
99

1010
<name>openai-java-sdk</name>
1111
<description>

0 commit comments

Comments
 (0)