chore: run dotnet format

This commit is contained in:
Stevan Freeborn
2024-07-01 22:46:02 -05:00
parent f848d4b792
commit 1ae90106b5
21 changed files with 78 additions and 78 deletions
+13 -13
View File
@@ -70,48 +70,48 @@ public class AnthropicHeaders
RequestId = headers.TryGetValues(RequestIdHeaderKey, out var requestIdValues)
? requestIdValues.FirstOrDefault()
: string.Empty;
RateLimitRequestsLimit = int.Parse(
headers.TryGetValues(RateLimitRequestsLimitHeaderKey, out var requestLimitValues)
? requestLimitValues.FirstOrDefault()
: "0"
);
RateLimitRequestsRemaining = int.Parse(
headers.TryGetValues(RateLimitRequestsRemainingHeaderKey, out var remainingRequestsValues)
? remainingRequestsValues.FirstOrDefault()
: "0"
);
RateLimitRequestsReset = DateTimeOffset.Parse(
headers.TryGetValues(RateLimitRequestsResetHeaderKey, out var requestResetValues)
? requestResetValues.FirstOrDefault()
: DateTimeOffset.MinValue.ToString()
);
RateLimitTokensLimit = int.Parse(
headers.TryGetValues(RateLimitTokensLimitHeaderKey, out var limitValues)
? limitValues.FirstOrDefault()
: "0"
);
RateLimitTokensRemaining = int.Parse(
headers.TryGetValues(RateLimitTokensRemainingHeaderKey, out var remainingTokensValues)
? remainingTokensValues.FirstOrDefault()
: "0"
);
RateLimitTokensReset = DateTimeOffset.Parse(
headers.TryGetValues(RateLimitTokensResetHeaderKey, out var tokenResetValues)
? tokenResetValues.FirstOrDefault()
headers.TryGetValues(RateLimitTokensResetHeaderKey, out var tokenResetValues)
? tokenResetValues.FirstOrDefault()
: DateTimeOffset.MinValue.ToString()
);
RetryAfter = int.Parse(
headers.TryGetValues(RetryAfterHeaderKey, out var retryValues)
? retryValues.FirstOrDefault()
headers.TryGetValues(RetryAfterHeaderKey, out var retryValues)
? retryValues.FirstOrDefault()
: "0"
);
}
@@ -63,4 +63,4 @@ public class AnthropicResult<T>
{
return new AnthropicResult<T>(default!, error, false, headers);
}
}
}
@@ -7,7 +7,7 @@ namespace AnthropicClient.Models;
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class FunctionParameterAttribute : Attribute
{
{
/// <summary>
/// The name of the parameter.
/// </summary>
+1 -1
View File
@@ -24,6 +24,6 @@ public static class ImageType
/// Represents the WebP image type.
/// </summary>
public const string Webp = "image/webp";
internal static bool IsValidImageType(string imageType) => imageType is Jpg or Png or Gif or Webp;
}
+2 -2
View File
@@ -9,7 +9,7 @@ namespace AnthropicClient.Models;
/// </summary>
public abstract class MessageRequest
{
/// <summary>
/// <summary>
/// Gets the model ID to use for the request.
/// </summary>
public string Model { get; init; } = string.Empty;
@@ -66,7 +66,7 @@ public abstract class MessageRequest
/// Gets the tools to use for the request.
/// </summary>
public List<Tool>? Tools { get; init; } = null;
/// <summary>
/// Gets a value indicating whether the message should be streamed.
/// </summary>
+1 -1
View File
@@ -14,6 +14,6 @@ public static class MessageRole
/// Represents the assistant role.
/// </summary>
public const string Assistant = "assistant";
internal static bool IsValidRole(string role) => role is User or Assistant;
}
+5 -5
View File
@@ -39,13 +39,13 @@ public class Tool
/// </summary>
[JsonIgnore]
public string DisplayName { get; }
internal Tool(string name, string description, AnthropicFunction function)
{
ArgumentValidator.ThrowIfNullOrWhitespace(name, nameof(name));
ArgumentValidator.ThrowIfNullOrWhitespace(description, nameof(description));
ArgumentValidator.ThrowIfNull(function, nameof(function));
// Anthropic imposes a limit on tool names. Tool names must be...
// - between 1 and 64 characters long
// - contain only letters, numbers, underscores, and hyphens
@@ -76,7 +76,7 @@ public class Tool
ArgumentValidator.ThrowIfNull(type, nameof(type));
var method = type.GetMethod(methodName, BindingFlags.Public | BindingFlags.Static);
if (method is null)
{
throw new ArgumentException($"Method '{methodName}' not found in type '{type.FullName}'.", nameof(methodName));
@@ -103,7 +103,7 @@ public class Tool
ArgumentValidator.ThrowIfNull(instance, nameof(instance));
var method = instance.GetType().GetMethod(methodName, BindingFlags.Public | BindingFlags.Instance);
if (method is null)
{
throw new ArgumentException($"Method '{methodName}' not found in type '{instance.GetType().FullName}'.", nameof(methodName));
@@ -165,7 +165,7 @@ public class Tool
return new Tool(name, description, new AnthropicFunction(func.Method, func.Target));
}
private static string SanitizeName(string name)
{
+5 -5
View File
@@ -60,9 +60,9 @@ public class ToolCall
if (isAwaitable)
{
var task = (Task)Tool.Function.Method.Invoke(Tool.Function.Instance, arguments);
await task;
const string resultPropertyName = "Result";
var resultProperty = task.GetType().GetProperty(resultPropertyName);
result = resultProperty is not null ? (T)resultProperty.GetValue(task) : default;
@@ -89,9 +89,9 @@ public class ToolCall
{
var parameter = parameters[i];
var attribute = parameter.GetCustomAttribute<FunctionParameterAttribute>();
var parameterName = attribute is not null
? string.IsNullOrWhiteSpace(attribute.Name)
? parameter.Name
var parameterName = attribute is not null
? string.IsNullOrWhiteSpace(attribute.Name)
? parameter.Name
: attribute.Name
: parameter.Name;
+1 -1
View File
@@ -19,6 +19,6 @@ public class ToolChoiceType
/// Represents the specific tool choice type.
/// </summary>
public const string Tool = "tool";
internal static bool IsValidType(string type) => type is Auto or Any or Tool;
}