krishshharma/Code-Explainer
0
1---2title: Code Explainer3emoji: ๐4colorFrom: green5colorTo: pink6sdk: gradio7sdk_version: 5.29.08app_file: app.py9pinned: false10short_description: AI to analyze and explain code snippets in plain English.11---12 13Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference14 15# AI Code Explainer16 17An 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.18 19## Features20 21- Code explanation with detailed analysis22- Time complexity analysis23- Common use cases identification24- User-friendly web interface25- Powered by Mistral-7B-Instruct-v0.226 27## Prerequisites28 29- Python 3.9+30- Hugging Face account and API token31- Git32 33## Installation34 351. Clone the repository:36```bash37git clone https://github.com/krish341360/Code-Explainer.git38cd Code-Explainer39```40 412. Install the required dependencies:42```bash43pip install -r requirements.txt44```45 463. Set up your Hugging Face API token:47```bash48# Create a .env file49echo "HUGGINGFACEHUB_API_TOKEN=your_token_here" > .env50```51 524. Create a `data` directory and add your sample files:53```bash54mkdir data55# Add your sample code and documentation files56touch data/sample_code.py57touch data/docs.txt58```59 60## Usage61 621. Start the application:63```bash64python app.py65```66 672. Open your web browser and navigate to the URL shown in the terminal (typically http://127.0.0.1:7860)68 693. Paste your code snippet in the text box and click "Submit" to get an explanation70 71## Deploying to Hugging Face Spaces72 731. Create a new Space on Hugging Face:74 - Go to huggingface.co/spaces75 - Click "Create new Space"76 - Choose "Gradio" as the SDK77 - Name your space (e.g., "code-explainer")78 792. Push your code to the Space:80```bash81git remote add space https://huggingface.co/spaces/your-username/your-space-name82git push space main83```84 853. Set up your Hugging Face API token in the Space settings:86 - Go to your Space settings87 - Add a secret named `HUGGINGFACEHUB_API_TOKEN` with your token88 89## Project Structure90 91```92Code-Explainer/93โโโ app.py # Main application file94โโโ requirements.txt # Python dependencies95โโโ README.md # Project documentation96โโโ data/ # Sample code and documentation97 โโโ sample_code.py98 โโโ docs.txt99```100 101## Contributing102 103Contributions are welcome! Please feel free to submit a Pull Request.104 105## License106 107This project is licensed under the MIT License - see the LICENSE file for details.108 