feat: add LangChain integration, docs and example#54
Open
Conversation
Add comprehensive LangChain integration guide covering: - LLM proxy setup to route ChatOpenAI calls through LLMOps gateway - OpenTelemetry tracing configuration for full chain observability - Support for direct provider routing, streaming, embeddings, and tool calling - Examples in both TypeScript and Python Includes new @llmops/langchain-example with Express server, LLMOps SDK setup, and endpoints for chat completions, streaming, and embeddings.
LangChain's ChatOpenAI does not append /v1/ automatically unlike the OpenAI SDK, causing 404 on /api/genai/chat/completions.
Accumulate delta.content from SSE chunks in the streaming cost extractor so streaming responses show output in the trace view instead of "No output captured".
provider() sets x-llmops-internal which skips trace creation, expecting a separate OTLP exporter. Use explicit baseURL instead so the gateway creates traces automatically.
OTLP handler, trace batch writer, credentials cache, gateway adapter, and playground execute were all logging internal processing details at info level, cluttering production output.
… client Add full LangChain trace capture (agents, chains, tools, LLM calls) as nested spans. Two integration paths: - TypeScript SDK: llmopsClient.langchainTracer() with LangChainTracer - Python/env vars: LANGCHAIN_ENDPOINT pointed at /api/langsmith New files: - LangSmith HTTP handler (GET /info, POST /runs/batch) - SDK LangChain client (buffer-and-merge strategy, in-process routing) Updated example with agent + tools using the tracer, and docs with all three tracing approaches (SDK, env vars, OpenTelemetry).
- Use full 32-char UUID hex for spanId (was truncated to 16 chars, causing collisions with UUID v7 time-ordered IDs from LangChain) - Fix TraceBatchWriter flush order: insert spans before upserting traces to prevent spanCount inflation on re-queue - Make batchInsertSpans/Events skip invalid items instead of failing the entire batch - Add response status check to SDK langchain-client postBatch - Classify LangSmith spans by run_type for proper color coding (llm=blue, tool/retriever=green, embedding=cyan, chain=purple)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds comprehensive LangChain integration for Amarillo, enabling users to route LangChain LLM calls through the LLMOps gateway and send execution traces to the built-in OTLP endpoint.
Changes
docs/content/docs/integrations/langchain.mdx): Documents both LLM proxy setup and OpenTelemetry tracing configuration with TypeScript and Python examplesexamples/langchain/): Full-stack Express server with LLMOps middleware showing chat completions, streaming, and embeddings endpointsThis enables organizations to replace LangSmith with Amarillo's native observability for full chain tracing via OTLP.