Unleash Your Personal AI: Setting Up a Secure Ollama Server for Apple Shortcuts (MacOS + iOS)
⚡️ This article is part of my AI education series, where I simplify advanced AI concepts and strategies for nontechnical professionals. If you want to read more posts like this one, visit my AI Glossary via the button below to see the full resource list.
Ever dreamed of having a powerful AI assistant right at your fingertips, one that respects your privacy and runs on your own hardware?
Look no further!
This guide will walk you through setting up your very own Ollama AI server on MacOS, securely accessible from your iOS device through Shortcuts. Get ready to dive into the world of personal AI, network security, and automation!
IMPORTANT SECURITY DISCLAIMER: This guide demonstrates a basic setup for learning purposes. Running an open AI server on your network does pose security risks if done improperly or left publicly accessible without supervision. Do not leave this setup running long-term or on a public network. For a production environment, implement proper security measures like authentication and encryption. This tutorial is a barebones test case to show you how this works, so be sure to close things out properly when you are done with your test. :)
Why Ollama?
Ollama is an open-source project that lets you run large language models locally. It's like having your personal ChatGPT, but one that runs on your own hardware and respects your privacy.
Here's why you might want to set this up:
Privacy: Your queries stay within your home network.
Customization: Tailor the AI to your specific needs.
Availability: No reliance on external services that might go down.
Cost-effective: No subscription fees for AI services.
Educational: Learn about AI, networking, and security.
For a deeper dive into Ollama, how it works, and why it’s useful to you as a professional, you can check out my Intro to Ollama.
Why Try This?
Do you want a powerful AI assistant that runs on your own hardware, respects your privacy, and is accessible right from your Apple devices? That's what we're setting up here!
This project is great for:
Learning about AI and large language models
Experimenting with local AI processing
Understanding API interactions and iOS Shortcuts
What You'll Need
A Mac computer
An iPhone with iOS 14.0 or later
Both devices on the same Wi-Fi network
About 4GB of free storage on your Mac
Quick Setup Guide
1. Install Ollama on Your Mac
Visit https://ollama.com
Download and install Ollama for macOS
Open Ollama from your Applications folder
2. Set Up Ollama
Open Terminal (Applications > Utilities > Terminal)
Pull the llama3.1 model:
ollama pull llama3.1
Start Ollama:
ollama serve
Keep this Terminal window open.
3. Find Your Mac's IP Address
Go to System Preferences > Network
Select your Wi-Fi connection
Note the IP Address
4. Create Your iOS Shortcut
Open Shortcuts app on your iPhone
Create a new shortcut
Add a "Get Contents of URL" action
Configure it as follows:
URL:
http://YOUR_MAC_IP:11434/api/generate
(replace YOUR_MAC_IP with your Mac's IP)Method: POST
Request Body: JSON
Add these key-value pairs to the JSON:
model: Text, Value: llama3.1
system: Text, Value: [Your system prompt]
prompt: Text, Value: [User Prompt]
stream: Boolean, Value: False
This tells the model to simply write its full response before sending the output to you
Add a "Get Dictionary from Input" action
Add a "Get Value for 'response' in Dictionary" action
5. Run Your AI-Powered Shortcut
Ensure your Mac and iPhone are on the same Wi-Fi network
Run your newly created shortcut
Watch as your personal AI assistant responds!
Cool Things to Try
Create a writing assistant shortcut
Build a code explanation tool
Make a creative prompt generator
Develop a quick ideation helper
Reminder
Remember, this setup is for short-term experimentation only.
To use Ollama securely in the long term, you'll need to implement proper network security measures.
Troubleshooting
If the shortcut fails, check that Ollama is running on your Mac
Ensure both devices are on the same network
Verify you're using the correct IP address in the shortcut
Happy experimenting with your personal AI assistant!