base_ai_client module¶
Base AI Client - Abstract interface for different AI providers
- class base_ai_client.BaseAIClient(base_dir='.')[source]¶
Bases:
ABC
Abstract base class for AI content generation clients
- abstract generate_all_cover_letter_content(job_description, profile_content, company_name, position_title)[source]¶
Generate all cover letter content variables at once
- abstract extract_company_and_position(job_description)[source]¶
Extract company name and position title from job description
- exception base_ai_client.AIProviderError[source]¶
Bases:
Exception
Exception raised when AI provider is not available or configured incorrectly
- exception base_ai_client.AIContentError[source]¶
Bases:
Exception
Exception raised when AI content generation fails
Abstract Base Class¶
- class base_ai_client.BaseAIClient(base_dir='.')[source]¶
Abstract base class for AI content generation clients
- abstract generate_all_cover_letter_content(job_description, profile_content, company_name, position_title)[source]¶
Generate all cover letter content variables at once
- abstract extract_company_and_position(job_description)[source]¶
Extract company name and position title from job description
Abstract Methods¶
All AI client implementations must provide these methods:
Utility Methods¶
- abstract BaseAIClient.extract_company_and_position(job_description)[source]¶
Extract company name and position title from job description
- abstract BaseAIClient.generate_all_cover_letter_content(job_description, profile_content, company_name, position_title)[source]¶
Generate all cover letter content variables at once
- abstract BaseAIClient.is_available()[source]¶
Check if AI client is available and configured
- Return type:
Exception Classes¶
Implementation Guide¶
To create a new AI provider, inherit from BaseAIClient
and implement all abstract methods:
from base_ai_client import BaseAIClient, AIProviderError
class CustomAIClient(BaseAIClient):
def __init__(self, base_dir: str = ".", use_cache: bool = True):
super().__init__(base_dir, use_cache)
# Initialize your AI provider
def is_available(self) -> bool:
# Check if your AI provider is accessible
return True
def get_model_name(self) -> str:
return "custom-model-v1"
def generate_einstiegstext(self, job_description: str,
profile_content: str, company_name: str,
position_title: str) -> str:
# Implement content generation
return "Generated introduction text..."
# Implement other required methods...
Content Generation Methods¶
Each content generation method follows the same pattern:
Parameters¶
job_description (str): Full text of the job posting
profile_content (str): Applicant’s profile information
company_name (str): Name of the hiring company
position_title (str): Title of the position being applied for
Returns¶
str: Generated German text content for the specific section
Content Sections¶
einstiegstext: Opening paragraph expressing interest
fachliche_passung: Technical qualifications and experience match
motivationstext: Personal motivation and enthusiasm
mehrwert: Value proposition and unique contributions
abschlusstext: Professional closing and call to action
Caching Behavior¶
The base client provides automatic caching:
Content is cached by hash of input parameters
Cache survives between application runs
Cache can be disabled by setting
use_cache=False
Cache location:
.cache/ai_content_cache.json
Error Handling¶
All methods should raise AIProviderError
for provider-specific issues:
from base_ai_client import AIProviderError
def generate_content(self, ...):
try:
# AI provider call
response = self.ai_api.generate(...)
return response.text
except Exception as e:
raise AIProviderError(f"Failed to generate content: {e}")