This demo shows how to fetch and display custom metrics from the Galileo API after running LLM calls.
logstreams/logstream_demo.py- Runs LLM calls with Galileo logginglogstreams/fetch_session_metrics.py- Fetches and displays session metricslogstreams/fetch_logstream_metrics.py- Fetches and displays logstream metricsexperiments/create_dataset.py- Creates a dataset for legal advice detection testingexperiments/run_experiment.py- Runs an experiment using the dataset to test metricsexperiments/fetch_experiment.py- Fetches and displays experiment results by IDenv.template- Environment variables templateREADME.md- This file
- Install dependencies:
pip install galileo openai python-dotenv requests- Set up environment variables:
# Copy the template and fill in your values
cp env.template .env
# Edit .env with your actual credentialsRequired environment variables:
GALILEO_API_KEY- Your Galileo API keyGALILEO_PROJECT- Your Galileo project nameGALILEO_PROJECT_ID- Your Galileo project IDGALILEO_LOG_STREAM- Your Galileo log streamGALILEO_CONSOLE_URL- Your Galileo console URLGALILEO_API_URL- Your Galileo API URLOPENAI_API_KEY- Your OpenAI API key
python logstreams/logstream_demo.py# Fetch session metrics
python logstreams/fetch_session_metrics.py <session_id>
# Fetch logstream metrics (all sessions in a logstream)
python logstreams/fetch_logstream_metrics.py
# OR with explicit project and logstream names
python logstreams/fetch_logstream_metrics.py "My Project" "My Logstream"python experiments/create_dataset.pypython experiments/run_experiment.pypython experiments/fetch_experiment.py <experiment_id>- Runs legal advice LLM calls with Galileo logging
- Shows contrast between legal and non-legal questions
- Displays session ID for metrics fetching
- Fetches session metrics from Galileo API
- Displays comprehensive metrics from all levels (session, trace, span)
- Shows custom metrics like legal advice detection
- Fetches all metrics for a logstream using environment variables or explicit arguments
- Uses sessions, traces, and spans search with pagination to get complete data
- Returns hierarchical JSON with all sessions, traces, and spans in the logstream
- Environment variables:
GALILEO_PROJECTandGALILEO_LOG_STREAM - Command-line usage:
python fetch_logstream_metrics.py "Project Name" "Logstream Name"
- Creates a dataset with legal advice input-output pairs
- Contains examples where users ask for legal advice
- Shows proper refusals where the system politely declines to give legal advice
- Perfect for testing the "Legal Advice Offered" metric
- Fetches the dataset by name
- Runs an experiment using the dataset
- Tests the "Legal Advice Offered" metric on all dataset examples
- Uses a simple LLM function similar to the demo
- Provides experiment ID for fetching results separately
- Fetches experiment results by ID from Galileo API
- Displays comprehensive results including metrics and feedback
- Shows dataset information and experiment details
- Standalone script for fetching any experiment results
The demo will show:
- LLM responses
- Polling progress
- Session metrics
- Trace metrics
- Span metrics
- Metric info with status and values