-
Notifications
You must be signed in to change notification settings - Fork 222
interactive widget #894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
interactive widget #894
Conversation
Preview ID generated: preview-srinte-1760463295-dee7375 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds an interactive visualization widget for LangChain middleware hooks that demonstrates how different middleware configurations affect agent execution flow. The widget provides language-specific diagrams that automatically switch between Python (snake_case) and JavaScript (camelCase) naming conventions.
Key Changes:
- Interactive HTML widget with checkboxes to toggle different middleware hooks
- Dynamic diagram generation using Mermaid.js that updates based on selected hook combinations
- Language detection that adapts hook names and diagrams based on the current documentation context
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
src/plugins/middleware_visualization/index.html |
Main interactive widget with styling, controls, and JavaScript logic |
src/plugins/middleware_visualization/generate_middleware_diagrams.py |
Python script to generate all possible middleware hook combination diagrams |
src/plugins/middleware_visualization/diagrams_python.js |
Pre-generated Python diagrams with snake_case naming |
src/plugins/middleware_visualization/diagrams_js.js |
Pre-generated JavaScript diagrams with camelCase naming |
src/plugins/middleware_visualization/README.md |
Documentation for the widget usage and regeneration process |
src/oss/langchain/middleware.mdx |
Enhanced middleware documentation with detailed hook descriptions |
src/oss/langchain/agents.mdx |
Added visualization section with embedded widget |
tests/unit_tests/test_builder.py |
Added .html to supported file extensions |
pipeline/core/builder.py |
Updated build pipeline to handle HTML files and plugin directories |
pyproject.toml |
Excluded diagram generator from linting and type checking |
font-size: 0.75rem; | ||
} | ||
|
Copilot
AI
Oct 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate font-size declaration. The .section-title
class already has font-size: 0.875rem
on line 71, and this line overrides it with a different value. Consider removing one of these declarations or using a more specific selector if different font sizes are needed.
font-size: 0.75rem; | |
} | |
} |
Copilot uses AI. Check for mistakes.
/* Inline code styling to match Mintlify */ | ||
code { | ||
font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace); | ||
font-size: 1.25em; |
Copilot
AI
Oct 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The font-size of 1.25em for inline code seems unusually large and may cause layout issues. Consider using a more standard size like 0.875em or 0.9em for better readability and consistency with typical code formatting.
font-size: 1.25em; | |
font-size: 0.9em; |
Copilot uses AI. Check for mistakes.
<script id="diagrams-python" src="./diagrams_python.js"></script> | ||
<script id="diagrams-js" src="./diagrams_js.js"></script> |
Copilot
AI
Oct 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These script tags with src attributes don't need id attributes since they're not being referenced by their IDs in the code. The id attributes can be removed for cleaner HTML.
<script id="diagrams-python" src="./diagrams_python.js"></script> | |
<script id="diagrams-js" src="./diagrams_js.js"></script> | |
<script src="./diagrams_python.js"></script> | |
<script src="./diagrams_js.js"></script> |
Copilot uses AI. Check for mistakes.
class DemoModel(SimpleChatModel): | ||
"""Demo model for generating diagrams.""" | ||
|
||
def _call(self, messages, stop=None, run_manager=None, **kwargs): |
Copilot
AI
Oct 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method parameters should have type hints for consistency with modern Python practices. Consider adding type annotations for messages
, stop
, run_manager
, and the return type.
Copilot uses AI. Check for mistakes.
(r"BeforeAgentMiddleware\\2ebefore_agent", "BeforeAgentMiddleware"), | ||
(r"BeforeModelMiddleware\\2ebefore_model", "BeforeModelMiddleware"), | ||
(r"AfterModelMiddleware\\2eafter_model", "AfterModelMiddleware"), | ||
(r"AfterAgentMiddleware\\2eafter_agent", "AfterAgentMiddleware"), |
Copilot
AI
Oct 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These regex replacements are removing the hook name portion but keeping the class name, which may not provide the intended cleanup. Consider whether these replacements should completely remove the escaped dot notation or replace it with something more meaningful.
(r"BeforeAgentMiddleware\\2ebefore_agent", "BeforeAgentMiddleware"), | |
(r"BeforeModelMiddleware\\2ebefore_model", "BeforeModelMiddleware"), | |
(r"AfterModelMiddleware\\2eafter_model", "AfterModelMiddleware"), | |
(r"AfterAgentMiddleware\\2eafter_agent", "AfterAgentMiddleware"), | |
(r"BeforeAgentMiddleware\\2ebefore_agent", "beforeAgent"), | |
(r"BeforeModelMiddleware\\2ebefore_model", "beforeModel"), | |
(r"AfterModelMiddleware\\2eafter_model", "afterModel"), | |
(r"AfterAgentMiddleware\\2eafter_agent", "afterAgent"), |
Copilot uses AI. Check for mistakes.
No description provided.