This project demonstrates how to create custom output renderers for LangSmith annotation queues and datasets. It provides a React-based UI that receives data from LangSmith via the postMessage API and displays it in a customizable format.
The renderer displays conversation turns in a clean, chat-like interface with model information, token usage, and metadata for easy annotation.
The annotation queue endpoint includes a Guidelines tab that displays external resources (such as PDF documents) alongside the conversation thread. This allows reviewers to reference documentation, guidelines, or other contextual materials while annotating traces. The guidelines are displayed using a PDF viewer that works seamlessly even when the renderer is loaded in an iframe.
The dataset endpoint supports both regular outputs and reference outputs, displaying them in the same conversation format for easy comparison.
The medical records endpoint demonstrates domain-specific formatting, displaying structured medical data including patient information, vital signs, diagnoses, medications, and clinical notes in a native medical record format.
- Multi-turn Conversation View: Automatically parses and displays messages as conversation turns (human + AI pairs)
- Model Information: Shows model name, provider, and token usage for each AI response
- Token Usage Display: Detailed token metrics including input/output/total tokens and cache statistics
- Raw Payload Inspector: Toggle to view the complete raw payload structure for debugging
- Annotation-Friendly UI: Clean, chat-like interface optimized for reviewers to annotate threads
- Real-time Updates: Automatically displays new messages as they arrive from LangSmith
- Node.js 18+ and npm/yarn
- ngrok (for exposing the local server)
- Install dependencies:
npm install- Start the development server:
npm run devThe server will start on http://localhost:8000.
- Install ngrok (if not already installed):
# macOS
brew install ngrok
# Or download from https://ngrok.com/download- In a separate terminal, expose your local server:
ngrok http 8000- Copy the public URL provided by ngrok (e.g.,
https://abc123.ngrok-free.app)
This project provides multiple endpoints for different use cases:
/annotation-queue- For annotation queues in LangSmith/dataset- For datasets (supports both output and reference outputs)/medical- Domain-specific formatting for medical records
The root path (/) displays a selector page to choose between endpoints.
The custom renderer supports domain-specific formatting to display specialized data types in their native format:
- Medical Records (
/medical): Structured display of patient information, vital signs, diagnoses, medications, and clinical notes
See the examples/ directory for example datasets.
- Navigate to the Annotation Queues page in LangSmith
- Click on an existing annotation queue or create a new one
- In the annotation queue settings pane, scroll to the Custom Output Rendering section
- Toggle Enable custom output rendering
- Enter your ngrok URL with the
/annotation-queuepath:https://abc123.ngrok-free.app/annotation-queue - Click Save or Create
Example: If your ngrok URL is https://abc123.ngrok-free.app, use https://abc123.ngrok-free.app/annotation-queue
External Resources for Reviewers: The annotation queue endpoint includes a tabbed interface with a Guidelines tab that displays external resources (PDFs, documentation, etc.) alongside the conversation thread. To add guidelines, place a PDF file in the public/ directory (e.g., public/customer-support-guidelines.pdf) and it will be accessible via the Guidelines tab. This allows reviewers to reference important documentation, guidelines, or contextual materials while annotating traces without leaving the annotation interface.
- Navigate to your dataset in the Datasets & Experiments page
- Click ⋮ (three-dot menu) in the top right corner
- Select Custom Output Rendering
- Toggle Enable custom output rendering
- Enter your ngrok URL with the
/datasetpath:https://abc123.ngrok-free.app/dataset - Click Save
Example: If your ngrok URL is https://abc123.ngrok-free.app, use https://abc123.ngrok-free.app/dataset
Note: The dataset endpoint supports both "output" and "reference" message types. Reference outputs are clearly labeled in the UI.
LangSmith sends messages via the postMessage API with the following structure:
{
type: "output" | "reference",
data: {
// The outputs (actual output or reference output)
// Structure varies based on your application
},
metadata: {
inputs: {
// The inputs that generated this output
// Structure varies based on your application
}
}
}type: Indicates whether this is an actual output ("output") or a reference output ("reference")data: The output data itselfmetadata.inputs: The input data that generated this output, provided for context
LangSmith uses an exponential backoff retry mechanism to ensure your page receives the data even if it loads slowly. Messages are sent up to 6 times with increasing delays (100ms, 200ms, 400ms, 800ms, 1600ms, 3200ms).
.
├── pages/
│ ├── _app.js # Next.js app wrapper
│ ├── index.js # Landing page with endpoint selector
│ ├── annotation-queue.js # Annotation queue endpoint
│ └── dataset.js # Dataset endpoint
├── components/
│ └── ConversationTurn.js # Reusable conversation turn component
├── utils/
│ └── conversation.js # Conversation parsing utilities
├── styles/
│ ├── globals.css # Global styles
│ └── App.module.css # Component styles (CSS Modules)
├── next.config.js # Next.js configuration
└── package.json # Dependencies
npm run build
npm startThe built files will be in the .next directory.
The renderer automatically parses LangSmith messages and displays them as conversation turns. Each turn shows:
- User messages (left-aligned, blue background)
- AI assistant messages (right-aligned, green background) with:
- Model name and provider
- Token usage (input/output/total)
- Cache statistics (if available)
- Stop reason
- Tool calls count (if any)
- Raw payload toggle to view the complete JSON structure
This makes it easy for reviewers to understand the conversation flow and annotate threads effectively.
The /medical endpoint demonstrates how to format medical records in a structured, readable format:
- Patient Information: Name, age, ID, demographics
- Vital Signs: Blood pressure, heart rate, temperature, etc.
- Diagnosis: ICD codes and descriptions
- Medications: Dosage, frequency, duration
- Clinical Notes: Formatted clinical documentation
Example datasets are available in CSV format:
examples/medical-records-dataset.csv- Ready to upload to LangSmith
- Navigate to Datasets & Experiments in LangSmith
- Click Create Dataset → Upload CSV
- Select the CSV file from the
examples/directory - Map columns:
- Input columns:
input_question(orinput) - Output columns:
output(for regular outputs) oroutput_answer(for reference outputs)
- Input columns:
- Configure custom output rendering URL with the appropriate endpoint path
When configuring an annotation queue, use:
https://your-ngrok-url.ngrok-free.app/annotation-queue
This endpoint is optimized for annotation workflows and displays conversation turns with all relevant metadata for reviewers.
When configuring a dataset, use:
https://your-ngrok-url.ngrok-free.app/dataset
This endpoint supports both:
- Output messages: Actual run outputs from your application
- Reference messages: Expected/reference outputs for comparison
The UI clearly indicates when viewing a reference output vs. an actual output.
MIT



