ai_client_factory

AI Client Factory - Creates and manages different AI clients with fallback logic

Functions

load_dotenv([dotenv_path, stream, verbose, ...])

Parse a .env file and then load all the variables found as environment variables.

Classes

AIClientFactory([base_dir])

Factory for creating AI clients with automatic provider selection and fallback

BaseAIClient([base_dir])

Abstract base class for AI content generation clients

SampleAIClient([base_dir])

Fallback AI client that provides sample content

Exceptions

AIProviderError

Exception raised when AI provider is not available or configured incorrectly

class ai_client_factory.AIClientFactory(base_dir='.')[source]

Factory for creating AI clients with automatic provider selection and fallback

__init__(base_dir='.')[source]
create_client()[source]

Create an AI client based on configuration and availability

Provider selection logic: 1. If AI_PROVIDER is set to specific provider, try that first 2. If “auto” or not set, try providers in order: Llama -> Claude -> Sample 3. If fallback is enabled, continue down the chain until one works 4. If no providers work, return a mock client with sample content

Return type:

BaseAIClient

get_available_providers()[source]

Get list of available AI providers

Return type:

List[str]

test_all_providers()[source]

Test all available providers and return status

Return type:

dict

get_all_available_clients()[source]

Get all available AI clients instead of just the first working one

Returns:

[Llama, Claude, Sample]

Return type:

List of working AI clients in priority order

class ai_client_factory.SampleAIClient(base_dir='.')[source]

Fallback AI client that provides sample content

__init__(base_dir='.')[source]
is_available()[source]

Sample client is always available

Return type:

bool

generate_content(request)[source]

Generate sample content

generate_all_cover_letter_content(job_description, profile_content, company_name, position_title)[source]

Generate sample cover letter content

Return type:

dict

extract_company_and_position(job_description)[source]

Extract basic company and position info

Return type:

dict

get_provider_name()[source]

Get provider name

Return type:

str

get_model_name()[source]

Get model name

Return type:

str