- TypeScript
- Python
Trace a simple agent function that calls an LLM and returns a response
import { registerOTel, agent } from "@uselemma/tracing";
registerOTel();
const wrapped = agent("my-agent", async (input: { userMessage: string }) => {
const response = await callLLM(input.userMessage);
return response; // wrapper auto-captures output and closes the span
});
const { result, runId } = await wrapped({ userMessage });
from uselemma_tracing import register_otel, TraceContext, agent
register_otel()
async def run_agent(user_message: str, ctx: TraceContext) -> str:
response = await call_llm(user_message)
return response # wrapper auto-captures output and closes the span
wrapped = agent("my-agent", run_agent)
result, run_id, _ = await wrapped(user_message)