You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/machine-learning/prompt-flow/how-to-integrate-with-langchain.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ The [LangChain](https://python.langchain.com) Python library is a framework for
21
21
22
22
The integration of LangChain with prompt flow is a powerful combination that can help you build and test your custom language models with ease. You can use LangChain modules to initially build the flow, and then use the prompt flow process to scale experiments for bulk testing, evaluation, and eventual deployment. For example, you can conduct large scale experiments based on larger datasets.
23
23
24
-
If you already have a local prompt flow based on LangChain code, you can use streamlined prompt flow integration to easily convert it into an Azure Machine Learning prompt flow for further experimentation. Or, if you prefer to use LangChain SDK classes and functions directly, you can easily build flows with Python nodes that contain your custom LangChain code.
24
+
If you already have a local prompt flow based on LangChain code, you can use streamlined prompt flow integration to easily convert it into an Azure Machine Learning prompt flow for further experimentation. Or, if you prefer to use LangChain SDK classes and functions directly, you can easily build Azure Machine Learning flows with Python nodes that contain your custom LangChain code.
25
25
26
26
## Prerequisites
27
27
@@ -51,7 +51,7 @@ To create a connection that securely stores credentials such as your LLM API key
51
51
52
52
:::image type="content" source="./media/how-to-integrate-with-langchain/custom-connection-2.png" alt-text="Screenshot of adding custom connection key-value pairs.":::
53
53
54
-
1. To store an encrypted value for a key, select the **is secret** checkbox next to one or more key-value pairs. At least one value must be set as secret for the connection creation to succeed.
54
+
1. To store an encrypted value for a key, select the **is secret** checkbox next to one or more key-value pairs. At least one value must be set as secret for custom connection creation to succeed.
55
55
56
56
1. Select **Save**.
57
57
@@ -65,7 +65,7 @@ All your LangChain code can directly run in Python nodes in your flow, as long a
65
65
66
66
There are two ways to convert your LangChain code into an Azure Machine Learning prompt flow. The type of flow to implement depends on your use case.
67
67
68
-
- For better experiment management, you can convert your code to use Azure Machine Learning Python, LLM, and prompt tools in the flow. You extract the prompt template from your code into a prompt node, and put the remaining code in single or multiple Python nodes or tools. This option allows easy prompt tuning by running flow variants. You can choose the optimal prompt based on evaluation results.
68
+
- For better experiment management, you can convert your code to use Azure Machine Learning Python, LLM, and prompt tools in the flow. You extract the prompt template from your code into a prompt node, and put the remaining code in single or multiple Python nodes or tools. This option allows easy prompt tuning by running flow variants, and lets you choose the optimal prompt based on evaluation results.
69
69
70
70
- For a simpler conversion process, you can call the LangChain LLM library directly from within your Python nodes. All your code runs in Python nodes, including prompt definitions. This option permits faster batch testing based on larger scale datasets.
71
71
@@ -81,16 +81,16 @@ The following example shows a flow that uses Python nodes only:
81
81
82
82
After you structure your flow and move your code to specific tool nodes, you need to replace your original environment variables with the corresponding keys from your connection. To use the custom connection you created, follow these steps:
83
83
84
-
1. In your Python code, import the custom connection library by entering`from promptflow.connections import CustomConnection`.
84
+
1. In your Python code, import the custom connection library by entering<br>`from promptflow.connections import CustomConnection`.
85
85
86
86
>[!NOTE]
87
87
>To import an Azure OpenAI connection, use `from promptflow.connections import AzureOpenAIConnection`.
88
88
89
89
1. In your tool function, define an input parameter of the type `CustomConnection`.
90
90
91
-
1. Replace the environment variables that originally defined the key and credential with the corresponding key added in the connection.
92
-
93
91
:::image type="content" source="./media/how-to-integrate-with-langchain/custom-connection-python-node-1.png" alt-text="Screenshot of doc search chain node highlighting the custom connection. " lightbox = "./media/how-to-integrate-with-langchain/custom-connection-python-node-1.png":::
92
+
93
+
1. Replace the environment variables that originally defined the key and credential with the corresponding key added in the connection.
94
94
95
95
1. Parse the input to the input section of the node UI, and then select your custom connection in the **Value** dropdown.
0 commit comments