Skip to content

Commit a957627

Browse files
committed
touchups
1 parent 9e624de commit a957627

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

articles/machine-learning/prompt-flow/how-to-integrate-with-langchain.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ ms.date: 10/22/2024
1717

1818
# Integrate LangChain in prompt flows
1919

20-
The [LangChain](https://python.langchain.com) Python library is a framework for developing applications powered by large language models (LLMs), agents, and dependency tools. You can use LangChain in Azure Machine Learning prompt flows. This article shows you how to supercharge your LangChain development with prompt flow.
20+
The [LangChain](https://python.langchain.com) Python library is a framework for developing applications powered by large language models (LLMs), agents, and dependency tools. This article shows you how to supercharge your LangChain development with Azure Machine Learning prompt flow.
2121

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.
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 build the flow, 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.
2323

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.
24+
If you already have a local prompt flow based on LangChain code, you can 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 use your custom LangChain code.
2525

2626
## Prerequisites
2727

2828
- A local LangChain flow that's properly tested and ready for deployment.
2929
- A compute session that can run the Machine Learning prompt flow by adding packages listed in the *requirements.txt* file, including `langchain`. For more information, see [Manage prompt flow compute session](how-to-manage-compute-session.md).
3030

31-
## Convert LangChain code into prompt flows
31+
## Convert LangChain code into a prompt flow
3232

33-
The rest of the article describes how to convert your local LangChain code to a runnable Azure Machine Learning prompt flow.
33+
Use the following process to convert your local LangChain code to a runnable Azure Machine Learning prompt flow.
3434

3535
### Convert credentials to a prompt flow connection
3636

@@ -40,7 +40,7 @@ Your LangChain code might [define environment variables](https://python.langchai
4040

4141
When you run an Azure Machine Learning prompt flow in the cloud, it's better not to expose credentials as environment variables. To securely store and manage credentials separately from your code, you should convert the environmental variables into a prompt flow connection.
4242

43-
To create a connection that securely stores credentials such as your LLM API key or other required keys, follow these instructions:
43+
To create a connection that securely stores custom credentials such as your LLM API key or other required keys, follow these instructions:
4444

4545
1. On the **Prompt flow** page in your Azure Machine Learning workspace, select the **Connections** tab, and then select **Create**.
4646
1. Select a connection type from the dropdown list. For this example, select **Custom**.
@@ -51,23 +51,23 @@ To create a connection that securely stores credentials such as your LLM API key
5151

5252
:::image type="content" source="./media/how-to-integrate-with-langchain/custom-connection-2.png" alt-text="Screenshot of adding custom connection key-value pairs.":::
5353

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.
54+
1. To store an encrypted value for a key, select the **is secret** checkbox next to one or more key-value pairs. You must set at least one value as secret to successfully create a custom connection.
5555

5656
1. Select **Save**.
5757

58-
The custom connection can replace the keys and credentials or corresponding environmental variables explicitly defined in your LangChain code. To use the custom connection in the flow, see [Configure connection](#configure-connection).
58+
The custom connection can replace keys and credentials or corresponding environmental variables explicitly defined in your LangChain code. To use the custom connection in the flow, see [Configure connection](#configure-connection).
5959

6060
### Convert LangChain code to a runnable flow
6161

62-
To create a flow, select **Create** on the **Prompt flow** page in Azure Machine Learning studio, and choose a flow type. On the flow authoring page, start your compute session before you author the flow. Select tool types at the top of the pane to insert corresponding nodes into the flow. For detailed flow authoring instructions, see [Develop prompt flow](how-to-develop-a-standard-flow.md).
62+
To create a flow, select **Create** on the **Prompt flow** page in Azure Machine Learning studio, and choose a flow type. On the flow authoring page, start your compute session before you author the flow. Select tool types at the top of the page to insert corresponding nodes into the flow. For detailed flow authoring instructions, see [Develop prompt flow](how-to-develop-a-standard-flow.md).
6363

6464
All your LangChain code can directly run in Python nodes in your flow, as long as your compute session contains the `langchain` package dependency.
6565

6666
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.
6767

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.
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 lets you easily tune prompts by running variants and choose optimal prompts based on evaluation results.
6969

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.
70+
- For a simpler conversion process, you can call the LangChain LLM library directly from within Python nodes. All your code runs in Python nodes, including prompt definitions. This option supports faster batch testing based on larger datasets or other configurations.
7171

7272
The following example shows a flow that uses both prompt nodes and Python nodes:
7373

@@ -90,15 +90,15 @@ After you structure your flow and move your code to specific tool nodes, you nee
9090

9191
:::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":::
9292

93-
1. Replace the environment variables that originally defined the key and credential with the corresponding key added in the connection.
93+
1. Replace the environment variables that originally defined the key or credential with the corresponding key added in the connection.
9494

9595
1. Parse the input to the input section of the node UI, and then select your custom connection in the **Value** dropdown.
9696

9797
:::image type="content" source="./media/how-to-integrate-with-langchain/custom-connection-python-node-2.png" alt-text="Screenshot of the chain node highlighting the connection. " lightbox = "./media/how-to-integrate-with-langchain/custom-connection-python-node-2.png":::
9898

99-
1. Save, return to the authoring page, and also configure the connection parameter in the node input.
99+
1. Be sure to also configure the connection parameters in any other nodes that require it, such as LLM nodes.
100100

101-
### Configure input and output
101+
### Configure inputs and outputs
102102

103103
Before you run the flow, configure the node inputs and outputs and the overall flow inputs and outputs. This step is crucial to ensure that all the required data passes properly through the flow and produces desired results. For more information, see [Flow inputs and outputs](how-to-develop-flow.md#flow-input-and-output).
104104

-518 Bytes
Loading
1.26 KB
Loading
-6.17 KB
Loading

0 commit comments

Comments
 (0)