Skip to content

Modules API

Modules are the basic building blocks of programs in Synalinks. A Module consists of data model-in & data model-out computation function (the module's call() method) and some state (held in Variable).

A module instance is a callable, much like a function:

import synalinks
import asyncio

class Query(synalinks.DataModel):
    query: str = synalinks.Field(
        description="The user query",
    )

class AnswerWithThinking(synalinks.DataModel):
    thinking: str = synalinks.Field(
        description="Your step by step thinking",
    )
    answer: str = synalinks.Field(
        description="The correct answer",
    )

async def main():
    language_model = LanguageModel(
        model="ollama/deepseek-r1"
    )

    generator = synalinks.Generator(
        data_model=AnswerWithThinking,
        language_model=language_model,
    )

    inputs = Query(query="What is the capital of France?")
    outputs = await generator(inputs)


if __name__ == "__main__":
    asyncio.run(main())

Modules API overview


Core Modules


Merging Modules


Test Time Compute Modules


Knowledge Modules


Agents Modules