-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
80 lines (66 loc) · 2.59 KB
/
config.py
File metadata and controls
80 lines (66 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
"""
Configuration for Job Application Assistant Agent
"""
import os
from dataclasses import dataclass
from pathlib import Path
import google.generativeai as genai
# Load environment variables from .env file
try:
from dotenv import load_dotenv
# Find .env file in project root
env_path = Path(__file__).parent / '.env'
if env_path.exists():
load_dotenv(dotenv_path=env_path)
print(f"Loaded environment variables from {env_path}")
except ImportError:
# python-dotenv not installed, fall back to system environment variables
print("INFO: python-dotenv not installed. Using system environment variables.")
@dataclass
class JobAssistantConfiguration:
"""Configuration for job assistant models and parameters.
Attributes:
parsing_model (str): Model for parsing tasks (faster).
generation_model (str): Model for generation tasks (higher quality).
gemini_api_key (str): API key for Google Gemini.
max_retries (int): Maximum number of retries for failed operations.
temperature (float): Default temperature for model generations.
"""
parsing_model: str = "gemini-2.0-flash"
generation_model: str = "gemini-2.5-pro"
gemini_api_key: str = os.getenv("GEMINI_API_KEY", "")
max_retries: int = 3
temperature: float = 0.7
# Legacy compatibility
@property
def worker_model(self) -> str:
"""Alias for parsing_model for backward compatibility."""
return self.parsing_model
@property
def critic_model(self) -> str:
"""Alias for generation_model for backward compatibility."""
return self.generation_model
# Initialize configuration
config = JobAssistantConfiguration()
# Configure Gemini API
if not config.gemini_api_key:
raise ValueError(
"\n" + "="*70 + "\n"
"ERROR: GEMINI_API_KEY not found!\n\n"
"This application requires Google Gemini API to function properly.\n"
"Please set your API key:\n\n"
"Option 1 - Create .env file (Recommended):\n"
" 1. Copy .env.example to .env:\n"
" cp .env.example .env\n"
" 2. Edit .env and add your API key:\n"
" GEMINI_API_KEY=your-api-key-here\n\n"
"Option 2 - Set environment variable:\n"
" export GEMINI_API_KEY='your-api-key-here'\n\n"
"Get your free API key from: https://makersuite.google.com/app/apikey\n"
"="*70 + "\n"
)
try:
genai.configure(api_key=config.gemini_api_key)
print("Gemini API configured successfully!")
except Exception as e:
raise RuntimeError(f"Failed to configure Gemini API: {str(e)}")