Logo Lanfrica

joelmwaka/MageziAI

Domain:

digital infrastructure

Record type:

software
Creator:
joe
Host:
A python-based application that enables users in regions with limited internet access to use Large Language Models (LLMs) via SMS. It integrates Africa's Talking APIs, OpenAI, and DeepSeek-R1 models. Messages are saved in a MongoDB enabling the LLMs to track conversations over time in a more natural chat format. # Magezi AI ## Description This Python-based application enables users to access Large Language Models (LLMs) via SMS. It integrates with Africa's Talking to handle SMS reception and response delivery. The application supports two LLM approaches: - OpenAI API: Uses OpenAI's gpt-4o for processing requests. - Local Models: Runs deepseek-r1 models (1.5B, 7B) locally, with potential for larger models depending on compute power. Upon receiving an SMS, the application stores the message in a MongoDB database, processes it using the selected LLM, and then returns an abbreviated response via SMS (due to SMS character limits). The backend is built using FastAPI, and ngrok is used to expose the application for handling Africa's Talking callbacks. ## Features - Seamless SMS-based AI access without internet connectivity. - Choice of LLMs between OpenAI API (```gpt-4o```) or self-hosted ```deepseek-r1``` models. - MongoDB integration for storing prompts and responses. - FastAPI-powered backend with a structured API. - Ngrok tunneling for webhook access. ## Set Up Instructions ### Prerequisites Ensure you have the following installed on your system: - Python 3.12 (Python 3.8+ might be sufficient) - MongoDB (local or cloud-based, e.g., MongoDB Atlas) - Ngrok (for exposing local ports) - Africa's Talking API credentials - OpenAI API Key (if using OpenAI models) ### Installation 1. Clone repository: ```bash git clone github.com cd MageziAI ``` 2. Create and activate virtual environment: ```bash python3 -m venv venv source venv/bin/activate ``` 3. Install dependencies: ```bash pip install -r requirements.txt ``` 4. Set environment variables: Create a ```.env``` file in the project root and add the following variables: ```bash MONGO_DB_URI= MONGO_DB_NAME= OPENAI_API_KEY= OLLAMA_HOST= AT_USERNAME= AT_API_KEY= ASSISTANT_SHORTCODE= ``` **Note**: In the sections "Africa's Talking", "OpenAI", and "MongoDB", you will find instructions on h …