vsj0702 commited on
Commit
26e151e
Β·
verified Β·
1 Parent(s): fa678dc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +197 -44
README.md CHANGED
@@ -4,81 +4,234 @@ emoji: πŸ’»
4
  colorFrom: indigo
5
  colorTo: blue
6
  sdk: streamlit
7
- sdk_version: 1.47.0
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 open-source, multi-language code editor with real-time execution and built-in AI assistance β€” all in your browser.
18
 
19
- Built using [Streamlit](https://streamlit.io), it supports multiple languages, code uploads, theme switching, and AI code help via **Groq's LLaMA 3.3**.
20
 
21
  ---
22
 
23
- ## πŸš€ Features
24
 
25
- - 🧠 **AI Code Assistant** powered by Groq’s LLaMA-3 70B (via LangChain)
26
- - ✍️ **Multi-language support**: Python, Java, C++, C, JavaScript, C#
27
- - πŸ“€ **File uploader** with auto language detection
28
- - πŸ“₯ **Stdin simulation** for interactive inputs
29
- - πŸŒ“ **Dark/Light theme toggle**
30
- - πŸ’¬ **Scrollable chatbot** with memory and summarization
31
- - πŸ”Š **Narration**: Converts answers to audio with Edge TTS
32
- - 🧾 **Download your code** in one click
33
- - πŸ“ **Execution metrics**: Time & memory used
34
 
35
  ---
36
 
37
- ## 🧠 Tech Stack
38
 
39
- - **Frontend**: Streamlit + streamlit-ace
40
- - **AI Backend**: LangChain + Groq (LLaMA 3.3–70B)
41
- - **Execution**: Native subprocess + OneCompiler API
42
- - **Audio**: Edge-TTS
43
- - **Hosting**: Hugging Face Spaces
44
 
45
  ---
46
 
47
- ## πŸ› οΈ Modular Codebase
48
 
49
- ```text
50
- β”œβ”€β”€ app.py # Main entry point
51
- β”œβ”€β”€ code_editor.py # Code editor & execution logic
52
- β”œβ”€β”€ chatbot.py # LLM assistant logic
53
- β”œβ”€β”€ layout.py # Theme and CSS customization
54
- β”œβ”€β”€ utils.py # Language-specific runners
55
- β”œβ”€β”€ requirements.txt # Python dependencies
56
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
  ---
59
 
60
- ## πŸ§ͺ Try It Live
61
 
62
- πŸ‘‰ [Click here to run the app](https://huggingface.co/spaces/vsj0702/Code_editor)
63
- No login or setup required β€” just type, run, and chat!
64
 
65
  ---
66
 
67
- ## 🀝 Contribute or Fork
68
 
69
- This project is open to contributions.
70
- You can clone this Space, fork it, or add new features like test case evaluation, Gist export, or multi-file projects.
 
 
71
 
72
  ---
73
 
74
- ## 🧠 Powered by
75
 
76
- - **LLaMA 3–70B (Groq)**
77
- - **LangChain prompt templates & memory**
78
- - **Edge TTS** for text-to-speech
79
- - **Hugging Face Spaces** for deployment
80
 
81
  ---
82
 
83
- Made with ❀️ by **Vaibhav (vsj0702)**
84
- πŸ“§ Contact: [vsj0702@gmail.com](mailto:vsj0702@gmail.com)
 
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!