import os import gradio as gr from huggingface_hub import InferenceApi model_id = 'dicta-il/dictalm-7b-instruct' # יצירת API של Hugging Face api_key = os.getenv('HUGGINGFACE_API_KEY', '') generator = InferenceApi(repo_id=model_id, token=api_key) # פונקציית יצירת הטקסט def chat_with_model(history): prompt = history[-1]["content"] try: response = generator(prompt) if isinstance(response, dict) and "generated_text" in response: result = response["generated_text"] else: result = response except Exception as e: result = f"Error: {str(e)}" return history + [{"role": "bot", "content": result}] # יצירת ממשק מתקדם עם Gradio בצורת צ'ט-בוט בסגנון אקדמי with gr.Blocks(theme="default") as demo: gr.HTML("""
ברוכים הבאים לצ'אט האינטראקטיבי שלנו, המאפשר לכם להתנסות בשיחה עם מודל AI מתקדם.