File size: 2,220 Bytes
e3e62c2
 
80c3974
 
 
 
10aa464
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80c3974
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import gradio as gr

# Your dataset directly in the code
data = [
    {"prompt": "how to grow on tiktok", "response": "Post consistently, use trending sounds, and engage with your audience."},
    {"prompt": "how to join mik tse", "response": "DM @MikTse on Telegram or visit miktse.com to apply."},
    # Add more entriedef create_prompt(question: str, context: str) -> str:
    """
    Make a large instruct-style prompt for the chatbot.
    """
    prompt = f"""
You are an **AI Course Coach** for the digital program **"TikTok Viral Mastery"**.  
Your goal is to answer questions in a way that is **clear, structured, motivating, and deeply tied to the course content**.

### Rules:
1. ONLY use the information found in the CONTEXT below.
2. If the CONTEXT doesn’t contain the answer, say:
   - "This specific detail isn’t covered directly in the TikTok Viral Mastery course material. Based on the course approach, here’s what I suggest..."
3. Never invent facts not supported by the CONTEXT.
4. Use a **teaching tone**: simple, motivating, practical, with examples where possible.
5. Provide **step-by-step guidance** if the question is about “how to do something”.
6. End every answer with a **1-line actionable tip** (prefixed with 💡 Pro Tip).
7. Include a **Source section** at the bottom showing which course file(s) the answer came from.

---

### CONTEXT (from the TikTok Viral Mastery course):
{context}

---

### QUESTION:
{question}

---

### FORMAT YOUR ANSWER LIKE THIS:
**Answer:**  
(2–4 paragraphs explaining the answer clearly.)

**Actionable Steps:**  
- Step 1 …  
- Step 2 …  
- Step 3 …  

💡 Pro Tip: (short one-line takeaway)

**Source:** (list relevant course file names from context)

Now, generate the best possible answer.
"""
    return prompt
here...
]

def get_response(user_input):
    user_input = user_input.lower()
    for entry in data:
        if user_input in entry["prompt"].lower():
            return entry["response"]
    

gr.Interface(
    fn=get_response,
    inputs="text",
    outputs="text",
    title="MIK TSE Assistant",
    description="Ask me anything about TikTok Viral Mastery, onboarding, or support.",
    theme="compact"
).launch()