Enrich your traces by annotating chains and workflows in your app
Traceloop SDK supports several ways to annotate workflows, tasks, agents and tools in your code to get a more complete picture of your app structure.
If you’re using a framework like Langchain, Haystack or LlamaIndex - no need
to do anything! OpenLLMetry will automatically detect the framework and
annotate your traces.
While the examples above shows how to decorate functions, you can also decorate classes.
In this case, you will also need to provide the name of the method that runs the workflow, task, agent or tool.
Python
from openai import OpenAIfrom traceloop.sdk.decorators import agentclient = OpenAI(api_key=os.environ["OPENAI_API_KEY"])@agent(name="base_joke_generator", method_name="generate_joke")classJokeAgent:defgenerate_joke(self): completion = client.chat.completions.create( model="gpt-3.5-turbo", messages=[{"role":"user","content":"Tell me a joke about Traceloop"}],)return completion.choices[0].message.content