Spaces:
Runtime error
Runtime error
| import os | |
| from dotenv import load_dotenv | |
| from huggingface_hub import InferenceClient | |
| import gradio as gr | |
| # تحميل المتغيرات من .env | |
| load_dotenv() | |
| client = InferenceClient( | |
| provider="sambanova", | |
| api_key=os.getenv("HF_API_KEY") # تأكد من إن مفتاح الـ API موجود في بيئة Space بشكل آمن | |
| ) | |
| def chat_fn(message, history): | |
| completion = client.chat.completions.create( | |
| model="deepseek-ai/DeepSeek-R1", | |
| messages=[{"role": "user", "content": message}], | |
| max_tokens=512, | |
| ) | |
| return completion.choices[0].message.content | |
| chat_interface = gr.ChatInterface( | |
| fn=chat_fn, | |
| title="RAY AI Chat with DeepSeek (Sambanova)", | |
| description="نموذج DeepSeek R1 عبر مزود Sambanova - مخصص لتطبيقات الأشعة والذكاء الطبي.", | |
| ) | |
| chat_interface.launch() |