This project demonstrates function-calling with Python and Ollama, utilizing the Africa's Talking API to send airtime and messages to phone numbers using natural language prompts. Ollama + LLM w/ functions + Natural language = User Interface for non-coders.
# Exploring function calling 🗣️ 🤖 🔉 with Python and ollama 🦙
Function-calling with Python and ollama. We are going to use the Africa's Talking API to send airtime, mobile data, make voice calls, and messages to a phone number using Natural language. Thus, creating an generative ai agent. Other features include: internet search, translation services, Speech to text, Text to Speech.
## Available Services
✅ **Currently Working**: SMS/Messages, Airtime, Voice Calls with Text-to-Speech**
⚠️ **Requires Approval**: Voice Calls (production account), Mobile Data (business approval)
Here are examples of prompts you can use:
- Send airtime to xxxxxxxxx2046 and xxxxxxxxx3524 with an amount of 10 in currency KES
- Send a message to xxxxxxxxx2046 and xxxxxxxxx3524 with a message "Hello, how are you?", using the username "username".
- Dial a USSD code like *123# on xxxxxxxxx2046 *(requires approval)*
- Send 500MB of data to xxxxxxxxx2046 on provider safaricom *(requires business approval)*
- Call xxxxxxxxx2046 from xxxxxxxxx0001 *(requires production account with registered caller ID)*
- **NEW**: Make a voice call from xxxxxxxxx0001 to xxxxxxxxx5678 and say "Hello, this is a test message" *(with callback server setup)*
NB: The phone numbers are placeholders for the actual phone numbers.
You need some VRAM to run this project. You can get VRAM from here or here
We recommend 400MB-8GB of VRAM for this project. It can run on CPU however, I recommend smaller models for this. If you are looking to hosting you can also try railway. For models like Gemma make sure function calling is supported.
FunctionGemma, Mistral 7B, **llama 3.2 3B/1B**, **Qwen 3: 0.6/1.7B**, nemotron-mini 4b and llama3.1 8B are the recommended models for this project. As for the VLM's (Vision Language Models), in the workflow consider using llama3.2-vision or Moondream2 or olm OCR.
Ensure ollama is installed on your laptop/server and running before running this project. You can install ollama from here
Learn mo …