Sci-Fi Code Improver is a web application that enhances your programming code by analyzing and improving it for security, performance, maintainability, and adherence to coding best practices. It also generates commit messages following the Conventional Commits format.
- Code Improvement: Automatically refactors code while preserving functionality.
- Commit Message Generator: Creates informative commit messages conforming to Conventional Commits.
- Syntax Highlighting: Supports multiple programming languages.
- Theme Toggle: Switch between light and dark themes.
- Session Management: Version history maintained in user sessions.
- Auto Language Detection: Determines the coding language from the input.
- Docker Support: Easy deployment using Docker containers.
- API Flexibility: Support for both OpenRouter and OpenAI APIs.
- Health Monitoring: Built-in healthcheck and logging system.
- FreeTekno modding: Background video FX and Free Undeground Tekno Radio music for a unique experience!
# Pull the Docker image
docker pull fabriziosalmi/sci-fi:latest
# Create a .env file with your configuration
cat > .env << EOL
OPENROUTER_API_KEY=your-api-key
MODEL_NAME=qwen2.5-coder-3b-instruct-mlx
MAX_TOKENS=2048
TEMPERATURE=0.2
CHUNK_SIZE=500
CONTEXT_WINDOW=10
BASE_URL=http://localhost:1234/v1
EOL
# Run the container
docker run -p 7860:7860 --env-file .env fabriziosalmi/sci-fi:latest
- Clone the repository:
git clone https://github.com/fabriziosalmi/sci-fi.git cd sci-fi
- Set up the Python environment:
python -m venv venv source venv/bin/activate # On Windows use venv\Scripts\activate pip install -r requirements.txt
- Configure Environment Variables:
Create a
.env
file in the project root with your configuration.
-
Create docker-compose.yml:
version: '3.8' services: web: image: fabriziosalmi/sci-fi:latest ports: - "7860:7860" volumes: - ./improvements:/app/improvements - ./.env:/app/.env:ro environment: - OPENROUTER_API_KEY=${OPENROUTER_API_KEY} - MODEL_NAME=${MODEL_NAME} - MAX_TOKENS=${MAX_TOKENS} - TEMPERATURE=${TEMPERATURE} - CHUNK_SIZE=${CHUNK_SIZE} - CONTEXT_WINDOW=${CONTEXT_WINDOW} - BASE_URL=${BASE_URL} restart: unless-stopped
-
Start the application:
docker-compose up -d
- Access the app at http://localhost:7860
- Paste your code into the text area
- Click the magic icon to improve the code
- View the improved code and generated commit message
- Use the copy/download buttons to handle output
The application supports both OpenRouter and OpenAI APIs:
- OpenRouter: Set
BASE_URL=https://openrouter.ai/api/v1
- OpenAI: Set
BASE_URL=https://api.openai.com/v1
andLLM_API_TYPE=openai
The Docker container includes:
- Health checks every 30 seconds
- JSON file logging with rotation to efficiently manage log data.
- Maximum log file size of 10MB to prevent excessive disk usage.
- Retains the 3 most recent log files for quick audits.
Contributions are welcome! Please:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Submit a pull request with details of your changes.
This project is licensed under the MIT License. See the LICENSE file for details.
- Docker support for streamlined deployment.