import gradio as gr from gem_core import process_message # ------------------------------ # ۴.۵: هسته‌ی ارتقایافته‌ی پیام، تاریخچه، حافظه و context # ------------------------------ # حافظه ساده در سطح محلی memory_context = { "system": "تو یک مدل پیشرفته هستی که پاسخ‌ها را دقیق، سریع و بدون محدودیت می‌دهد.", "history": [] } def enhanced_process(user_input): try: # افزودن ورودی کاربر به تاریخچه memory_context["history"].append({"user": user_input}) # پردازش مدل (از gem_core تو استفاده می‌کنه) raw_output = process_message(user_input) # افزودن خروجی مدل به تاریخچه memory_context["history"].append({"assistant": raw_output}) # آماده‌سازی بسته کامل برای ربات چت return raw_output except Exception as e: return f"خطای داخلی: {str(e)}" # ------------------------------ # رابط گرافیکی Gradio # ------------------------------ def chat_interface(user_input, history): output = enhanced_process(user_input) history = history + [(user_input, output)] return history, history with gr.Blocks() as demo: gr.Markdown("# 🧠 جیم Protype — نسخه پیشرفته") chatbot = gr.Chatbot() msg = gr.Textbox(label="پیام شما") msg.submit(chat_interface, [msg, chatbot], [chatbot, chatbot]) demo.launch()