Skip to content

Commit

Permalink
Update documentation for function calling on Azure OpenAI Service (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcominerva authored Jul 20, 2023
2 parents 3fdded7 + 46a77e1 commit a9ccf8c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 11 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ Register ChatGPT service at application startup:
- _ApiVersion_: the version of the API to use (optional). Allowed values:
- 2023-03-15-preview
- 2023-05-15
- 2023-06-01-preview (default).
- 2023-06-01-preview
- 2023-07-01-preview (default)
- _AuthenticationType_: it specifies if the key is an actual API Key or an [Azure Active Directory token](https://learn.microsoft.com/azure/cognitive-services/openai/how-to/managed-identity) (optional, default: "ApiKey").

### DefaultModel
Expand Down Expand Up @@ -116,7 +117,7 @@ The configuration can be automatically read from [IConfiguration](https://learn.
"ApiKey": "", // Required
//"Organization": "", // Optional, used only by OpenAI
"ResourceName": "", // Required when using Azure OpenAI Service
"ApiVersion": "2023-06-01-preview", // Optional, used only by Azure OpenAI Service. Allowed values: 2023-03-15-preview, 2023-05-15 or 2023-06-01-preview (default)
"ApiVersion": "2023-07-01-preview", // Optional, used only by Azure OpenAI Service (default: 2023-07-01-preview)
"AuthenticationType": "ApiKey", // Optional, used only by Azure OpenAI Service. Allowed values: ApiKey (default) or ActiveDirectory

"DefaultModel": "my-model",
Expand Down Expand Up @@ -267,7 +268,14 @@ The _preserveSetup_ argument allows to decide whether mantain also the _system_

With function calling, we can describe functions and have the model intelligently choose to output a JSON object containing arguments to call those functions. This is a new way to more reliably connect GPT's capabilities with external tools and APIs.

**ChatGptNet** fully supports function calling by providing an overload of the **AskAsync** method that allows to specify function specifications. If this parameter is supplied, then the model will decide when it is appropiate to use one the functions. For example:
> **Note**
Currently, on Azure OpenAI Service, function calling is supported in the following models in API version `2023-07-01-preview`:
>- gpt-35-turbo-0613
>- gpt-35-turbo-16k-0613
>- gpt-4-0613
>- gpt-4-32k-0613
**ChatGptNet** fully supports function calling by providing an overload of the **AskAsync** method that allows to specify function definitions. If this parameter is supplied, then the model will decide when it is appropiate to use one the functions. For example:

var functions = new List<ChatGptFunction>
{
Expand Down
2 changes: 1 addition & 1 deletion samples/ChatGptApi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"ApiKey": "", // Required
//"Organization": "", // Optional, used only by OpenAI
"ResourceName": "", // Required when using Azure OpenAI Service
"ApiVersion": "2023-06-01-preview", // Optional, used only by Azure OpenAI Service. Allowed values: 2023-03-15-preview, 2023-05-15 or 2023-06-01-preview (default)
"ApiVersion": "2023-07-01-preview", // Optional, used only by Azure OpenAI Service (default: 2023-07-01-preview)
"AuthenticationType": "ApiKey", // Optional, used only by Azure OpenAI Service. Allowed values : ApiKey (default) or ActiveDirectory

"DefaultModel": "my-model",
Expand Down
2 changes: 1 addition & 1 deletion samples/ChatGptConsole/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"ApiKey": "", // Required
//"Organization": "", // Optional, used only by OpenAI
"ResourceName": "", // Required when using Azure OpenAI Service
"ApiVersion": "2023-06-01-preview", // Optional, used only by Azure OpenAI Service. Allowed values: 2023-03-15-preview, 2023-05-15 or 2023-06-01-preview (default)
"ApiVersion": "2023-07-01-preview", // Optional, used only by Azure OpenAI Service (default: 2023-07-01-preview)
"AuthenticationType": "ApiKey", // Optional, used only by Azure OpenAI Service. Allowed values: ApiKey (default) or ActiveDirectory

"DefaultModel": "my-model",
Expand Down
4 changes: 2 additions & 2 deletions samples/ChatGptFunctionCallingConsole/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"ApiKey": "", // Required
//"Organization": "", // Optional, used only by OpenAI
"ResourceName": "", // Required when using Azure OpenAI Service
"ApiVersion": "2023-06-01-preview", // Optional, used only by Azure OpenAI Service. Allowed values: 2023-03-15-preview, 2023-05-15 or 2023-06-01-preview (default)
"AuthenticationType": "ApiKey", // Optional, used only by Azure OpenAI Service. Allowed values : ApiKey (default) or ActiveDirectory
"ApiVersion": "2023-07-01-preview", // Optional, used only by Azure OpenAI Service (default: 2023-07-01-preview)
"AuthenticationType": "ApiKey", // Optional, used only by Azure OpenAI Service. Allowed values: ApiKey (default) or ActiveDirectory

"DefaultModel": "gpt-3.5-turbo",
"MessageLimit": 20,
Expand Down
2 changes: 1 addition & 1 deletion samples/ChatGptStreamConsole/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"ApiKey": "", // Required
//"Organization": "", // Optional, used only by OpenAI
"ResourceName": "", // Required when using Azure OpenAI Service
"ApiVersion": "2023-06-01-preview", // Optional, used only by Azure OpenAI Service. Allowed values: 2023-03-15-preview, 2023-05-15 or 2023-06-01-preview (default)
"ApiVersion": "2023-07-01-preview", // Optional, used only by Azure OpenAI Service (default: 2023-07-01-preview)
"AuthenticationType": "ApiKey", // Optional, used only by Azure OpenAI Service. Allowed values : ApiKey (default) or ActiveDirectory

"DefaultModel": "my-model",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ internal class AzureChatGptServiceConfiguration : ChatGptServiceConfiguration
/// <summary>
/// The default API version for Azure OpenAI service.
/// </summary>
public const string DefaultApiVersion = "2023-06-01-preview";
public const string DefaultApiVersion = "2023-07-01-preview";

/// <summary>
/// Gets or sets the name of the Azure OpenAI Resource.
/// </summary>
public string? ResourceName { get; set; }

/// <summary>
/// Gets or sets the API version of the Azure OpenAI service (Default: 2023-06-01-preview).
/// Gets or sets the API version of the Azure OpenAI service (Default: 2023-07-01-preview).
/// </summary>
/// <remarks>
/// Currently supported versions are:
Expand All @@ -35,6 +35,10 @@ internal class AzureChatGptServiceConfiguration : ChatGptServiceConfiguration
/// <term>2023-06-01-preview</term>
/// <description><see href="https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-06-01-preview/inference.json">Swagger spec</see></description>
/// </item>
/// <item>
/// <term>2023-07-01-preview</term>
/// <description><see href="https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview/2023-07-01-preview/generated.json">Swagger spec</see></description>
/// </item>
/// </list>
/// </remarks>
public string ApiVersion { get; set; } = DefaultApiVersion;
Expand Down
2 changes: 1 addition & 1 deletion src/ChatGptNet/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "2.1",
"version": "2.2",
"publicReleaseRefSpec": [
"^refs/heads/master$" // we release out of master
],
Expand Down

0 comments on commit a9ccf8c

Please sign in to comment.