Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.liquid.ai/llms.txt

Use this file to discover all available pages before exploring further.

This page consolidates the lower-level reference symbols used by Constrained Generation and Function Calling. Most apps don’t touch these directly — the high-level pages cover the usual flows. Reach here when you need to inspect schemas, build options programmatically, or wire a custom parser.

GenerationOptions

Per-request controls. Leave any field as null / nil to fall back to the manifest defaults.
public struct GenerationOptions {
  public var temperature: Float?
  public var topP: Float?
  public var minP: Float?
  public var repetitionPenalty: Float?
  public var jsonSchemaConstraint: String?
  public var functionCallParser: LeapFunctionCallParserProtocol?

  public init(
    temperature: Float? = nil,
    topP: Float? = nil,
    minP: Float? = nil,
    repetitionPenalty: Float? = nil,
    jsonSchemaConstraint: String? = nil,
    functionCallParser: LeapFunctionCallParserProtocol? = LFMFunctionCallParser()
  )

  public mutating func setResponseFormat<T: GeneratableType>(type: T.Type) throws
}
Builder-style chaining (v0.10.0+):
let opts = GenerationOptions()
    .with(temperature: 0.3)
    .with(minP: 0.15)
    .with(repetitionPenalty: 1.05)
    .with(jsonSchema: schemaString)
  • Sampling fields — use the model card’s recommended values; arbitrary defaults from generic tutorials usually underperform.
  • jsonSchemaConstraint — JSON Schema string for constrained generation. Use the setResponseFormat(type:) / setResponseFormatType(...) helpers instead of writing the schema by hand.
  • functionCallParserLFMFunctionCallParser (default), HermesFunctionCallParser(), or null/nil to disable parsing and surface raw tool-call text in Chunks.

Constrained generation utilities

// Compile-time schema synthesis lives in the @Generatable macro.
// For ad-hoc inspection:
let schemaString = try JSONSchemaGenerator.getJSONSchema(for: CityFact.self)
JSONSchemaGenerator.getJSONSchema(for:) returns the same JSON Schema string the macro emits at compile time. Useful when embedding the schema in the prompt itself, or when you want to debug the schema the model is being constrained against.See Constrained Generation for the full @Generatable / @Guide macro reference.

Function-calling type reference

The full surface is documented in Function Calling; the type signatures here are the at-a-glance reference.
public struct LeapFunction {
  public let name: String
  public let description: String
  public let parameters: [LeapFunctionParameter]
}

public struct LeapFunctionParameter {
  public let name: String
  public let type: LeapFunctionParameterType
  public let description: String
  public let optional: Bool
}

public indirect enum LeapFunctionParameterType: Codable, Equatable {
  case string(StringType)
  case number(NumberType)
  case integer(IntegerType)
  case boolean(BooleanType)
  case array(ArrayType)
  case object(ObjectType)
  case null(NullType)
}

public struct LeapFunctionCall {
  public let name: String
  public let arguments: [String: Any?]
}
Type wrappers (StringType, NumberType, etc.) carry per-type metadata like enumValues for restricting valid inputs and description for prompt-time hints (used when the type is nested inside an array or object).

Parsers

Two parser implementations ship with the SDK on every platform:
  • LFMFunctionCallParser — default. Handles Liquid Foundation Model (LFM2) Pythonic-style control tokens (<|tool_call_start|> / <|tool_call_end|>).
  • HermesFunctionCallParser — Qwen3 and other models using the Hermes function-calling format.
Implement LeapFunctionCallParserProtocol (Swift) / LeapFunctionCallParser (Kotlin) to add support for a new format.

Backend-specific extras

Some runtime utilities are exposed on the concrete LiquidInferenceEngineRunner rather than the cross-platform ModelRunner protocol/interface. The most common is prompt token budgeting — useful when you need to estimate context usage before sending a long request.
if let engine = runner as? LiquidInferenceEngineRunner {
    let count = engine.getPromptTokensSize(messages: history, addBosToken: true)
    print("Prompt would consume \(count) tokens")
}
These methods are backend-specific and may be elevated to the ModelRunner interface in a future release — defensively check the cast.