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
@@ -30,12 +30,13 @@ In this tutorial, you learn how to use the packages `langchain-azure-ai` to buil
30
30
To run this tutorial, you need:
31
31
32
32
* An [Azure subscription](https://azure.microsoft.com).
33
-
* A model deployment supporting the [Model Inference API](https://aka.ms/azureai/modelinference) deployed. In this example, we use a `Mistral-Large-2407` deployment in the [Foundry Models](../../../ai-foundry/model-inference/overview.md).
33
+
34
+
* A model deployment supporting the [Model Inference API](https://aka.ms/azureai/modelinference) deployed. In this example, we use a `Mistral-medium-2505` deployment in the [Foundry Models](../../../ai-foundry/model-inference/overview.md).
34
35
* Python 3.9 or later installed, including pip.
35
36
* LangChain installed. You can do it with:
36
37
37
38
```bash
38
-
pip install langchain-core
39
+
pip install langchain
39
40
```
40
41
41
42
* In this example, we're working with the Model Inference API, hence we install the following packages:
@@ -63,7 +64,7 @@ To use LLMs deployed in Azure AI Foundry portal, you need the endpoint and crede
63
64
> [!TIP]
64
65
> If your model was deployed with Microsoft Entra ID support, you don't need a key.
65
66
66
-
In this scenario, we placed both the endpoint URL and key in the following environment variables:
67
+
In this scenario, set the endpoint URL and key as environment variables. (If the endpoint you copied includes additional text after `/models`, remove it so the URL ends at `/models` as shown below.)
> **Breaking change:** Parameter `model_name` was renamed `model` in version `0.1.3`.
@@ -104,7 +97,7 @@ from langchain_azure_ai.chat_models import AzureAIChatCompletionsModel
104
97
model = AzureAIChatCompletionsModel(
105
98
endpoint=os.environ["AZURE_INFERENCE_ENDPOINT"],
106
99
credential=DefaultAzureCredential(),
107
-
model="mistral-large-2407",
100
+
model="mistral-medium-2505",
108
101
)
109
102
```
110
103
@@ -122,7 +115,7 @@ from langchain_azure_ai.chat_models import AzureAIChatCompletionsModel
122
115
model = AzureAIChatCompletionsModel(
123
116
endpoint=os.environ["AZURE_INFERENCE_ENDPOINT"],
124
117
credential=DefaultAzureCredentialAsync(),
125
-
model="mistral-large-2407",
118
+
model="mistral-medium-2505",
126
119
)
127
120
```
128
121
@@ -142,21 +135,13 @@ model = AzureAIChatCompletionsModel(
142
135
143
136
Let's first use the model directly. `ChatModels` are instances of LangChain `Runnable`, which means they expose a standard interface for interacting with them. To call the model, we can pass in a list of messages to the `invoke` method.
144
137
145
-
```python
146
-
from langchain_core.messages import HumanMessage, SystemMessage
147
-
148
-
messages = [
149
-
SystemMessage(content="Translate the following from English into Italian"),
Models deployed to Azure AI Foundry support the Model Inference API, which is standard across all the models. Chain multiple LLM operations based on the capabilities of each model so you can optimize for the right model based on capabilities.
193
171
194
-
In the following example, we create two model clients. One is a producer and another one is a verifier. To make the distinction clear, we're using a multi-model endpoint like the [Model Inference API](../../model-inference/overview.md) and hence we're passing the parameter `model` to use a `Mistral-Large` and a `Mistral-Small` model, quoting the fact that **producing content is more complex than verifying it**.
195
-
196
-
```python
197
-
from langchain_azure_ai.chat_models import AzureAIChatCompletionsModel
172
+
In the following example, we create two model clients. One is a producer and another one is a verifier. To make the distinction clear, we're using a multi-model endpoint like the [Foundry Models API](../../model-inference/overview.md) and hence we're passing the parameter `model` to use a `Mistral-Medium` and a `Mistral-Small` model, quoting the fact that **producing content is more complex than verifying it**.
The previous chain returns the output of the step `verifier` only. Since we want to access the intermediate result generated by the `producer`, in LangChain you need to use a `RunnablePassthrough` object to also output that intermediate step. The following code shows how to do it:
188
+
The previous chain returns the output of the step `verifier` only. Since we want to access the intermediate result generated by the `producer`, in LangChain you need to use a `RunnablePassthrough` object to also output that intermediate step.
245
189
246
190
```python
247
191
from langchain_core.runnables import RunnablePassthrough, RunnableParallel
0 commit comments