-
Notifications
You must be signed in to change notification settings - Fork 22
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
5 changed files
with
178 additions
and
1 deletion.
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
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 | ||
} | ||
} | ||
``` |
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,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://..." | ||
} | ||
] | ||
} | ||
``` | ||
|
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
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