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

Docs: Add 'Optional' to installation section to fix an issue #28902

Closed

Conversation

ahmadelmalah
Copy link
Contributor

Problem:
"Optional" object is used in one example without importing, which raises the following error when copying the example into IDE or Jupyter Lab
image

Solution:
Just importing Optional from typing_extensions module, this solves the problem!

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Dec 24, 2024
Copy link

vercel bot commented Dec 24, 2024

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

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 24, 2024 0:09am

@dosubot dosubot bot added the 🤖:docs Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder label Dec 24, 2024
@ahmadelmalah ahmadelmalah changed the title Docs: Fixing 'Optional' is not defined error Docs: Add 'Optional' to installation section to fix an issue Dec 24, 2024
@efriis
Copy link
Member

efriis commented Dec 24, 2024

I'm guessing you didn't run the above code because Optional is imported towards the top of the doc!

@efriis efriis closed this Dec 24, 2024
@ahmadelmalah
Copy link
Contributor Author

Hi @efriis , thanks for your review!
A good guess and this is exactly why I created the PR!

This is not a tutorial where we follow instructions from top to bottom, it's a how-to guide where we select the part we need to apply.

Each method should be an independent working example, because they're different methods serving different purposes.

So, in my case I don't need to copy Pydantic example from above so that TypedDict or JSON work.

and btw, this is good for consistency, as you can see on the other section "Choosing between multiple schemas" we imported Optional again on this line "from typing import Optional, Union" although we imported it early, because they're independent code blocks which makes more sense.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:docs Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

2 participants