Skip to content

Commit 8c1911e

Browse files
trrwilsonRalph El Hage
andauthored
Azure OpenAI: update to 2023-08-01-preview with chat extensions support (Azure#38142)
* initial integration of /extensions/chat/completions * ingest naming update: 'extensions' for outward representation * snap to latest tsp update * test update with now-working deployment * updates for streaming (service support pending) * incorporate feedback: include use of strong representation of Azure Cognitive Search options * tsp update; move ACS options type to custom code pending future union approach * Update BYOD streaming tests to pass * Update TypeSpec to point to main * Minor tweaks * post-merge code regeneration * test asset ref update --------- Co-authored-by: Ralph El Hage <ralphe@microsoft.com>
1 parent 6f87f9e commit 8c1911e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1324
-73
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
package-lock.json
12
TempTypeSpecFiles/
23
**/Generated/cadl.json
34
**/Generated/configuration.json

sdk/openai/Azure.AI.OpenAI/Azure.AI.OpenAI.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.29806.167
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.6.33927.249
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.AI.OpenAI", "src\Azure.AI.OpenAI.csproj", "{E33D09D9-D809-472C-82E6-6A26BDB86FC2}"
77
EndProject

sdk/openai/Azure.AI.OpenAI/api/Azure.AI.OpenAI.netstandard2.0.cs

Lines changed: 94 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,86 @@
11
namespace Azure.AI.OpenAI
22
{
3+
public partial class AzureChatExtensionConfiguration
4+
{
5+
public AzureChatExtensionConfiguration() { }
6+
public AzureChatExtensionConfiguration(Azure.AI.OpenAI.AzureChatExtensionType type, System.BinaryData parameters) { }
7+
public System.BinaryData Parameters { get { throw null; } set { } }
8+
public virtual Azure.AI.OpenAI.AzureChatExtensionType Type { get { throw null; } set { } }
9+
}
10+
public partial class AzureChatExtensionsMessageContext
11+
{
12+
public AzureChatExtensionsMessageContext() { }
13+
public System.Collections.Generic.IList<Azure.AI.OpenAI.ChatMessage> Messages { get { throw null; } }
14+
}
15+
public partial class AzureChatExtensionsOptions
16+
{
17+
public AzureChatExtensionsOptions() { }
18+
public System.Collections.Generic.IList<Azure.AI.OpenAI.AzureChatExtensionConfiguration> Extensions { get { throw null; } }
19+
}
20+
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
21+
public readonly partial struct AzureChatExtensionType : System.IEquatable<Azure.AI.OpenAI.AzureChatExtensionType>
22+
{
23+
private readonly object _dummy;
24+
private readonly int _dummyPrimitive;
25+
public AzureChatExtensionType(string value) { throw null; }
26+
public static Azure.AI.OpenAI.AzureChatExtensionType AzureCognitiveSearch { get { throw null; } }
27+
public bool Equals(Azure.AI.OpenAI.AzureChatExtensionType other) { throw null; }
28+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
29+
public override bool Equals(object obj) { throw null; }
30+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
31+
public override int GetHashCode() { throw null; }
32+
public static bool operator ==(Azure.AI.OpenAI.AzureChatExtensionType left, Azure.AI.OpenAI.AzureChatExtensionType right) { throw null; }
33+
public static implicit operator Azure.AI.OpenAI.AzureChatExtensionType (string value) { throw null; }
34+
public static bool operator !=(Azure.AI.OpenAI.AzureChatExtensionType left, Azure.AI.OpenAI.AzureChatExtensionType right) { throw null; }
35+
public override string ToString() { throw null; }
36+
}
37+
public partial class AzureCognitiveSearchChatExtensionConfiguration : Azure.AI.OpenAI.AzureChatExtensionConfiguration
38+
{
39+
public AzureCognitiveSearchChatExtensionConfiguration() { }
40+
public AzureCognitiveSearchChatExtensionConfiguration(Azure.AI.OpenAI.AzureChatExtensionType type, System.Uri searchEndpoint, Azure.AzureKeyCredential searchKey, string indexName) { }
41+
public int? DocumentCount { get { throw null; } set { } }
42+
public System.Uri EmbeddingEndpoint { get { throw null; } set { } }
43+
public Azure.AzureKeyCredential EmbeddingKey { get { throw null; } set { } }
44+
public Azure.AI.OpenAI.AzureCognitiveSearchIndexFieldMappingOptions FieldMappingOptions { get { throw null; } set { } }
45+
public string IndexName { get { throw null; } set { } }
46+
public Azure.AI.OpenAI.AzureCognitiveSearchQueryType? QueryType { get { throw null; } set { } }
47+
public System.Uri SearchEndpoint { get { throw null; } set { } }
48+
public Azure.AzureKeyCredential SearchKey { get { throw null; } set { } }
49+
public string SemanticConfiguration { get { throw null; } set { } }
50+
public bool? ShouldRestrictResultScope { get { throw null; } set { } }
51+
public override Azure.AI.OpenAI.AzureChatExtensionType Type { get { throw null; } set { } }
52+
}
53+
public partial class AzureCognitiveSearchIndexFieldMappingOptions
54+
{
55+
public AzureCognitiveSearchIndexFieldMappingOptions() { }
56+
public System.Collections.Generic.IList<string> ContentFieldNames { get { throw null; } }
57+
public string ContentFieldSeparator { get { throw null; } set { } }
58+
public string FilepathFieldName { get { throw null; } set { } }
59+
public string TitleFieldName { get { throw null; } set { } }
60+
public string UrlFieldName { get { throw null; } set { } }
61+
public System.Collections.Generic.IList<string> VectorFieldNames { get { throw null; } }
62+
}
63+
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
64+
public readonly partial struct AzureCognitiveSearchQueryType : System.IEquatable<Azure.AI.OpenAI.AzureCognitiveSearchQueryType>
65+
{
66+
private readonly object _dummy;
67+
private readonly int _dummyPrimitive;
68+
public AzureCognitiveSearchQueryType(string value) { throw null; }
69+
public static Azure.AI.OpenAI.AzureCognitiveSearchQueryType Semantic { get { throw null; } }
70+
public static Azure.AI.OpenAI.AzureCognitiveSearchQueryType Simple { get { throw null; } }
71+
public static Azure.AI.OpenAI.AzureCognitiveSearchQueryType Vector { get { throw null; } }
72+
public static Azure.AI.OpenAI.AzureCognitiveSearchQueryType VectorSemanticHybrid { get { throw null; } }
73+
public static Azure.AI.OpenAI.AzureCognitiveSearchQueryType VectorSimpleHybrid { get { throw null; } }
74+
public bool Equals(Azure.AI.OpenAI.AzureCognitiveSearchQueryType other) { throw null; }
75+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
76+
public override bool Equals(object obj) { throw null; }
77+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
78+
public override int GetHashCode() { throw null; }
79+
public static bool operator ==(Azure.AI.OpenAI.AzureCognitiveSearchQueryType left, Azure.AI.OpenAI.AzureCognitiveSearchQueryType right) { throw null; }
80+
public static implicit operator Azure.AI.OpenAI.AzureCognitiveSearchQueryType (string value) { throw null; }
81+
public static bool operator !=(Azure.AI.OpenAI.AzureCognitiveSearchQueryType left, Azure.AI.OpenAI.AzureCognitiveSearchQueryType right) { throw null; }
82+
public override string ToString() { throw null; }
83+
}
384
public static partial class AzureOpenAIModelFactory
485
{
586
public static Azure.AI.OpenAI.ChatChoice ChatChoice(Azure.AI.OpenAI.ChatMessage message = null, int index = 0, Azure.AI.OpenAI.CompletionsFinishReason finishReason = default(Azure.AI.OpenAI.CompletionsFinishReason), Azure.AI.OpenAI.ChatMessage deltaMessage = null, Azure.AI.OpenAI.ContentFilterResults contentFilterResults = null) { throw null; }
@@ -13,8 +94,8 @@ public static partial class AzureOpenAIModelFactory
1394
public static Azure.AI.OpenAI.EmbeddingItem EmbeddingItem(System.Collections.Generic.IEnumerable<float> embedding = null, int index = 0) { throw null; }
1495
public static Azure.AI.OpenAI.Embeddings Embeddings(System.Collections.Generic.IEnumerable<Azure.AI.OpenAI.EmbeddingItem> data = null, Azure.AI.OpenAI.EmbeddingsUsage usage = null) { throw null; }
1596
public static Azure.AI.OpenAI.EmbeddingsUsage EmbeddingsUsage(int promptTokens = 0, int totalTokens = 0) { throw null; }
16-
public static Azure.AI.OpenAI.ImageGenerations ImageGenerations(System.DateTimeOffset created = default(System.DateTimeOffset), System.Collections.Generic.IEnumerable<Azure.AI.OpenAI.InternalImageLocation> data = null) { throw null; }
17-
public static Azure.AI.OpenAI.InternalImageLocation InternalImageLocation(System.Uri url = null) { throw null; }
97+
public static Azure.AI.OpenAI.ImageGenerations ImageGenerations(System.DateTimeOffset created = default(System.DateTimeOffset), System.Collections.Generic.IEnumerable<Azure.AI.OpenAI.ImageLocation> data = null) { throw null; }
98+
public static Azure.AI.OpenAI.ImageLocation ImageLocation(System.Uri url = null) { throw null; }
1899
public static Azure.AI.OpenAI.PromptFilterResult PromptFilterResult(int promptIndex = 0, Azure.AI.OpenAI.ContentFilterResults contentFilterResults = null) { throw null; }
19100
public static Azure.AI.OpenAI.StreamingChatChoice StreamingChatChoice(Azure.AI.OpenAI.ChatChoice originalBaseChoice = null) { throw null; }
20101
public static Azure.AI.OpenAI.StreamingChatCompletions StreamingChatCompletions(Azure.AI.OpenAI.ChatCompletions baseChatCompletions = null, System.Collections.Generic.List<Azure.AI.OpenAI.StreamingChatChoice> streamingChatChoices = null) { throw null; }
@@ -42,6 +123,7 @@ public partial class ChatCompletionsOptions
42123
{
43124
public ChatCompletionsOptions() { }
44125
public ChatCompletionsOptions(System.Collections.Generic.IEnumerable<Azure.AI.OpenAI.ChatMessage> messages) { }
126+
public Azure.AI.OpenAI.AzureChatExtensionsOptions AzureExtensionsOptions { get { throw null; } set { } }
45127
public int? ChoiceCount { get { throw null; } set { } }
46128
public float? FrequencyPenalty { get { throw null; } set { } }
47129
public Azure.AI.OpenAI.FunctionDefinition FunctionCall { get { throw null; } set { } }
@@ -59,6 +141,7 @@ public partial class ChatMessage
59141
{
60142
public ChatMessage() { }
61143
public ChatMessage(Azure.AI.OpenAI.ChatRole role, string content) { }
144+
public Azure.AI.OpenAI.AzureChatExtensionsMessageContext AzureExtensionsContext { get { throw null; } set { } }
62145
public string Content { get { throw null; } set { } }
63146
public Azure.AI.OpenAI.FunctionCall FunctionCall { get { throw null; } set { } }
64147
public string Name { get { throw null; } set { } }
@@ -73,6 +156,7 @@ public ChatMessage(Azure.AI.OpenAI.ChatRole role, string content) { }
73156
public static Azure.AI.OpenAI.ChatRole Assistant { get { throw null; } }
74157
public static Azure.AI.OpenAI.ChatRole Function { get { throw null; } }
75158
public static Azure.AI.OpenAI.ChatRole System { get { throw null; } }
159+
public static Azure.AI.OpenAI.ChatRole Tool { get { throw null; } }
76160
public static Azure.AI.OpenAI.ChatRole User { get { throw null; } }
77161
public bool Equals(Azure.AI.OpenAI.ChatRole other) { throw null; }
78162
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
@@ -244,7 +328,12 @@ public partial class ImageGenerations
244328
{
245329
internal ImageGenerations() { }
246330
public System.DateTimeOffset Created { get { throw null; } }
247-
public System.Collections.Generic.IReadOnlyList<Azure.AI.OpenAI.InternalImageLocation> Data { get { throw null; } }
331+
public System.Collections.Generic.IReadOnlyList<Azure.AI.OpenAI.ImageLocation> Data { get { throw null; } }
332+
}
333+
public partial class ImageLocation
334+
{
335+
internal ImageLocation() { }
336+
public System.Uri Url { get { throw null; } }
248337
}
249338
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
250339
public readonly partial struct ImageSize : System.IEquatable<Azure.AI.OpenAI.ImageSize>
@@ -265,11 +354,6 @@ internal ImageGenerations() { }
265354
public static bool operator !=(Azure.AI.OpenAI.ImageSize left, Azure.AI.OpenAI.ImageSize right) { throw null; }
266355
public override string ToString() { throw null; }
267356
}
268-
public partial class InternalImageLocation
269-
{
270-
internal InternalImageLocation() { }
271-
public System.Uri Url { get { throw null; } }
272-
}
273357
public partial class OpenAIClient
274358
{
275359
protected OpenAIClient() { }
@@ -297,13 +381,14 @@ public OpenAIClient(System.Uri endpoint, Azure.Core.TokenCredential tokenCredent
297381
}
298382
public partial class OpenAIClientOptions : Azure.Core.ClientOptions
299383
{
300-
public OpenAIClientOptions(Azure.AI.OpenAI.OpenAIClientOptions.ServiceVersion version = Azure.AI.OpenAI.OpenAIClientOptions.ServiceVersion.V2023_07_01_Preview) { }
384+
public OpenAIClientOptions(Azure.AI.OpenAI.OpenAIClientOptions.ServiceVersion version = Azure.AI.OpenAI.OpenAIClientOptions.ServiceVersion.V2023_08_01_Preview) { }
301385
public enum ServiceVersion
302386
{
303387
V2022_12_01 = 1,
304388
V2023_05_15 = 2,
305389
V2023_06_01_Preview = 3,
306390
V2023_07_01_Preview = 4,
391+
V2023_08_01_Preview = 5,
307392
}
308393
}
309394
public partial class PromptFilterResult

sdk/openai/Azure.AI.OpenAI/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/openai/Azure.AI.OpenAI",
5-
"Tag": "net/openai/Azure.AI.OpenAI_2732937895"
5+
"Tag": "net/openai/Azure.AI.OpenAI_a0250cd0f1"
66
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
// <auto-generated/>
5+
6+
#nullable disable
7+
8+
using System;
9+
using Azure.Core;
10+
11+
namespace Azure.AI.OpenAI
12+
{
13+
public partial class AzureChatExtensionConfiguration
14+
{
15+
// CUSTOM CODE NOTE: required properties are moved here to support an init-only default constructor pattern.
16+
17+
/// <summary> Initializes a new instance of AzureChatExtensionConfiguration. </summary>
18+
public AzureChatExtensionConfiguration()
19+
{
20+
}
21+
22+
/// <summary>
23+
/// The label for the type of an Azure chat extension. This typically corresponds to a matching Azure resource.
24+
/// Azure chat extensions are only compatible with Azure OpenAI.
25+
/// </summary>
26+
public virtual AzureChatExtensionType Type { get; set; }
27+
/// <summary>
28+
/// The configuration payload used for the Azure chat extension. The structure payload details are specific to the
29+
/// extension being configured.
30+
/// Azure chat extensions are only compatible with Azure OpenAI.
31+
/// <para>
32+
/// To assign an object to this property use <see cref="BinaryData.FromObjectAsJson{T}(T, System.Text.Json.JsonSerializerOptions?)"/>.
33+
/// </para>
34+
/// <para>
35+
/// To assign an already formated json string to this property use <see cref="BinaryData.FromString(string)"/>.
36+
/// </para>
37+
/// <para>
38+
/// Examples:
39+
/// <list type="bullet">
40+
/// <item>
41+
/// <term>BinaryData.FromObjectAsJson("foo")</term>
42+
/// <description>Creates a payload of "foo".</description>
43+
/// </item>
44+
/// <item>
45+
/// <term>BinaryData.FromString("\"foo\"")</term>
46+
/// <description>Creates a payload of "foo".</description>
47+
/// </item>
48+
/// <item>
49+
/// <term>BinaryData.FromObjectAsJson(new { key = "value" })</term>
50+
/// <description>Creates a payload of { "key": "value" }.</description>
51+
/// </item>
52+
/// <item>
53+
/// <term>BinaryData.FromString("{\"key\": \"value\"}")</term>
54+
/// <description>Creates a payload of { "key": "value" }.</description>
55+
/// </item>
56+
/// </list>
57+
/// </para>
58+
/// </summary>
59+
public BinaryData Parameters { get; set; }
60+
}
61+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
// <auto-generated/>
5+
6+
#nullable disable
7+
8+
using System.Text.Json;
9+
using Azure.Core;
10+
11+
namespace Azure.AI.OpenAI
12+
{
13+
public partial class AzureChatExtensionsOptions : IUtf8JsonSerializable
14+
{
15+
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
16+
{
17+
// CUSTOM CODE NOTE: dataSources deserialize directly into the parent options payload.
18+
writer.WritePropertyName("dataSources");
19+
writer.WriteStartArray();
20+
foreach (AzureChatExtensionConfiguration dataSource in Extensions)
21+
{
22+
(dataSource as IUtf8JsonSerializable).Write(writer);
23+
}
24+
writer.WriteEndArray();
25+
}
26+
}
27+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
// <auto-generated/>
5+
6+
#nullable disable
7+
8+
using System.Collections.Generic;
9+
10+
namespace Azure.AI.OpenAI
11+
{
12+
/// <summary>
13+
/// An abstraction of additional settings used by chat completions to supplement standard behavior with
14+
/// capabilities from configured Azure OpenAI extensions. These capabilities are specific to Azure OpenAI
15+
/// and chat completions requests configured to use them will require use with with that service endpoint.
16+
/// </summary>
17+
public partial class AzureChatExtensionsOptions
18+
{
19+
// CUSTOM CODE NOTE: this wrapper type for /extensions/chat/completions data sources is currently "client
20+
// only" and not yet reflected in the REST wire format. This will likely converge in
21+
// future versions but for exists outside of code generation.
22+
23+
/// <summary>
24+
/// Gets the collection of data source configurations to use with Azure OpenAI extensions for chat
25+
/// completions.
26+
/// </summary>
27+
public IList<AzureChatExtensionConfiguration> Extensions { get; }
28+
29+
/// <summary>
30+
/// Instantiates a new instance of AzureChatExtensionsOptions.
31+
/// </summary>
32+
public AzureChatExtensionsOptions()
33+
{
34+
Extensions = new List<AzureChatExtensionConfiguration>();
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)