CoolFace
Apppublic

krishshharma/Code-Explainer

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

AI Code Explainer

An AI-powered application that explains code snippets, providing insights into their functionality, time complexity, and common use cases. Built with LangChain, Hugging Face, and Gradio.

Features

  • Code explanation with detailed analysis
  • Time complexity analysis
  • Common use cases identification
  • User-friendly web interface
  • Powered by Mistral-7B-Instruct-v0.2

Prerequisites

  • Python 3.9+
  • Hugging Face account and API token
  • Git

Installation

  1. 1.Clone the repository:
bash
git clone https://github.com/krish341360/Code-Explainer.git
cd Code-Explainer
  1. 1.Install the required dependencies:
bash
pip install -r requirements.txt
  1. 1.Set up your Hugging Face API token:
bash
# Create a .env file
echo "HUGGINGFACEHUB_API_TOKEN=your_token_here" > .env
  1. 1.Create a data directory and add your sample files:
bash
mkdir data
# Add your sample code and documentation files
touch data/sample_code.py
touch data/docs.txt

Usage

  1. 1.Start the application:
bash
python app.py
  1. 1.Open your web browser and navigate to the URL shown in the terminal (typically http://127.0.0.1:7860)
  1. 1.Paste your code snippet in the text box and click "Submit" to get an explanation

Deploying to Hugging Face Spaces

  1. 1.Create a new Space on Hugging Face:
  2. 2.Go to huggingface.co/spaces
  3. 3.Click "Create new Space"
  4. 4.Choose "Gradio" as the SDK
  5. 5.Name your space (e.g., "code-explainer")
  1. 1.Push your code to the Space:
bash
git remote add space https://huggingface.co/spaces/your-username/your-space-name
git push space main
  1. 1.Set up your Hugging Face API token in the Space settings:
  2. 2.Go to your Space settings
  3. 3.Add a secret named HUGGINGFACEHUB_API_TOKEN with your token

Project Structure

Code-Explainer/
├── app.py              # Main application file
├── requirements.txt    # Python dependencies
├── README.md          # Project documentation
└── data/              # Sample code and documentation
    ├── sample_code.py
    └── docs.txt

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.