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

View file

@ -21,7 +21,7 @@ async fn stream_via_provider<P: Provider>(
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum ProviderClient { pub enum ProviderClient {
Anthropic(AnthropicClient), Anthropic(Box<AnthropicClient>),
Xai(OpenAiCompatClient), Xai(OpenAiCompatClient),
OpenAi(OpenAiCompatClient), OpenAi(OpenAiCompatClient),
} }
@ -37,10 +37,10 @@ impl ProviderClient {
) -> Result<Self, ApiError> { ) -> Result<Self, ApiError> {
let resolved_model = providers::resolve_model_alias(model); let resolved_model = providers::resolve_model_alias(model);
match providers::detect_provider_kind(&resolved_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), Some(auth) => AnthropicClient::from_auth(auth),
None => AnthropicClient::from_env()?, None => AnthropicClient::from_env()?,
})), }))),
ProviderKind::Xai => Ok(Self::Xai(OpenAiCompatClient::from_env( ProviderKind::Xai => Ok(Self::Xai(OpenAiCompatClient::from_env(
OpenAiCompatConfig::xai(), OpenAiCompatConfig::xai(),
)?)), )?)),
@ -62,7 +62,9 @@ impl ProviderClient {
#[must_use] #[must_use]
pub fn with_prompt_cache(self, prompt_cache: PromptCache) -> Self { pub fn with_prompt_cache(self, prompt_cache: PromptCache) -> Self {
match 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, other => other,
} }
} }
@ -88,7 +90,7 @@ impl ProviderClient {
request: &MessageRequest, request: &MessageRequest,
) -> Result<MessageResponse, ApiError> { ) -> Result<MessageResponse, ApiError> {
match self { 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, Self::Xai(client) | Self::OpenAi(client) => send_via_provider(client, request).await,
} }
} }
@ -98,7 +100,7 @@ impl ProviderClient {
request: &MessageRequest, request: &MessageRequest,
) -> Result<MessageStream, ApiError> { ) -> Result<MessageStream, ApiError> {
match self { match self {
Self::Anthropic(client) => stream_via_provider(client, request) Self::Anthropic(client) => stream_via_provider(client.as_ref(), request)
.await .await
.map(MessageStream::Anthropic), .map(MessageStream::Anthropic),
Self::Xai(client) | Self::OpenAi(client) => stream_via_provider(client, request) Self::Xai(client) | Self::OpenAi(client) => stream_via_provider(client, request)

View file

@ -407,7 +407,7 @@ async fn provider_client_dispatches_anthropic_requests() {
.expect("anthropic provider client should be constructed"); .expect("anthropic provider client should be constructed");
let client = match client { let client = match client {
ProviderClient::Anthropic(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:?}"), other => panic!("expected anthropic provider, got {other:?}"),
}; };