Text analytics for LLM apps. The PostHog of text analytics. Extract evaluations, intents and events from text messages. phospho leverages LLM (OpenAI, MistralAI, Ollama, etc.)

Primary LanguagePythonApache License 2.0Apache-2.0

phospho: Text Analytics Platform for LLM Apps

phospho logo phospho npm package phospho Python package on PyPi Y Combinator W24 Discord

Phospho is the text analytics platform for LLM apps. Detect issues and extract insights from text messages of your users or your app. Gather user feedback and measure success. Iterate on your app to create the best conversational experience for your users.

Ship your LLM app in production with confidence, and iterate on it with insights from your users.

Key Features

  • Flexible logging
  • Automatic evaluation
  • Insights extraction
  • Data visualization
  • Collaboration
phospho diagram



Quickstart: Discover the phospho lab

The phospho lab is the core analytics component of phospho. The phospho lab helps you run batched evaluations and event detections on your messages.

Step 1 - Install the phospho lab:

pip install "phospho[lab]"

We will run a simple Event detection job that use OpenAI to read a message and figure out whether an Event happened or not.

export OPENAI_API_KEY=your_openai_api_key

Step 2 - Run the event detection job:

Phospho helps you define a bunch of jobs to efficiently run in a workload on users messages.

from phospho import lab

# A workload is a set of jobs to run on messages
# A job is a Python function that leverages LLM and ML models to extract insights from text
workload = lab.Workload()
            event_description="The user asks a question to the assistant",

# The workload runs the jobs in parallel on all the messages to perform analytics
await workload.async_run(
            content="What is the weather today in Paris?",

message_results = workload.results["my_message_id"]
print(f"The event question_answering was detected: {message_results['question_answering'].value}")

Step 3 - Check the results:

The event question_answering was detected: True

This event detection pipeline can then be linked back to your product or alerting solution (eg. Slack) through webhooks or used to notice patterns in the user data.

You can use other jobs from the phospho library or create your own jobs to run on your messages.

See more examples of what you can do with phospho in the examples folder.

Self deploy

This repository contains the implementation of the platform frontend, the API backend, and the insights extraction pipeline.

  • phospho-python: Python client with analytics engine
  • extractor: FastAPI analytics service wrapping the analytics engine
  • backend: FastAPI backend
  • platform: NextJS frontend
  • internal-tools: Platform management tools
  1. Clone the repo:
git clone git@github.com:phospho-app/monorepo.git
  1. Register to the core external services:

    • OpenAI (or another OpenAI-compatible model provider)
    • Cohere
    • MongoDB Atlas (Alternative: self host a MongoDB)
  2. (Optional) Extend the platform capabilities by registering to additional services:

    • Resend (emails)
    • Sentry (performance analytics)
    • Propelauth (authentication)
    • Stripe (payment)
  3. Follow the deployment instructions in backend/README.md and platform/README.md

  4. Enjoy !

Access the hosted version

To manage the phospho lab evaluations on a collaborative platform, the easiest way is to register to the hosted version.

  1. Create a phospho account
  2. Install a phospho client: pip install phospho or npm i phospho
  3. Create environment variables for PHOSPHO_API_KEY and PHOSPHO_PROJECT_ID
  4. Initialize phospho: phospho.init()
  5. Log to phospho with phospho.log(input="question", output="answer")

Follow this guide to get started.


This project is licensed under the Apache 2.0 License - see the LICENSE file for details

Related projects