llmkit 0.1.3

Production-grade LLM client - 100+ providers, 11,000+ models. Pure Rust.
Documentation
#![allow(dead_code)]
//! ChatLAW legal domain provider (API access pending).
//!
//! This module provides a skeleton for ChatLAW, a specialized legal AI assistant
//! designed for contract analysis, legal research, and compliance checking.
//!
//! # Status
//!
//! API access is currently pending evaluation and partnership approval.
//! Expected availability: Q1-Q2 2026 (partnership dependent).

use std::pin::Pin;

use async_trait::async_trait;
use futures::Stream;

use crate::error::{Error, Result};
use crate::provider::{Provider, ProviderConfig};
use crate::types::{CompletionRequest, CompletionResponse, StreamChunk};

const CHATLAW_API_URL: &str = "https://api.chatlaw.ai/v1";

/// ChatLAW legal AI provider.
///
/// Specialized LLM for legal domain applications:
/// - Contract analysis and summarization
/// - Legal document classification
/// - Case law research and citation
/// - Regulatory compliance checking
/// - Legal document generation
#[derive(Debug)]
pub struct ChatLawProvider {
    config: ProviderConfig,
}

impl ChatLawProvider {
    /// Create a new ChatLAW provider.
    ///
    /// # Note
    ///
    /// This provider requires API access partnership with ChatLAW.
    /// Contact ChatLAW via chatlaw.ai
    pub fn new(_config: ProviderConfig) -> Result<Self> {
        Err(Error::config(
            "ChatLAW API access requires partnership approval. Contact ChatLAW via chatlaw.ai",
        ))
    }

    /// Create a new ChatLAW provider from environment.
    pub fn from_env() -> Result<Self> {
        Err(Error::config(
            "ChatLAW API access requires partnership approval. Contact ChatLAW via chatlaw.ai",
        ))
    }

    /// Create a new ChatLAW provider with an API key.
    pub fn with_api_key(_api_key: impl Into<String>) -> Result<Self> {
        Err(Error::config(
            "ChatLAW API access requires partnership approval. Contact ChatLAW via chatlaw.ai",
        ))
    }

    fn _api_url(&self) -> &str {
        CHATLAW_API_URL
    }
}

#[async_trait]
impl Provider for ChatLawProvider {
    fn name(&self) -> &str {
        "chatlaw"
    }

    async fn complete(&self, _request: CompletionRequest) -> Result<CompletionResponse> {
        Err(Error::config(
            "ChatLAW API access requires partnership approval. Contact ChatLAW via chatlaw.ai",
        ))
    }

    async fn complete_stream(
        &self,
        _request: CompletionRequest,
    ) -> Result<Pin<Box<dyn Stream<Item = Result<StreamChunk>> + Send>>> {
        Err(Error::config(
            "ChatLAW API access requires partnership approval. Contact ChatLAW via chatlaw.ai",
        ))
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_chatlaw_requires_partnership() {
        let config = ProviderConfig::new("test-key");
        let result = ChatLawProvider::new(config);
        assert!(result.is_err());
        assert!(result.unwrap_err().to_string().contains("partnership"));
    }

    #[test]
    fn test_chatlaw_is_legal_domain() {
        // ChatLAW specializes in legal applications
        // This is verified by the provider name and capabilities
        assert_eq!(CHATLAW_API_URL, "https://api.chatlaw.ai/v1");
    }

    #[test]
    fn test_chatlaw_legal_specialization() {
        // Provider supports legal document analysis
        // (Verified when API becomes available)
    }
}