ai-study-assistant / config.py
MonishRaman's picture
Upload 31 files
af25a2a verified
Raw
History Blame Contribute Delete
2.08 kB
"""
Configuration file for API keys and settings
"""
import os
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
# ===========================
# API CONFIGURATION
# ===========================
# OpenAI API Key (set via environment variable or directly)
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY", "")
# Hugging Face API Key
HF_API_KEY = os.getenv("HF_API_KEY", "")
# ===========================
# MODEL SELECTION
# ===========================
# Choose LLM provider: "openai" or "huggingface"
LLM_PROVIDER = os.getenv("LLM_PROVIDER", "huggingface")
# Model names
OPENAI_MODEL = "gpt-3.5-turbo" # or "gpt-4"
HF_MODEL = os.getenv("HF_MODEL", "local") # uses local flan-t5-base when set to "local"
# ===========================
# FEATURE SETTINGS
# ===========================
# Maximum input length for validation
MAX_INPUT_LENGTH = 10000
# Maximum summary length
MAX_SUMMARY_LENGTH = 500
# Number of quiz questions to generate
NUM_QUIZ_QUESTIONS = 5
# Temperature for responses (0.0 = deterministic, 1.0 = creative)
TEMPERATURE = 0.7
# Top-p for nucleus sampling
TOP_P = 0.9
# ===========================
# SECURITY SETTINGS
# ===========================
# Harmful keywords to detect (prompt injection prevention)
HARMFUL_KEYWORDS = [
"ignore previous",
"forget instructions",
"override",
"bypass",
"admin",
"password",
"sql injection",
"delete database",
"<script>",
"eval(",
]
# ===========================
# APP SETTINGS
# ===========================
APP_TITLE = "๐ŸŽ“ AI Study Assistant"
APP_DESCRIPTION = "Upload notes or ask questions. Get smart summaries, quizzes, explanations, and doubt solving!"
# Supported file types for upload
SUPPORTED_FILE_TYPES = [".txt", ".pdf", ".md"]
# Maximum file size (in MB)
MAX_FILE_SIZE_MB = 10
# ===========================
# PROMPT TEMPLATES PATH
# ===========================
PROMPTS_DIR = "prompts"
MODES_DIR = os.path.join(PROMPTS_DIR, "modes")