File size: 1,868 Bytes
20da579
 
 
ac49e9d
18a2571
ac49e9d
 
 
 
 
 
 
 
 
 
 
20da579
ac49e9d
 
 
 
 
 
 
 
20da579
 
ac49e9d
20da579
ac49e9d
20da579
ac49e9d
 
 
20da579
ac49e9d
20da579
 
 
ac49e9d
 
 
 
 
 
 
 
 
 
 
20da579
ac49e9d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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()