You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
4
4
5
-
***Models**: [listModels](https://beta.openai.com/docs/api-reference/models/list), and [retrieveModel](https://beta.openai.com/docs/api-reference/models/retrieve)
***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)
***Models**: [listModels](https://beta.openai.com/docs/api-reference/models/list), and [retrieveModel](https://beta.openai.com/docs/api-reference/models/retrieve)
***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)
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.
13
16
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.
16
18
17
-
## Installation
19
+
## Installation 🚀
18
20
19
21
The currently supported Scala versions are **2.12** and **2.13** but **Scala 3**-version will come out soon.
20
22
@@ -34,25 +36,25 @@ or to *pom.xml* (if you use maven)
34
36
</dependency>
35
37
```
36
38
37
-
## Config
39
+
## Config ⚙️
38
40
39
41
- Env. variables: `OPENAI_SCALA_CLIENT_API_KEY` and optionally also `OPENAI_SCALA_CLIENT_ORG_ID` (if you have one)
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`.
valtext="""Extract the name and mailing address from this email:
105
107
|Dear Kelly,
@@ -109,12 +111,12 @@ Examples:
109
111
|Maya
110
112
""".stripMargin
111
113
112
-
service.createCompletion(text).map(completition=>
113
-
println(completition.choices.head.text)
114
+
service.createCompletion(text).map(completion=>
115
+
println(completion.choices.head.text)
114
116
)
115
117
```
116
118
117
-
- Create completion with a custom setting:
119
+
- Create completion with a custom setting
118
120
119
121
```scala
120
122
valtext="""Extract the name and mailing address from this email:
@@ -129,26 +131,27 @@ Examples:
129
131
text,
130
132
settings =CreateCompletionSettings(
131
133
model =ModelId.text_davinci_001,
132
-
max_tokens =Some(2000),
134
+
max_tokens =Some(1500),
133
135
temperature =Some(0.9),
134
136
presence_penalty =Some(0.2),
135
137
frequency_penalty =Some(0.2)
136
138
)
137
-
).map(completition=>
138
-
println(completition.choices.head.text)
139
+
).map(completion=>
140
+
println(completion.choices.head.text)
139
141
)
140
142
```
141
143
142
144
143
-
## FAQ
145
+
## FAQ 🤔
144
146
145
-
1.*Wen Scala 3?*
147
+
1._Wen Scala 3?_
146
148
147
149
Feb 2023
148
150
149
-
2. I got a timeout exception. How can I change the timeout setting?
150
151
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:
152
155
153
156
```
154
157
openai-scala-client {
@@ -161,13 +164,17 @@ openai-scala-client {
161
164
}
162
165
```
163
166
164
-
## License
167
+
3._It all looks cool. I want to chat with about your research and development?_
This library is available and published as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
167
174
168
-
## Contributors
175
+
## Contributors 🙏
169
176
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)).
171
178
172
179
Development of this library has been supported by [<imgsrc="https://cequence.io/favicon-16x16.png"> - Cequence.io](https://cequence.io) - `The future of contracting`
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).
5
5
6
-
## Installation
6
+
## Installation 🚀
7
7
8
8
The currently supported Scala versions are **2.12** and **2.13**.
9
9
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
-
18
10
To pull the library you have to add the following dependency to your *build.sbt*
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).
5
5
6
-
## Installation
6
+
## Installation 🚀
7
7
8
8
The currently supported Scala versions are **2.12** and **2.13**.
0 commit comments