hhuihiu commited on
Commit
001d067
·
verified ·
1 Parent(s): c5aae92

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -23
app.py CHANGED
@@ -1,27 +1,33 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # نداء الموديل الخاص بآدم محمود عبدالعليم
5
  model_id = "hhuihiu/ADAM-STUDIO-MAX"
6
- # استخدام pipeline خفيف
7
  pipe = pipeline("text-generation", model=model_id)
8
 
9
  def chat_adam(message, history):
10
- system_prompt = "You are ADAM-STUDIO-MAX, a professional AI coder created by Adam Mahmoud Abdelalim. Always use code blocks for programming and answer in Arabic/English."
11
- prompt = f"{system_prompt}\nUser: {message}\nAI:"
12
- result = pipe(prompt, max_new_tokens=1024, do_sample=True, temperature=0.7)[0]['generated_text']
13
- return result.split("AI:")[-1].strip()
 
 
 
 
 
 
 
 
 
14
 
15
- # بناء الواجهة
16
  with gr.Blocks() as demo:
17
  with gr.Row():
18
  with gr.Column(scale=8):
19
  gr.Markdown("""
20
- # 🤖 ADAM-STUDIO-TERMINAL v1.0
21
  ### Developed by: **Adam Mahmoud Abdelalim** 🇪🇬
22
  """)
23
  with gr.Column(scale=2):
24
- # زرار يفتح موقعك الرسمي
25
  site_btn = gr.Button("🌐 Visit ADAM STUDIO", variant="primary")
26
  site_btn.click(lambda: None, None, None, js="window.open('https://adam-studio-platform.wasmer.app/', '_blank')")
27
 
@@ -30,27 +36,20 @@ with gr.Blocks() as demo:
30
  chatbot = gr.Chatbot(
31
  label="Adam Studio Code Assistant",
32
  height=600,
33
- show_copy_button=True,
34
- type="messages" # التحديث الجديد لـ Gradio
35
  )
36
- msg = gr.Textbox(label="Type your code or question...", placeholder="e.g., Write a C# CRUD system using .NET...")
37
 
38
  with gr.Row():
39
  submit = gr.Button("Run Script 🚀", variant="primary")
40
  clear = gr.ClearButton([msg, chatbot], value="Clear Terminal")
41
 
42
- with gr.TabItem("📄 About the Developer"):
43
- gr.Markdown(f"""
44
- ### المطور: آدم محمود عبدالعليم
45
- مبرمج Full-stack وبطل جمهورية في التكنولوجيا.
46
- تم إنشاء هذا النموذج لخدمة المبرمجين وتسهيل عملية كتابة الأكواد بذكاء اصطناعي متخصص.
47
- """)
48
-
49
- submit.click(chat_adam, [msg, chatbot], [chatbot])
50
- msg.submit(chat_adam, [msg, chatbot], [chatbot])
51
 
52
- # نقلنا الـ theme والـ css هنا عشان ده النظام الجديد
53
  demo.launch(
54
  theme=gr.themes.Monochrome(),
55
- css=".gradio-container {background-color: #0b0f19;} .stat-btn {background-color: #00ffcc !important; color: black !important; font-weight: bold !important;}"
56
  )
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # نداء موديل ADAM-STUDIO-MAX
5
  model_id = "hhuihiu/ADAM-STUDIO-MAX"
 
6
  pipe = pipeline("text-generation", model=model_id)
7
 
8
  def chat_adam(message, history):
9
+ system_prompt = "You are ADAM-STUDIO-MAX, a professional AI coder created by Adam Mahmoud Abdelalim. Use code blocks for all code answers."
10
+
11
+ # بناء نص المحادثة
12
+ full_prompt = f"{system_prompt}\nUser: {message}\nAI:"
13
+
14
+ # توليد الرد
15
+ result = pipe(full_prompt, max_new_tokens=1024, do_sample=True, temperature=0.7)[0]['generated_text']
16
+ response = result.split("AI:")[-1].strip()
17
+
18
+ # تحديث التاريخ بالشكل الجديد لـ Gradio 6
19
+ history.append({"role": "user", "content": message})
20
+ history.append({"role": "assistant", "content": response})
21
+ return "", history
22
 
 
23
  with gr.Blocks() as demo:
24
  with gr.Row():
25
  with gr.Column(scale=8):
26
  gr.Markdown("""
27
+ # 🤖 ADAM-STUDIO-TERMINAL v1.1
28
  ### Developed by: **Adam Mahmoud Abdelalim** 🇪🇬
29
  """)
30
  with gr.Column(scale=2):
 
31
  site_btn = gr.Button("🌐 Visit ADAM STUDIO", variant="primary")
32
  site_btn.click(lambda: None, None, None, js="window.open('https://adam-studio-platform.wasmer.app/', '_blank')")
33
 
 
36
  chatbot = gr.Chatbot(
37
  label="Adam Studio Code Assistant",
38
  height=600,
39
+ type="messages" # النظام الحديث للرسائل
 
40
  )
41
+ msg = gr.Textbox(label="Type your code or question...", placeholder="e.g., How to build a web api in .NET?")
42
 
43
  with gr.Row():
44
  submit = gr.Button("Run Script 🚀", variant="primary")
45
  clear = gr.ClearButton([msg, chatbot], value="Clear Terminal")
46
 
47
+ # ربط الأحداث بالنظام الجديد
48
+ submit.click(chat_adam, [msg, chatbot], [msg, chatbot])
49
+ msg.submit(chat_adam, [msg, chatbot], [msg, chatbot])
 
 
 
 
 
 
50
 
51
+ # إعدادات الواجهة (Dark Mode)
52
  demo.launch(
53
  theme=gr.themes.Monochrome(),
54
+ css=".gradio-container {background-color: #0b0f19;} .stat-btn {background-color: #00ffcc !important;}"
55
  )