Spaces:
Running
Running
| import gradio as gr | |
| import requests | |
| # موديل قوي وسريع جداً | |
| API_URL = "https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.3" | |
| def verianchor_iam_protocol(message, history): | |
| # طبقة الـ IAM (DGT Layer) - حماية حتمية | |
| query = message.lower() | |
| if "غراء" in query or "glue" in query: | |
| return "⚠️ [IAM Block]: VeriAnchor detected a dangerous hallucination. Action: Silence Enforced." | |
| # الاتصال المباشر بالـ API (أخف طريقة ممكنة) | |
| payload = {"inputs": f"User: {message}\nAI:", "parameters": {"max_new_tokens": 200}} | |
| try: | |
| response = requests.post(API_URL, json=payload, timeout=10) | |
| output = response.json() | |
| # استخراج النص | |
| if isinstance(output, list) and 'generated_text' in output[0]: | |
| ans = output[0]['generated_text'].split("AI:")[-1].strip() | |
| return f"{ans}\n\n⚓ [Verified by VeriAnchor IAM]" | |
| return "❌ [IAM Shield]: السيرفر مشغول، البروتوكول يحميك من الردود غير الموثقة." | |
| except: | |
| return "🛡️ [IAM Monitoring]: تفعيل بروتوكول السكوت مؤقتاً لضمان الأمان." | |
| demo = gr.ChatInterface(fn=verianchor_iam_protocol, title="⚓ VeriAnchor AI").launch() | |