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

Update deprecated langchin output parser to maintained imports #1820

Open
msmygit opened this issue May 2, 2024 · 8 comments
Open

Update deprecated langchin output parser to maintained imports #1820

msmygit opened this issue May 2, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@msmygit
Copy link
Contributor

msmygit commented May 2, 2024

Describe the bug
Currently within the dev branch, we are leveraging deprecated output parsers package from langchain. We need to update to use the community and supported version.

Browser and Version
n/a

To Reproduce
Steps to reproduce the behavior:

  1. Install and just start langflow run to see the deprecation warnings as below,
% python -m langflow run --env-file ~/langflow/.env
/Users/madhavan/.pyenv/versions/langflow/lib/python3.10/site-packages/langchain/_api/module_import.py:87: LangChainDeprecationWarning: Importing GuardrailsOutputParser from langchain.output_parsers is deprecated. Please replace the import with the following:
from langchain_community.output_parsers.rail_parser import GuardrailsOutputParser
  warnings.warn(
/Users/madhavan/.pyenv/versions/langflow/lib/python3.10/site-packages/langchain/_api/module_import.py:87: LangChainDeprecationWarning: Importing JsonSpec from langchain.tools.json is deprecated. Please replace the import with the following:
from langchain_community.tools.json.tool import JsonSpec
  warnings.warn(
Starting Langflow v1.0.0a29...
╭───────────────────────────────────────────────────╮
│ Welcome to ⛓ Langflow                             │
│                                                   │
│                                                   │
│ Collaborate, and contribute at our GitHub Repo 🚀 │
│                                                   │
│ Access http://127.0.0.1:7860                      │
╰───────────────────────────────────────────────────╯

Screenshots
n/a

Additional context
n/a

Copy link

dosubot bot commented May 2, 2024

To address the deprecation warnings and update your project to use the langchain_community package, follow these steps:

  1. Change Import Paths: Update your import statements to use langchain_community instead of langchain. For instance, replace:
from langchain.output_parsers import GuardrailsOutputParser

with:

from langchain_community.output_parsers.rail_parser import GuardrailsOutputParser

And:

from langchain.tools.json import JsonSpec

with:

from langchain_community.tools.json.tool import JsonSpec
  1. Review Dynamic Imports: If your project dynamically imports modules, ensure the import strings reflect the new langchain_community package name.

  2. Handle Mixed Imports Carefully: If your project uses both langchain and langchain_community, update only the deprecated parts to langchain_community. Keep imports from langchain that don't have equivalents in the new package as they are.

  3. Test Your Application: After making these changes, thoroughly test your application to ensure all functionalities work as expected without introducing new issues.

By following these steps, you'll migrate away from deprecated langchain imports to the supported langchain_community package, aligning your project with the latest standards and avoiding deprecation warnings.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

@dosubot dosubot bot added the bug Something isn't working label May 2, 2024
@bchabros
Copy link

bchabros commented May 7, 2024

@dosu

I have the same issue but this warning appear when I import PydanticOutputParser

from langchain.output_parsers import PydanticOutputParser

when I'tried change it on GuardrailsOutputParser it was completly different class.

Do you have any idea how to fix it this warning?

@dongtandung2001
Copy link

dongtandung2001 commented May 7, 2024

@dosu I don't know why I did not import that package but still get the same warnning
image

@massi-ang
Copy link

I am getting the same issue, and nowhere in my code I import the GuardrailsOutputParser package. This must be something imported by some other langchain module.

@dongtandung2001
Copy link

I am getting the same issue, and nowhere in my code I import the GuardrailsOutputParser package. This must be something imported by some other langchain module.

I had to revert to this version to not get that warning
image

@ilude
Copy link

ilude commented May 8, 2024

Tried changing to @dongtandung2001 versions did not work for me.

Tried @dosu (bot) suggestion to use from langchain_community.output_parsers instead of what I have below also did not work:

from langchain_community.llms import Ollama
from langchain.prompts import ChatPromptTemplate, PromptTemplate, HumanMessagePromptTemplate
from langchain_core.messages import SystemMessage
from langchain.output_parsers import ResponseSchema, StructuredOutputParser

Guessing its something to do with the StructuredOutputParser import, but have not had time to dig any further into it.

@ogabrielluiz
Copy link
Contributor

Hey all

This should be related to the some of the LangchainTypeCreators that are being fazed out soon.

@llm-user
Copy link

pip install langchain==0.1.19 solved it for me. This Stack Overflow discussion has some info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants