Setup logging in your app
Log text messages to phospho in real time
You can setup the logging to phospho in your app in a few minutes.
1. Get your phospho API key and your project id
Go to the phospho platform. Login or create an account if you don’t have one.
If this is your first time using phospho, a Default project has been created for you. On the main page, note down the project id and follow the link to create a new API key.
If you already have a project, go to Settings. Your project id is displayed on the top of the page. To create an API key, click on the Manage Organization & API keys button. Store your API key safely!
2. Setup phospho logging in your app
Add environment variables
In your code, add the following environment variables:
Log to phospho
The basic abstraction of phospho is the task. If you’re a programmer, you can think of tasks like a function.
input (str)
: The text that goes into the system. Eg: the user message.output (Optional[str])
: The text that comes out of the system. Eg: the system response.
We prefer to use this abstraction because of its flexibility. You can log any text to a task, not just chat messages: call to an LLM, answering a question, searching in documents, summarizing a text, performing inference of a model, steps of a chain-of-thought…
Tasks can be grouped into sessions. Tasks and Sessions can be attached to users.
How to setup logging?
The phospho Python module in the easiest way to log to phospho. It is compatible with Python 3.9+.
To log tasks, use phospho.log
. The logged tasks are analyzed by the phospho analytics pipeline.
More about logging in Python
Did you know you could log OpenAI completions, streaming outputs and metadata? Learn more by clicking here.
3. Get insights in the dashboard
phospho run analytics pipelines on the messages logged. Discover the insights in the phospho dashboard.
Next steps
Automatic tagging
Automatically annotate your text data and be alerted. Take action.
Unsupervized clustering
Group users messages based on their intention. Find out what your users are talking about.
AB Testing
Run experiments and iterate on your LLM app, while keeping track of performances. Keep shipping.
Flexible evaluation pipeline
Discover how to run and design a text analytics pipeline using natural language. No code needed.
User analytics
Detect user languages, sentiment, and more. Get to know power users.
Was this page helpful?