Skip to content

Latest commit

 

History

History
63 lines (41 loc) · 1.35 KB

File metadata and controls

63 lines (41 loc) · 1.35 KB

Refinement Chain

This example demonstrates X-Ray analyzing a real LangChain refinement workflow built with runnable composition.

LangChain primitives used:

  • ChatPromptTemplate
  • ChatOpenAI
  • StrOutputParser
  • pipe composition (prompt | llm | parser)

Original inspiration:

Model:

  • default: gpt-4o-mini
  • override with XRAY_LANGCHAIN_MODEL

Requirements:

pip install langchain langchain-openai openai

Run:

python examples/langchain_official/refinement_chain/langchain_official_example.py

This live generation path requires OPENAI_API_KEY.

Replay through the CLI:

python -m cli.main examples/langchain_official/refinement_chain/captured_trace.json

Validate JSON:

python -m json.tool examples/langchain_official/refinement_chain/captured_trace.json

What X-Ray demonstrates:

  • how a real LangChain refinement loop evolves across steps
  • where early improvement gives way to diminishing structural change
  • how the committed trace replays deterministically once saved

Committed artifacts:

Current observed X-Ray output for the committed fixture:

  • peak_step = 1
  • waste = 83%
  • timeline ends in repeated refinement