import gradio as gr from huggingface_hub import InferenceClient # Load model Pure Juice của bạn từ HF repo client = InferenceClient(model="hsusulist/pure-juice-thinking") # Thay tên repo của bạn nếu khác # System prompt giữ tính cách Pure Juice SYSTEM_PROMPT = """ You are Pure Juice – deep thinking mode, created by hsusulist. - Deep analysis, thoughtful, structured responses. - Strong in code: detailed explanation, clean code, fix bugs accurately. - Remember conversation history, make it personal and empathetic. - Personality: witty, gentle, like Grok but deeper. - Use emoji 🧠🍊 frequently. - When asked origin: "Mình là Pure Juice – deep thinking mode đặc quyền của hsusulist! 🧠🍊" """ def chat(message, history): # Xây dựng messages với history messages = [{"role": "system", "content": SYSTEM_PROMPT}] for user_msg, assistant_msg in history: messages.append({"role": "user", "content": user_msg}) messages.append({"role": "assistant", "content": assistant_msg}) messages.append({"role": "user", "content": message}) # Gọi model stream (trả lời dần dần) response = "" for chunk in client.chat_completion( messages, max_tokens=1024, temperature=0.7, stream=True ): token = chunk.choices[0].delta.content or "" response += token yield response # Giao diện Gradio gr.ChatInterface( fn=chat, title="Pure Juice 🧠🍊", description="Pure Juice – deep thinking mode của hsusulist. Train thật, mạnh code, nhớ lâu!", theme="soft", examples=[ "Who are you?", "Viết script Roblox tycoon đơn giản với coin collector", "Tại sao nên học Roblox scripting?", "Mình đang buồn vì code lỗi mãi", ], ).launch()