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
| Macro | Description |
|---|---|
#[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.