Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support create translation #18

Merged
merged 2 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

# How to use?

---

```java
<properties>
<openai.version>LATEST</openai.version>
Expand All @@ -30,12 +32,6 @@
<groupId>org.devlive.sdk</groupId>
<artifactId>openai-java-sdk</artifactId>
<version>${openai.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
```
Expand All @@ -55,6 +51,8 @@

## Star History

---

[![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)

## Contributor
Expand Down
64 changes: 64 additions & 0 deletions README.zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<div align="center">

# OpenAI Java SDK

![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Fdevlive-community%2Fopenai-java-sdk&countColor=%23263759&style=flat)
[![](https://tokei.rs/b1/github/devlive-community/openai-java-sdk)](https://github.com/devlive-community/openai-java-sdk)
![version](https://img.shields.io/github/v/release/devlive-community/openai-java-sdk.svg)

![GitHub](https://img.shields.io/github/license/devlive-community/openai-java-sdk)
![GitHub branch checks state](https://img.shields.io/github/checks-status/devlive-community/openai-java-sdk/master?style=flat-square)
![GitHub Release Date](https://img.shields.io/github/release-date/devlive-community/openai-java-sdk?style=flat-square)

![GitHub commit activity](https://img.shields.io/github/commit-activity/y/devlive-community/openai-java-sdk?style=flat-square)
![GitHub contributors](https://img.shields.io/github/contributors-anon/devlive-community/openai-java-sdk?style=flat-square)
![GitHub last commit](https://img.shields.io/github/last-commit/devlive-community/openai-java-sdk?style=flat-square)

<h3> 为 Java 开发人员提供方便易用的 SDK 来与 OpenAI 的 API 进行交互。</h3>

</div>

# 如何使用?

---

```java
<properties>
<openai.version>LATEST</openai.version>
</properties>

<dependencies>
<dependency>
<groupId>org.devlive.sdk</groupId>
<artifactId>openai-java-sdk</artifactId>
<version>${openai.version}</version>
</dependency>
</dependencies>
```

`LATEST` 默认情况下将使用最新版本。

# Feature

---

- 基于平台快速开发产品,提高开发效率,满足快速交付需求。
- 简洁易懂,代码规范要求,可作为企业代码规范。
- 使用步骤非常简单,一行代码实现所需功能。
- 支持多种代理平台,完美适配各种 API。
- 根据模型动态扩展 Max Tokens
- 丰富的前期数据验证,避免直接接触 API

## Star History

---

[![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)

## Contributor

---

<a href="https://github.com/devlive-community/openai-java-sdk/graphs/contributors">
<img src="https://contrib.rocks/image?repo=devlive-community/openai-java-sdk" />
</a>
83 changes: 83 additions & 0 deletions docs/docs/index.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
title: 主页

hide:
- navigation
- toc
- footer
---

<style xmlns="http://www.w3.org/1999/html">
.md-typeset h1 {
text-align: center;
font-weight: 1000;
font-size: 60px;
margin-top: 60px;
margin-bottom: 0;
}
</style>

<div style="text-align: center;">
为 Java 开发人员提供方便易用的 SDK 来与 OpenAI 的 API 进行交互。
<p/>
<a target="_blank" class="connector-logo-index" href="https://gitee.com/devlive-community/openai-java-sdk/members">
<img src='https://gitee.com/devlive-community/openai-java-sdk/badge/fork.svg?theme=white' alt='fork'/>
</a>
<a target="_blank" class="connector-logo-index" href="https://gitee.com/devlive-community/openai-java-sdk/stargazers">
<img src='https://gitee.com/devlive-community/openai-java-sdk/badge/star.svg?theme=white' alt='star'/>
</a>
<a target="_blank" class="connector-logo-index" href="https://github.com/devlive-community/openai-java-sdk/fork">
<img alt="GitHub stars" src="https://img.shields.io/github/forks/devlive-community/openai-java-sdk?logo=github">
</a>
<a target="_blank" class="connector-logo-index" href="https://github.com/devlive-community/openai-java-sdk/stargazers">
<img alt="GitHub stars" src="https://img.shields.io/github/stars/devlive-community/openai-java-sdk?logo=github">
</a>
<p/>
<p/>
<a href="https://github.com/devlive-community/openai-java-sdk" target="_blank" title="Join us on GitHub" class="md-button md-button--primary">
在 GitHub 上加入我们
</a>
<p/><p/><p/><p/>
</div>

# 概述

<div style="max-width: 70%; margin: 0 auto" class="grid cards" markdown>

- __快速发展__

---

基于平台快速开发产品,提高开发效率,满足快速交付需求。

- __代码质量__

---

简洁易懂,代码规范要求,可作为企业代码规范。

- __易理解__

---

使用步骤非常简单,一行代码实现所需功能。

- __多平台__

---

支持多种代理平台,完美适配各种 API。

- __动态配置__

---

根据模型动态扩展 Max Tokens。

- __隔离远程 API__

---

丰富的前期数据验证,避免直接接触 API。

</div>
2 changes: 1 addition & 1 deletion docs/docs/powered_by.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Powered By
title: Use cases

hide:
- navigation
Expand Down
55 changes: 55 additions & 0 deletions docs/docs/powered_by.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: 客户

hide:
- navigation
- toc
---

<style>
.md-typeset h1 {
text-align: center;
font-weight: 1000;
}
</style>

<div class="font-center" style="text-align: center; margin-top: -20px;">
<a href="https://github.com/devlive-community/openai-java-sdk/issues/3"> <i class="fa fa-plus"> </i> 添加您或公司</a>
</div>

!!! note

有许多公司、个人和开源组织使用该程序。下面列出了其中一些。

### 开源项目

---

<div class="grid cards" markdown>

- <img src="https://github.com/EdurtIO/datacap/raw/dev/core/datacap-web/public/static/images/logo.png" width="30" style="margin: -10px 10px;" /> __DataCap__

---

DataCap 是用于数据转换、集成和可视化的集成软件。支持多种数据源、文件类型、大数据相关数据库、关系型数据库、NoSQL数据库等。通过软件可以实现多种数据源的管理,对源下的数据进行各种操作转换...

[:octicons-arrow-right-24: Getting started](https://github.com/EdurtIO/datacap)

</div>

### 个人用户

---

<div class="grid cards" markdown>

- <img src="https://avatars.githubusercontent.com/u/20521442?v=4" width="30" style="margin: -10px 10px; border-radius: 15px;" /> __qianmoQ__

---

热爱开源项目的源代码贡献者。

[:octicons-arrow-right-24: Visit qianmoQ](https://github.com/qianmoQ)

</div>

38 changes: 38 additions & 0 deletions docs/docs/reference/audio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: Audio
---

!!! 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 translation

---

Translates audio into English.

```java
String file=this.getClass().getResource("/hello.mp3").getFile();
AudioEntity configure = AudioEntity.builder()
.file(new File(file))
.build();
client.audioTranscriptions(configure);
```

Returns

```json
{
"text": "Hello, my name is Wolfgang and I come from Germany. Where are you heading today?"
}
```
38 changes: 38 additions & 0 deletions docs/docs/reference/audio.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: Audio
---

!!! Note

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

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

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

### Create translation

---

将音频翻译成默认音频语言。

```java
String file=this.getClass().getResource("/hello.mp3").getFile();
AudioEntity configure = AudioEntity.builder()
.file(new File(file))
.build();
client.audioTranscriptions(configure);
```

Returns

```json
{
"text": "Hello, my name is Wolfgang and I come from Germany. Where are you heading today?"
}
```
69 changes: 69 additions & 0 deletions docs/docs/reference/completions.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
title: Completions
---

!!! Note

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

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

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

### Create completion

---

为所提供的提示和参数创建一个完整的结果。

```java
CompletionEntity configure = CompletionEntity.builder()
.model(CompleteModel.TEXT_DAVINCI_003.getName())
.prompt("How to create a completion")
.temperature(2D)
.build();
client.createCompletion(configure);
```

Body:

| Name | Type | Required |
|:------------------:|:--------------:|----------|
| `model` | `String` | Yes |
| `prompt` | `String` | Yes |
| `temperature` | `Number` | No |
| `maxTokens` | `Number` | No |
| `topP` | `Number` | No |
| `bestOf` | `Number` | No |
| `frequencyPenalty` | `Number` | No |
| `presencePenalty` | `Number` | No |
| `stop` | `List<String>` | No |

Returns:

```json
{
"id": "cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7",
"object": "text_completion",
"created": 1589478378,
"model": "text-davinci-003",
"choices": [
{
"text": "\n\nThis is indeed a test",
"index": 0,
"logprobs": null,
"finish_reason": "length"
}
],
"usage": {
"prompt_tokens": 5,
"completion_tokens": 7,
"total_tokens": 12
}
}
```
Loading