-
Notifications
You must be signed in to change notification settings - Fork 15.5k
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
langchain_core: add file_type
option to make file type default as png
#27855
Conversation
langchain_core.runnables.graph_mermaid.draw_mermaid_png calls this function, but the Mermaid API returns JPEG as default. Add option `file_type` with default `png` type to be consistent. Also background_color default was wrong and fixed with `!`
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
I mistakenly thought there was an error in the `background_color` option and added a `!` for correction. However, the `!` was already correctly added further down. This commit reverts the incorrect fix.
The `file_type` option was added as the second option, but the other function calling the function `_render_mermaid_using_api` without option names crashes. The `file_type` option was added as the last option, so the effect is controlled locally.
@@ -306,6 +306,7 @@ def _render_mermaid_using_api( | |||
mermaid_syntax: str, | |||
output_file_path: Optional[str] = None, | |||
background_color: Optional[str] = "white", | |||
file_type: Optional[str] = "png", |
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.
could you make the type Optional[Literal["jpeg", "png", "webp"]]
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.
Thank you for the review.
typing.Literal
is imported and type annotation is updated as suggested.
I have updated the type annotations to be more stringent. `Optional[str]` to `Optional[Literal["jpeg", "png", "webp"]]`.
`Literal` has not been imported. Fixed.
…png` (langchain-ai#27855) Thank you for contributing to LangChain! - [ ] **PR title**: "package: description" - Where "package" is whichever of langchain, community, core, etc. is being modified. Use "docs: ..." for purely docs changes, "templates: ..." for template changes, "infra: ..." for CI changes. - Example: "community: add foobar LLM" - [ ] **description** langchain_core.runnables.graph_mermaid.draw_mermaid_png calls this function, but the Mermaid API returns JPEG by default. To be consistent, add the option `file_type` with the default `png` type. - [ ] **Add tests and docs**: If you're adding a new integration, please include With this small change, I didn't add tests and docs. - [ ] **Lint and test**: Run `make format`, `make lint` and `make test` from the root of the package(s) you've modified. See contribution guidelines for more: One long sentence was divided into two. Additional guidelines: - Make sure optional dependencies are imported within a function. - Please do not add dependencies to pyproject.toml files (even optional ones) unless they are required for unit tests. - Most PRs should not touch more than one package. - Changes should be backwards compatible. - If you are adding something to community, do not re-import it in langchain. If no one reviews your PR within a few days, please @-mention one of baskaryan, efriis, eyurtsev, ccurme, vbarda, hwchase17.
Thank you for contributing to LangChain!
PR title: "package: description"
description
langchain_core.runnables.graph_mermaid.draw_mermaid_png calls this function, but the Mermaid API returns JPEG by default. To be consistent, add the option
file_type
with the defaultpng
type.Add tests and docs: If you're adding a new integration, please include
With this small change, I didn't add tests and docs.
Lint and test: Run
make format
,make lint
andmake test
from the root of the package(s) you've modified. See contribution guidelines for more:One long sentence was divided into two.
Additional guidelines:
If no one reviews your PR within a few days, please @-mention one of baskaryan, efriis, eyurtsev, ccurme, vbarda, hwchase17.