Jun 2025 (v0.3.4)
Mochi v0.3.4 introduces tool calling, union types, and inline methods, enabling richer integrations and more expressive type definitions.
Tool Calling
generate blocks can now invoke registered tools. Each tool may include a description used by the LLM when deciding to call it.
fun getWeather(city: string): string {
return "Clear"
}
let reply = generate text {
prompt: "Weather in Paris?"
tools: [
getWeather { description: "Lookup current weather" }
]
}
Union Types
Programs may declare algebraic data types using the type A = ... | ... syntax. Pattern matching integrates seamlessly with these unions.
type Tree =
Leaf
| Node(left: Tree, value: int, right: Tree)
let total = match someTree {
Leaf => 0
Node(l, v, r) => v + total(l) + total(r)
}
Inline Methods
Struct types can embed function members that act as methods:
type Circle {
radius: float
fun area(): float {
return 3.14 * radius * radius
}
}
Other Changes
- Tool descriptions exported in JSON schemas
- Examples extended with method and binary tree demos
- Fixed several issues around tool call handling