microsoft / promptflow

Build high-quality LLM apps - from prototyping, testing to production deployment and monitoring.
https://microsoft.github.io/promptflow/
MIT License
9.18k stars 829 forks source link

[BUG] Langchain in promptflow parse failure #3591

Closed SingTeng closed 3 weeks ago

SingTeng commented 1 month ago

Describe the bug I have a flow which use the Vector Index provided in promptflow. At the same time, we are also using langchain to implement contextual compression in the flow.

There're issue parsing the code when importing langchain library in the code.

from langchain.retrievers import ContextualCompressionRetriever

Below is the error message:

Validate and parse input failed : ImportError: cannot import name 'invalid_tool_call' from 'langchain_core.messages.tool' (/azureml-envs/prompt-flow/runtime/lib/python3.9/site-packages/langchain_core/messages/tool.py)

I tried to upgrade the langchain by specifying langchain==0.2.11 in the requirements.txt file but there seems to be some conflict.

How To Reproduce the bug Steps to reproduce the behavior, how frequent can you experience the bug:

  1. In Python tool, import langchain such as 'from langchain.retrievers import ContextualCompressionRetriever'
  2. Click 'Validate and parse input'

Expected behavior Be able to parse code with no error.

Screenshots image

Running Information(please complete the following information):

Additional context

Bowen-Guo commented 1 month ago

To use langchain==0.2.11, I suggest you use our new multi-container experience. Here is what to do:

  1. Add "flight=PFMultiContainer" in the url. For example: https://ml.azure.com/prompts/flow/bb99fa90-4815-4dcb-b9bd-ece6974528be/1db17e33-b6a6-42d1-a092-fb81a4c5a6bd/details?wsid=/subscriptions/96aede12-2f73-41cb-b983-6d11a904839b/resourcegroups/dacai-daily-eastus/providers/Microsoft.MachineLearningServices/workspaces/dacai-daily-ws&flight=PFMultiContainer&tid=72f988bf-86f1-41af-91ab-2d7cd011db47

  2. Add langchain==0.2.11 in the requirements.txt

  3. Start compute session.

AhanaBasak commented 1 day ago

@Bowen-Guo

Facing the same issue even after updating the url and the requirements.txt with langchain ==0.2.11

image

image