Context
Context provides user analytics for LLM-powered products and features.
With Context
, you can start understanding your users and improving their experiences in less than 30 minutes.
In this guide we will show you how to integrate with Context.
Installation and Setup
%pip install --upgrade --quiet langchain langchain-openai langchain-community context-python
Getting API Credentials
To get your Context API token:
- Go to the settings page within your Context account (https://with.context.ai/settings).
- Generate a new API Token.
- Store this token somewhere secure.
Setup Context
To use the ContextCallbackHandler
, import the handler from Langchain and instantiate it with your Context API token.
Ensure you have installed the context-python
package before using the handler.
from langchain_community.callbacks.context_callback import ContextCallbackHandler
API Reference:ContextCallbackHandler
import os
token = os.environ["CONTEXT_API_TOKEN"]
context_callback = ContextCallbackHandler(token)