kawkabelaloom commited on
Commit
3c8b892
·
verified ·
1 Parent(s): 21c3ed0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -0
app.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ import json
4
+
5
+ # رابط النموذج
6
+ MODEL_ID = "kawkabelaloom/astramind"
7
+
8
+ def test_model_directly():
9
+ """اختبار مباشر للنموذج"""
10
+ print("🔍 اختبار تحميل الملفات...")
11
+
12
+ # تحقق من الملفات مباشرة
13
+ base_url = "https://huggingface.co/kawkabelaloom/astramind/raw/main"
14
+
15
+ files_to_check = [
16
+ "config.json",
17
+ "tokenizer.json",
18
+ "model.safetensors.index.json"
19
+ ]
20
+
21
+ for file in files_to_check:
22
+ try:
23
+ response = requests.get(f"{base_url}/{file}", timeout=10)
24
+ print(f"✅ {file}: {response.status_code} ({len(response.text)} chars)")
25
+ except:
26
+ print(f"❌ {file}: غير موجود")
27
+
28
+ print("\n🔍 اختبار Inference...")
29
+
30
+ # جرب API مباشرة
31
+ api_url = f"https://router.huggingface.co/hf-inference/models/{MODEL_ID}"
32
+
33
+ # أولاً بدون token
34
+ response = requests.post(api_url, json={"inputs": "مرحبا"}, timeout=15)
35
+ print(f"📊 بدون Token: {response.status_code}")
36
+
37
+ # إذا مش شغال، جرب مع token
38
+ if response.status_code != 200:
39
+ print("\n🔑 جرب مع Token...")
40
+ # أضف token هنا إذا عندك
41
+ token = "" # ضع token إذا عندك
42
+ if token:
43
+ headers = {"Authorization": f"Bearer {token}"}
44
+ response = requests.post(api_url, headers=headers, json={"inputs": "اهلا"}, timeout=15)
45
+ print(f"📊 مع Token: {response.status_code}")
46
+
47
+ return "✅ تم الاختبار - شاهد النتائج في logs"
48
+
49
+ # واجهة بسيطة
50
+ with gr.Blocks() as demo:
51
+ gr.Markdown("# 🔍 اختبار نموذج Astramind")
52
+ gr.Markdown("جاري اختبار النموذج على Hugging Face...")
53
+
54
+ test_btn = gr.Button("بدء الاختبار")
55
+ output = gr.Textbox(label="النتيجة")
56
+
57
+ test_btn.click(test_model_directly, outputs=output)
58
+
59
+ demo.launch(debug=True)