Files changed (1) hide show
  1. app.py +0 -83
app.py DELETED
@@ -1,83 +0,0 @@
1
- import gradio as gr
2
- import requests
3
- import uuid
4
-
5
- N8N_WEBHOOK_URL = "https://eisssa107-testn8n.hf.space/webhook/cf41540b-08b9-40f5-96c4-6ba21d049ad1"
6
-
7
- session_id = str(uuid.uuid4())
8
-
9
- def chat(message, history):
10
-
11
- history = history or []
12
-
13
- try:
14
-
15
- response = requests.post(
16
- N8N_WEBHOOK_URL,
17
- json={
18
- "message": message,
19
- "session_id": session_id
20
- },
21
- timeout=30
22
- )
23
-
24
- # اعرض النص الكامل القادم من n8n
25
- bot_reply = f"""
26
- Status: {response.status_code}
27
-
28
- Response:
29
-
30
- {response.text}
31
- """
32
-
33
- except Exception as e:
34
-
35
- bot_reply = f"خطأ:\n{str(e)}"
36
-
37
- history.append(
38
- (
39
- message,
40
- bot_reply
41
- )
42
- )
43
-
44
- return history, ""
45
-
46
-
47
- with gr.Blocks(title="شاتي بوت") as demo:
48
-
49
- gr.Markdown("# 🤖 شاتي بوت\nمساعدك الذكي")
50
-
51
- chatbot = gr.Chatbot(height=500)
52
-
53
- msg = gr.Textbox(
54
- placeholder="اكتب رسالتك...",
55
- label="رسالتك"
56
- )
57
-
58
- with gr.Row():
59
-
60
- send = gr.Button("إرسال 📨")
61
- clear = gr.Button("مسح 🗑️")
62
-
63
- send.click(
64
- chat,
65
- [msg, chatbot],
66
- [chatbot, msg]
67
- )
68
-
69
- msg.submit(
70
- chat,
71
- [msg, chatbot],
72
- [chatbot, msg]
73
- )
74
-
75
- clear.click(
76
- lambda:([],""),
77
- outputs=[chatbot,msg]
78
- )
79
-
80
- demo.launch(
81
- server_name="0.0.0.0",
82
- server_port=7860
83
- )