- Scala 99.8%
- Nix 0.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
The subtitle read "Jev by TypeSafe AI", which made the library look Jev-only now that it supports OpenAI Decisions too. It now reads "JVM · Scala.js · Jev · OpenAI Decisions", in the same outlined Fredoka 500 at 32px, and still sits inside the 40px safe margin. The PNG is re-rendered from the SVG with headless Chrome, which reproduces the old PNG pixel for pixel from the old SVG. The logo itself is vendor-neutral and is unchanged. |
||
| .github | ||
| docs | ||
| scripts | ||
| verdict4s | ||
| verdict4s-client | ||
| verdict4s-core | ||
| verdict4s-examples/src | ||
| .gitignore | ||
| .mill-version | ||
| .scalafmt.conf | ||
| build.mill | ||
| CLAUDE.md | ||
| CODE_OF_CONDUCT.md | ||
| devshell.toml | ||
| flake.lock | ||
| flake.nix | ||
| LICENSE | ||
| README.md | ||
A Scala 3 client for typed decision models: TypeSafe AI's Jev and OpenAI Decisions. A decision model answers typed questions about your program state with choices, scores and calibrated probabilities instead of text. The same questions and the same typed answers work with either vendor.
Cross-built for the JVM and Scala.js from one source tree.
enum Dept derives Options:
case Billing, Technical, Sales
val (urgent, team, mood) = client.ask(
Ask(
Question.noul("Does this convey urgency?"),
Question.choice[Dept]("Which team should handle this?"),
Question.score("How frustrated?", Seq("Calm", "Frustrated", "Very angry"))
),
"Help! My payouts have been failing for 3 days."
)
urgent is a NoulAnswer, team a ChoiceAnswer[Dept], mood a
ScoreAnswer — destructured positionally, at exactly the right types, with no
casts and no lookups by string.
client comes from Verdict4s.jev[IO](key) or Verdict4s.openAI[IO](key).
Nothing else changes between the two vendors. A feature only one vendor has,
such as Jev's model list, is a capability on that vendor's client, so the
compiler catches a call the other vendor cannot serve.
Why the types matter
The services enforce real limits: a Choice takes at most 255 options, a Score 2 to 10 ordered levels, probabilities live in the unit interval. Those are carried by the types rather than discovered a network round trip later, and each vendor's own stricter rules are checked before a request is sent.
Probability(0.95) // fine
Probability(1.5) // does not compile
Questions are validated before anything is sent, and failures accumulate, so a request with three problems reports all three at once.
Install
Requires Java 17 or later on the JVM. The latest <version> is on the Maven
Central badge above.
// Mill
def mvnDeps = Seq(mvn"com.softinio::verdict4s::<version>")
// sbt
libraryDependencies += "com.softinio" %%% "verdict4s" % "<version>"
| Module | Use it when |
|---|---|
verdict4s |
You want a working client in one line. Brings its own transport. |
verdict4s-client |
You already have an http4s Client[F], or want a specific backend. |
verdict4s-core |
You want the types and codecs only, with no effect system at all. |
Documentation
- Getting started
- Choosing a vendor — Jev or OpenAI Decisions, and what differs
- Typed questions
- Errors and retries
- Bring your own client — any http4s backend, or an in-memory fake
- No effect system — driving either vendor by hand
- Other effect systems — ZIO, Future, and anything without a cats-effect instance
- API reference — all three modules in one Scaladoc site
Development
Everything runs inside the Nix devshell. nix develop --command <cmd> works
non-interactively; the aliases below assume you are already inside it.
mill __.test # all 12 targets: 3 modules x {jvm,js} x {3.3.8,3.9.0}
mill "__.jvm[3.9.0].test" # one platform, one Scala version
mill "verdict4s-core.jvm[3.3.8].test" # one module
fmt / fmtCheck # scalafmt
testAll # mill __.test
testJvm17 # JVM tests on Java 17, the floor, as CI does
testJvm25 # JVM tests on Java 25, as CI does
buildDocs / previewDocs # Laika site, or serve on :4242
mill verdict4s-examples.compile # the ZIO / Future / JDK HttpClient examples
Integration tests run against the real services and are gated on each vendor's API key. Without one they report as ignored, so the suite stays green offline:
TYPESAFE_API_KEY=… mill "verdict4s.jvm[3.3.8].test.testOnly" com.softinio.verdict4s.LiveApiIT
OPENAI_API_KEY=… mill "verdict4s.jvm[3.3.8].test.testOnly" com.softinio.verdict4s.LiveOpenAIIT
LiveOpenAIIT needs an OpenAI account with credits. Without them, the request
schema test still passes, because OpenAI checks a body before it checks credit,
but every test that reads an answer fails with "the account has no credits".
mill docs.preview holds Mill's workspace lock while it runs; stop it before
building anything else.
Releasing
Versions come from git tags. Pushing a v* tag from main runs the release:
git tag v0.1.0 && git push origin v0.1.0
- Release publishes the six artifacts (each module for the JVM and Scala.js, all built by Scala 3.3.8) to Maven Central and creates a GitHub release with generated notes.
- Documentation then builds the site from the tag, with that version in its dependency lines, and deploys it to https://verdict4s.softinio.dev. It can be re-run by hand for a tag from the Actions tab.
Run the integration tests above before tagging; they are the only check against the live services.
Structure
verdict4s-core/ effect-free: models, Ask, the Vendor trait, Jev and OpenAI codecs
verdict4s-client/ a client over a caller-supplied http4s Client[F]
verdict4s/ batteries included: Ember on JVM, Fetch on Scala.js
verdict4s-examples/ interop examples, compiled by CI, never published
docs/ Laika narrative site
Contributing
GitHub Issues are disabled to encourage direct community contribution. When you encounter bugs or documentation issues, please contribute fixes through Pull Requests instead.
How to contribute: Open a PR with your solution, draft changes, or a test reproducing the issue. We'll collaborate from there to refine and merge improvements.
This approach creates faster fixes while building a stronger, community-driven project where everyone benefits from shared contributions.
Everyone taking part is expected to follow the Code of Conduct.
License
Apache-2.0. See LICENSE.