amkyawdev commited on
Commit
007def3
Β·
verified Β·
1 Parent(s): 8601a53

Enhanced Gradio UI with features, examples, and improved design

Browse files
Files changed (2) hide show
  1. README.md +56 -18
  2. app.py +144 -25
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
  title: amk-coder-v2
3
  emoji: πŸ€–
4
- colorFrom: purple
5
- colorTo: blue
6
  sdk: gradio
7
  sdk_version: 6.5.1
8
  app_file: app.py
@@ -15,23 +15,61 @@ license: apache-2.0
15
 
16
  # πŸ€– amk-coder-v2
17
 
18
- Myanmar Coding Assistant powered by **amk-coder-v2** (fine-tuned from Qwen2.5-Coder-1.5B)
19
 
20
- ## Features
21
- - πŸ‡²πŸ‡² Myanmar & English language support
22
- - πŸ’» Code generation with Myanmar comments
23
- - πŸ” Powered by HuggingFace Inference API
24
 
25
- ## Model
26
- **amk-coder-v2**: https://huggingface.co/amkyawdev/amk-coder-v2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
- ## Usage
29
- 1. Sign in with HuggingFace
30
- 2. Type your message in Myanmar or English
31
- 3. Adjust temperature and max tokens as needed
32
- 4. Click submit to chat
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
- ## Example Prompts
35
- - "Python ဖြင့် hello world ရေးပါ"
36
- - "Write a function to find the largest number in a list"
37
- - "Fibonacci sequence generator myanmar comments α€”α€²α€· ရေးပါ"
 
1
  ---
2
  title: amk-coder-v2
3
  emoji: πŸ€–
4
+ colorFrom: blue
5
+ colorTo: purple
6
  sdk: gradio
7
  sdk_version: 6.5.1
8
  app_file: app.py
 
15
 
16
  # πŸ€– amk-coder-v2
17
 
18
+ Myanmar Coding Assistant - Fine-tuned from **Qwen2.5-Coder-1.5B**
19
 
20
+ [![Model](https://img.shields.io/badge/Model-Size-2B-blue)](https://huggingface.co/amkyawdev/amk-coder-v2)
21
+ [![License](https://img.shields.io/badge/License-Apache--2.0-green)](LICENSE)
22
+ [![HuggingFace](https://img.shields.io/badge/πŸ€—-HuggingFace-orange)](https://huggingface.co/amkyawdev/amk-coder-v2)
 
23
 
24
+ ---
25
+
26
+ ## ✨ Features
27
+
28
+ | Feature | Description |
29
+ |---------|-------------|
30
+ | πŸ‡²πŸ‡² **Myanmar Support** | Full Myanmar Unicode text support |
31
+ | πŸ’» **Code Generation** | Python, JavaScript, C++, Java, and more |
32
+ | πŸ› **Debugging** | Bug detection and fixes |
33
+ | πŸ“– **Code Explanation** | Line-by-line explanations |
34
+ | πŸ” **Web Search** | Integration for latest documentation |
35
+
36
+ ---
37
+
38
+ ## πŸš€ Quick Start
39
+
40
+ 1. **Sign in** with your HuggingFace account
41
+ 2. **Type** your message in Myanmar or English
42
+ 3. **Adjust** temperature and max tokens as needed
43
+ 4. **Click submit** to chat!
44
+
45
+ ---
46
+
47
+ ## πŸ’‘ Example Prompts
48
+
49
+ ### πŸ‡²πŸ‡² Myanmar
50
+ - `Python function တစ်ခုရေးပါ။ list sorting α€œα€―α€•α€Ία€•α€±α€Έα€•α€«α‹`
51
+ - `JavaScript α€”α€²α€· API call ရေးပါ`
52
+ - `Fibonacci sequence generator myanmar comments α€”α€²α€· ရေးပါ`
53
 
54
+ ### πŸ‡¬πŸ‡§ English
55
+ - `Write a function to find the largest number in a list`
56
+ - `Explain this code: for i in range(10): print(i)`
57
+ - `Fix this Python code: print('Hello' + 5)`
58
+
59
+ ---
60
+
61
+ ## πŸ“š Resources
62
+
63
+ - [πŸ€— Model Card](https://huggingface.co/amkyawdev/amk-coder-v2)
64
+ - [πŸ™ GitHub](https://github.com/amkyawdev)
65
+ - [πŸ“˜ Qwen2.5-Coder](https://qwenlm.github.io/blog/Qwen2.5-Coder/)
66
+
67
+ ---
68
+
69
+ ## πŸ“ License
70
+
71
+ Apache License 2.0
72
+
73
+ ---
74
 
75
+ *Made with ❀️ for Myanmar Developers*
 
 
 
app.py CHANGED
@@ -12,14 +12,13 @@ def respond(
12
  hf_token: gr.OAuthToken,
13
  ):
14
  """
15
- For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
 
16
  """
17
  client = InferenceClient(token=hf_token.token, model="amkyawdev/amk-coder-v2")
18
 
19
  messages = [{"role": "system", "content": system_message}]
20
-
21
  messages.extend(history)
22
-
23
  messages.append({"role": "user", "content": message})
24
 
25
  response = ""
@@ -35,34 +34,154 @@ def respond(
35
  token = ""
36
  if len(choices) and choices[0].delta.content:
37
  token = choices[0].delta.content
38
-
39
  response += token
40
  yield response
41
 
42
 
43
- """
44
- For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
45
- """
46
- chatbot = gr.ChatInterface(
47
- respond,
48
- additional_inputs=[
49
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
50
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
51
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
52
- gr.Slider(
53
- minimum=0.1,
54
- maximum=1.0,
55
- value=0.95,
56
- step=0.05,
57
- label="Top-p (nucleus sampling)",
58
- ),
59
- ],
60
- )
61
-
62
- with gr.Blocks() as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  with gr.Sidebar():
64
  gr.LoginButton()
65
- chatbot.render()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
 
68
  if __name__ == "__main__":
 
12
  hf_token: gr.OAuthToken,
13
  ):
14
  """
15
+ Myanmar Coding Assistant - amk-coder-v2
16
+ Powered by HuggingFace Inference API
17
  """
18
  client = InferenceClient(token=hf_token.token, model="amkyawdev/amk-coder-v2")
19
 
20
  messages = [{"role": "system", "content": system_message}]
 
21
  messages.extend(history)
 
22
  messages.append({"role": "user", "content": message})
23
 
24
  response = ""
 
34
  token = ""
35
  if len(choices) and choices[0].delta.content:
36
  token = choices[0].delta.content
 
37
  response += token
38
  yield response
39
 
40
 
41
+ # Enhanced Gradio UI
42
+ with gr.Blocks(
43
+ title="πŸ€– amk-coder-v2 - Myanmar Coding Assistant",
44
+ theme=gr.themes.Soft(
45
+ primary_hue="blue",
46
+ secondary_hue="purple",
47
+ ),
48
+ css="""
49
+ #title {
50
+ text-align: center;
51
+ font-size: 2em;
52
+ color: #2c3e50;
53
+ margin-bottom: 0.5em;
54
+ }
55
+ .subtitle {
56
+ text-align: center;
57
+ color: #7f8c8d;
58
+ margin-bottom: 1em;
59
+ }
60
+ .features {
61
+ background: #f8f9fa;
62
+ padding: 1em;
63
+ border-radius: 10px;
64
+ margin: 1em 0;
65
+ }
66
+ .footer {
67
+ text-align: center;
68
+ color: #95a5a6;
69
+ font-size: 0.85em;
70
+ margin-top: 2em;
71
+ padding: 1em;
72
+ }
73
+ .example-box {
74
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
75
+ color: white;
76
+ padding: 0.8em;
77
+ border-radius: 8px;
78
+ margin: 0.3em 0;
79
+ cursor: pointer;
80
+ }
81
+ """
82
+ ) as demo:
83
+
84
+ gr.Markdown("""
85
+ # πŸ€– amk-coder-v2
86
+ ### Myanmar Coding Assistant | Powered by Qwen2.5-Coder-1.5B
87
+
88
+ πŸ‡²πŸ‡² α€™α€Όα€”α€Ία€™α€¬α€˜α€¬α€žα€¬α€…α€€α€¬α€Έα€”α€Ύα€„α€·α€Ί English α€”α€Ύα€…α€Ία€α€―α€œα€―α€Άα€Έα€α€½α€„α€Ί code α€›α€±α€Έα€•α€±α€Έα€•α€«α€žα€Šα€Ί
89
+ """)
90
+
91
+ gr.Markdown("""
92
+ <div class="features">
93
+ <h3>✨ Features</h3>
94
+ <ul>
95
+ <li>πŸ‡²πŸ‡² <b>Myanmar Support</b> - Full Myanmar Unicode text support</li>
96
+ <li>πŸ’» <b>Code Generation</b> - Python, JavaScript, C++, Java, and more</li>
97
+ <li>πŸ› <b>Debugging</b> - Bug detection and fixes</li>
98
+ <li>πŸ“– <b>Code Explanation</b> - Line-by-line explanations</li>
99
+ <li>πŸ” <b>Web Search</b> - Integration for latest documentation</li>
100
+ </ul>
101
+ </div>
102
+ """)
103
+
104
+ gr.Markdown("""
105
+ <div class="features">
106
+ <h3>πŸ’‘ Example Prompts</h3>
107
+ <div class="example-box">πŸ‡²πŸ‡² Python function တစ်ခုရေးပါ။ list sorting α€œα€―α€•α€Ία€•α€±α€Έα€•α€«α‹</div>
108
+ <div class="example-box">πŸ‡²πŸ‡² JavaScript α€”α€²α€· API call ရေးပါ</div>
109
+ <div class="example-box">πŸ‡¬πŸ‡§ Write a Python function to reverse a string</div>
110
+ <div class="example-box">πŸ‡¬πŸ‡§ Explain this code: for i in range(10): print(i)</div>
111
+ <div class="example-box">πŸ› Fix this Python code: print('Hello' + 5)</div>
112
+ </div>
113
+ """)
114
+
115
  with gr.Sidebar():
116
  gr.LoginButton()
117
+ gr.Markdown("""
118
+ ### βš™οΈ Settings
119
+ Adjust generation parameters below
120
+ """)
121
+
122
+ chatbot = gr.ChatInterface(
123
+ respond,
124
+ additional_inputs=[
125
+ gr.Textbox(
126
+ value="""You are amk-coder-v2, a helpful Myanmar coding assistant.
127
+ - Respond in the same language as the user (Myanmar or English)
128
+ - Provide clean, well-commented code
129
+ - Explain code when helpful
130
+ - Focus on best practices and readability""",
131
+ label="System Prompt",
132
+ lines=4
133
+ ),
134
+ gr.Slider(
135
+ minimum=64,
136
+ maximum=2048,
137
+ value=512,
138
+ step=64,
139
+ label="Max New Tokens"
140
+ ),
141
+ gr.Slider(
142
+ minimum=0.1,
143
+ maximum=1.0,
144
+ value=0.2,
145
+ step=0.1,
146
+ label="Temperature (lower = more focused)"
147
+ ),
148
+ gr.Slider(
149
+ minimum=0.1,
150
+ maximum=1.0,
151
+ value=0.95,
152
+ step=0.05,
153
+ label="Top-p (nucleus sampling)"
154
+ ),
155
+ ],
156
+ examples=[
157
+ ["Python function တစ်ခုရေးပါ။ list sorting α€œα€―α€•α€Ία€•α€±α€Έα€•α€«α‹"],
158
+ ["Write a Fibonacci function in Python"],
159
+ ["JavaScript α€”α€²α€· API call ရေးပါ"],
160
+ ["Explain this code:\nfor i in range(10):\n print(i)"],
161
+ ["Fix this: print('Hello' + 5)"],
162
+ ],
163
+ chatbot=gr.Chatbot(
164
+ height=450,
165
+ show_copy_button=True,
166
+ avatar_images=("πŸ‘€", "πŸ€–"),
167
+ ),
168
+ title="",
169
+ description="",
170
+ )
171
+
172
+ gr.Markdown("""
173
+ <div class="footer">
174
+ <hr>
175
+ <p>
176
+ <b>amk-coder-v2</b> | Fine-tuned from Qwen2.5-Coder-1.5B<br>
177
+ πŸ‡²πŸ‡² Made with ❀️ for Myanmar Developers<br>
178
+ <a href="https://huggingface.co/amkyawdev/amk-coder-v2">πŸ“¦ Model Card</a> Β·
179
+ <a href="https://github.com/amkyawdev">πŸ™ GitHub</a> Β·
180
+ <a href="https://huggingface.co/amkyawdev">πŸ€— HuggingFace</a>
181
+ </p>
182
+ <p>Apache-2.0 License</p>
183
+ </div>
184
+ """)
185
 
186
 
187
  if __name__ == "__main__":