Skip to content

Commit

Permalink
Released for 1.6.0 (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
qianmoQ authored Jul 18, 2023
2 parents 960d4a2 + 8b1b6f8 commit 0d60f47
Show file tree
Hide file tree
Showing 52 changed files with 808 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
distribution: 'temurin'
- run: chmod 755 ./mvnw
- run: |
./mvnw clean install test -Dfindbugs.skip -Dcheckstyle.skip -Dgpg.skip -Dskip.yarn -Dopenai.token=${{ secrets.OPENAI_TOKEN }} -Dproxy.token=${{ secrets.PROXY_TOKEN }} -Dproxy.host=${{ secrets.PROXY_HOST }} -Dazure.token=${{ secrets.AZURE_TOKEN}}
./mvnw clean install test -Dfindbugs.skip -Dcheckstyle.skip -Dgpg.skip -Dskip.yarn -Dopenai.token=${{ secrets.OPENAI_TOKEN }} -Dproxy.token=${{ secrets.PROXY_TOKEN }} -Dproxy.host=${{ secrets.PROXY_HOST }} -Dazure.token=${{ secrets.AZURE_TOKEN}} -Dclaude.token=${{ secrets.CLAUDE_TOKEN }}
before_checker_package:
runs-on: ubuntu-latest
Expand Down
29 changes: 29 additions & 0 deletions docs/docs/reference/anthropic/completions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Completions
---

!!! note

Support the claude, product address: [https://claude.ai/](https://claude.ai/)

### Create completion

---

Creates a completion for the provided prompt and parameters.

```java
// Automatic resource release
try(OpenAiClient client=OpenAiClient.builder()
.apiKey(System.getProperty("claude.token"))
.provider(ProviderModel.CLAUDE)
.build())
{
CompletionEntity configure = CompletionEntity.builder()
.model(CompletionModel.CLAUDE_2.getName())
.prompt("How to create a completion")
.build();
client.createCompletion(configure).getChoices();
}
```

28 changes: 28 additions & 0 deletions docs/docs/reference/anthropic/completions.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: Completions
---

!!! note

支持 claude,产品地址: [https://claude.ai/](https://claude.ai/)

### Create completion

---

为提供的提示和参数创建补全。

```java
// Automatic resource release
try(OpenAiClient client=OpenAiClient.builder()
.apiKey(System.getProperty("claude.token"))
.provider(ProviderModel.CLAUDE)
.build())
{
CompletionEntity configure = CompletionEntity.builder()
.model(CompletionModel.CLAUDE_2.getName())
.prompt("How to create a completion")
.build();
client.createCompletion(configure).getChoices();
}
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Azure OpenAI
title: Completions
---

!!! note
Expand All @@ -22,10 +22,12 @@ title: Azure OpenAI
| `model` | Model name deployed in Azure |
| `version` | Model version deployed in Azure |

### Example
### Create completion

---

Creates a completion for the provided prompt and parameters.

```java
// Automatic resource release
try(OpenAiClient client=OpenAiClient.builder()
Expand All @@ -36,6 +38,11 @@ try(OpenAiClient client=OpenAiClient.builder()
.version("2022-12-01")
.build())
{
CompletionEntity configure = CompletionEntity.builder()
.model(CompletionModel.TEXT_DAVINCI_003.getName())
.prompt("How to create a completion")
.temperature(2D)
.build();
client.createCompletion(configure).getChoices();
}
```
Expand Down
48 changes: 48 additions & 0 deletions docs/docs/reference/azure/completions.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: Completions
---

!!! note

支持微软提供的 Open Ai服务,产品地址: [https://azure.microsoft.com/zh-cn/products/cognitive-services/openai-service/](https://azure.microsoft.com/zh-cn/products/cognitive-services/openai-service/)

### Required

---

!!! note

以下是调用服务必须指定的一些配置.

| name | description |
|:----------:|-----------------------------------------------------|
| `apiHost` |`${your-resource-name}.openai.azure.com` 格式创建区域标记 |
| `apiKey` | Azure 令牌 |
| `provider` | 指定 `ProviderModel.azure` |
| `model` | Azure 中部署的模型名称 |
| `version` | Azure 中部署的模型版本 |

### Create completion

---

为提供的提示和参数创建补全。

```java
// 自动资源释放
try(OpenAiClient client=OpenAiClient.builder()
.apiHost("https://eus-chatgpt.openai.azure.com")
.apiKey(System.getProperty("azure.token"))
.provider(ProviderModel.azure)
.model("text-davinci-002")
.version("2022-12-01")
.build())
{
CompletionEntity configure = CompletionEntity.builder()
.model(CompletionModel.TEXT_DAVINCI_003.getName())
.prompt("How to create a completion")
.temperature(2D)
.build();
client.createCompletion(configure).getChoices();
}
```
60 changes: 60 additions & 0 deletions docs/docs/reference/azure/completions_chat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: Chat Completions
---

!!! note

Support the Open Ai service provided by Microsoft, product address: [https://azure.microsoft.com/zh-cn/products/cognitive-services/openai-service/](https://azure.microsoft.com/zh-cn/products/cognitive-services/openai-service/)

### Required

---

!!! note

The following are some configurations that must be specified to invoke the service.

| name | description |
|:----------:|-----------------------------------------------------------------------------|
| `apiHost` | Created zone markers in the format `${your-resource-name}.openai.azure.com` |
| `apiKey` | Azure token |
| `provider` | Specify `ProviderModel.azure` |
| `model` | Model name deployed in Azure |
| `version` | Model version deployed in Azure |

### Create chat completion

---

Creates a model response for the given chat conversation.

```java
// Automatic resource release
try(OpenAiClient client=OpenAiClient.builder()
.apiHost("https://eus-chatgpt.openai.azure.com")
.apiKey(System.getProperty("azure.token"))
.provider(ProviderModel.azure)
.model("text-davinci-002")
.version("2022-12-01")
.build())
{
List<CompletionMessageEntity> messages = Lists.newArrayList();
messages.add(CompletionMessageEntity.builder()
.content("Hello, my name is openai-java-sdk")
.build());

CompletionChatEntity configure = CompletionChatEntity.builder()
.messages(messages)
.build();

client.createChatCompletion(configure)
.getChoices()
.forEach(choice -> messages.add(choice.getMessage()));

messages.add(CompletionMessageEntity.builder()
.content("What is my name?")
.build());
client.createChatCompletion(configure).getChoices();
}
```

60 changes: 60 additions & 0 deletions docs/docs/reference/azure/completions_chat.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: Chat Completions
---

!!! note

支持微软提供的 Open Ai服务,产品地址: [https://azure.microsoft.com/zh-cn/products/cognitive-services/openai-service/](https://azure.microsoft.com/zh-cn/products/cognitive-services/openai-service/)

### Required

---

!!! note

以下是调用服务必须指定的一些配置.

| name | description |
|:----------:|-----------------------------------------------------|
| `apiHost` |`${your-resource-name}.openai.azure.com` 格式创建区域标记 |
| `apiKey` | Azure 令牌 |
| `provider` | 指定 `ProviderModel.azure` |
| `model` | Azure 中部署的模型名称 |
| `version` | Azure 中部署的模型版本 |

### Create chat completion

---

为给定的聊天对话创建模型响应。

```java
// Automatic resource release
try(OpenAiClient client=OpenAiClient.builder()
.apiHost("https://eus-chatgpt.openai.azure.com")
.apiKey(System.getProperty("azure.token"))
.provider(ProviderModel.azure)
.model("text-davinci-002")
.version("2022-12-01")
.build())
{
List<CompletionMessageEntity> messages = Lists.newArrayList();
messages.add(CompletionMessageEntity.builder()
.content("Hello, my name is openai-java-sdk")
.build());

CompletionChatEntity configure = CompletionChatEntity.builder()
.messages(messages)
.build();

client.createChatCompletion(configure)
.getChoices()
.forEach(choice -> messages.add(choice.getMessage()));

messages.add(CompletionMessageEntity.builder()
.content("What is my name?")
.build());
client.createChatCompletion(configure).getChoices();
}
```

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
51 changes: 51 additions & 0 deletions docs/docs/reference/openai/edits.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: Edits
---

!!! Note

Please build the client before calling, the build code is as follows:

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

`System.getProperty("openai.token")` is the key to access the API authorization.

### Create edit

---

Creates a new edit for the provided input, instruction, and parameters.

```java
EditEntity configure = EditEntity.builder()
.model(EditModel.TEXT_DAVINCI_EDIT_001)
.input("Hello OpenAi Java SDK")
.instruction("Fix the spelling mistakes")
.build();
client.edit(configure);
```

Returns

```json
{
"object": "edit",
"created": 1589478378,
"choices": [
{
"text": "What day of the week is it?",
"index": 0,
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 32,
"total_tokens": 57
}
}
```
51 changes: 51 additions & 0 deletions docs/docs/reference/openai/edits.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: Edits
---

!!! Note

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

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

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

### Create edit

---

为提供的输入、指令和参数创建新的编辑。

```java
EditEntity configure = EditEntity.builder()
.model(EditModel.TEXT_DAVINCI_EDIT_001)
.input("Hello OpenAi Java SDK")
.instruction("Fix the spelling mistakes")
.build();
client.edit(configure);
```

Returns

```json
{
"object": "edit",
"created": 1589478378,
"choices": [
{
"text": "What day of the week is it?",
"index": 0,
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 32,
"total_tokens": 57
}
}
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 0d60f47

Please sign in to comment.