diff --git a/src/Anthropic.Foundry/AnthropicFoundryClient.cs b/src/Anthropic.Foundry/AnthropicFoundryClient.cs index 792cbd5c..2b6cb28b 100644 --- a/src/Anthropic.Foundry/AnthropicFoundryClient.cs +++ b/src/Anthropic.Foundry/AnthropicFoundryClient.cs @@ -26,6 +26,12 @@ public AnthropicFoundryClient(IAnthropicFoundryCredentials azureCredentials) BaseUrl = new Uri(url, UriKind.Absolute); } + private AnthropicFoundryClient(IAnthropicFoundryCredentials azureCredentials, ClientOptions options) + : base(options) + { + _azureCredentials = azureCredentials ?? throw new ArgumentNullException(nameof(azureCredentials)); + } + [Obsolete("The {nameof(APIKey)} property is not supported in this configuration.", true)] #pragma warning disable CS0809 // Obsolete member overrides non-obsolete member public override string? APIKey @@ -35,6 +41,11 @@ public override string? APIKey init => throw new NotSupportedException($"The {nameof(APIKey)} property is not supported in this configuration."); } + public override IAnthropicClient WithOptions(Func modifier) + { + return new AnthropicFoundryClient(_azureCredentials, modifier(_options)); + } + protected override ValueTask BeforeSend(HttpRequest request, HttpRequestMessage requestMessage, CancellationToken cancellationToken) { _azureCredentials.Apply(requestMessage); diff --git a/src/Anthropic/AnthropicClient.cs b/src/Anthropic/AnthropicClient.cs index aa3de14b..f31d8d63 100644 --- a/src/Anthropic/AnthropicClient.cs +++ b/src/Anthropic/AnthropicClient.cs @@ -21,7 +21,7 @@ static Random Random get { return _threadLocalRandom.Value!; } } - readonly ClientOptions _options; + protected readonly ClientOptions _options; public HttpClient HttpClient { @@ -65,7 +65,7 @@ public virtual string? AuthToken init { this._options.AuthToken = value; } } - public IAnthropicClient WithOptions(Func modifier) + public virtual IAnthropicClient WithOptions(Func modifier) { return new AnthropicClient(modifier(this._options)); }