-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into agent-name-regex
- Loading branch information
Showing
32 changed files
with
723 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
dotnet/src/Connectors/Connectors.MistralAI/Client/ContentChunk.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System.Text.Json.Serialization; | ||
|
||
namespace Microsoft.SemanticKernel.Connectors.MistralAI.Client; | ||
|
||
[JsonDerivedType(typeof(TextChunk))] | ||
[JsonDerivedType(typeof(ImageUrlChunk))] | ||
internal abstract class ContentChunk(ContentChunkType type) | ||
{ | ||
[JsonPropertyName("type")] | ||
public string Type { get; set; } = type.ToString(); | ||
} |
62 changes: 62 additions & 0 deletions
62
dotnet/src/Connectors/Connectors.MistralAI/Client/ContentChunkType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Microsoft.SemanticKernel.Connectors.MistralAI.Client; | ||
|
||
internal readonly struct ContentChunkType : IEquatable<ContentChunkType> | ||
{ | ||
public static ContentChunkType Text { get; } = new("text"); | ||
|
||
public static ContentChunkType ImageUrl { get; } = new("image_url"); | ||
|
||
public string Type { get; } | ||
|
||
/// <summary> | ||
/// Creates a new <see cref="ContentChunkType"/> instance with the provided type. | ||
/// </summary> | ||
/// <param name="type">The label to associate with this <see cref="ContentChunkType"/>.</param> | ||
[JsonConstructor] | ||
public ContentChunkType(string type) | ||
{ | ||
Verify.NotNullOrWhiteSpace(type, nameof(type)); | ||
this.Type = type!; | ||
} | ||
|
||
/// <summary> | ||
/// Returns a value indicating whether two <see cref="ContentChunkType"/> instances are equivalent, as determined by a | ||
/// case-insensitive comparison of their labels. | ||
/// </summary> | ||
/// <param name="left"> the first <see cref="ContentChunkType"/> instance to compare </param> | ||
/// <param name="right"> the second <see cref="ContentChunkType"/> instance to compare </param> | ||
/// <returns> true if left and right are both null or have equivalent labels; false otherwise </returns> | ||
public static bool operator ==(ContentChunkType left, ContentChunkType right) | ||
=> left.Equals(right); | ||
|
||
/// <summary> | ||
/// Returns a value indicating whether two <see cref="ContentChunkType"/> instances are not equivalent, as determined by a | ||
/// case-insensitive comparison of their labels. | ||
/// </summary> | ||
/// <param name="left"> the first <see cref="ContentChunkType"/> instance to compare </param> | ||
/// <param name="right"> the second <see cref="ContentChunkType"/> instance to compare </param> | ||
/// <returns> false if left and right are both null or have equivalent labels; true otherwise </returns> | ||
public static bool operator !=(ContentChunkType left, ContentChunkType right) | ||
=> !left.Equals(right); | ||
|
||
/// <inheritdoc/> | ||
public override bool Equals([NotNullWhen(true)] object? obj) | ||
=> obj is ContentChunkType otherRole && this == otherRole; | ||
|
||
/// <inheritdoc/> | ||
public bool Equals(ContentChunkType other) | ||
=> string.Equals(this.Type, other.Type, StringComparison.OrdinalIgnoreCase); | ||
|
||
/// <inheritdoc/> | ||
public override int GetHashCode() | ||
=> StringComparer.OrdinalIgnoreCase.GetHashCode(this.Type); | ||
|
||
/// <inheritdoc/> | ||
public override string ToString() => this.Type; | ||
} |
11 changes: 11 additions & 0 deletions
11
dotnet/src/Connectors/Connectors.MistralAI/Client/ImageUrlChunk.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Microsoft.SemanticKernel.Connectors.MistralAI.Client; | ||
internal class ImageUrlChunk(Uri imageUrl) : ContentChunk(ContentChunkType.ImageUrl) | ||
{ | ||
[JsonPropertyName("image_url")] | ||
public string ImageUrl { get; set; } = imageUrl.ToString(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.