use async_trait::async_trait;
use serde_json::Value;
use crate::Result;
use crate::core::config::LlmConfig;
use crate::types::LlmUsage;
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
pub trait LlmClient: Send + Sync + 'static {
async fn complete_with_json_schema(
&self,
llm_config: &LlmConfig,
prompt: &str,
schema_name: &str,
schema: &Value,
source: &str,
) -> Result<(Value, Option<LlmUsage>)>;
}
#[derive(Debug, Default, Clone, Copy)]
pub struct LiterLlmClient;
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
impl LlmClient for LiterLlmClient {
async fn complete_with_json_schema(
&self,
llm_config: &LlmConfig,
prompt: &str,
schema_name: &str,
schema: &Value,
source: &str,
) -> Result<(Value, Option<LlmUsage>)> {
crate::llm::structured::complete_with_json_schema(llm_config, prompt, schema_name, schema, source).await
}
}