Skip to content

Commit 2b3d268

Browse files
committed
READMEs updated
1 parent dd1125b commit 2b3d268

File tree

5 files changed

+55
-74
lines changed

5 files changed

+55
-74
lines changed

README.md

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
# OpenAI Scala Client [![version](https://img.shields.io/badge/version-0.0.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.0.1-green.svg)](https://cequence.io) [![License](https://img.shields.io/badge/License-MIT-lightgrey.svg)](https://opensource.org/licenses/MIT)
22

33
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:
44

5-
* **Models**: [listModels](https://beta.openai.com/docs/api-reference/models/list), and [retrieveModel](https://beta.openai.com/docs/api-reference/models/retrieve)
6-
* **Completions**: [createCompletion](https://beta.openai.com/docs/api-reference/completions/create)
7-
* **Edits**: [createEdit](https://beta.openai.com/docs/api-reference/edits/create)
8-
* **Images**: [createImage](https://beta.openai.com/docs/api-reference/images/create), [createImageEdit](https://beta.openai.com/docs/api-reference/images/create-edit), and [createImageVariation](https://beta.openai.com/docs/api-reference/images/create-variation)
9-
* **Embeddings**: [createEmbeddings](https://beta.openai.com/docs/api-reference/embeddings/create)
10-
* **Files**: [listFiles](https://beta.openai.com/docs/api-reference/files/list), [uploadFile](https://beta.openai.com/docs/api-reference/files/upload), [deleteFile](https://beta.openai.com/docs/api-reference/files/delete), [retrieveFile](https://beta.openai.com/docs/api-reference/files/retrieve), and [retrieveFileContent](https://beta.openai.com/docs/api-reference/files/retrieve-content)
11-
* **Fine-tunes**: [createFineTune](https://beta.openai.com/docs/api-reference/fine-tunes/create), [listFineTunes](https://beta.openai.com/docs/api-reference/fine-tunes/list), [retrieveFineTune](https://beta.openai.com/docs/api-reference/fine-tunes/retrieve), [cancelFineTune](https://beta.openai.com/docs/api-reference/fine-tunes/cancel), [listFineTuneEvents](https://beta.openai.com/docs/api-reference/fine-tunes/events), and [deleteFineTuneModel](https://beta.openai.com/docs/api-reference/fine-tunes/delete-model)
12-
* **Moderations**: [createModeration](https://beta.openai.com/docs/api-reference/moderations/create)
5+
* **Models**: [listModels](https://beta.openai.com/docs/api-reference/models/list), and [retrieveModel](https://beta.openai.com/docs/api-reference/models/retrieve)
6+
* **Completions**: [createCompletion](https://beta.openai.com/docs/api-reference/completions/create)
7+
* **Edits**: [createEdit](https://beta.openai.com/docs/api-reference/edits/create)
8+
* **Images**: [createImage](https://beta.openai.com/docs/api-reference/images/create), [createImageEdit](https://beta.openai.com/docs/api-reference/images/create-edit), and [createImageVariation](https://beta.openai.com/docs/api-reference/images/create-variation)
9+
* **Embeddings**: [createEmbeddings](https://beta.openai.com/docs/api-reference/embeddings/create)
10+
* **Files**: [listFiles](https://beta.openai.com/docs/api-reference/files/list), [uploadFile](https://beta.openai.com/docs/api-reference/files/upload), [deleteFile](https://beta.openai.com/docs/api-reference/files/delete), [retrieveFile](https://beta.openai.com/docs/api-reference/files/retrieve), and [retrieveFileContent](https://beta.openai.com/docs/api-reference/files/retrieve-content)
11+
* **Fine-tunes**: [createFineTune](https://beta.openai.com/docs/api-reference/fine-tunes/create), [listFineTunes](https://beta.openai.com/docs/api-reference/fine-tunes/list), [retrieveFineTune](https://beta.openai.com/docs/api-reference/fine-tunes/retrieve), [cancelFineTune](https://beta.openai.com/docs/api-reference/fine-tunes/cancel), [listFineTuneEvents](https://beta.openai.com/docs/api-reference/fine-tunes/events), and [deleteFineTuneModel](https://beta.openai.com/docs/api-reference/fine-tunes/delete-model)
12+
* **Moderations**: [createModeration](https://beta.openai.com/docs/api-reference/moderations/create)
13+
14+
Note that in order to be consistent with the OpenAI API naming, the service function names match exactly the API endpoint names/descriptions with camelcase.
15+
Also, we aimed the lib to be self-contained and reduced dependencies as much as possible therefore we use only two libs `play-ahc-ws-standalone` and `play-ahc-ws-standalone`. Additionally, if dependency injection is required we use `scala-guice` lib.
1316

14-
Note that in order to be consistent with the OpenAI API naming, the service's function names match exactly the API endpoint names/descriptions with camelcase.
15-
We also aimed to reduce dependencies as much as possible therefore we aimed the lib to be self-contained and use only two libs `play-ahc-ws-standalone` and `play-ahc-ws-standalone`. Additionally, if dependency injection is required we use `scala-guice` lib.
17+
**✔️ Important**: this is a "community-maintained" library and, as such, has no relation to OpenAI company.
1618

17-
## Installation
19+
## Installation 🚀
1820

1921
The currently supported Scala versions are **2.12** and **2.13** but **Scala 3**-version will come out soon.
2022

@@ -34,25 +36,25 @@ or to *pom.xml* (if you use maven)
3436
</dependency>
3537
```
3638

37-
## Config
39+
## Config ⚙️
3840

3941
- Env. variables: `OPENAI_SCALA_CLIENT_API_KEY` and optionally also `OPENAI_SCALA_CLIENT_ORG_ID` (if you have one)
4042
- File config: [openai-scala-client.conf](./openai-core/src/main/resources/openai-scala-client.conf)
4143

42-
## Usage
44+
## Usage 👨‍🎓
4345

4446
**I. Obtaining OpenAIService**
4547

46-
First you need to provide an implicit execution context and akka materializer, e.g., as
48+
First you need to provide an implicit execution context as well as akka materializer, e.g., as
4749

4850
```scala
4951
implicit val ec = ExecutionContext.global
5052
implicit val materializer = Materializer(ActorSystem())
5153
```
5254

53-
Then you can get a service in one of the following ways:
55+
Then you can obtain a service in one of the following ways:
5456

55-
- Default config (expects env. variables to be set as defined in `Config` section)
57+
- Default config (expects env. variable(s) to be set as defined in `Config` section)
5658
```scala
5759
val service = OpenAIServiceFactory()
5860
```
@@ -72,34 +74,34 @@ Then you can get a service in one of the following ways:
7274
)
7375
```
7476

75-
- Via dependecy injection (requires `openai-scala-guice` lib)
77+
- Via dependency injection (requires `openai-scala-guice` lib)
7678

7779
```scala
7880
class MyClass @Inject() (openAIService: OpenAIService) {...}
7981
```
8082

8183
**II. Calling functions**
8284

83-
Note that all calls are async therefore they return `Future`s. Full documentation of each call, which includes the inputs and the settings, is provided in [OpenAIService](./openai-core/src/main/scala/io/cequence/openaiscala/service/OpenAIService.scala)
85+
Full documentation of each call with their respective inputs and settings is provided in [OpenAIService](./openai-core/src/main/scala/io/cequence/openaiscala/service/OpenAIService.scala). Since all the calls are async they return responses wrapped in `Future`.
8486

8587
Examples:
8688

87-
- List models:
89+
- List models
8890

8991
```scala
9092
service.listModels.map(models =>
91-
models.foreach(println(_))
93+
models.foreach(println)
9294
)
9395
```
9496

95-
- Retrieve model:
97+
- Retrieve model
9698
```scala
9799
service.retrieveModel(ModelId.text_davinci_003).map(model =>
98100
println(model.getOrElse("N/A"))
99101
)
100102
```
101103

102-
- Create completion:
104+
- Create completion
103105
```scala
104106
val text = """Extract the name and mailing address from this email:
105107
|Dear Kelly,
@@ -109,12 +111,12 @@ Examples:
109111
|Maya
110112
""".stripMargin
111113

112-
service.createCompletion(text).map(completition =>
113-
println(completition.choices.head.text)
114+
service.createCompletion(text).map(completion =>
115+
println(completion.choices.head.text)
114116
)
115117
```
116118

117-
- Create completion with a custom setting:
119+
- Create completion with a custom setting
118120

119121
```scala
120122
val text = """Extract the name and mailing address from this email:
@@ -129,26 +131,27 @@ Examples:
129131
text,
130132
settings = CreateCompletionSettings(
131133
model = ModelId.text_davinci_001,
132-
max_tokens = Some(2000),
134+
max_tokens = Some(1500),
133135
temperature = Some(0.9),
134136
presence_penalty = Some(0.2),
135137
frequency_penalty = Some(0.2)
136138
)
137-
).map(completition =>
138-
println(completition.choices.head.text)
139+
).map(completion =>
140+
println(completion.choices.head.text)
139141
)
140142
```
141143

142144

143-
## FAQ
145+
## FAQ 🤔
144146

145-
1. *Wen Scala 3?*
147+
1. _Wen Scala 3?_
146148

147149
Feb 2023
148150

149-
2. I got a timeout exception. How can I change the timeout setting?
150151

151-
You can do it either by passing the `timeouts` param to `OpenAIServiceFactory` or if you use your own configuration file then you can set it there, such as:
152+
2. _I got a timeout exception. How can I change the timeout setting?_
153+
154+
You can do it either by passing the `timeouts` param to `OpenAIServiceFactory` or, if you use your own configuration file, then you can simply add it there as:
152155

153156
```
154157
openai-scala-client {
@@ -161,13 +164,17 @@ openai-scala-client {
161164
}
162165
```
163166

164-
## License
167+
3. _It all looks cool. I want to chat with about your research and development?_
168+
169+
Just shoot as an email at [[email protected]](mailto:[email protected]?subject=Research%20andDevelopment).
170+
171+
## License ⚖️
165172

166173
This library is available and published as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
167174

168-
## Contributors
175+
## Contributors 🙏
169176

170-
This project is open-source and welcomes any contribution or feedback ([here]()).
177+
This project is open-source and welcomes any contribution or feedback ([here](https://github.com/cequence-io/openai-scala-client/issues)).
171178

172179
Development of this library has been supported by [<img src="https://cequence.io/favicon-16x16.png"> - Cequence.io](https://cequence.io) - `The future of contracting`
173180

openai-client/README.md

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,24 @@
1-
# OpenAI Scala Client - Core [![version](https://img.shields.io/badge/version-0.0.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.0.1-green.svg)](https://cequence.io) [![License](https://img.shields.io/badge/License-MIT-lightgrey.svg)](https://opensource.org/licenses/MIT)
22

3-
This is the core module, which contains mostly domain classes and the [OpenAIService](./src/main/scala/io/cequence/openaiscala/service/OpenAIService.scala) definition.
4-
The full documentation can be found [here](../README.md).
3+
This module provided the actual meat, i.e. WS client implementation ([OpenAIServiceImpl and OpenAIServiceFactory](./src/main/scala/io/cequence/openaiscala/service/OpenAIServiceImpl.scala)).
4+
Note that the full project documentation can be found [here](../README.md).
55

6-
## Installation
6+
## Installation 🚀
77

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

10-
To pull the library you have to add the following dependency to your *build.sbt*
11-
This is the core module, which contains mostly domain classes and the [OpenAIService](./src/main/scala/io/cequence/openaiscala/service/OpenAIService.scala) definition.
12-
The full documentation can be found [here](../README.md).
13-
14-
## Installation
15-
16-
The currently supported Scala versions are: **2.12** and **2.13**.
17-
1810
To pull the library you have to add the following dependency to your *build.sbt*
1911

2012
```
21-
"io.cequence" %% "openai-scala-core" % "0.0.1"
13+
"io.cequence" %% "openai-scala-client" % "0.0.1"
2214
```
2315

2416
or to *pom.xml* (if you use maven)
2517

2618
```
2719
<dependency>
2820
<groupId>io.cequence</groupId>
29-
<artifactId>openai-scala-core_2.12</artifactId>
21+
<artifactId>openai-scala-client_2.12</artifactId>
3022
<version>0.0.1</version>
3123
</dependency>
32-
```
33-
34-
```
35-
"io.cequence" %% "openai-scala-core" % "0.0.1"
36-
```
37-
38-
or to *pom.xml* (if you use maven)
39-
40-
```
41-
<dependency>
42-
<groupId>io.cequence</groupId>
43-
<artifactId>openai-scala-core_2.12</artifactId>
44-
<version>0.0.1</version>
45-
</dependency>
46-
```
24+
```

openai-client/src/main/scala/io/cequence/openaiscala/service/ws/WSRequestHelper.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ trait WSRequestHelper extends WSHelper {
141141
val request = getWSRequestOptional(Some(endPoint), endPointParam, params)
142142
val bodyParamsX = bodyParams.collect { case (fieldName, Some(jsValue)) => (fieldName.toString, jsValue) }
143143

144-
println(Json.prettyPrint(JsObject(bodyParamsX)))
145-
146144
execPOSTAux(request, JsObject(bodyParamsX), Some(endPoint), acceptableStatusCodes)
147145
}
148146

@@ -216,8 +214,6 @@ trait WSRequestHelper extends WSHelper {
216214
val paramsString = paramsOptionalAsString(params)
217215
val url = createUrl(endPoint, endPointParam) + paramsString
218216

219-
println(url)
220-
221217
client.url(url)
222218
}
223219

openai-core/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# OpenAI Scala Client - Core [![version](https://img.shields.io/badge/version-0.0.1-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.
4-
The full project documentation can be found [here](../README.md).
4+
Note that the full project documentation can be found [here](../README.md).
55

6-
## Installation
6+
## Installation 🚀
77

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

openai-guice/README.md

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

3-
This module provides dependency injection support (by `Guice` library) for the OpenAI Scala client.
4-
The full project documentation can be found [here](../README.md).
3+
This module provides dependency injection for the OpenAI Scala client with a help of `Guice` library.
4+
Note that the full project documentation can be found [here](../README.md).
55

6-
## Installation
6+
## Installation 🚀
77

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

0 commit comments

Comments
 (0)