Do not index
Do not index
Original Paper
Blog URL
Athina Tracing works with Langchain through Langchain Callbacks, a feature of the Athina Logger SDK.
This SDK automatically generates detailed, nested traces for each Langchain application execution, which can then be used to set up monitoring, debugging, alerting and evaluations.
Importance of Tracing
Here is what a Langchain trace looks like once it is logged to Athina. Try out our interactive demo below.
For developers working with Language Learning Models (LLMs), tracing and logging are crucial for:
- Observability
- Debugging
- Performance monitoring
- Ensuring applications run smoothly
Athina's tracing capabilities enable automatic capture of detailed execution flows and data interactions, vital for optimizing and scaling applications.
How It Works
Athina's tracing mechanism involves attaching a callback handler to your Langchain application. This handler gathers detailed run information and transmits it to Athina's platform for viewing and analysis, with minimal codebase modifications required.
Step-by-Step Tutorial
Follow these steps to set up Langchain tracing with Athina:
Step 1: Install Necessary Packages
Install Athina Logger SDK, Langchain, and Langchain OpenAI using pip:
pip install athina-logger langchain --upgrade
Step 2: Set Up Athina API Key
Enable logging with your Athina API Key:
from athina_logger.api_key import AthinaApiKey
import os
AthinaApiKey.set_api_key(os.getenv('ATHINA_API_KEY'))
Step 3: Configure Langchain Callback Handler
Set up the Langchain Callback Handler to trace every execution:
from athina_logger.tracing.callback.langchain import LangchainCallbackHandler
athina_handler = LangchainCallbackHandler()
Step 4: Add the Athina callback handler to start logging Langchain traces
chain = LLMChain(llm=ChatOpenAI(openai_api_key=OPENAI_KEY), prompt=chat_prompt)
# THIS IS ALL YOU NEED TO ADD
response = chain.invoke('AI', {'callbacks': [athina_handler]})
That’s it! You’re all done 🎉
Need Help?
For any inquiries or further assistance with tracing integration for your Langchain applications, contact us at hello@athina.ai or visit https://athina.ai. We’re here to support you!