1Egyb commited on
Commit
ea37a47
·
verified ·
1 Parent(s): 333ef3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -10
app.py CHANGED
@@ -134,9 +134,10 @@ def apply_modifications_with_context(history):
134
  return create_modified_zip(), f"✅ تم تحديث {len(modified)} ملف."
135
  except Exception as e: return None, f"❌ خطأ: {str(e)}"
136
 
137
- # --- واجهة Gradio ---
138
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
139
  gr.Markdown("# 🚀 المبرمج الذكي PRO")
 
140
  with gr.Row():
141
  with gr.Column(scale=4):
142
  chatbot = gr.Chatbot(height=500, type="messages")
@@ -144,18 +145,43 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
144
  with gr.Row():
145
  btn = gr.Button("إرسال", variant="primary")
146
  clear = gr.Button("مسح")
 
147
  with gr.Column(scale=2):
148
- zip_input = gr.File(label="ملف ZIP")
149
- zip_pwd = gr.Textbox(label="كلمة المرور", type="password")
150
- analyze_btn = gr.Button("تحليل الملف")
151
- status = gr.Markdown("انتظار الملف...")
152
- apply_btn = gr.Button(" تنفيذ التعديلات", variant="primary")
153
- download = gr.File(label="تحميل الناتج")
154
-
155
- analyze_btn.click(analyze_zip_content, [zip_input, zip_pwd], [zip_input, status])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  msg.submit(chat_wrapper, [msg, chatbot, zip_input], [chatbot, msg])
157
  btn.click(chat_wrapper, [msg, chatbot, zip_input], [chatbot, msg])
158
- apply_btn.click(apply_modifications_with_context, [chatbot], [download, status])
 
 
 
 
 
 
 
 
159
  clear.click(lambda: [], None, chatbot)
160
 
161
  if __name__ == "__main__":
 
134
  return create_modified_zip(), f"✅ تم تحديث {len(modified)} ملف."
135
  except Exception as e: return None, f"❌ خطأ: {str(e)}"
136
 
137
+ # --- واجهة Gradio النهائية ---
138
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
139
  gr.Markdown("# 🚀 المبرمج الذكي PRO")
140
+
141
  with gr.Row():
142
  with gr.Column(scale=4):
143
  chatbot = gr.Chatbot(height=500, type="messages")
 
145
  with gr.Row():
146
  btn = gr.Button("إرسال", variant="primary")
147
  clear = gr.Button("مسح")
148
+
149
  with gr.Column(scale=2):
150
+ # السطر المقصود مع تحسينات إضافية لقبول الملفات
151
+ zip_input = gr.File(
152
+ label="ملف ZIP",
153
+ file_types=[".zip", "zip", "application/zip", "application/x-zip-compressed"],
154
+ type="filepath" # التأكد من تمرير المسار كـ string
155
+ )
156
+ zip_pwd = gr.Textbox(label="كلمة المرور (إن وجدت)", type="password")
157
+ analyze_btn = gr.Button("🔍 تحليل وتجهيز الملف", variant="secondary")
158
+ status = gr.Markdown("💡 ارفع ملفاً ثم اضغط تحليل")
159
+
160
+ gr.HTML("<hr>")
161
+ apply_btn = gr.Button("✨ تنفيذ التعديلات وحفظ الملف", variant="primary")
162
+ download = gr.File(label="تحميل الناتج النهائي")
163
+
164
+ # --- ربط العمليات (الأحداث) ---
165
+
166
+ # عند الضغط على زر التحليل
167
+ analyze_btn.click(
168
+ fn=analyze_zip_content,
169
+ inputs=[zip_input, zip_pwd],
170
+ outputs=[zip_input, status]
171
+ )
172
+
173
+ # عند إرسال رسالة في الشات
174
  msg.submit(chat_wrapper, [msg, chatbot, zip_input], [chatbot, msg])
175
  btn.click(chat_wrapper, [msg, chatbot, zip_input], [chatbot, msg])
176
+
177
+ # عند الضغط على زر تنفيذ التعديلات (يربط الشات بالتعديل الفعلي)
178
+ apply_btn.click(
179
+ fn=apply_modifications_with_context,
180
+ inputs=[chatbot],
181
+ outputs=[download, status]
182
+ )
183
+
184
+ # زر المسح
185
  clear.click(lambda: [], None, chatbot)
186
 
187
  if __name__ == "__main__":