LinkedinAgent / setup.py
Hydra-Bolt
add
3856f78
#!/usr/bin/env python3
"""
Setup script for LinkedIn Agent
Helps users configure API credentials and set up the application
"""
import os
import sys
import shutil
from pathlib import Path
def print_banner():
"""Print setup banner"""
print("=" * 60)
print("πŸ”— LinkedIn Agent Setup")
print("=" * 60)
print()
def check_python_version():
"""Check if Python version is compatible"""
if sys.version_info < (3, 8):
print("❌ Python 3.8 or higher is required")
sys.exit(1)
print(f"βœ… Python {sys.version_info.major}.{sys.version_info.minor} detected")
def create_env_file():
"""Create .env file from template"""
env_template = "env_example.txt"
env_file = ".env"
if os.path.exists(env_file):
print(f"⚠️ {env_file} already exists")
response = input("Do you want to overwrite it? (y/N): ").lower()
if response != 'y':
print("Skipping .env file creation")
return
if os.path.exists(env_template):
shutil.copy(env_template, env_file)
print(f"βœ… Created {env_file} from template")
print(f"πŸ“ Please edit {env_file} with your API credentials")
else:
print(f"❌ Template file {env_template} not found")
sys.exit(1)
def install_dependencies():
"""Install Python dependencies"""
print("πŸ“¦ Installing dependencies...")
try:
os.system(f"{sys.executable} -m pip install -r requirements.txt")
print("βœ… Dependencies installed successfully")
except Exception as e:
print(f"❌ Failed to install dependencies: {e}")
sys.exit(1)
def print_setup_instructions():
"""Print setup instructions"""
print("\n" + "=" * 60)
print("πŸ“‹ Setup Instructions")
print("=" * 60)
print()
print("1. πŸ”‘ Get Google Custom Search API credentials:")
print(" - Go to: https://console.cloud.google.com/apis/credentials")
print(" - Create a new project or select existing one")
print(" - Enable Custom Search API")
print(" - Create API key")
print(" - Go to: https://cse.google.com/cse/")
print(" - Create a new search engine")
print(" - Add 'linkedin.com/in/' to sites to search")
print(" - Copy the Search Engine ID")
print()
print("2. πŸ€– Get Google Gemini API key:")
print(" - Go to: https://makersuite.google.com/app/apikey")
print(" - Create a new API key")
print()
print("3. βš™οΈ Configure the application:")
print(" - Edit the .env file with your API credentials")
print(" - Replace placeholder values with actual keys")
print()
print("4. πŸš€ Run the application:")
print(" - python -m app.main")
print(" - Or: uvicorn app.main:app --reload")
print()
print("5. 🌐 Test the API:")
print(" - Open: http://localhost:8000")
print(" - Check health: http://localhost:8000/health")
print()
def main():
"""Main setup function"""
print_banner()
print("πŸ” Checking system requirements...")
check_python_version()
print()
print("πŸ“ Creating configuration files...")
create_env_file()
print()
print("πŸ“¦ Installing dependencies...")
install_dependencies()
print()
print_setup_instructions()
print("πŸŽ‰ Setup complete!")
print("Next step: Edit .env file with your API credentials")
if __name__ == "__main__":
main()