Skip to content

Commit

Permalink
Released for 1.4.0 (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
qianmoQ committed Jul 11, 2023
2 parents a5835ec + 1693ac7 commit 6801f40
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 1 deletion.
55 changes: 55 additions & 0 deletions docs/docs/reference/embeddings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: Embeddings
---

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

---

Creates an embedding vector representing the input text.

```java
EmbeddingEntity configure=EmbeddingEntity.builder()
.model("text-similarity-ada-001")
.input("Hello OpenAi Java SDK")
.build();
client.createEmbeddings(configure);
```

Return

```json
{
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [
0.0023064255,
-0.009327292,
.... (1536 floats total for ada-002)
-0.0028842222,
],
"index": 0
}
],
"model": "text-embedding-ada-002",
"usage": {
"prompt_tokens": 8,
"total_tokens": 8
}
}
```
109 changes: 109 additions & 0 deletions docs/docs/reference/images.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
title: Images
---

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

---

Creates an image given a prompt.

```java
ImageEntity configure=ImageEntity.builder()
.prompt("Create a bus")
.build();
client.createImages(configure)
```

Returns

```json
{
"created": 1589478378,
"data": [
{
"url": "https://..."
},
{
"url": "https://..."
}
]
}
```

### Create image edit

---

Creates an edited or extended image given an original image and a prompt.

```java
String file=this.getClass().getResource("/logo.png").getFile();
ImageEntity configure=ImageEntity.builder()
.prompt("Add hello to image")
.image(new File(file))
.isEdit(Boolean.TRUE)
.build();
client.editImages(configure);
```

Returns

```json
{
"created": 1589478378,
"data": [
{
"url": "https://..."
},
{
"url": "https://..."
}
]
}
```

### Create image variation

---

Creates a variation of a given image.

```java
String file=this.getClass().getResource("/logo.png").getFile();
ImageEntity configure=ImageEntity.builder()
.image(new File(file))
.isVariation(Boolean.TRUE)
.build();
client.variationsImages(configure);
```

Return

```json
{
"created": 1589478378,
"data": [
{
"url": "https://..."
},
{
"url": "https://..."
}
]
}
```

11 changes: 11 additions & 0 deletions docs/docs/released.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ hide:
- navigation
---

### 1.4.0

---

- Support images api
- Create image
- Create image edit
- Create image variation
- Support embeddings api
- Create embeddings

### 1.3.0

---
Expand Down
2 changes: 2 additions & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ nav:
- reference/models.md
- reference/completions.md
- reference/completions_chat.md
- reference/images.md
- reference/embeddings.md
- Provider:
- reference/provider/azure.md
- released.md
Expand Down
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>1.4.0-SNAPSHOT</version>
<version>1.4.0</version>

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

0 comments on commit 6801f40

Please sign in to comment.