Spaces:
Sleeping
Sleeping
Delete app.py
#2
by Eissa - opened
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283import gradio as grimport requestsimport uuid
N8N_WEBHOOK_URL = "https://eisssa107-testn8n.hf.space/webhook/cf41540b-08b9-40f5-96c4-6ba21d049ad1"
session_id = str(uuid.uuid4())
def chat(message, history):
history = history or []
try:
response = requests.post( N8N_WEBHOOK_URL, json={ "message": message, "session_id": session_id }, timeout=30 )
# اعرض النص الكامل القادم من n8n bot_reply = f"""Status: {response.status_code}
Response:
{response.text}"""
except Exception as e:
bot_reply = f"خطأ:\n{str(e)}"
history.append( ( message, bot_reply ) )
return history, ""
with gr.Blocks(title="شاتي بوت") as demo:
gr.Markdown("# 🤖 شاتي بوت\nمساعدك الذكي")
chatbot = gr.Chatbot(height=500)
msg = gr.Textbox( placeholder="اكتب رسالتك...", label="رسالتك" )
with gr.Row():
send = gr.Button("إرسال 📨") clear = gr.Button("مسح 🗑️")
send.click( chat, [msg, chatbot], [chatbot, msg] )
msg.submit( chat, [msg, chatbot], [chatbot, msg] )
clear.click( lambda:([],""), outputs=[chatbot,msg] )
demo.launch( server_name="0.0.0.0", server_port=7860)app.pyDeleted-83