Skip to content

Commit d5e7a76

Browse files
authored
Merge pull request sashirestela#54 from sashirestela/40-update-readme
Update Readme
2 parents df22f87 + 98becac commit d5e7a76

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

README.md

+33-6
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,40 @@ A Java library to use the OpenAI Api in the simplest possible way.
88

99

1010
## 💡 Description
11-
Simple-OpenAI is a Java http client library for sending requests to and receiving responses from the [OpenAI Api](https://platform.openai.com/docs/api-reference). It exposes a consistent interface across all the services, yet as simple as you can find in other languages like Python or NodeJs. It's a _community-maintained_ library.
11+
Simple-OpenAI is a Java http client library for sending requests to and receiving responses from the [OpenAI API](https://platform.openai.com/docs/api-reference). It exposes a consistent interface across all the services, yet as simple as you can find in other languages like Python or NodeJs. It's a _community-maintained_ library.
1212

13-
Simple-OpenAI uses the [CleverClient](https://github.com/sashirestela/cleverclient) library for http communication, [Jackson](https://github.com/FasterXML/jackson) for Json parsing, and [Lombok](https://projectlombok.org/) to minimize boilerplate code.
13+
Simple-OpenAI uses the [CleverClient](https://github.com/sashirestela/cleverclient) library for http communication, [Jackson](https://github.com/FasterXML/jackson) for Json parsing, and [Lombok](https://projectlombok.org/) to minimize boilerplate code, among others libraries.
14+
15+
16+
## ✴ Support for Other OpenAI Providers
17+
Simple-OpenAI can be used with other providers that are compatible with the OpenAI API. At this moment, there is support for the following providers:
18+
19+
### Azure OpenAI
20+
[Azure OpenIA](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference) is supported by Simple-OpenAI. We can use the class `SimpleOpenAIAzure`, which extends the class `BaseSimpleOpenAI`, to start using this provider.
21+
```java
22+
var openai = SimpleOpenAIAzure.builder()
23+
.apiKey(System.getenv("AZURE_OPENAI_API_KEY"))
24+
.baseUrl(System.getenv("AZURE_OPENAI_BASE_URL")) // Including resourceName and deploymentId
25+
.apiVersion(System.getenv("AZURE_OPENAI_API_VERSION"))
26+
//.httpClient(customHttpClient) Optionally you could pass a custom HttpClient
27+
.build();
28+
```
29+
Currently we are supporting the `openai.chatCompletionService()` service only.
30+
31+
### Anyscale
32+
[Anyscale](https://www.anyscale.com/endpoints) is suported by Simple-OpenAI. We can use the class `SimpleOpenAIAnyscale`, which extends the class `BaseSimpleOpenAI`, to start using this provider.
33+
```java
34+
var openai = SimpleOpenAIAnyscale.builder()
35+
.apiKey(System.getenv("AZURE_OPENAI_API_KEY"))
36+
//.baseUrl(customUrl) Optionally you could pass a custom baseUrl
37+
//.httpClient(customHttpClient) Optionally you could pass a custom HttpClient
38+
.build();
39+
```
40+
Currently we are supporting the `openai.chatCompletionService()` service only. It was tested with the model Mistral.
1441

1542

1643
## ✅ Supported Services
17-
Full support for all of the OpenAI services, including the latest changes announced at the [DevDay](https://openai.com/blog/new-models-and-developer-products-announced-at-devday) on Nov 6th, 2023:
44+
Full support for all of the OpenAI services:
1845

1946
* Text to speech (as part of Audio)
2047
* Speech to text (as part of Audio)
@@ -69,7 +96,7 @@ var openai = SimpleOpenAI.builder()
6996
.organizationId(System.getenv("OPENAI_ORGANIZATION_ID"))
7097
.build();
7198
```
72-
Optionally, as well, you could provide a custom Java HttpClient object if you want to have more options for the http connection, such as executor, proxy, timeout, cookies, etc. ([See here](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.Builder.html) for more details). In the following example we are providing a custom HttpClient:
99+
Optionally, as well, you could provide a custom Java HttpClient object if you want to have more options for the http connection, such as executors, proxy, timeout, cookies, etc. ([See here](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.Builder.html) for more details). In the following example we are providing a custom HttpClient:
73100
```java
74101
var httpClient = HttpClient.newBuilder()
75102
.version(Version.HTTP_1_1)
@@ -86,10 +113,10 @@ var openai = SimpleOpenAI.builder()
86113
```
87114

88115
### Calling the SimpleOpenAI Services
89-
After you have created a SimpleOpenAI object, you are ready to call its services in order to communicate to OpenAI Api. Let's see some examples.
116+
After you have created a SimpleOpenAI object, you are ready to call its services in order to communicate to OpenAI API. Let's see some examples.
90117

91118
#### Audio Service
92-
Example to call th Audio service to transform text to audio. We are requesting to receive the audio in binary format (InputStream):
119+
Example to call the Audio service to transform text to audio. We are requesting to receive the audio in binary format (InputStream):
93120
```java
94121
var speechRequest = AudioSpeechRequest.builder()
95122
.model("tts-1")

0 commit comments

Comments
 (0)