-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
808 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.