Skip to content

Commit 1143751

Browse files
authored
Support create translation (#18)
2 parents 6801f40 + 025c24f commit 1143751

29 files changed

+1160
-9
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
# How to use?
2222

23+
---
24+
2325
```java
2426
<properties>
2527
<openai.version>LATEST</openai.version>
@@ -30,12 +32,6 @@
3032
<groupId>org.devlive.sdk</groupId>
3133
<artifactId>openai-java-sdk</artifactId>
3234
<version>${openai.version}</version>
33-
<exclusions>
34-
<exclusion>
35-
<groupId>org.slf4j</groupId>
36-
<artifactId>slf4j-simple</artifactId>
37-
</exclusion>
38-
</exclusions>
3935
</dependency>
4036
</dependencies>
4137
```
@@ -55,6 +51,8 @@
5551

5652
## Star History
5753

54+
---
55+
5856
[![Star History Chart](https://api.star-history.com/svg?repos=devlive-community/openai-java-sdk&type=Date)](https://star-history.com/#devlive-community/openai-java-sdk&Date)
5957

6058
## Contributor

README.zh_CN.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<div align="center">
2+
3+
# OpenAI Java SDK
4+
5+
![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Fdevlive-community%2Fopenai-java-sdk&countColor=%23263759&style=flat)
6+
[![](https://tokei.rs/b1/github/devlive-community/openai-java-sdk)](https://github.com/devlive-community/openai-java-sdk)
7+
![version](https://img.shields.io/github/v/release/devlive-community/openai-java-sdk.svg)
8+
9+
![GitHub](https://img.shields.io/github/license/devlive-community/openai-java-sdk)
10+
![GitHub branch checks state](https://img.shields.io/github/checks-status/devlive-community/openai-java-sdk/master?style=flat-square)
11+
![GitHub Release Date](https://img.shields.io/github/release-date/devlive-community/openai-java-sdk?style=flat-square)
12+
13+
![GitHub commit activity](https://img.shields.io/github/commit-activity/y/devlive-community/openai-java-sdk?style=flat-square)
14+
![GitHub contributors](https://img.shields.io/github/contributors-anon/devlive-community/openai-java-sdk?style=flat-square)
15+
![GitHub last commit](https://img.shields.io/github/last-commit/devlive-community/openai-java-sdk?style=flat-square)
16+
17+
<h3> 为 Java 开发人员提供方便易用的 SDK 来与 OpenAI 的 API 进行交互。</h3>
18+
19+
</div>
20+
21+
# 如何使用?
22+
23+
---
24+
25+
```java
26+
<properties>
27+
<openai.version>LATEST</openai.version>
28+
</properties>
29+
30+
<dependencies>
31+
<dependency>
32+
<groupId>org.devlive.sdk</groupId>
33+
<artifactId>openai-java-sdk</artifactId>
34+
<version>${openai.version}</version>
35+
</dependency>
36+
</dependencies>
37+
```
38+
39+
`LATEST` 默认情况下将使用最新版本。
40+
41+
# Feature
42+
43+
---
44+
45+
- 基于平台快速开发产品,提高开发效率,满足快速交付需求。
46+
- 简洁易懂,代码规范要求,可作为企业代码规范。
47+
- 使用步骤非常简单,一行代码实现所需功能。
48+
- 支持多种代理平台,完美适配各种 API。
49+
- 根据模型动态扩展 Max Tokens
50+
- 丰富的前期数据验证,避免直接接触 API
51+
52+
## Star History
53+
54+
---
55+
56+
[![Star History Chart](https://api.star-history.com/svg?repos=devlive-community/openai-java-sdk&type=Date)](https://star-history.com/#devlive-community/openai-java-sdk&Date)
57+
58+
## Contributor
59+
60+
---
61+
62+
<a href="https://github.com/devlive-community/openai-java-sdk/graphs/contributors">
63+
<img src="https://contrib.rocks/image?repo=devlive-community/openai-java-sdk" />
64+
</a>

docs/docs/index.zh.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
title: 主页
3+
4+
hide:
5+
- navigation
6+
- toc
7+
- footer
8+
---
9+
10+
<style xmlns="http://www.w3.org/1999/html">
11+
.md-typeset h1 {
12+
text-align: center;
13+
font-weight: 1000;
14+
font-size: 60px;
15+
margin-top: 60px;
16+
margin-bottom: 0;
17+
}
18+
</style>
19+
20+
<div style="text-align: center;">
21+
为 Java 开发人员提供方便易用的 SDK 来与 OpenAI 的 API 进行交互。
22+
<p/>
23+
<a target="_blank" class="connector-logo-index" href="https://gitee.com/devlive-community/openai-java-sdk/members">
24+
<img src='https://gitee.com/devlive-community/openai-java-sdk/badge/fork.svg?theme=white' alt='fork'/>
25+
</a>
26+
<a target="_blank" class="connector-logo-index" href="https://gitee.com/devlive-community/openai-java-sdk/stargazers">
27+
<img src='https://gitee.com/devlive-community/openai-java-sdk/badge/star.svg?theme=white' alt='star'/>
28+
</a>
29+
<a target="_blank" class="connector-logo-index" href="https://github.com/devlive-community/openai-java-sdk/fork">
30+
<img alt="GitHub stars" src="https://img.shields.io/github/forks/devlive-community/openai-java-sdk?logo=github">
31+
</a>
32+
<a target="_blank" class="connector-logo-index" href="https://github.com/devlive-community/openai-java-sdk/stargazers">
33+
<img alt="GitHub stars" src="https://img.shields.io/github/stars/devlive-community/openai-java-sdk?logo=github">
34+
</a>
35+
<p/>
36+
<p/>
37+
<a href="https://github.com/devlive-community/openai-java-sdk" target="_blank" title="Join us on GitHub" class="md-button md-button--primary">
38+
在 GitHub 上加入我们
39+
</a>
40+
<p/><p/><p/><p/>
41+
</div>
42+
43+
# 概述
44+
45+
<div style="max-width: 70%; margin: 0 auto" class="grid cards" markdown>
46+
47+
- __快速发展__
48+
49+
---
50+
51+
基于平台快速开发产品,提高开发效率,满足快速交付需求。
52+
53+
- __代码质量__
54+
55+
---
56+
57+
简洁易懂,代码规范要求,可作为企业代码规范。
58+
59+
- __易理解__
60+
61+
---
62+
63+
使用步骤非常简单,一行代码实现所需功能。
64+
65+
- __多平台__
66+
67+
---
68+
69+
支持多种代理平台,完美适配各种 API。
70+
71+
- __动态配置__
72+
73+
---
74+
75+
根据模型动态扩展 Max Tokens。
76+
77+
- __隔离远程 API__
78+
79+
---
80+
81+
丰富的前期数据验证,避免直接接触 API。
82+
83+
</div>

docs/docs/powered_by.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Powered By
2+
title: Use cases
33

44
hide:
55
- navigation

docs/docs/powered_by.zh.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: 客户
3+
4+
hide:
5+
- navigation
6+
- toc
7+
---
8+
9+
<style>
10+
.md-typeset h1 {
11+
text-align: center;
12+
font-weight: 1000;
13+
}
14+
</style>
15+
16+
<div class="font-center" style="text-align: center; margin-top: -20px;">
17+
<a href="https://github.com/devlive-community/openai-java-sdk/issues/3"> <i class="fa fa-plus"> </i> 添加您或公司</a>
18+
</div>
19+
20+
!!! note
21+
22+
有许多公司、个人和开源组织使用该程序。下面列出了其中一些。
23+
24+
### 开源项目
25+
26+
---
27+
28+
<div class="grid cards" markdown>
29+
30+
- <img src="https://github.com/EdurtIO/datacap/raw/dev/core/datacap-web/public/static/images/logo.png" width="30" style="margin: -10px 10px;" /> __DataCap__
31+
32+
---
33+
34+
DataCap 是用于数据转换、集成和可视化的集成软件。支持多种数据源、文件类型、大数据相关数据库、关系型数据库、NoSQL数据库等。通过软件可以实现多种数据源的管理,对源下的数据进行各种操作转换...
35+
36+
[:octicons-arrow-right-24: Getting started](https://github.com/EdurtIO/datacap)
37+
38+
</div>
39+
40+
### 个人用户
41+
42+
---
43+
44+
<div class="grid cards" markdown>
45+
46+
- <img src="https://avatars.githubusercontent.com/u/20521442?v=4" width="30" style="margin: -10px 10px; border-radius: 15px;" /> __qianmoQ__
47+
48+
---
49+
50+
热爱开源项目的源代码贡献者。
51+
52+
[:octicons-arrow-right-24: Visit qianmoQ](https://github.com/qianmoQ)
53+
54+
</div>
55+

docs/docs/reference/audio.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Audio
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 translation
19+
20+
---
21+
22+
Translates audio into English.
23+
24+
```java
25+
String file=this.getClass().getResource("/hello.mp3").getFile();
26+
AudioEntity configure = AudioEntity.builder()
27+
.file(new File(file))
28+
.build();
29+
client.audioTranscriptions(configure);
30+
```
31+
32+
Returns
33+
34+
```json
35+
{
36+
"text": "Hello, my name is Wolfgang and I come from Germany. Where are you heading today?"
37+
}
38+
```

docs/docs/reference/audio.zh.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Audio
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+
### Create translation
19+
20+
---
21+
22+
将音频翻译成默认音频语言。
23+
24+
```java
25+
String file=this.getClass().getResource("/hello.mp3").getFile();
26+
AudioEntity configure = AudioEntity.builder()
27+
.file(new File(file))
28+
.build();
29+
client.audioTranscriptions(configure);
30+
```
31+
32+
Returns
33+
34+
```json
35+
{
36+
"text": "Hello, my name is Wolfgang and I come from Germany. Where are you heading today?"
37+
}
38+
```
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
title: Completions
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+
### Create completion
19+
20+
---
21+
22+
为所提供的提示和参数创建一个完整的结果。
23+
24+
```java
25+
CompletionEntity configure = CompletionEntity.builder()
26+
.model(CompleteModel.TEXT_DAVINCI_003.getName())
27+
.prompt("How to create a completion")
28+
.temperature(2D)
29+
.build();
30+
client.createCompletion(configure);
31+
```
32+
33+
Body:
34+
35+
| Name | Type | Required |
36+
|:------------------:|:--------------:|----------|
37+
| `model` | `String` | Yes |
38+
| `prompt` | `String` | Yes |
39+
| `temperature` | `Number` | No |
40+
| `maxTokens` | `Number` | No |
41+
| `topP` | `Number` | No |
42+
| `bestOf` | `Number` | No |
43+
| `frequencyPenalty` | `Number` | No |
44+
| `presencePenalty` | `Number` | No |
45+
| `stop` | `List<String>` | No |
46+
47+
Returns:
48+
49+
```json
50+
{
51+
"id": "cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7",
52+
"object": "text_completion",
53+
"created": 1589478378,
54+
"model": "text-davinci-003",
55+
"choices": [
56+
{
57+
"text": "\n\nThis is indeed a test",
58+
"index": 0,
59+
"logprobs": null,
60+
"finish_reason": "length"
61+
}
62+
],
63+
"usage": {
64+
"prompt_tokens": 5,
65+
"completion_tokens": 7,
66+
"total_tokens": 12
67+
}
68+
}
69+
```

0 commit comments

Comments
 (0)