Skip to content

Commit

Permalink
[Release] Released for 2024.01.1 (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
qianmoQ committed Mar 2, 2024
2 parents 049b23e + b094da4 commit 36c2891
Show file tree
Hide file tree
Showing 5 changed files with 259 additions and 30 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

```java
<properties>
<openai.version>2023.12.1</openai.version>
<openai.version>2024.01.1</openai.version>
</properties>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion README.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

```java
<properties>
<openai.version>2023.12.1</openai.version>
<openai.version>2024.01.1</openai.version>
</properties>

<dependencies>
Expand Down
30 changes: 3 additions & 27 deletions docs/docs/reference/openai/assistants.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@ title: Assistants <span style="font-weight:bold; margin-left:10px; color:red;">B

---

Create an assistant with a model and instructions.

```java
AssistantsEntity entity = AssistantsEntity.builder()
.name("Math Tutor")
.model(CompletionModel.GPT_35_TURBO)
.instructions("You are a personal math tutor. When asked a question, write and run Python code to answer the question.")
.build();
client.

createAssistants(entity);
client.createAssistants(entity);
```

Returns:
Expand Down Expand Up @@ -57,8 +53,6 @@ Returns:

---

Create an assistant file by attaching a File to an assistant.

```java
client.createAssistantsFile("file-jNuKdx61rNQ0FUhuPFpMNmGZ","asst_xv9N9dNXstuV8OVLElLqgV7U")
```
Expand All @@ -78,18 +72,14 @@ Returns:

---

Returns a list of assistants.

```java
client.listAssistants(null);

// With query params
QueryEntity configure = QueryEntity.builder()
.limit(2)
.build();
client.

assistants(configure);
client.assistants(configure);
```

Returns:
Expand Down Expand Up @@ -121,8 +111,6 @@ Returns:

---

Returns a list of assistant files.

```java
client.assistantsFiles("asst_xv9N9dNXstuV8OVLElLqgV7U"));
```
Expand Down Expand Up @@ -150,8 +138,6 @@ Returns:

---

Retrieves an assistant.

```java
client.retrieveAssistant("asst_xv9N9dNXstuV8OVLElLqgV7U");
```
Expand Down Expand Up @@ -181,8 +167,6 @@ Returns:

---

Retrieves an assistant file.

```java
client.retrieveAssistantFile("asst_xv9N9dNXstuV8OVLElLqgV7U","file-jNuKdx61rNQ0FUhuPFpMNmGZ");
```
Expand All @@ -202,17 +186,13 @@ Returns:

---

Modifies an assistant.

```java
AssistantsEntity entity = AssistantsEntity.builder()
.name("Math Tutor 1")
.model(CompletionModel.GPT_35_TURBO)
.instructions("You are a personal math tutor. When asked a question, write and run Python code to answer the question.")
.build();
client.

updateAssistant("asst_xv9N9dNXstuV8OVLElLqgV7U",entity);
client.updateAssistant("asst_xv9N9dNXstuV8OVLElLqgV7U",entity);
```

Returns:
Expand Down Expand Up @@ -240,8 +220,6 @@ Returns:

---

Deletes an assistant.

```java
client.deleteAssistant("asst_xv9N9dNXstuV8OVLElLqgV7U");
```
Expand All @@ -260,8 +238,6 @@ Returns:

---

Deletes an assistant file.

```java
client.deleteAssistantFile("asst_xv9N9dNXstuV8OVLElLqgV7U","file-jNuKdx61rNQ0FUhuPFpMNmGZ");
```
Expand Down
253 changes: 253 additions & 0 deletions docs/docs/reference/openai/assistants.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
---
title: Assistants <span style="font-weight:bold; margin-left:10px; color:red;">Beta</span>
---

!!! Note

调用前请先构建客户端,构建代码如下:

```java
OpenAiClient client = OpenAiClient.builder()
.apiHost("https://api.openai.com")
.apiKey(System.getProperty("openai.token"))
.build();
```

`System.getProperty("openai.token")` 是访问 API 授权的关键。

### 创建助手

---

```java
AssistantsEntity entity = AssistantsEntity.builder()
.name("Math Tutor")
.model(CompletionModel.GPT_35_TURBO)
.instructions("You are a personal math tutor. When asked a question, write and run Python code to answer the question.")
.build();
client.createAssistants(entity);
```

返回:

```json
{
"id": "asst_abc123",
"object": "assistant",
"created_at": 1698984975,
"name": "Math Tutor",
"description": null,
"model": "gpt-4",
"instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
"tools": [
{
"type": "code_interpreter"
}
],
"file_ids": [],
"metadata": {}
}
```

### 创建助手文件

---

```java
client.createAssistantsFile("file-jNuKdx61rNQ0FUhuPFpMNmGZ","asst_xv9N9dNXstuV8OVLElLqgV7U")
```

返回:

```json
{
"id": "file-abc123",
"object": "assistant.file",
"created_at": 1699055364,
"assistant_id": "asst_abc123"
}
```

### 列出助手

---

```java
client.listAssistants(null);

// With query params
QueryEntity configure = QueryEntity.builder()
.limit(2)
.build();
client.assistants(configure);
```

返回:

```json
{
"object": "list",
"data": [
{
"id": "asst_abc123",
"object": "assistant",
"created_at": 1698982736,
"name": "Coding Tutor",
"description": null,
"model": "gpt-4",
"instructions": "You are a helpful assistant designed to make me better at coding!",
"tools": [],
"file_ids": [],
"metadata": {}
}
],
"first_id": "asst_abc123",
"last_id": "asst_abc789",
"has_more": false
}
```

### 列出助手文件

---

```java
client.assistantsFiles("asst_xv9N9dNXstuV8OVLElLqgV7U"));
```

返回:

```json
{
"object": "list",
"data": [
{
"id": "file-abc123",
"object": "assistant.file",
"created_at": 1699060412,
"assistant_id": "asst_abc123"
}
],
"first_id": "file-abc123",
"last_id": "file-abc456",
"has_more": false
}
```

### 检索助手

---

```java
client.retrieveAssistant("asst_xv9N9dNXstuV8OVLElLqgV7U");
```

Returns:

```json
{
"id": "asst_abc123",
"object": "assistant",
"created_at": 1698984975,
"name": "Math Tutor",
"description": null,
"model": "gpt-4",
"instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
"tools": [
{
"type": "code_interpreter"
}
],
"file_ids": [],
"metadata": {}
}
```

### 检索助手文件

---

```java
client.retrieveAssistantFile("asst_xv9N9dNXstuV8OVLElLqgV7U","file-jNuKdx61rNQ0FUhuPFpMNmGZ");
```

返回:

```json
{
"id": "file-abc123",
"object": "assistant.file",
"created_at": 1699055364,
"assistant_id": "asst_abc123"
}
```

### 修改助手

---

```java
AssistantsEntity entity = AssistantsEntity.builder()
.name("Math Tutor 1")
.model(CompletionModel.GPT_35_TURBO)
.instructions("You are a personal math tutor. When asked a question, write and run Python code to answer the question.")
.build();
client.updateAssistant("asst_xv9N9dNXstuV8OVLElLqgV7U",entity);
```

返回:

```json
{
"id": "asst_abc123",
"object": "assistant",
"created_at": 1698984975,
"name": "Math Tutor 1",
"description": null,
"model": "gpt-4",
"instructions": "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
"tools": [
{
"type": "code_interpreter"
}
],
"file_ids": [],
"metadata": {}
}
```

### 删除助手

---

```java
client.deleteAssistant("asst_xv9N9dNXstuV8OVLElLqgV7U");
```

返回:

```json
{
"id": "asst_abc123",
"object": "assistant.deleted",
"deleted": true
}
```

### 删除助手文件

---

```java
client.deleteAssistantFile("asst_xv9N9dNXstuV8OVLElLqgV7U","file-jNuKdx61rNQ0FUhuPFpMNmGZ");
```

返回:

```json
{
"id": "file-abc123",
"object": "assistant.file.deleted",
"deleted": true
}
```
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.devlive.sdk</groupId>
<artifactId>openai-java-sdk</artifactId>
<version>2024.01.1-SNAPSHOT</version>
<version>2024.01.1</version>

<name>openai-java-sdk</name>
<description>
Expand Down

0 comments on commit 36c2891

Please sign in to comment.