https://github.com/dallinhuff/openai4s
Scala serialization/deserialization library for OpenAI REST API
https://github.com/dallinhuff/openai4s
openai scala typelevel
Last synced: 12 months ago
JSON representation
Scala serialization/deserialization library for OpenAI REST API
- Host: GitHub
- URL: https://github.com/dallinhuff/openai4s
- Owner: dallinhuff
- License: mit
- Created: 2024-01-30T18:45:51.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-05T09:12:09.000Z (about 2 years ago)
- Last Synced: 2025-02-16T10:14:52.537Z (about 1 year ago)
- Topics: openai, scala, typelevel
- Language: Scala
- Homepage:
- Size: 44.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# openai4s (OpenAI For Scala)
This project aims to provide type-safe request & response bindings for OpenAI's public APIs.
Currently, bindings exist for the new [completions]() API, with more to come.
Future releases will include http clients for sending and receiving requests,
but for now this library is primarily concerned with providing safe serialization & deserialization
of request bodies, where request handling can be handled by another library.
## Installation
#### sbt
`com.dallinhuff %% openai4s % 0.1.1-SNAPSHOT`
## Usage
```scala
import com.dallinhuff.openai4s.completions.*
//...
// CreateChatCompletion and ChatCompletion have circe Codecs,
// so you can serialize them in HTTP requests/responses using
// whichever http client library you prefer
val prompt = CreateChatCompletion(
model = "gpt-3.5-turbo",
messages = List(
Message.SystemMessage("you are a cranky old man who never tells jokes"),
Message.UserMessage("tell me a joke please")
),
n = Some(2)
)
```