Skip to content

Commit 3a2c179

Browse files
committed
Version 0.2.0 - README
1 parent 765c2ea commit 3a2c179

File tree

5 files changed

+53
-19
lines changed

5 files changed

+53
-19
lines changed

README.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# OpenAI Scala Client 🤖 [![version](https://img.shields.io/badge/version-0.1.1-green.svg)](https://cequence.io) [![License](https://img.shields.io/badge/License-MIT-lightgrey.svg)](https://opensource.org/licenses/MIT)
1+
# OpenAI Scala Client 🤖 [![version](https://img.shields.io/badge/version-0.2.0-green.svg)](https://cequence.io) [![License](https://img.shields.io/badge/License-MIT-lightgrey.svg)](https://opensource.org/licenses/MIT)
22

3-
This is a no-nonsense async Scala client for OpenAI API supporting all the available endpoints and params (as defined [here](https://beta.openai.com/docs/api-reference)), provided in a single, convenient service called [OpenAIService](./openai-core/src/main/scala/io/cequence/openaiscala/service/OpenAIService.scala). The supported calls are:
3+
This is a no-nonsense async Scala client for OpenAI API supporting all the available endpoints and params **including streaming** (as defined [here](https://beta.openai.com/docs/api-reference)), provided in a single, convenient service called [OpenAIService](./openai-core/src/main/scala/io/cequence/openaiscala/service/OpenAIService.scala). The supported calls are:
44

55
* **Models**: [listModels](https://beta.openai.com/docs/api-reference/models/list), and [retrieveModel](https://beta.openai.com/docs/api-reference/models/retrieve)
66
* **Completions**: [createCompletion](https://beta.openai.com/docs/api-reference/completions/create)
@@ -28,7 +28,7 @@ The currently supported Scala versions are **2.12** and **2.13** ~~but **Scala 3
2828
To pull the library you have to add the following dependency to your *build.sbt*
2929

3030
```
31-
"io.cequence" %% "openai-scala-client" % "0.1.1"
31+
"io.cequence" %% "openai-scala-client" % "0.2.0"
3232
```
3333

3434
or to *pom.xml* (if you use maven)
@@ -37,10 +37,12 @@ or to *pom.xml* (if you use maven)
3737
<dependency>
3838
<groupId>io.cequence</groupId>
3939
<artifactId>openai-scala-client_2.12</artifactId>
40-
<version>0.1.1</version>
40+
<version>0.2.0</version>
4141
</dependency>
4242
```
4343

44+
If you want a streaming support use `"io.cequence" %% "openai-scala-client-stream" % "0.2.0"` instead.
45+
4446
## Config ⚙️
4547

4648
- Env. variables: `OPENAI_SCALA_CLIENT_API_KEY` and optionally also `OPENAI_SCALA_CLIENT_ORG_ID` (if you have one)
@@ -57,7 +59,7 @@ First you need to provide an implicit execution context as well as akka material
5759
implicit val materializer = Materializer(ActorSystem())
5860
```
5961

60-
Then you can obtain a service in one of the following ways:
62+
Then you can obtain a service in one of the following ways.
6163

6264
- Default config (expects env. variable(s) to be set as defined in `Config` section)
6365
```scala
@@ -79,6 +81,8 @@ Then you can obtain a service in one of the following ways:
7981
)
8082
```
8183

84+
**✔️ Important**: If you want to use streaming use `OpenAIServiceStreamedFactory` from `openai-scala-client-stream` lib instead of `OpenAIServiceFactory` (in the three examples above). Two additional functions - `createCompletionStreamed` and `listFineTuneEventsStreamed` provided by [OpenAIServiceStreamedExtra](./openai-client-stream/src/main/scala/io/cequence/openaiscala/service/OpenAIServiceStreamedExtra.scala) will be then available.
85+
8286
- Via dependency injection (requires `openai-scala-guice` lib)
8387

8488
```scala
@@ -146,6 +150,25 @@ Examples:
146150
)
147151
```
148152

153+
- Create completion with streaming and a custom setting
154+
155+
```scala
156+
val source = service.createCompletionStreamed(
157+
prompt = "Write me a Shakespeare poem about two cats playing baseball in Russia using at least 2 pages",
158+
settings = CreateCompletionSettings(
159+
model = ModelId.text_davinci_003,
160+
max_tokens = Some(1500),
161+
temperature = Some(0.9),
162+
presence_penalty = Some(0.2),
163+
frequency_penalty = Some(0.2)
164+
)
165+
)
166+
167+
source.map(completion =>
168+
println(completion.choices.head.text)
169+
).runWith(Sink.ignore)
170+
```
171+
(For this to work you need to use `OpenAIServiceStreamedFactory` from `openai-scala-client-stream` lib)
149172

150173
## FAQ 🤔
151174

openai-client-stream/README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1-
# OpenAI Scala Client - Stream Support [![version](https://img.shields.io/badge/version-0.1.1-green.svg)](https://cequence.io) [![License](https://img.shields.io/badge/License-MIT-lightgrey.svg)](https://opensource.org/licenses/MIT)
1+
# OpenAI Scala Client - Stream Support [![version](https://img.shields.io/badge/version-0.2.0-green.svg)](https://cequence.io) [![License](https://img.shields.io/badge/License-MIT-lightgrey.svg)](https://opensource.org/licenses/MIT)
22

33
This module provides streaming support for the client. Note that the full project documentation can be found [here](../README.md).
44

55
## Installation 🚀
66

77
The currently supported Scala versions are **2.12** and **2.13**.
88

9-
~~To pull the library you have to add the following dependency to your *build.sbt*~~
9+
To pull the library you have to add the following dependency to your *build.sbt*
1010

11-
**Not yet released**
12-
...
11+
```
12+
"io.cequence" %% "openai-scala-client-stream" % "0.2.0"
13+
```
14+
15+
or to *pom.xml* (if you use maven)
16+
17+
```
18+
<dependency>
19+
<groupId>io.cequence</groupId>
20+
<artifactId>openai-scala-client-stream_2.12</artifactId>
21+
<version>0.2.0</version>
22+
</dependency>
23+
```

openai-client/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# OpenAI Scala Client - Client [![version](https://img.shields.io/badge/version-0.1.1-green.svg)](https://cequence.io) [![License](https://img.shields.io/badge/License-MIT-lightgrey.svg)](https://opensource.org/licenses/MIT)
1+
# OpenAI Scala Client - Client [![version](https://img.shields.io/badge/version-0.2.0-green.svg)](https://cequence.io) [![License](https://img.shields.io/badge/License-MIT-lightgrey.svg)](https://opensource.org/licenses/MIT)
22

3-
This module provided the actual meat, i.e. WS client implementation ([OpenAIServiceImpl and OpenAIServiceFactory](./src/main/scala/io/cequence/openaiscala/service/OpenAIServiceImpl.scala)).
3+
This module provides the actual meat, i.e. WS client implementation ([OpenAIServiceImpl and OpenAIServiceFactory](./src/main/scala/io/cequence/openaiscala/service/OpenAIServiceImpl.scala)).
44
Note that the full project documentation can be found [here](../README.md).
55

66
## Installation 🚀
@@ -10,7 +10,7 @@ The currently supported Scala versions are **2.12, 2.13**, and **3**.
1010
To pull the library you have to add the following dependency to your *build.sbt*
1111

1212
```
13-
"io.cequence" %% "openai-scala-client" % "0.1.1"
13+
"io.cequence" %% "openai-scala-client" % "0.2.0"
1414
```
1515

1616
or to *pom.xml* (if you use maven)
@@ -19,6 +19,6 @@ or to *pom.xml* (if you use maven)
1919
<dependency>
2020
<groupId>io.cequence</groupId>
2121
<artifactId>openai-scala-client_2.12</artifactId>
22-
<version>0.1.1</version>
22+
<version>0.2.0</version>
2323
</dependency>
2424
```

openai-core/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# OpenAI Scala Client - Core [![version](https://img.shields.io/badge/version-0.1.1-green.svg)](https://cequence.io) [![License](https://img.shields.io/badge/License-MIT-lightgrey.svg)](https://opensource.org/licenses/MIT)
1+
# OpenAI Scala Client - Core [![version](https://img.shields.io/badge/version-0.2.0-green.svg)](https://cequence.io) [![License](https://img.shields.io/badge/License-MIT-lightgrey.svg)](https://opensource.org/licenses/MIT)
22

33
This is the core module, which contains mostly domain classes and the [OpenAIService](./src/main/scala/io/cequence/openaiscala/service/OpenAIService.scala) definition.
44
Note that the full project documentation can be found [here](../README.md).
@@ -10,7 +10,7 @@ The currently supported Scala versions are **2.12, 2.13**, and **3**.
1010
To pull the library you have to add the following dependency to your *build.sbt*
1111

1212
```
13-
"io.cequence" %% "openai-scala-core" % "0.1.1"
13+
"io.cequence" %% "openai-scala-core" % "0.2.0"
1414
```
1515

1616
or to *pom.xml* (if you use maven)
@@ -19,6 +19,6 @@ or to *pom.xml* (if you use maven)
1919
<dependency>
2020
<groupId>io.cequence</groupId>
2121
<artifactId>openai-scala-core_2.12</artifactId>
22-
<version>0.1.1</version>
22+
<version>0.2.0</version>
2323
</dependency>
2424
```

openai-guice/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# OpenAI Scala Client - Guice [![version](https://img.shields.io/badge/version-0.1.1-green.svg)](https://cequence.io) [![License](https://img.shields.io/badge/License-MIT-lightgrey.svg)](https://opensource.org/licenses/MIT)
1+
# OpenAI Scala Client - Guice [![version](https://img.shields.io/badge/version-0.2.0-green.svg)](https://cequence.io) [![License](https://img.shields.io/badge/License-MIT-lightgrey.svg)](https://opensource.org/licenses/MIT)
22

33
This module provides dependency injection for the OpenAI Scala client with a help of `Guice` library.
44
Note that the full project documentation can be found [here](../README.md).
@@ -10,7 +10,7 @@ The currently supported Scala versions are **2.12** and **2.13**.
1010
To pull the library you have to add the following dependency to your *build.sbt*
1111

1212
```
13-
"io.cequence" %% "openai-scala-guice" % "0.1.1"
13+
"io.cequence" %% "openai-scala-guice" % "0.2.0"
1414
```
1515

1616
or to *pom.xml* (if you use maven)
@@ -19,6 +19,6 @@ or to *pom.xml* (if you use maven)
1919
<dependency>
2020
<groupId>io.cequence</groupId>
2121
<artifactId>openai-scala-guice_2.12</artifactId>
22-
<version>0.1.1</version>
22+
<version>0.2.0</version>
2323
</dependency>
2424
```

0 commit comments

Comments
 (0)