anaspro commited on
Commit
d1b249e
·
1 Parent(s): dfb1538
Files changed (4) hide show
  1. README.md +40 -11
  2. app.py +17 -2
  3. requirements.txt +10 -10
  4. test_deployment.py +77 -0
README.md CHANGED
@@ -1,24 +1,53 @@
1
  ---
2
- title: GPT-OSS-20B Chat Assistant
3
  emoji: 🤖
4
  colorFrom: blue
5
- colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 5.42.0
8
  app_file: app.py
9
  pinned: false
10
- hf_oauth: true
11
- hf_oauth_scopes:
12
- - inference-api
13
  models:
14
- - unsloth/gpt-oss-20b-unsloth-bnb-4bit
15
  tags:
16
- - gpt-oss
17
- - reasoning
18
- - chat
19
  - arabic
 
 
 
 
20
  ---
21
 
22
- A powerful chatbot powered by GPT-OSS-20B (OpenAI's open-weight reasoning model) with 4-bit quantization for efficient inference. Features advanced reasoning capabilities, tool use, and supports Arabic language conversations.
23
 
24
- Built with [Gradio](https://gradio.app) and deployed on Hugging Face Spaces for easy access.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: TechSolutions Customer Support - Alex Assistant
3
  emoji: 🤖
4
  colorFrom: blue
5
+ colorTo: green
6
  sdk: gradio
7
  sdk_version: 5.42.0
8
  app_file: app.py
9
  pinned: false
 
 
 
10
  models:
11
+ - anaspro/iraqi-7b
12
  tags:
13
+ - customer-support
 
 
14
  - arabic
15
+ - chatbot
16
+ - iraqi-dialect
17
+ - tech-support
18
+ - multilingual
19
  ---
20
 
21
+ مساعد خدمة عملاء ذكي لشركة TechSolutions يدعم اللغة العربية والإنجليزية.
22
 
23
+ 🚀 **المميزات:**
24
+ - 🌐 دعم ثنائي اللغة (عربي وإنجليزي)
25
+ - 💬 لهجة محادثة طبيعية بالعراقية
26
+ - 🔧 دعم فني واستكشاف الأخطاء
27
+ - 📋 معلومات الخدمات والإرشاد
28
+ - 🎯 مدعوم بـ موديل ذكي مع تحسينات الأداء
29
+
30
+ 📞 احجي مع أليكس لحل مشاكلك التقنية، استفسر عن الخدمات، أو احصل على معلومات المنتجات.
31
+
32
+ ## 🚀 كيفية النشر على Hugging Face Spaces ZeroGPU
33
+
34
+ 1. **إنشاء Space جديد:**
35
+ - اذهب إلى [Hugging Face Spaces](https://huggingface.co/spaces)
36
+ - اضغط "Create new Space"
37
+ - اختر اسم مناسب (مثل: TechSolutions-Support)
38
+ - اختر "Gradio" كـ SDK
39
+ - اختر "ZeroGPU" كـ Hardware
40
+
41
+ 2. **رفع الملفات:**
42
+ - ارفع `app.py`, `requirements.txt`, `README.md`, `system_prompt.txt`
43
+ - تأكد من أن `app.py` هو الملف الرئيسي
44
+
45
+ 3. **إعدادات البيئة:**
46
+ - اذهب إلى Settings → Variables and secrets
47
+ - أضف `HF_TOKEN` إذا كنت تحتاج token للوصول للمودل
48
+
49
+ 4. **تشغيل Space:**
50
+ - اضغط "Restart this space" لإعادة التشغيل
51
+ - سيعمل التطبيق تلقائياً على ZeroGPU
52
+
53
+ Built with [Gradio](https://gradio.app) and deployed on Hugging Face Spaces ZeroGPU.
app.py CHANGED
@@ -34,8 +34,23 @@ hf_token = os.getenv("HF_TOKEN")
34
 
35
  device = "cuda" if torch.cuda.is_available() else "cpu"
36
 
37
- tokenizer = AutoTokenizer.from_pretrained(model_path, token=hf_token)
38
- model = AutoModelForCausalLM.from_pretrained(model_path, device_map="auto", trust_remote_code=True, token=hf_token)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  if tokenizer.pad_token is None:
41
  tokenizer.pad_token = tokenizer.eos_token
 
34
 
35
  device = "cuda" if torch.cuda.is_available() else "cpu"
36
 
37
+ # تحميل المودل مع تحسينات لـ ZeroGPU
38
+ print("جاري تحميل المودل...")
39
+ tokenizer = AutoTokenizer.from_pretrained(
40
+ model_path,
41
+ token=hf_token,
42
+ trust_remote_code=True
43
+ )
44
+
45
+ model = AutoModelForCausalLM.from_pretrained(
46
+ model_path,
47
+ device_map="auto",
48
+ trust_remote_code=True,
49
+ token=hf_token,
50
+ torch_dtype=torch.float16 if device == "cuda" else torch.float32,
51
+ low_cpu_mem_usage=True
52
+ )
53
+ print("تم تحميل المودل بنجاح!")
54
 
55
  if tokenizer.pad_token is None:
56
  tokenizer.pad_token = tokenizer.eos_token
requirements.txt CHANGED
@@ -1,10 +1,10 @@
1
- gradio
2
- spaces
3
- huggingface-hub
4
- transformers
5
- accelerate
6
- torch
7
- bitsandbytes
8
- hf-transfer
9
- sentencepiece
10
- protobuf
 
1
+ gradio>=4.0.0
2
+ spaces[huggingface]>=0.28.0
3
+ huggingface-hub>=0.20.0
4
+ transformers>=4.35.0
5
+ accelerate>=0.25.0
6
+ torch>=2.1.0
7
+ bitsandbytes>=0.41.0
8
+ hf-transfer>=0.1.4
9
+ sentencepiece>=0.1.99
10
+ protobuf>=4.21.0
test_deployment.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ اختبار سريع للتأكد من أن التطبيق يعمل قبل النشر
4
+ """
5
+
6
+ import sys
7
+ import os
8
+
9
+ def test_imports():
10
+ """اختبار الاستيراد"""
11
+ try:
12
+ import torch
13
+ import gradio as gr
14
+ import spaces
15
+ from transformers import AutoTokenizer, AutoModelForCausalLM
16
+ print("✅ جميع الاستيرادات نجحت")
17
+ return True
18
+ except ImportError as e:
19
+ print(f"❌ خطأ في الاستيراد: {e}")
20
+ return False
21
+
22
+ def test_model_loading():
23
+ """اختبار تحميل المودل"""
24
+ try:
25
+ from transformers import AutoTokenizer, AutoModelForCausalLM
26
+ import torch
27
+
28
+ model_path = "anaspro/iraqi-7b"
29
+ hf_token = os.getenv("HF_TOKEN")
30
+
31
+ print("🔄 جاري تحميل المودل للاختبار...")
32
+
33
+ # تحميل سريع للاختبار فقط
34
+ tokenizer = AutoTokenizer.from_pretrained(
35
+ model_path,
36
+ token=hf_token,
37
+ trust_remote_code=True
38
+ )
39
+
40
+ # تحميل المودل على CPU فقط للاختبار
41
+ model = AutoModelForCausalLM.from_pretrained(
42
+ model_path,
43
+ device_map="cpu", # استخدام CPU للاختبار فقط
44
+ trust_remote_code=True,
45
+ token=hf_token,
46
+ torch_dtype=torch.float32,
47
+ low_cpu_mem_usage=True
48
+ )
49
+
50
+ print("✅ تحميل المودل نجح")
51
+ return True
52
+
53
+ except Exception as e:
54
+ print(f"❌ خطأ في تحميل المودل: {e}")
55
+ return False
56
+
57
+ def main():
58
+ print("🚀 اختبار النشر على Hugging Face ZeroGPU")
59
+ print("=" * 50)
60
+
61
+ # اختبار الاستيراد
62
+ if not test_imports():
63
+ sys.exit(1)
64
+
65
+ # اختبار تحميل المودل
66
+ if not test_model_loading():
67
+ sys.exit(1)
68
+
69
+ print("\n🎉 جميع الاختبارات نجحت! التطبيق جاهز للنشر")
70
+ print("\n📋 الملفات المطلوبة للنشر:")
71
+ print("- app.py")
72
+ print("- requirements.txt")
73
+ print("- README.md")
74
+ print("- system_prompt.txt")
75
+
76
+ if __name__ == "__main__":
77
+ main()