-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsettings.py
More file actions
46 lines (38 loc) · 2.08 KB
/
settings.py
File metadata and controls
46 lines (38 loc) · 2.08 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
"""Configuration settings for the OpenAI Automation. Loads and validates environment variables."""
import os
from dotenv import load_dotenv
load_dotenv()
class ConfigManager:
"""Responsible for managing configuration settings from environment variables."""
@staticmethod
def validate_email_config(sender_email, sender_password, receiver_email):
"""Validates email configuration parameters."""
if not all([sender_email, sender_password, receiver_email]):
raise ValueError(
"Email configuration (SENDER_EMAIL, SENDER_PASSWORD, RECEIVER_EMAIL) "
"must be set in environment variables or .env file."
)
@staticmethod
def validate_api_config(api_key, model_name):
"""Validates API configuration parameters."""
if not api_key:
raise ValueError("OPENAI_API_KEY must be set in environment variables or .env file.")
if not model_name:
raise ValueError("OPENAI_MODEL must be set in environment variables or .env file.")
class EmailConfig:
"""Email configuration settings."""
SENDER_EMAIL = os.environ.get("SENDER_EMAIL")
SENDER_PASSWORD = os.environ.get("SENDER_PASSWORD") # Use App Password for Gmail
RECEIVER_EMAIL = os.environ.get("RECEIVER_EMAIL")
SMTP_SERVER = os.environ.get("SMTP_SERVER", "smtp.gmail.com")
SMTP_PORT = int(os.environ.get("SMTP_PORT", 587))
EMAIL_SUBJECT = os.environ.get("EMAIL_SUBJECT", "Report Summary")
EMAIL_DISCLAIMER = os.environ.get("EMAIL_DISCLAIMER", "This is an automated summary generated by an AI. Please verify information from original sources.")
class OpenAIConfig:
"""OpenAI API configuration settings."""
API_KEY = os.environ.get("OPENAI_API_KEY", "")
MODEL = os.environ.get("OPENAI_MODEL", "gpt-3.5-turbo")
PROMPT = os.environ.get(
"OPENAI_PROMPT",
"Summarize the latest report from the Income Tax Department of India. Focus on key changes, deadlines, and implications for taxpayers. Format the information in a clear, concise manner suitable for an email newsletter."
)