Fix enum serialization (#61)
* Fix enum serialization * Add tests for enum serialization * Add missing enum serialization configuration. * Ensure enums serialize as expected using defaults --------- Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
This commit is contained in:
parent
1a5732b158
commit
96ba2fa076
1 changed files with 58 additions and 28 deletions
|
|
@ -485,7 +485,7 @@ public static class McpClientExtensions
|
|||
Throw.IfNull(client);
|
||||
|
||||
return client.SendRequestAsync<EmptyResult>(
|
||||
CreateRequest("logging/setLevel", new() { ["level"] = level.ToJsonValue() }),
|
||||
CreateRequest("logging/setLevel", new() { ["level"] = level }),
|
||||
cancellationToken);
|
||||
}
|
||||
|
||||
|
|
@ -514,22 +514,6 @@ public static class McpClientExtensions
|
|||
return parameters;
|
||||
}
|
||||
|
||||
private static string ToJsonValue(this LoggingLevel level)
|
||||
{
|
||||
return level switch
|
||||
{
|
||||
LoggingLevel.Debug => "debug",
|
||||
LoggingLevel.Info => "info",
|
||||
LoggingLevel.Notice => "notice",
|
||||
LoggingLevel.Warning => "warning",
|
||||
LoggingLevel.Error => "error",
|
||||
LoggingLevel.Critical => "critical",
|
||||
LoggingLevel.Alert => "alert",
|
||||
LoggingLevel.Emergency => "emergency",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(level))
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Provides an AI function that calls a tool through <see cref="IMcpClient"/>.</summary>
|
||||
private sealed class McpAIFunction(IMcpClient client, Tool tool) : AIFunction
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue