Spaces:
Sleeping
Sleeping
| #!/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() |