ibrahimlasfar commited on
Commit
dfc8c95
·
1 Parent(s): 2fae3ca

Shorten short_description to meet Hugging Face metadata requirements

Browse files
Files changed (2) hide show
  1. LICENSE +2 -1
  2. main.py +37 -115
LICENSE CHANGED
@@ -186,7 +186,8 @@
186
  same "printed page" as the copyright notice for easier
187
  identification within third-party archives.
188
 
189
- Copyright [yyyy] [name of copyright owner]
 
190
 
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
  you may not use this file except in compliance with the License.
 
186
  same "printed page" as the copyright notice for easier
187
  identification within third-party archives.
188
 
189
+ Copyright 2025 Mark Elasfar , Ibrahim Al-Asfar
190
+
191
 
192
  Licensed under the Apache License, Version 2.0 (the "License");
193
  you may not use this file except in compliance with the License.
main.py CHANGED
@@ -32,32 +32,7 @@ CONCURRENCY_LIMIT = int(os.getenv("CONCURRENCY_LIMIT", 20))
32
  # إعداد CSS
33
  css = """
34
  .gradio-container { max-width: 1200px; margin: auto; }
35
-
36
-
37
- .chatbot {
38
- background: #fafafa;
39
- border: 1px solid #ddd;
40
- border-radius: 12px;
41
- padding: 10px;
42
- }
43
-
44
- .header h1 {
45
- font-size: 32px;
46
- color: #333;
47
- }
48
- .header p {
49
- color: #555;
50
- margin-top: -10px;
51
- }
52
-
53
- .gr-accordion {
54
- border-radius: 12px;
55
- border: 1px solid #ddd;
56
- margin-top: 15px;
57
- }
58
-
59
-
60
-
61
  .input-textbox { font-size: 16px; padding: 10px; }
62
  .upload-button::before {
63
  content: '📷';
@@ -144,95 +119,42 @@ def process_input(message, audio_input=None, file_input=None, history=None, syst
144
  yield response_text, audio_response
145
 
146
  # إعداد واجهة Gradio
147
- with gr.Blocks(css=css, theme="gradio/soft") as chatbot_ui:
148
- with gr.Column(elem_classes="header"):
149
- gr.Markdown("<h1 style='text-align:center'>🤖 MGZon Chatbot</h1>")
150
- gr.Markdown(
151
- "<p style='text-align:center; font-size:16px'>"
152
- "A versatile assistant powered by DeepSeek, CLIP, Whisper, and Parler-TTS for text, image, audio, and file queries."
153
- "</p>"
154
- )
155
-
156
- with gr.Row():
157
- chatbot = gr.Chatbot(
158
- label="MGZon Chatbot",
159
- height=750,
160
- latex_delimiters=LATEX_DELIMS,
161
- elem_classes="chatbot"
162
- )
163
-
164
- gr.Markdown("---") # فاصل بسيط
165
-
166
- with gr.Accordion("⚙️ Settings", open=False):
167
- with gr.Row():
168
- with gr.Column(scale=2):
169
- system_prompt = gr.Textbox(
170
- label="System Prompt",
171
- value="""You are an expert assistant providing detailed, comprehensive, and well-structured responses.
172
- Support text, audio, image, and file inputs.
173
- For audio, transcribe using Whisper. For text-to-speech, use Parler-TTS.
174
- For images and files, analyze content appropriately.
175
- Continue generating content until the query is fully addressed, leveraging the full capacity of the model.""",
176
- lines=6,
177
- elem_classes="input-textbox"
178
- )
179
- reasoning_effort = gr.Radio(
180
- label="Reasoning Effort",
181
- choices=["low", "medium", "high"],
182
- value="medium"
183
- )
184
- enable_browsing = gr.Checkbox(
185
- label="Enable DeepSearch (web browsing)",
186
- value=True
187
- )
188
- with gr.Column(scale=1):
189
- temperature = gr.Slider(
190
- label="Temperature",
191
- minimum=0.0,
192
- maximum=1.0,
193
- step=0.1,
194
- value=0.7
195
- )
196
- max_new_tokens = gr.Slider(
197
- label="Max New Tokens",
198
- minimum=50,
199
- maximum=128000,
200
- step=50,
201
- value=128000
202
- )
203
- audio_input = gr.Audio(
204
- label="Voice Input",
205
- type="filepath",
206
- elem_classes="audio-input"
207
- )
208
- file_input = gr.File(
209
- label="Upload Image/File",
210
- file_types=["image", ".pdf", ".txt"],
211
- elem_classes="upload-button"
212
- )
213
-
214
- audio_output = gr.Audio(
215
- label="Voice Output",
216
- type="filepath",
217
- elem_classes="audio-output",
218
- autoplay=True
219
- )
220
-
221
- gr.ChatInterface(
222
- fn=process_input,
223
- chatbot=chatbot,
224
- additional_inputs=[system_prompt, temperature, reasoning_effort, enable_browsing, max_new_tokens, audio_input, file_input],
225
- additional_outputs=[audio_output],
226
- stop_btn="Stop",
227
- examples=[
228
- ["Explain the difference between supervised and unsupervised learning in detail with examples."],
229
- ["Generate a complete React component for a login form with form validation and error handling."],
230
- ["Describe this image: https://example.com/image.jpg"],
231
- ["Transcribe this audio: [upload audio file]."],
232
- ["Convert this text to speech: Hello, welcome to MGZon!"],
233
- ["Analyze this file: [upload PDF or text file]."],
234
- ],
235
- )
236
 
237
  # إعداد FastAPI
238
  app = FastAPI(title="MGZon Chatbot API")
 
32
  # إعداد CSS
33
  css = """
34
  .gradio-container { max-width: 1200px; margin: auto; }
35
+ .chatbot { border: 1px solid #ccc; border-radius: 10px; padding: 15px; background-color: #f9f9f9; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  .input-textbox { font-size: 16px; padding: 10px; }
37
  .upload-button::before {
38
  content: '📷';
 
119
  yield response_text, audio_response
120
 
121
  # إعداد واجهة Gradio
122
+ chatbot_ui = gr.ChatInterface(
123
+ fn=process_input,
124
+ chatbot=gr.Chatbot(
125
+ label="MGZon Chatbot",
126
+ height=800,
127
+ latex_delimiters=LATEX_DELIMS,
128
+ ),
129
+ additional_inputs_accordion=gr.Accordion("⚙️ Settings", open=True),
130
+ additional_inputs=[
131
+ gr.Textbox(
132
+ label="System Prompt",
133
+ value="You are an expert assistant providing detailed, comprehensive, and well-structured responses. Support text, audio, image, and file inputs. For audio, transcribe using Whisper. For text-to-speech, use Parler-TTS. For images and files, analyze content appropriately. Continue generating content until the query is fully addressed, leveraging the full capacity of the model.",
134
+ lines=4
135
+ ),
136
+ gr.Slider(label="Temperature", minimum=0.0, maximum=1.0, step=0.1, value=0.7),
137
+ gr.Radio(label="Reasoning Effort", choices=["low", "medium", "high"], value="medium"),
138
+ gr.Checkbox(label="Enable DeepSearch (web browsing)", value=True),
139
+ gr.Slider(label="Max New Tokens", minimum=50, maximum=128000, step=50, value=128000),
140
+ gr.Audio(label="Voice Input", type="filepath", elem_classes="audio-input"),
141
+ gr.File(label="Upload Image/File", file_types=["image", ".pdf", ".txt"], elem_classes="upload-button"),
142
+ ],
143
+ additional_outputs=[gr.Audio(label="Voice Output", type="filepath", elem_classes="audio-output", autoplay=True)],
144
+ stop_btn="Stop",
145
+ examples=[
146
+ ["Explain the difference between supervised and unsupervised learning in detail with examples."],
147
+ ["Generate a complete React component for a login form with form validation and error handling."],
148
+ ["Describe this image: https://example.com/image.jpg"],
149
+ ["Transcribe this audio: [upload audio file]."],
150
+ ["Convert this text to speech: Hello, welcome to MGZon!"],
151
+ ["Analyze this file: [upload PDF or text file]."],
152
+ ],
153
+ title="MGZon Chatbot",
154
+ description="A versatile chatbot powered by DeepSeek, CLIP, Whisper, and Parler-TTS for text, image, audio, and file queries. Supports long responses, voice input/output, file uploads with custom icons, and backup token switching. Licensed under Apache 2.0.",
155
+ theme="gradio/soft",
156
+ css=css,
157
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
 
159
  # إعداد FastAPI
160
  app = FastAPI(title="MGZon Chatbot API")