Documentation Index
Fetch the complete documentation index at: https://braintrust.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
Summary
To minimize costs while collecting user feedback for dataset curation, use init_logger() to create a logger instance and only call logger.log() when users provide feedback (thumbs up/down). This approach avoids automatic tracing of every interaction and allows manual review before promoting logs to datasets for experiments.
Configuration Steps
Step 1: Initialize logger at startup
Create a logger instance at application startup instead of using traced decorators for automatic logging.
import braintrust
logger = braintrust.init_logger(project="My App")
Step 2: Log only on feedback events
Call logger.log() exclusively when user feedback is received to avoid logging every interaction.
def on_feedback(user_input, agent_output, thumbs_up: bool):
logger.log(
input=user_input,
output=agent_output,
scores={"user_feedback": 1 if thumbs_up else 0},
tags=["user-feedback"],
)
Review logged interactions in the project Logs tab, add additional tags as needed, and promote entries to datasets for running experiments.
Alternative: Direct Dataset Insertion
Skip logging layer entirely
For maximum cost savings, insert directly into datasets when feedback is received without using the logging layer.
import braintrust
dataset = braintrust.init_dataset(project="My App", name="user-feedback")
def on_feedback(user_input, agent_output, thumbs_up: bool):
dataset.insert(
input=user_input,
expected=agent_output,
metadata={"feedback": "positive" if thumbs_up else "negative"},
)