miktse-chatbot / app.py
michaeltsegaye's picture
Update app.py
10aa464 verified
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()