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
Merged PR 48268: Address M.E.VectorData feedback for IEmbeddingGenerator (#6058)
Address M.E.VectorData feedback for IEmbeddingGenerator (#6058)
* Move GetService down to a non-generic IEmbeddingGenerator interface
* Separate UriContent from DataContent
Copy file name to clipboardExpand all lines: src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataContent.cs
+69-58Lines changed: 69 additions & 58 deletions
Original file line number
Diff line number
Diff line change
@@ -8,17 +8,17 @@
8
8
usingMicrosoft.Shared.Diagnostics;
9
9
10
10
#pragma warning disable S3996// URI properties should not be strings
11
+
#pragma warning disable CA1054// URI-like parameters should not be strings
11
12
#pragma warning disable CA1056// URI-like properties should not be strings
12
13
13
14
namespaceMicrosoft.Extensions.AI;
14
15
15
16
/// <summary>
16
-
/// Represents data content, such as an image or audio.
17
+
/// Represents binary content with an associated media type (also known as MIME type).
17
18
/// </summary>
18
19
/// <remarks>
19
20
/// <para>
20
-
/// The represented content may either be the actual bytes stored in this instance, or it may
21
-
/// be a URI that references the location of the content.
21
+
/// The content represents in-memory data. For references to data at a remote URI, use <see cref="UriContent"/> instead.
22
22
/// </para>
23
23
/// <para>
24
24
/// <see cref="Uri"/> always returns a valid URI string, even if the instance was constructed from
@@ -32,20 +32,27 @@ public class DataContent : AIContent
32
32
// Ideally DataContent would be based in terms of Uri. However, Uri has a length limitation that makes it prohibitive
33
33
// for the kinds of data URIs necessary to support here. As such, this type is based in strings.
34
34
35
+
/// <summary>Parsed data URI information.</summary>
36
+
privatereadonlyDataUriParser.DataUri?_dataUri;
37
+
35
38
/// <summary>The string-based representation of the URI, including any data in the instance.</summary>
36
39
privatestring?_uri;
37
40
38
41
/// <summary>The data, lazily initialized if the data is provided in a data URI.</summary>
39
42
privateReadOnlyMemory<byte>?_data;
40
43
41
-
/// <summary>Parsed data URI information.</summary>
42
-
privateDataUriParser.DataUri?_dataUri;
43
-
44
44
/// <summary>
45
45
/// Initializes a new instance of the <see cref="DataContent"/> class.
46
46
/// </summary>
47
-
/// <param name="uri">The URI of the content. This can be a data URI.</param>
48
-
/// <param name="mediaType">The media type (also known as MIME type) represented by the content.</param>
47
+
/// <param name="uri">The data URI containing the content.</param>
48
+
/// <param name="mediaType">
49
+
/// The media type (also known as MIME type) represented by the content. If not provided,
50
+
/// it must be provided as part of the <paramref name="uri"/>.
51
+
/// </param>
52
+
/// <exception cref="ArgumentNullException"><paramref name="uri"/> is <see langword="null"/>.</exception>
53
+
/// <exception cref="ArgumentException"><paramref name="uri"/> is not a data URI.</exception>
54
+
/// <exception cref="ArgumentException"><paramref name="uri"/> did not contain a media type and <paramref name="mediaType"/> was not supplied.</exception>
55
+
/// <exception cref="ArgumentException"><paramref name="mediaType"/> is an invalid media type.</exception>
/// Initializes a new instance of the <see cref="DataContent"/> class.
56
63
/// </summary>
57
-
/// <param name="uri">The URI of the content. This can be a data URI.</param>
64
+
/// <param name="uri">The data URI containing the content.</param>
58
65
/// <param name="mediaType">The media type (also known as MIME type) represented by the content.</param>
66
+
/// <exception cref="ArgumentNullException"><paramref name="uri"/> is <see langword="null"/>.</exception>
67
+
/// <exception cref="ArgumentException"><paramref name="uri"/> is not a data URI.</exception>
68
+
/// <exception cref="ArgumentException"><paramref name="uri"/> did not contain a media type and <paramref name="mediaType"/> was not supplied.</exception>
69
+
/// <exception cref="ArgumentException"><paramref name="mediaType"/> is an invalid media type.</exception>
0 commit comments