mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-13 22:59:05 +00:00
Fix CDN URL in mermaid graph renderer (#20381)
Description of features on mermaid graph renderer: - Fixing CDN to use official Mermaid JS CDN: https://www.jsdelivr.com/package/npm/mermaid?tab=files - Add device_scale_factor to allow increasing quality of resulting PNG.
This commit is contained in:
parent
3cbc4693f5
commit
d55a365c6c
@ -185,6 +185,7 @@ async def _render_mermaid_using_pyppeteer(
|
|||||||
output_file_path: Optional[str] = None,
|
output_file_path: Optional[str] = None,
|
||||||
background_color: Optional[str] = "white",
|
background_color: Optional[str] = "white",
|
||||||
padding: int = 10,
|
padding: int = 10,
|
||||||
|
device_scale_factor: int = 3,
|
||||||
) -> bytes:
|
) -> bytes:
|
||||||
"""Renders Mermaid graph using Pyppeteer."""
|
"""Renders Mermaid graph using Pyppeteer."""
|
||||||
try:
|
try:
|
||||||
@ -199,7 +200,9 @@ async def _render_mermaid_using_pyppeteer(
|
|||||||
|
|
||||||
# Setup Mermaid JS
|
# Setup Mermaid JS
|
||||||
await page.goto("about:blank")
|
await page.goto("about:blank")
|
||||||
await page.addScriptTag({"url": "https://unpkg.com/mermaid/dist/mermaid.min.js"})
|
await page.addScriptTag(
|
||||||
|
{"url": "https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"}
|
||||||
|
)
|
||||||
await page.evaluate(
|
await page.evaluate(
|
||||||
"""() => {
|
"""() => {
|
||||||
mermaid.initialize({startOnLoad:true});
|
mermaid.initialize({startOnLoad:true});
|
||||||
@ -236,6 +239,7 @@ async def _render_mermaid_using_pyppeteer(
|
|||||||
{
|
{
|
||||||
"width": int(dimensions["width"] + padding),
|
"width": int(dimensions["width"] + padding),
|
||||||
"height": int(dimensions["height"] + padding),
|
"height": int(dimensions["height"] + padding),
|
||||||
|
"deviceScaleFactor": device_scale_factor,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user