Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -4,81 +4,234 @@ emoji: π»
|
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: blue
|
| 6 |
sdk: streamlit
|
| 7 |
-
sdk_version: 1.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: true
|
| 10 |
-
thumbnail: >-
|
| 11 |
-
https://cdn-uploads.huggingface.co/production/uploads/6752c8b21288ea13c1ceeef0/ABBVkk2t2WGk9W1FMZNYX.png
|
| 12 |
-
short_description: An AI-powered multi-language code editor with real-time exec
|
| 13 |
---
|
| 14 |
|
| 15 |
# π» Pro Code Playground
|
| 16 |
|
| 17 |
-
**Pro Code Playground** is an
|
| 18 |
|
| 19 |
-
|
| 20 |
|
| 21 |
---
|
| 22 |
|
| 23 |
-
##
|
| 24 |
|
| 25 |
-
- π§
|
| 26 |
-
- βοΈ
|
| 27 |
-
- π€
|
| 28 |
-
- π₯
|
| 29 |
-
-
|
| 30 |
-
- π¬
|
| 31 |
-
-
|
| 32 |
-
-
|
| 33 |
-
-
|
| 34 |
|
| 35 |
---
|
| 36 |
|
| 37 |
-
##
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
- **Execution**: Native subprocess + OneCompiler API
|
| 42 |
-
- **Audio**: Edge-TTS
|
| 43 |
-
- **Hosting**: Hugging Face Spaces
|
| 44 |
|
| 45 |
---
|
| 46 |
|
| 47 |
-
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
- **Hugging Face Spaces** for deployment
|
| 80 |
|
| 81 |
---
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
|
|
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: blue
|
| 6 |
sdk: streamlit
|
| 7 |
+
sdk_version: 1.46.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: true
|
|
|
|
|
|
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
# π» Pro Code Playground
|
| 13 |
|
| 14 |
+
**Pro Code Playground** is an interactive, multi-language coding environment with a built-in AI assistant and live execution β all accessible directly from your browser.
|
| 15 |
|
| 16 |
+
Powered by Hugging Face Spaces, Streamlit, and Groqβs LLaMA 3.3β70B, this project merges code editing, language support, AI debugging, and even narration in a single clean, responsive app. No installations. No setup. Just code, ask, listen, and learn.
|
| 17 |
|
| 18 |
---
|
| 19 |
|
| 20 |
+
## π₯ Features
|
| 21 |
|
| 22 |
+
- π§ AI-powered Code Assistant via **Groq + LangChain**
|
| 23 |
+
- βοΈ Support for **Python, Java, C++, C, JavaScript, C#**
|
| 24 |
+
- π€ File upload with **auto language detection**
|
| 25 |
+
- π₯ Stdin simulation for programs needing user input
|
| 26 |
+
- π **Voice narration** of assistant responses (Edge TTS)
|
| 27 |
+
- π¬ Scrollable chatbot with memory and summarization
|
| 28 |
+
- π **Dark/light theme toggle** with instant styling
|
| 29 |
+
- πΎ One-click code download with proper extension
|
| 30 |
+
- π§ͺ Runtime stats (execution time, memory used)
|
| 31 |
|
| 32 |
---
|
| 33 |
|
| 34 |
+
## π Try It Live
|
| 35 |
|
| 36 |
+
π [Click here to run it](https://huggingface.co/spaces/vsj0702/Code_editor)
|
| 37 |
+
No login or install required β it runs right in your browser.
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
---
|
| 40 |
|
| 41 |
+
# π Usage Guide
|
| 42 |
|
| 43 |
+
### π 1. Toggle Light/Dark Theme
|
| 44 |
+
|
| 45 |
+
- Click the theme button (π or βοΈ) on the top-right to switch between dark and light modes.
|
| 46 |
+
- Styling is fully dynamic and applies instantly to all components including the code editor and chat.
|
| 47 |
+
|
| 48 |
+
---
|
| 49 |
+
|
| 50 |
+
### π§βπ» 2. Select a Language
|
| 51 |
+
|
| 52 |
+
- Choose from: Python, Java, C, C++, JavaScript, or C#
|
| 53 |
+
- Language auto-switches when uploading supported files
|
| 54 |
+
|
| 55 |
+
---
|
| 56 |
+
|
| 57 |
+
### π 3. Write or Upload Code
|
| 58 |
+
|
| 59 |
+
- Start writing code directly in the editor
|
| 60 |
+
- Or upload a file: `.py`, `.cpp`, `.c`, `.java`, `.js`, `.cs`, `.txt`
|
| 61 |
+
- The editor auto-switches to the detected language
|
| 62 |
+
|
| 63 |
+
---
|
| 64 |
+
|
| 65 |
+
### π§ͺ 4. Input (stdin)
|
| 66 |
+
|
| 67 |
+
- Use the **Input (stdin)** text box for user inputs
|
| 68 |
+
- Inputs are passed line-by-line to your code
|
| 69 |
+
|
| 70 |
+
---
|
| 71 |
+
|
| 72 |
+
### βΆοΈ 5. Run the Code
|
| 73 |
+
|
| 74 |
+
- Hit **βΆοΈ Run**
|
| 75 |
+
- Output is shown in a result panel
|
| 76 |
+
- Errors are displayed separately in red
|
| 77 |
+
- Runtime and memory stats appear below the result
|
| 78 |
+
|
| 79 |
+
---
|
| 80 |
+
|
| 81 |
+
### π¬ 6. Ask the AI Assistant
|
| 82 |
+
|
| 83 |
+
- Use the chat sidebar to ask anything about your code
|
| 84 |
+
- The AI uses full context (code, input, output, errors, history)
|
| 85 |
+
- Great for debugging, refactoring, or learning
|
| 86 |
+
|
| 87 |
+
---
|
| 88 |
+
|
| 89 |
+
### π 7. Narrate Responses
|
| 90 |
+
|
| 91 |
+
- Click "π Narrate" to generate a voice explanation of the AIβs answer
|
| 92 |
+
- Plays using Edge TTS voices
|
| 93 |
+
- You can replay the audio or skip it
|
| 94 |
+
|
| 95 |
+
---
|
| 96 |
+
|
| 97 |
+
### πΎ 8. Download Your Code
|
| 98 |
+
|
| 99 |
+
- Download the edited code anytime
|
| 100 |
+
- File is automatically named with the correct extension
|
| 101 |
+
|
| 102 |
+
---
|
| 103 |
+
|
| 104 |
+
# π³ File Structure: Think of It Like a Tree
|
| 105 |
+
|
| 106 |
+
Imagine your app like a growing tree.
|
| 107 |
+
|
| 108 |
+
At the **trunk**, thereβs `app.py` β the brain of your app. Everything connects to it, and it sends life (data, layout, session state) to all other components. From this trunk, other files branch out like **modules**, each handling a specific responsibility. The result? A modular, clean, powerful structure that makes debugging and extending your app a breeze.
|
| 109 |
+
|
| 110 |
+
---
|
| 111 |
+
|
| 112 |
+
### π² `app.py` β The Trunk of the Tree
|
| 113 |
+
|
| 114 |
+
This is the **entry point** of the application β the first file Streamlit runs. Think of it as the control center. Its responsibilities include:
|
| 115 |
+
|
| 116 |
+
- Setting page layout and title
|
| 117 |
+
- Initializing theme and session state
|
| 118 |
+
- Dividing the screen into columns
|
| 119 |
+
- Calling the editor module (`code_editor.py`) on the left
|
| 120 |
+
- Calling the chatbot module (`chatbot.py`) on the right
|
| 121 |
+
|
| 122 |
+
**Without this file, nothing would render.** It acts as the coordinator, delegating tasks to the appropriate submodules like a team lead.
|
| 123 |
+
|
| 124 |
+
---
|
| 125 |
+
|
| 126 |
+
### πΏ `code_editor.py` β The Code Branch
|
| 127 |
+
|
| 128 |
+
This file handles everything related to writing and running code. Itβs like the **workbench** where users type, upload, and execute their programs.
|
| 129 |
+
|
| 130 |
+
Key responsibilities:
|
| 131 |
+
- Displaying the code editor using `streamlit_ace`
|
| 132 |
+
- Handling file uploads and auto-detecting language
|
| 133 |
+
- Taking user input (stdin)
|
| 134 |
+
- Running code via the backend (local or OneCompiler API)
|
| 135 |
+
- Showing output, errors, runtime, and memory stats
|
| 136 |
+
- Offering code download with the correct extension
|
| 137 |
+
|
| 138 |
+
Itβs tightly integrated with `utils.py`, which handles the actual logic for compiling and executing the code.
|
| 139 |
+
|
| 140 |
+
---
|
| 141 |
+
|
| 142 |
+
### πΏ `chatbot.py` β The Smart Brain Branch
|
| 143 |
+
|
| 144 |
+
This file gives your app its **AI assistant powers**. It's responsible for:
|
| 145 |
+
|
| 146 |
+
- Talking to Groq's LLaMA 3.3 model via LangChain
|
| 147 |
+
- Generating code explanations, debugging suggestions, and summaries
|
| 148 |
+
- Managing a memory-aware chat history
|
| 149 |
+
- Handling narration of responses using Edge TTS
|
| 150 |
+
- Controlling how chatbot responses are shown (Markdown + CSS)
|
| 151 |
+
- Making sure your assistant sounds human-like, helpful, and context-aware
|
| 152 |
+
|
| 153 |
+
Itβs the most dynamic and intelligent part of the app β and beautifully modular.
|
| 154 |
+
|
| 155 |
+
---
|
| 156 |
+
|
| 157 |
+
### πΏ `layout.py` β The Skin and Styling Layer
|
| 158 |
+
|
| 159 |
+
This file controls the **aesthetic** of your app. It defines:
|
| 160 |
+
|
| 161 |
+
- Light and dark themes
|
| 162 |
+
- Custom CSS injected into Streamlit
|
| 163 |
+
- Fonts, button styles, scroll behavior, sidebar visuals
|
| 164 |
+
- Consistent layout feel across components
|
| 165 |
+
|
| 166 |
+
Whenever the user toggles dark mode, `layout.py` updates everything instantly. It makes your app look polished and consistent, like a professionally built product.
|
| 167 |
+
|
| 168 |
+
---
|
| 169 |
+
|
| 170 |
+
### πΏ `utils.py` β The Engine Room
|
| 171 |
+
|
| 172 |
+
This is your appβs **execution engine**.
|
| 173 |
+
|
| 174 |
+
It abstracts the messy stuff β compiling, running, capturing outputs, handling errors β so that the rest of the app stays clean.
|
| 175 |
+
|
| 176 |
+
Responsibilities include:
|
| 177 |
+
- Executing Python code using `exec()` with stdin override
|
| 178 |
+
- Compiling and running C/C++ code via `gcc`/`g++`
|
| 179 |
+
- Sending Java, JavaScript, and C# code to OneCompiler API
|
| 180 |
+
- Gracefully falling back between API keys if one fails
|
| 181 |
+
- Returning outputs, stderr, and exceptions for display
|
| 182 |
+
|
| 183 |
+
If `code_editor.py` is the workbench, this file is the **machine under the hood**.
|
| 184 |
+
|
| 185 |
+
---
|
| 186 |
+
|
| 187 |
+
### πΏ `requirements.txt` β The DNA
|
| 188 |
+
|
| 189 |
+
This file contains all the dependencies needed to run the app.
|
| 190 |
+
|
| 191 |
+
From Streamlit to LangChain, Edge TTS to Groqβs SDK β this file ensures your app has all the tools it needs to function.
|
| 192 |
+
|
| 193 |
+
---
|
| 194 |
+
|
| 195 |
+
### π± Summary: A Living, Breathing System
|
| 196 |
+
|
| 197 |
+
Every file has a job. Every module connects like a healthy tree:
|
| 198 |
+
|
| 199 |
+
- `app.py` = Trunk (controls everything)
|
| 200 |
+
- `layout.py` = Skin and theme
|
| 201 |
+
- `code_editor.py` = Workbench for code
|
| 202 |
+
- `utils.py` = Engine for execution
|
| 203 |
+
- `chatbot.py` = Brain for intelligence
|
| 204 |
+
- `requirements.txt` = Genetic blueprint
|
| 205 |
+
|
| 206 |
+
This modular structure lets you:
|
| 207 |
+
- Debug easily
|
| 208 |
+
- Extend individual parts without breaking others
|
| 209 |
+
- Understand how data flows
|
| 210 |
+
- Keep your code organized and clean
|
| 211 |
|
| 212 |
---
|
| 213 |
|
| 214 |
+
If youβre reading this to understand or contribute β welcome aboard! The structure is made for developers like you.
|
| 215 |
|
| 216 |
+
Feel free to explore each module and give feedback π
|
|
|
|
| 217 |
|
| 218 |
---
|
| 219 |
|
| 220 |
+
## π€ Author
|
| 221 |
|
| 222 |
+
**Vaibhav Shankar (vsj0702)**
|
| 223 |
+
π§ Email: [vsj0702@gmail.com](mailto:vsj0702@gmail.com)
|
| 224 |
+
π LinkedIn: [vaibhavshankar](https://www.linkedin.com/in/vaibhavshankar?utm_source=share&utm_campaign=share_via&utm_content=profile&utm_medium=android_app)
|
| 225 |
+
π€ Hugging Face: [@vsj0702](https://huggingface.co/vsj0702)
|
| 226 |
|
| 227 |
---
|
| 228 |
|
| 229 |
+
## π License
|
| 230 |
|
| 231 |
+
This project is licensed under the **GNU General Public License v3.0 (GVL-3)**.
|
| 232 |
+
You are free to use, modify, and distribute the project under the terms of this license.
|
|
|
|
|
|
|
| 233 |
|
| 234 |
---
|
| 235 |
|
| 236 |
+
Thanks for exploring **Pro Code Playground** π»
|
| 237 |
+
Let me know what you build with it!
|