Sandipan Haldar
adding submission
b309c22
|
raw
history blame
4.97 kB

πŸš€ Smart Auto-Complete - Setup Guide

This guide will help you set up and run the Smart Auto-Complete application.

πŸ“‹ Prerequisites

πŸš€ Quick Installation

Option 1: Automated Installation (Recommended)

# Run the installation script
python install.py

This will:

  • Check Python version compatibility
  • Install all required dependencies
  • Set up environment configuration
  • Run setup tests to verify everything works

Option 2: Manual Installation

# 1. Install dependencies
pip install -r requirements.txt

# 2. Set up environment
cp .env.example .env

# 3. Edit .env file with your API keys
# Add your API keys to the .env file

# 4. Test the setup
python test_setup.py

βš™οΈ Configuration

Environment Variables

Edit the .env file with your configuration:

# Required: Add at least one API key
OPENAI_API_KEY=your_openai_key_here
ANTHROPIC_API_KEY=your_anthropic_key_here

# Optional: Customize settings
DEFAULT_PROVIDER=openai
MAX_SUGGESTIONS=5
DEBOUNCE_DELAY=300
CACHE_TTL=3600

API Keys Setup

OpenAI API Key

  1. Go to OpenAI Platform
  2. Create a new API key
  3. Copy the key (starts with sk-)
  4. Add to .env file: OPENAI_API_KEY=sk-your-key-here

Anthropic API Key

  1. Go to Anthropic Console
  2. Create a new API key
  3. Copy the key (starts with sk-ant-)
  4. Add to .env file: ANTHROPIC_API_KEY=sk-ant-your-key-here

πŸƒβ€β™‚οΈ Running the Application

# Start the application
python app.py

The application will be available at: http://localhost:7860

πŸ§ͺ Testing

Run Setup Tests

python test_setup.py

Run Unit Tests

# Install test dependencies (if not already installed)
pip install pytest pytest-cov

# Run all tests
python -m pytest tests/

# Run with coverage
python -m pytest tests/ --cov=src/

πŸ“ Project Structure

Smart-Auto-Complete/
β”œβ”€β”€ app.py                 # Main Gradio application
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ autocomplete.py    # Core autocomplete logic
β”‚   β”œβ”€β”€ api_client.py      # API integration layer
β”‚   β”œβ”€β”€ cache.py           # Caching system
β”‚   └── utils.py           # Utility functions
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── settings.py        # Configuration management
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ test_autocomplete.py
β”‚   β”œβ”€β”€ test_api_client.py
β”‚   └── test_cache.py
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ .env.example          # Environment template
β”œβ”€β”€ install.py            # Installation script
β”œβ”€β”€ test_setup.py         # Setup verification
└── README.md             # Main documentation

πŸ”§ Troubleshooting

Common Issues

Import Errors

# Make sure you're in the correct directory
cd Smart-Auto-Complete

# Install dependencies
pip install -r requirements.txt

API Key Issues

  • Verify your API keys are correct and active
  • Check that keys are properly set in .env file
  • Ensure you have sufficient API credits

Port Already in Use

# If port 7860 is busy, specify a different port
python app.py --server-port 7861

Permission Errors

# On macOS/Linux, you might need:
python3 app.py

# Or use virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
python app.py

Debug Mode

Enable debug mode for detailed logging:

# Set in .env file
DEBUG_MODE=true
LOG_LEVEL=DEBUG

🎯 Usage Examples

Email Writing

Input: "Dear Mr. Johnson,"
Context: Email
β†’ Suggests professional email continuations

Code Documentation

Input: "// This function calculates"
Context: Code
β†’ Suggests technical documentation

Creative Writing

Input: "Once upon a time, in a kingdom far away"
Context: Creative
β†’ Suggests story continuations

πŸ”’ Security Notes

  • API keys are stored locally in .env file
  • Never commit .env file to version control
  • Input text is sanitized before processing
  • No user data is stored permanently

πŸ“ž Support

If you encounter issues:

  1. Check this setup guide
  2. Run python test_setup.py to diagnose problems
  3. Check the console output for error messages
  4. Verify your API keys and internet connection

πŸŽ‰ Success!

If everything is working correctly, you should see:

  • βœ… All setup tests passing
  • 🌐 Application running at http://localhost:7860
  • πŸ’‘ Real-time suggestions as you type

Enjoy using Smart Auto-Complete! πŸš€