Skip to main content

Getting Started

Welcome to Constellations — a type-safe Scala 3 toolkit for AI function calling, schema derivation, and observability.

Installation​

Tools only (constellations-common)​

For routing LLM tool calls to Scala methods without Executor/Memory:

libraryDependencies += "io.github.serhiip" %% "constellations-common" % "0.1.33-SNAPSHOT"

Full stack​

For conversation loops plus a provider:

libraryDependencies ++= Seq(
"io.github.serhiip" %% "constellations-core" % "0.1.33-SNAPSHOT",
"io.github.serhiip" %% "constellations-openrouter" % "0.1.33-SNAPSHOT"
)

constellations-core pulls constellations-common transitively.

Scala versions​

  • constellations-common and constellations-mcp are built with Scala 3.3.8 (LTS) and work on 3.3.8+
  • Other modules (core, providers, …) require Scala 3.7.x

Quick example​

Define an effectful trait, generate a ToolDispatcher, then dispatch a call named {Trait}_{snake_case_method}:

import cats.effect.IO
import io.github.serhiip.constellations.ToolDispatcher
import io.github.serhiip.constellations.common.*

trait Calculator[F[_]]:
/** Adds two numbers together */
def add(a: Int, b: Int): F[Int]

/** Multiplies two numbers */
def multiply(a: Int, b: Int): F[Int]

val calculatorImpl = new Calculator[IO]:
def add(a: Int, b: Int): IO[Int] = IO.pure(a + b)
def multiply(a: Int, b: Int): IO[Int] = IO.pure(a * b)

val dispatcher: ToolDispatcher[IO] =
ToolDispatcher.generate[IO](calculatorImpl)
import cats.effect.unsafe.implicits.global

val call = FunctionCall(
name = "calculator_add",
args = Struct(Map(
"a" -> Value.number(5),
"b" -> Value.number(3)
))
)
// call: FunctionCall = FunctionCall(
// name = "calculator_add",
// args = Struct(Map("a" -> NumberValue(5.0), "b" -> NumberValue(3.0))),
// callId = None
// )

val result = dispatcher.dispatch(call).unsafeRunSync()
// result: Result = Response(
// FunctionResponse(
// call = FunctionCall(
// name = "calculator_add",
// args = Struct(Map("a" -> NumberValue(5.0), "b" -> NumberValue(3.0))),
// callId = None
// ),
// response = Struct(Map("value" -> NumberValue(8.0)))
// )
// )
result match
case ToolDispatcher.Result.Response(response) =>
println(s"Result: ${response.response}")
case ToolDispatcher.Result.HumanInTheLoop =>
println("Human approval required")
// Result: Struct(Map(value -> NumberValue(8.0)))

Scalar results are wrapped as a struct with a value field (here {"value": 8.0}).

Modules​

ModuleRole
constellations-commonTypes, codecs, schema derivation, ToolDispatcher
constellations-coreExecutor, memory, invoker abstractions
constellations-openrouter / google-genai / …LLM providers
constellations-mcpExpose tools via Model Context Protocol

Next steps​