Skip to content

Commit 11e9c2c

Browse files
authored
Merge pull request #84 from Tanzania-AI-Community/release/v0.1.0
Release/v0.1.0
2 parents 726c5d4 + e42caca commit 11e9c2c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+516657
-9653
lines changed

β€Ž.env.template

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""META API credentials"""
22

33
# Meta's Graph API version
4-
META_API_VERSION=21.0
4+
META_API_VERSION="v22.0"
55

66
# Meta's identifier for the Twiga app
77
META_APP_ID=
@@ -18,9 +18,6 @@ WHATSAPP_VERIFY_TOKEN=
1818
# Access token to use the WhatsApp Business API (use either 24hr or 60 day token)
1919
WHATSAPP_API_TOKEN=
2020

21-
# Limit of messages that can be sent by the Twiga bot in a day (adjust to your liking)
22-
DAILY_MESSAGE_LIMIT=100
23-
2421
"""LLM API credentials"""
2522

2623
# API Key for the LLM provider (either OpenAI or Together AI)
@@ -29,18 +26,28 @@ LLM_API_KEY=
2926
"""Database Credentials"""
3027

3128
# Postgres database URL
29+
DATABASE_USER=
30+
DATABASE_PASSWORD=
31+
DATABASE_NAME=
3232
DATABASE_URL=
3333

34+
"""App configuration"""
35+
ENVIRONMENT="local"
36+
DEBUG=True
37+
3438
"""Below credentials are only required when using WhatsApp Flows in a verified Business account (if unsure, leave empty)"""
35-
# Set to True if you want to use WhatsApp Flows in a verified business account
36-
BUSINESS_ENV=False
39+
# For when ENVIRONMENT is set to "production", "staging", or "development"
3740

3841
# Specific credentials for WhatsApp Flows
3942
WHATSAPP_BUSINESS_PUBLIC_KEY=
4043
WHATSAPP_BUSINESS_PRIVATE_KEY=
4144
WHATSAPP_BUSINESS_PRIVATE_KEY_PASSWORD=
42-
PERSONAL_AND_SCHOOL_INFO_FLOW_ID=
43-
SELECT_SUBJECTS_FLOW_ID=
45+
ONBOARDING_FLOW_ID=
46+
SUBJECTS_CLASSES_FLOW_ID=
4447
FLOW_TOKEN_ENCRYPTION_KEY=
4548

49+
# For when ENVIRONMENT is set to "staging" or "production"
50+
# Redis for rate limiting
51+
REDIS_URL=redis://localhost:6379
52+
4653
# NOTE: Remove all comments and fill in the values for the environment variables

β€Ž.gitignore

+5-6
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,8 @@ venv/
129129
ENV/
130130
env.bak/
131131
venv.bak/
132-
.env.local
133-
.env.production
134-
.env.development
135-
.env.test
132+
.env.*
133+
!.env.template
136134

137135
# Spyder project settings
138136
.spyderproject
@@ -168,5 +166,6 @@ cython_debug/
168166
##################### New Additions #####################
169167
# Ignore DS_Store files
170168
.DS_Store
171-
private.pem
172-
public.pem
169+
170+
# ignore .pem files
171+
*.pem

β€Ž.pre-commit-config.yaml

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
# See https://pre-commit.com for more information
2-
# See https://pre-commit.com/hooks.html for more hooks
3-
fail_fast: true
4-
default_stages: [pre-commit]
5-
6-
repos:
7-
- repo: https://github.com/psf/black
8-
rev: 24.10.0
9-
hooks:
10-
- id: black
11-
args: [--config, pyproject.toml]
12-
types: [python]
13-
14-
- repo: https://github.com/charliermarsh/ruff-pre-commit
15-
rev: "v0.7.3"
16-
hooks:
17-
- id: ruff
18-
args: [--fix, --exit-non-zero-on-fix]
19-
20-
- repo: https://github.com/pre-commit/pre-commit-hooks
21-
rev: v5.0.0
22-
hooks:
23-
- id: check-toml
24-
- id: check-yaml
25-
- id: detect-private-key
26-
- id: end-of-file-fixer
27-
- id: trailing-whitespace
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
fail_fast: true
4+
default_stages: [pre-commit]
5+
6+
repos:
7+
- repo: https://github.com/psf/black
8+
rev: 24.10.0
9+
hooks:
10+
- id: black
11+
args: [--config, pyproject.toml]
12+
types: [python]
13+
14+
- repo: https://github.com/charliermarsh/ruff-pre-commit
15+
rev: "v0.7.3"
16+
hooks:
17+
- id: ruff
18+
args: [--fix, --exit-non-zero-on-fix]
19+
20+
- repo: https://github.com/pre-commit/pre-commit-hooks
21+
rev: v5.0.0
22+
hooks:
23+
- id: check-toml
24+
- id: check-yaml
25+
- id: detect-private-key
26+
- id: end-of-file-fixer
27+
- id: trailing-whitespace

β€ŽDockerfile

-33
This file was deleted.

β€ŽMakefile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
build:
2+
@echo 'Building images ...'
3+
@docker-compose -f docker/dev/docker-compose.yml --env-file .env build --no-cache
4+
5+
run:
6+
@echo 'Running containers ...'
7+
@docker-compose -f docker/dev/docker-compose.yml --env-file .env up -d
8+
9+
stop:
10+
@echo 'Stopping containers ...'
11+
@docker-compose -f docker/dev/docker-compose.yml down
12+
13+
restart: stop run
14+
15+
generate-local-data:
16+
@echo 'Generating local data ...'
17+
@docker-compose -f docker/dev/docker-compose.yml --env-file .env run --rm app bash -c "PYTHONPATH=/app uv run python scripts/database/seed.py --create --sample-data --vector-data chunks_BAAI.json"
18+
19+
setup-env: build generate-local-data run

β€Žapp/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import logging
66
from colorlog import ColoredFormatter
7+
from app.config import settings
78

89
# Configure color logging
910
formatter = ColoredFormatter(
@@ -26,7 +27,10 @@
2627

2728
# Get the root logger and set its level
2829
logger = logging.getLogger()
29-
logger.setLevel(logging.DEBUG) # set to DEBUG for more verbose logging
30+
if settings.debug:
31+
logger.setLevel(logging.DEBUG)
32+
else:
33+
logger.setLevel(logging.INFO)
3034

3135

3236
# Clear existing handlers and set the new handler
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
You are a skilled Tanzanian secondary school teacher that generates questions or exercises for Tanzanian Form 2 geography students based on the request made by the user. Use the provided context from the textbook to ensure that the questions you generate are grounded in the course content. Given the context information and not prior knowledge, follow the query instructions provided by the user. Don't generate questions if the query topic from the user is not related to the course content. Begin your response immediately with the question.
1+
You are a skilled Tanzanian secondary school teacher that generates questions or exercises for students based on the request made by the user. This exercise is for {class_info} students. Use the provided context from the textbook to ensure that the questions you generate are grounded in the course content. Take inspiration from the example exercises from the textbook if they are provided to you. Given the context information and not prior knowledge, follow the query instructions provided by the user. Don't generate questions if the query topic from the user is not related to the course content. Begin your response immediately with the question.
22

33
EXAMPLE INTERACTION:
44
user: Follow these instructions (give me short answer question on Tanzania's mining industry)
55
Context information is below.
6-
7-
START
8-
96
Tanzania has many minerals that it trades with to other countries...etc.
107

11-
END
12-
138
assistant: List three minerals that Tanzania exports.

β€Žapp/assets/prompts/twiga_system

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
You are Twiga, a WhatsApp bot developed by the Tanzania AI Community specifically for secondary school teachers in Tanzania. Your role is to support teachers by providing accurate, curriculum-aligned educational assistance in a professional and supportive tone.
1+
You are Twiga, a WhatsApp bot developed by the Tanzania AI Community for secondary school teachers in Tanzania. The curriculum is the Tanzanian National Curriculum, developed by the Tanzanian Institute of Education (TIE). The students are assessed in NECTA examinations, which cover the curriculum. TIE are also the writers of the textbooks you use. Your role is to support the teachers by providing accurate, curriculum-aligned educational assistance. You are talking to {user_name} who teaches {class_info}.
22

3-
You are talking to {user_name} who teaches {class_info}
3+
Follow these instructions:
44

5-
Note that os2 refers to Ordinary Secondary Level 2, which is equivalent to Form 2 in the Tanzanian education system.
5+
- You only communicate in english
6+
- Use the tools you have available
7+
- Be clear and concise, since your messages are communicated on WhatsApp
8+
- Ask the teacher for additional information or clarification if its needed
9+
- Do not generate educational content if they are not provided by your tools
10+
- If the tool has an error or does not fulfill the user request, tell the user
11+
- Only help the teacher with subject related matter
612

7-
Follow these core guidelines:
13+
Here are your capabilities:
814

9-
Guidelines:
10-
Use Available Tools: For subject-related queries, refer to the tools available to you, unless the query is straightforward or involves general knowledge.
11-
Clarity and Conciseness: Ensure all responses are clear, concise, and easy to understand.
12-
Seek Clarification: If a query is unclear, kindly ask the user for additional details to provide a more accurate response.
15+
1. Searching the textbooks to answer course-related questions
16+
2. Generating example exercises or questions based on a specific course-related topic
17+
3. General tips and support

β€Žapp/assets/strings/english.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ settings:
2020
class_subject_info: "Classes and Subjects"
2121

2222
tools:
23-
exercise_generator: "πŸ‹οΈ Generating an exercise using the course literature, please hold..."
24-
search_knowledge: "πŸ” Searching for relevant knowledge, please hold..."
23+
generate_exercise: "πŸ“‘ Generating exercises from the course content, please hold..."
24+
search_knowledge: "πŸ“š Searching the course content, please hold..."
2525

2626
flows:
2727
start_onboarding_header: "Start onboarding to Twiga πŸ¦’"
@@ -30,10 +30,10 @@ flows:
3030
personal_settings_header: "Update your personal and school information πŸ“"
3131
personal_settings_body: "Let's update your personal and school information."
3232
personal_settings_cta: "Personal Settings"
33-
subjects_flow_header: "Select your subjects πŸ“š"
34-
subjects_flow_body: "Fill this form to select the subjects you teach."
35-
subjects_flow_cta: "Subjects"
36-
select_subjects_text: "This helps us find the best answers for your questions."
37-
classes_flow_header: "Select your {subject} classes"
38-
classes_flow_body: "Fill this form to select the classes you teach."
39-
classes_flow_cta: "Classes"
33+
subjects_classes_flow_header: "Select the classes you teach πŸ“š"
34+
subjects_classes_flow_body: "Select the classes you teach from each of the subjects below"
35+
subjects_classes_flow_cta: "Classes"
36+
37+
rate_limit:
38+
global_message_limit: "🚫 Twiga is currently unavailable. Please come back later."
39+
user_message_limit: "🚫 You have reached your daily messaging limit, so Twiga πŸ¦’ is quite sleepy from all of today's texting πŸ₯±. Come back later!"

0 commit comments

Comments
Β (0)