fix(api): box anthropic provider client enum variant

Resolves clippy::large_enum_variant in client.rs.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-04-02 14:55:51 +09:00
parent 2959cd1e51
commit 464a870180
2 changed files with 9 additions and 7 deletions
+8 -6
View File
@@ -21,7 +21,7 @@ async fn stream_via_provider<P: Provider>(
#[derive(Debug, Clone)]
pub enum ProviderClient {
Anthropic(AnthropicClient),
Anthropic(Box<AnthropicClient>),
Xai(OpenAiCompatClient),
OpenAi(OpenAiCompatClient),
}
@@ -37,10 +37,10 @@ impl ProviderClient {
) -> Result<Self, ApiError> {
let resolved_model = providers::resolve_model_alias(model);
match providers::detect_provider_kind(&resolved_model) {
ProviderKind::Anthropic => Ok(Self::Anthropic(match anthropic_auth {
ProviderKind::Anthropic => Ok(Self::Anthropic(Box::new(match anthropic_auth {
Some(auth) => AnthropicClient::from_auth(auth),
None => AnthropicClient::from_env()?,
})),
}))),
ProviderKind::Xai => Ok(Self::Xai(OpenAiCompatClient::from_env(
OpenAiCompatConfig::xai(),
)?)),
@@ -62,7 +62,9 @@ impl ProviderClient {
#[must_use]
pub fn with_prompt_cache(self, prompt_cache: PromptCache) -> Self {
match self {
Self::Anthropic(client) => Self::Anthropic(client.with_prompt_cache(prompt_cache)),
Self::Anthropic(client) => {
Self::Anthropic(Box::new((*client).with_prompt_cache(prompt_cache)))
}
other => other,
}
}
@@ -88,7 +90,7 @@ impl ProviderClient {
request: &MessageRequest,
) -> Result<MessageResponse, ApiError> {
match self {
Self::Anthropic(client) => send_via_provider(client, request).await,
Self::Anthropic(client) => send_via_provider(client.as_ref(), request).await,
Self::Xai(client) | Self::OpenAi(client) => send_via_provider(client, request).await,
}
}
@@ -98,7 +100,7 @@ impl ProviderClient {
request: &MessageRequest,
) -> Result<MessageStream, ApiError> {
match self {
Self::Anthropic(client) => stream_via_provider(client, request)
Self::Anthropic(client) => stream_via_provider(client.as_ref(), request)
.await
.map(MessageStream::Anthropic),
Self::Xai(client) | Self::OpenAi(client) => stream_via_provider(client, request)
+1 -1
View File
@@ -407,7 +407,7 @@ async fn provider_client_dispatches_anthropic_requests() {
.expect("anthropic provider client should be constructed");
let client = match client {
ProviderClient::Anthropic(client) => {
ProviderClient::Anthropic(client.with_base_url(server.base_url()))
ProviderClient::Anthropic(Box::new((*client).with_base_url(server.base_url())))
}
other => panic!("expected anthropic provider, got {other:?}"),
};