Skip to content
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

Merged
merged 7 commits into from
Nov 6, 2024

Conversation

MasaYan24
Copy link
Contributor

@MasaYan24 MasaYan24 commented Nov 2, 2024

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.

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 `!`
Copy link

vercel bot commented Nov 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Nov 6, 2024 8:44pm

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🤖:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs labels Nov 2, 2024
@MasaYan24 MasaYan24 marked this pull request as draft November 2, 2024 21:06
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.
@MasaYan24 MasaYan24 marked this pull request as ready for review November 2, 2024 21:22
@MasaYan24 MasaYan24 marked this pull request as draft November 3, 2024 20:37
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.
@MasaYan24 MasaYan24 marked this pull request as ready for review November 3, 2024 20:44
@@ -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",
Copy link
Contributor

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"]]

Copy link
Contributor Author

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.

@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Nov 5, 2024
I have updated the type annotations to be more stringent. `Optional[str]` to `Optional[Literal["jpeg", "png", "webp"]]`.
`Literal` has not been imported. Fixed.
@vbarda vbarda enabled auto-merge (squash) November 6, 2024 22:34
@vbarda vbarda merged commit 482c168 into langchain-ai:master Nov 6, 2024
78 checks passed
@MasaYan24 MasaYan24 deleted the patch-1 branch November 6, 2024 22:48
yanomaly pushed a commit to yanomaly/langchain that referenced this pull request Nov 8, 2024
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm PR looks good. Use to confirm that a PR is ready for merging. 🤖:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants