Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Anthropic.Foundry/AnthropicFoundryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<ClientOptions, ClientOptions> modifier)
{
return new AnthropicFoundryClient(_azureCredentials, modifier(_options));
}

protected override ValueTask BeforeSend<T>(HttpRequest<T> request, HttpRequestMessage requestMessage, CancellationToken cancellationToken)
{
_azureCredentials.Apply(requestMessage);
Expand Down
4 changes: 2 additions & 2 deletions src/Anthropic/AnthropicClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static Random Random
get { return _threadLocalRandom.Value!; }
}

readonly ClientOptions _options;
protected readonly ClientOptions _options;

public HttpClient HttpClient
{
Expand Down Expand Up @@ -65,7 +65,7 @@ public virtual string? AuthToken
init { this._options.AuthToken = value; }
}

public IAnthropicClient WithOptions(Func<ClientOptions, ClientOptions> modifier)
public virtual IAnthropicClient WithOptions(Func<ClientOptions, ClientOptions> modifier)
{
return new AnthropicClient(modifier(this._options));
}
Expand Down