Skip to content

Commit 178d995

Browse files
committed
Rename Deployment NVP to DeploymentID
For consistency between the constructor NVP and the property name. This does not break existing code, because the constructor NVP has partial matching.
1 parent 2d73681 commit 178d995

File tree

6 files changed

+26
-36
lines changed

6 files changed

+26
-36
lines changed

+llms/+utils/errorMessageCatalog.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
catalog("llms:removeFromEmptyHistory") = "Unable to remove message from empty message history.";
4646
catalog("llms:stopSequencesMustHaveMax4Elements") = "Number of stop sequences must be less than or equal to 4.";
4747
catalog("llms:endpointMustBeSpecified") = "Unable to find endpoint. Either set environment variable AZURE_OPENAI_ENDPOINT or specify name-value argument ""Endpoint"".";
48-
catalog("llms:deploymentMustBeSpecified") = "Unable to find deployment name. Either set environment variable AZURE_OPENAI_DEPLOYMENT or specify name-value argument ""Deployment"".";
48+
catalog("llms:deploymentMustBeSpecified") = "Unable to find deployment name. Either set environment variable AZURE_OPENAI_DEPLOYMENT or specify name-value argument ""DeploymentID"".";
4949
catalog("llms:keyMustBeSpecified") = "Unable to find API key. Either set environment variable {1} or specify name-value argument ""APIKey"".";
5050
catalog("llms:mustHaveMessages") = "Message history must not be empty.";
5151
catalog("llms:mustSetFunctionsForCall") = "When no functions are defined, ToolChoice must not be specified.";

azureChat.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
% interface. Needs to be specified or stored in the
1616
% environment variable AZURE_OPENAI_ENDPOINT.
1717
%
18-
% Deployment - The deployment as defined in the Azure OpenAI Services
18+
% DeploymentID - The deployment as defined in the Azure OpenAI Services
1919
% interface. Needs to be specified or stored in the
2020
% environment variable AZURE_OPENAI_DEPLOYMENT.
2121
%
@@ -103,7 +103,7 @@
103103
arguments
104104
systemPrompt {llms.utils.mustBeTextOrEmpty} = []
105105
nvp.Endpoint (1,1) string {mustBeNonzeroLengthTextScalar}
106-
nvp.Deployment (1,1) string {mustBeNonzeroLengthTextScalar}
106+
nvp.DeploymentID (1,1) string {mustBeNonzeroLengthTextScalar}
107107
nvp.APIKey {mustBeNonzeroLengthTextScalar}
108108
nvp.Tools (1,:) {mustBeA(nvp.Tools, "openAIFunction")} = openAIFunction.empty
109109
nvp.APIVersion (1,1) string {mustBeAPIVersion} = "2024-06-01"
@@ -394,8 +394,8 @@ function mustBeAPIVersion(model)
394394
end
395395

396396
function deployment = getDeployment(nvp)
397-
if isfield(nvp, "Deployment")
398-
deployment = nvp.Deployment;
397+
if isfield(nvp, "DeploymentID")
398+
deployment = nvp.DeploymentID;
399399
else
400400
if isenv("AZURE_OPENAI_DEPLOYMENT")
401401
deployment = getenv("AZURE_OPENAI_DEPLOYMENT");

doc/Azure.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ loadenv(".env")
3131

3232
## Establishing a connection to Chat Completions API using Azure
3333

34-
To connect MATLAB® to Chat Completions API via Azure, you will have to create an `azureChat` object. See [the Azure documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/chatgpt-quickstart) for details on the setup required and where to find your key, endpoint, and deployment name. As explained above, the endpoint, deployment, and key should be in the environment variables `AZURE_OPENAI_ENDPOINT`, `AZURE_OPENAI_DEPLOYMENYT`, and `AZURE_OPENAI_API_KEY`, or provided as `Endpoint=…`, `Deployment=…`, and `APIKey=…` in the `azureChat` call below.
34+
To connect MATLAB® to Chat Completions API via Azure, you will have to create an `azureChat` object. See [the Azure documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/chatgpt-quickstart) for details on the setup required and where to find your key, endpoint, and deployment name. As explained above, the endpoint, deployment, and key should be in the environment variables `AZURE_OPENAI_ENDPOINT`, `AZURE_OPENAI_DEPLOYMENYT`, and `AZURE_OPENAI_API_KEY`, or provided as `Endpoint=…`, `DeploymentID=…`, and `APIKey=…` in the `azureChat` call below.
3535

3636
In order to create the chat assistant, use the `azureChat` function, optionally providing a system prompt:
3737
```matlab
@@ -119,7 +119,7 @@ txt = generate(chat,"What is Model-Based Design and how is it related to Digital
119119

120120
You can use gpt-4o, gpt-4o-mini, or gpt-4-turbo to experiment with image understanding.
121121
```matlab
122-
chat = azureChat("You are an AI assistant.",Deployment="gpt-4o");
122+
chat = azureChat("You are an AI assistant.",DeploymentID="gpt-4o");
123123
image_path = "peppers.png";
124124
messages = messageHistory;
125125
messages = addUserMessageWithImages(messages,"What is in the image?",image_path);

doc/functions/azureChat.md

+15-25
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,6 @@ For more information on connecting to the Azure OpenAI API, see [Azure OpenAI Se
5959
For more information on keeping sensitive information out of code, see [Keep Sensitive Information Out of Code](https://www.mathworks.com/help/matlab/import_export/keep-sensitive-information-out-of-code.html).
6060

6161

62-
### `Deployment` — Deployment ID
63-
64-
character vector | string scalar
65-
66-
67-
Select a deployed model by specifying the corresponding deployment ID. Specifying the deployment ID also sets the `DeploymentID` property.
68-
69-
70-
Instead of using the `Deployment` name\-value argument, you can also set the environment variable AZURE\_OPENAI\_DEPLOYMENT. For more information, see [Azure OpenAI Services API](../Azure.md).
71-
72-
73-
**Example**: `"my-gpt-35-turbo-deployment"`
7462

7563
### `Tools` — Functions to call during output generation
7664

@@ -112,6 +100,21 @@ Instead of using the `Endpoint` name\-value argument, you can also set the envir
112100

113101
For more information on how to obtain an Azure endpoint, see [https://learn.microsoft.com/en\-us/azure/ai\-services/openai/chatgpt\-quickstart?tabs=command\-line%2Cpython\-new&pivots=rest\-api\#set\-up](https://learn.microsoft.com/en-us/azure/ai-services/openai/chatgpt-quickstart?tabs=command-line%2Cpython-new&pivots=rest-api#set-up).
114102

103+
### `DeploymentID` — Deployment ID
104+
105+
character vector | string scalar
106+
107+
108+
After construction, this property is read\-only.
109+
110+
111+
The deployment ID, also known as deployment name, specifies the Azure OpenAI deployment to use for generation.
112+
113+
114+
Instead of using the `DeploymentID` name\-value argument, you can also set the environment variable AZURE\_OPENAI\_DEPLOYMENT. For more information, see [Azure OpenAI Services API](../Azure.md).
115+
116+
**Example**: `"my-gpt-35-turbo-deployment"`
117+
115118
### `APIVersion` — API Version
116119

117120
`"2024-06-01"` (default) | `"2024-02-01"` | `"2023-05-15"` | `"2024-05-01-preview"` | `"2024-04-01-preview"` | ...
@@ -227,19 +230,6 @@ This property is read\-only.
227230

228231
Names of the custom functions specified in the `Tools` name\-value argument.
229232

230-
### `DeploymentID` — Deployment ID
231-
232-
character vector | string scalar
233-
234-
235-
This property is read\-only.
236-
237-
238-
The deployment ID specifies the model to use for generation.
239-
240-
241-
Set the `DeploymentID` property at construction either by using the `Deployment` name\-value argument, or by setting the environment variable AZURE\_OPENAI\_DEPLOYMENT. For more information, see [Azure OpenAI Services API](../Azure.md).
242-
243233
# Object Functions
244234

245235
[`generate`](generate.md) — Generate output from large language models

functionSignatures.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
[
5757
{"name":"systemPrompt","kind":"ordered","type":["string","scalar"]},
5858
{"name":"Endpoint","kind":"namevalue","type":["string","scalar"]},
59-
{"name":"Deployment","kind":"namevalue","type":["string","scalar"]},
59+
{"name":"DeploymentID","kind":"namevalue","type":["string","scalar"]},
6060
{"name":"APIKey","kind":"namevalue","type":["string","scalar"]},
6161
{"name":"Tools","kind":"namevalue","type":"openAIFunction"},
6262
{"name":"APIVersion","kind":"namevalue","type":"choices=llms.azure.apiVersions"},

tests/tazureChat.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function constructChatWithAllNVP(testCase)
2323
frequenceP = 2;
2424
systemPrompt = "This is a system prompt";
2525
timeout = 3;
26-
chat = azureChat(systemPrompt, Deployment=deploymentID, Tools=functions, ...
26+
chat = azureChat(systemPrompt, DeploymentID=deploymentID, Tools=functions, ...
2727
Temperature=temperature, TopP=topP, StopSequences=stop, APIKey=apiKey,...
2828
FrequencyPenalty=frequenceP, PresencePenalty=presenceP, TimeOut=timeout);
2929
testCase.verifyEqual(chat.Temperature, temperature);
@@ -56,7 +56,7 @@ function generateMultipleResponses(testCase)
5656
end
5757

5858
function generateWithImage(testCase)
59-
chat = azureChat(Deployment="gpt-4o");
59+
chat = azureChat(DeploymentID="gpt-4o");
6060
image_path = "peppers.png";
6161
emptyMessages = messageHistory;
6262
messages = addUserMessageWithImages(emptyMessages,"What is in the image?",image_path);
@@ -67,7 +67,7 @@ function generateWithImage(testCase)
6767

6868
function generateWithMultipleImages(testCase)
6969
import matlab.unittest.constraints.ContainsSubstring
70-
chat = azureChat(Deployment="gpt-4o");
70+
chat = azureChat(DeploymentID="gpt-4o");
7171
image_path = "peppers.png";
7272
emptyMessages = messageHistory;
7373
messages = addUserMessageWithImages(emptyMessages,"Compare these images.",[image_path,image_path]);

0 commit comments

Comments
 (0)