Skip to main content

Crate synaptic_macros

Crate synaptic_macros 

Source
Expand description

Procedural macros for the Synaptic framework.

This crate provides attribute macros that reduce boilerplate when defining tools, runnable chains, graph entrypoints, tasks, middleware hooks, and traced functions.

§Macros

MacroDescription
#[tool]Convert an async fn into a Tool implementor
#[chain]Convert an async fn into a BoxRunnable
#[entrypoint]Define a LangGraph-style workflow entry point
#[task]Define a trackable task inside an entrypoint
#[before_agent]Middleware: before agent loop
#[before_model]Middleware: before model call
#[after_model]Middleware: after model call
#[after_agent]Middleware: after agent loop
#[wrap_model_call]Middleware: wrap model call
#[wrap_tool_call]Middleware: wrap tool call
#[dynamic_prompt]Middleware: dynamic system prompt
#[traceable]Add tracing instrumentation

Attribute Macros§

after_agent
Middleware: run a hook after the agent loop finishes.
after_model
Middleware: run a hook after each model call.
before_agent
Middleware: run a hook before the agent loop starts.
before_model
Middleware: run a hook before each model call.
chain
Convert an async function into a BoxRunnable<InputType, OutputType> factory.
dynamic_prompt
Middleware: dynamically generate a system prompt based on current messages.
entrypoint
Define a LangGraph-style workflow entry point.
task
Define a trackable task inside an entrypoint.
tool
Convert an async function into a struct that implements synaptic_core::Tool.
traceable
Add tracing instrumentation to an async or sync function.
wrap_model_call
Middleware: wrap the model call with custom logic.
wrap_tool_call
Middleware: wrap a tool call with custom logic.