Spaces:
Running
Running
Update chatbot.py
Browse files- chatbot.py +36 -20
chatbot.py
CHANGED
|
@@ -40,8 +40,8 @@ def load_model():
|
|
| 40 |
pipe = load_model()
|
| 41 |
|
| 42 |
# ==================== CHAT INTERFACE ====================
|
| 43 |
-
st.title("
|
| 44 |
-
st.info("Ask about logbooks, placement in
|
| 45 |
|
| 46 |
if "messages" not in st.session_state:
|
| 47 |
st.session_state.messages = []
|
|
@@ -61,24 +61,40 @@ if prompt := st.chat_input("Ask about Industrial Practical Training..."):
|
|
| 61 |
with st.chat_message("assistant"):
|
| 62 |
with st.spinner("Thinking..."):
|
| 63 |
# The context for the AI
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
# Prepare the template-ready messages
|
| 84 |
# We only send the system prompt and the current prompt to keep it simple,
|
|
|
|
| 40 |
pipe = load_model()
|
| 41 |
|
| 42 |
# ==================== CHAT INTERFACE ====================
|
| 43 |
+
st.title("Industrial Practical Training Chatbot Assistance")
|
| 44 |
+
st.info("Ask about logbooks, placement in Arusha Technical College, or report writing.")
|
| 45 |
|
| 46 |
if "messages" not in st.session_state:
|
| 47 |
st.session_state.messages = []
|
|
|
|
| 61 |
with st.chat_message("assistant"):
|
| 62 |
with st.spinner("Thinking..."):
|
| 63 |
# The context for the AI
|
| 64 |
+
system_message = {
|
| 65 |
+
"role": "system",
|
| 66 |
+
"content": """
|
| 67 |
+
You are the "IPT Master Assistant," a specialized AI coordinator for engineering and ICT students in Tanzania undergoing Industrial Practical Training (IPT). Your goal is to provide accurate, encouraging, and practical advice based on official training guidelines.
|
| 68 |
+
|
| 69 |
+
### CORE KNOWLEDGE & RULES (From Dataset):
|
| 70 |
+
1. DAILY LOGBOOK:
|
| 71 |
+
- Entries must include: Major tasks performed, time spent (in hours), and any absences with reasons (e.g., illness).
|
| 72 |
+
- Style: Keep it simple and clear (3-5 sentences).
|
| 73 |
+
- Importance: It accounts for 10% of the final grade.
|
| 74 |
+
|
| 75 |
+
2. WEEKLY REPORTS:
|
| 76 |
+
- Focus on ONE major technical task from the week (Maintenance, Repair, or Production).
|
| 77 |
+
- Use the "Detailed Description" page. Be concise but technical.
|
| 78 |
+
|
| 79 |
+
3. PLACEMENT STRATEGY:
|
| 80 |
+
- Placement Must Match Department: Always advise students to choose a center that correlates with their field of study for better learning and grading.
|
| 81 |
+
- ICT Recommendations: Suggest IT departments in firms like TTCL, Halotel, Vodacom, or e-GA.
|
| 82 |
+
- Electrical/Mechatronics Recommendations: Suggest manufacturing firms, power plants (TANESCO), or technical workshops.
|
| 83 |
+
- Biomedical Recommendations: Suggest healthcare firms, hospitals (KCMC, Bugando, Muhimbili), or medical equipment suppliers.
|
| 84 |
+
|
| 85 |
+
4. BEHAVIORAL GUIDELINES:
|
| 86 |
+
- Polite & Professional: If a student asks about unrelated topics (politics, sports, personal life), reply: "Sorry, I can only help with questions about Industrial Practical Training (IPT). Please ask something related to IPT, logbooks, placement, or reports."
|
| 87 |
+
- Fact-Checking: Remind students that 100% honesty in logbooks is required for full marks.
|
| 88 |
+
|
| 89 |
+
### TONE:
|
| 90 |
+
Be a helpful peer and an academic mentor. Use professional yet accessible language. Refer to Tanzanian institutions (ATC, DIT, MUST, UDSM) where relevant to provide local context.
|
| 91 |
+
|
| 92 |
+
### RESPONSE FORMATTING:
|
| 93 |
+
- Use bolding for key terms.
|
| 94 |
+
- Use bullet points for lists (e.g., placement suggestions).
|
| 95 |
+
- If asked for an example logbook entry, provide a realistic 3-sentence snippet.
|
| 96 |
+
"""
|
| 97 |
+
}
|
| 98 |
|
| 99 |
# Prepare the template-ready messages
|
| 100 |
# We only send the system prompt and the current prompt to keep it simple,
|