langflow-ai / langflow

⛓️ Langflow is a dynamic graph where each node is an executable unit. Its modular and interactive design fosters rapid experimentation and prototyping, pushing hard on the limits of creativity.
http://www.langflow.org
MIT License
17.87k stars 2.68k forks source link

[pre-release alpha bug] ERROR - code_parser - cannot import name 'DocumentSearchHit' from 'langchain_core.documents' #1806

Open msmygit opened 2 weeks ago

msmygit commented 2 weeks ago

Describe the bug When attempting to start langflow post upgrade to Langflow v1.0.0a29 version, we get:

2024-04-30 12:51:20 - ERROR    - code_parser - cannot import name 'DocumentSearchHit' from 'langchain_core.documents'

Entire stacktrace is attached below,

lf-a29-startup-bug_20240430.txt

To Reproduce Steps to reproduce the behavior:

  1. Go to local langflow project virtual environment and perform python -m pip install langflow --pre --force-reinstall -U
  2. Attempt to kick start the langflow using python -m langflow run --env-file ~/langflow/.env [env file is optional here]
  3. See the great wall of error text

Screenshots n/a

Additional context Just attempting to start the langflow post upgrade.

msmygit commented 2 weeks ago

Attempted to perform rm -rf /Users/username/Library/Caches/langflow followed by starting it via python -m langflow run --env-file ~/langflow/.env which yielded the below,

% python -m langflow run --env-file ~/langflow/.env
/Users/username/.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/madhavansridharan/.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                      │
╰───────────────────────────────────────────────────╯

which unfortunately deleted all my local project/flows/components :-(

dosubot[bot] commented 2 weeks ago

To address the import error with DocumentSearchHit from langchain_core.documents, it seems like a compatibility issue with the Langflow v1.0.0a29 update. Try reinstalling Langflow and its dependencies forcefully to see if it resolves the issue: python -m pip install langflow --pre -U --force-reinstall. If the problem persists, this might be a bug in the new release, and reporting it to the Langflow maintainers could help resolve it.

For the deprecation warnings about GuardrailsOutputParser and JsonSpec, you should replace these with their suggested new imports from the langchain_community package. Update your code to import GuardrailsOutputParser from langchain_community.output_parsers.rail_parser and JsonSpec from langchain_community.tools.json.tool. This should eliminate the deprecation warnings and ensure your project is up-to-date with the latest Langflow practices.

Regarding the deletion of your local projects/flows/components, it's crucial to regularly back up your data, especially before performing upgrades or significant changes. If you have backups or version control, you can restore your projects from there. Unfortunately, without a built-in recovery feature in Langflow for such a scenario, manual restoration from backups is the primary solution.

For future reference, always ensure you have a recent backup of your work to prevent data loss during upgrades or when encountering unexpected issues. If these steps don't resolve your issues or if you encounter further problems, reaching out to the Langflow support team or community forums for assistance might provide more specific solutions.

#### Details **Sources** - [src/backend/base/langflow/initial_setup/setup.py](https://github.com/logspace-ai/langflow/blob/dev/src/backend/base/langflow/initial_setup/setup.py) - [docs/docs/migration/possible-installation-issues.mdx](https://github.com/logspace-ai/langflow/blob/dev/docs/docs/migration/possible-installation-issues.mdx) - [src/backend/langflow/interface/tools/constants.py](https://github.com/logspace-ai/langflow/blob/dev/src/backend/langflow/interface/tools/constants.py) - [src/frontend/src/stores/flowsManagerStore.ts](https://github.com/logspace-ai/langflow/blob/dev/src/frontend/src/stores/flowsManagerStore.ts) - [src/backend/langflow/api/v1/flows.py](https://github.com/logspace-ai/langflow/blob/dev/src/backend/langflow/api/v1/flows.py)
**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.