Skip to main content
Langextract transforms PraisonAI agent runs into self-contained interactive HTML visualizations, grounding extractions in the original input text for deeper analysis.

Quick Start

1

Install langextract

Install PraisonAI with langextract support:
2

Programmatic Usage

Set up langextract observability for any agent run:
3

CLI Usage

Use langextract with any PraisonAI workflow:

How It Works

Event TypeExtraction ClassGroundedDescription
AGENT_STARTagent_runFirst 200 chars of inputAgent run initiation
TOOL_STARTtool_callNo (ungrounded)Tool execution start
TOOL_ENDtool_resultNoTool execution result
OUTPUTfinal_outputFirst 1000 chars of outputAgent final output
ERRORerrorNoError events

Configuration Options

The LangextractSinkConfig class provides comprehensive configuration:
OptionTypeDefaultDescription
output_pathstr"praisonai-trace.html"HTML file written on close()
jsonl_pathOptional[str]NoneAnnotated-documents JSONL path (derived from output_path if None)
document_idstr"praisonai-run"Document ID in the JSONL
auto_openboolFalseOpen the HTML in a browser after render
include_llm_contentboolTrueInclude response text in attributes
include_tool_argsboolTrueInclude tool args in attributes
enabledboolTrueMaster switch

CLI Reference

render command

Render a YAML workflow with langextract observability:
Options:
  • -o, --output FILE: Output HTML file path (default: workflow.html)
  • --no-open: Don’t open HTML in browser automatically
  • --api-url URL: API URL if using remote API

view command

Render an existing annotated-documents JSONL to HTML:
Options:
  • -o, --output FILE: Output HTML file path (default: trace.html)
  • --no-open: Don’t open HTML in browser automatically

—observe flag

Instrument any PraisonAI command with langextract:

Common Patterns


Troubleshooting

Ensure you call sink.close() to trigger the rendering process. The CLI commands handle this automatically, but programmatic usage requires explicit closure.
Install langextract with the PraisonAI extra:
This installs both PraisonAI and the required langextract dependency.
Verify that your agent actually emits trace events. Single agents require proper trace emitter setup as shown in the examples above.
Check the auto_open configuration:
For CLI commands, remove the --no-open flag.

Best Practices

Disable automatic browser opening in automated environments:
Restore the previous emitter after your run to avoid affecting other code:
Set meaningful document IDs for easier trace identification:
Langextract rendering failures don’t break agent execution - check logs for details:

Observability Overview

Compare all observability providers

Langfuse Integration

Hosted observability alternative