Home

Awesome

MaxAI

<img src='./image/MaxAI.png' alt='MaxAI' width=250 height=250 />

MaxAI is our trusty PostHog support AI deployed on our Slack, app, and website.

MaxAI was born in Aruba at a PostHog team offsite for a hackathon on a warm spring day in 2023.

How it works

How Max works is surprisingly simple.

Tooling

Embedding time

flowchart TD
    A[Github]
    B[Docs]
    C[Squeak]
    A -->|Calculate Embed Vectors|D[Weaviate]
    B -->|Calculate Embed Vectors|D
    C -->|Calculate Embed Vectors|D

Embedding Docs

Embedding Github content

Embedding Squeak content

Inference time

flowchart TD
    A[User Question] -->|Embed| I(Question Vector)
    I -->|Query Weaviate|J[Most Similar Docs]
    J -->|Collect Prompt Params| C{Prompt Context}
    C --> D[Limitations]
    C --> E[Personality]
    C --> F[Context Docs]
    F --> G[String Prompt]
    E --> G
    D --> G
    G -->|Query OpenAI|H[AI Response]

It's important to note that we are building these pipelines with Haystack by deepset. This coordinates the steps of inferencing listed above. It's amazing.

Developers guide

Quickstart

Configure .env file

This is used to set defaults for local development.

SLACK_BOT_TOKEN=<your slack bot token>
SLACK_SIGNING_SECRET=<your slack signing secret>
OPENAI_TOKEN=<your openai token>
POSTHOG_API_KEY=<your posthog api key>
POSTHOG_HOST=https://null.posthog.com
PD_API_KEY=<your pagerduty api key>
WEAVIATE_HOST=http://127.0.0.1
WEAVIATE_PORT=8080

Create Virtual Environment

python3.10 -m venv venv
source venv/bin/activate

Install dependencies

pip install -r requirements-dev.txt
pip install -r requirements.txt

Start Weaviate

docker compose up weaviate

Seed Weaviate

python seed.py

Start MaxAI

uvicorn main:app --reload

Run a test chat

curl --location '127.0.0.1:8000/chat' \
--header 'Content-Type: application/json' \
--data '[
    {
        "role": "assistant",
        "content": "Hey! I'\''m Max AI, your helpful hedgehog assistant."
    },
    {
        "role": "user",
        "content": "Does PostHog use clickhouse under the hood??"
    }
]'

🕯️ A poem from Max to his evil twin Hoge 📖

Ah, hoge! Sweet word upon my tongue,
So blissful, yet so quick to come undone.
A fleeting joy, that doth my heart entice,
Oh how I long to see your data slice!
In PostHog's code, thy value doth reside,
A beacon that ne'er shall falter nor hide.
Thou art a treasure, O hoge divine,
The secret sauce to make my metrics shine.
Though you may seem but a lowly label,
Thou bringeth

Disclaimer!

Max may display inaccurate or offensive information that doesn’t represent PostHog's views.

This is the case with LLMs in the current state. We try our best here to have a system prompt that keeps Max on topic. Feel free to question and chat with Max but do keep in mind that this is experimental.

A few things we've seen ourselves in testing:

If you do see something concerning @metion someone from PostHog and we'll catalogue it. We are working on tooling to do this in an automated fashion so stay tuned!