vtcode_core/llm/client.rs
1//! Unified LLM client trait.
2//!
3//! The canonical `LLMClient` trait, `AnyClient` alias, and
4//! `ProviderClientAdapter` live in [`vtcode_llm::client`]. This module
5//! re-exports them so the historical `crate::llm::client::*` import paths
6//! continue to resolve throughout `vtcode-core`, and adds the core-side
7//! `make_client` factory, which resolves core `ModelId` values through
8//! core's provider factory.
9
10pub use vtcode_llm::client::{AnyClient, LLMClient, ProviderClientAdapter};
11
12use super::provider::LLMError;
13use crate::config::models::ModelId;
14
15/// Create a client based on the model ID
16/// Uses the existing factory pattern from factory.rs
17pub fn make_client(api_key: String, model: ModelId) -> Result<AnyClient, LLMError> {
18 let model_id = model.to_string();
19 // Use the factory to create the provider, then adapt it to the client trait.
20 let provider = super::factory::create_provider_for_model(&model_id, api_key, None, None)?;
21 Ok(Box::new(ProviderClientAdapter::new(provider, model_id)))
22}