You can also check out our full working example of a RAG pipeline with Pinecone here.
Install the SDK
Run the following command in your terminal:
pip install traceloop-sdk
In your LLM app, initialize the Traceloop tracer like this:
from traceloop.sdk import Traceloop Traceloop.init()
If you’re running this locally, you may want to disable batch sending, so you can see the traces immediately:
Annotate your workflows
If you have complex workflows or chains, you can annotate them to get a better understanding of what’s going on. You’ll see the complete trace of your workflow on Traceloop or any other dashboard you’re using.
We have a set of decorators to make this easier.
Assume you have a function that renders a prompt and calls an LLM, simply add
@workflow (or for asynchronous methods -
If you’re using an LLM framework like Haystack, Langchain or LlamaIndex - we’ll do that for you. No need to add any annotations to your code.
from traceloop.sdk.decorators import workflow @workflow(name="suggest_answers") def suggest_answers(question: str): ...
For more information, see the dedicated section in the docs.
Configure trace exporting
Lastly, you’ll need to configure where to export your traces.
The 2 environment variables controlling this are
For Traceloop, read on. For other options, see Exporting.
Using Traceloop Cloud
Go to Traceloop, and create a new account. Then, click on Environments on the left-hand navigation bar. Or go to directly to https://app.traceloop.com/settings/api-keys. Click Generate API Key to generate an API key for the developement environment and click Copy API Key to copy it over.
Set the copied Traceloop’s API key as an environment variable in your app named
Done! You’ll get instant visibility into everything that’s happening with your LLM. If you’re calling a vector DB, or any other external service or database, you’ll also see it in the Traceloop dashboard.