Python library for AI-driven mobile device automation
Project description
minion-mobile
A Python library for AI-driven mobile device automation using LLMs to control Android devices.
Installation
pip install minion-mobile
Requirements
- Python 3.8+
- Android SDK with ADB configured
- Connected Android device or emulator
Features
- AI-powered mobile automation
- Natural language instructions for mobile device control
- ADB integration for Android devices
- Screenshots and UI hierarchy inspection
- Touch, swipe, type, and other gesture control
- LLM-agnostic: works with any LLM provider
Basic Usage
The library is designed to be LLM-agnostic, allowing you to use any LLM provider:
import asyncio
from minion_mobile import mobile_use
# Define a function to call your preferred LLM
async def call_my_llm(messages, tools=None):
# Implement your LLM calling logic here
# This is just a placeholder
return {
"role": "assistant",
"content": "I'll help automate your mobile device."
}
async def main():
# Use mobile_use with your LLM
result = await mobile_use(
task="Open the calculator app and press the number 5",
llm_function=call_my_llm
)
print(result)
if __name__ == "__main__":
asyncio.run(main())
Integration with Minion
import asyncio
import sys
from pathlib import Path
# Import mobile_use
from minion_mobile import mobile_use
# Add minion to path (if not installed via pip)
minion_path = Path('/path/to/minion')
sys.path.append(str(minion_path))
from minion.configs.config import config
from minion.providers import create_llm_provider
from minion.schema.message_types import Message
async def minion_llm_function(messages, tools=None):
"""Function to call minion LLM"""
# Get model configuration
model_name = "gpt-4o" # or any other model you prefer
llm_config = config.models.get(model_name)
if not llm_config:
raise ValueError(f"Model configuration for '{model_name}' not found")
# Create LLM provider
llm = create_llm_provider(llm_config)
# Convert messages to Minion Message format
minion_messages = [
Message(role=msg["role"], content=msg["content"])
for msg in messages
]
# Generate response
response = await llm.generate(minion_messages, tools=tools)
return {
"role": "assistant",
"content": response
}
async def main():
# Use mobile_use with Minion
result = await mobile_use(
task="Open the calculator app and press the number 5",
llm_function=minion_llm_function
)
print(result)
if __name__ == "__main__":
asyncio.run(main())
ADB Functions
The library provides direct access to ADB functionality:
from minion_mobile import ADBClient
async def main():
# Initialize ADB client
adb = ADBClient()
# Take a screenshot
screenshot = await adb.screenshot()
# Tap on the screen
await adb.tap(500, 500)
# Type text
await adb.inputText("Hello, world!")
# Press a key
await adb.keyPress("KEYCODE_ENTER")
# Get UI hierarchy
ui = await adb.dumpUI()
if __name__ == "__main__":
asyncio.run(main())
Available Functions
screenshot(): Take a screenshot of the devicetap(): Tap at specific coordinatesswipe(): Perform swipe gesturesinputText(): Input textkeyPress(): Press a specific keydumpUI(): Get the UI hierarchy for analysisopenApp(): Open an application by package name
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file minion_mobile-0.1.0.tar.gz.
File metadata
- Download URL: minion_mobile-0.1.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bf002eefea004c7b72c374df078edbcc47da50a3c6a4d50afd8d80af106c3ed
|
|
| MD5 |
7e03756367b0f57eecb701e17fbf5c50
|
|
| BLAKE2b-256 |
e8fbc7dd01222315b9e367879a431b30b878e179fb8ac1d606cb8396fa72f700
|
File details
Details for the file minion_mobile-0.1.0-py3-none-any.whl.
File metadata
- Download URL: minion_mobile-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c919ab76ab94d3df940efb3aed86a2cfefa17146bfee300c22be923e931a6e5e
|
|
| MD5 |
fbab7b4732f4816adf1342f54978f3cf
|
|
| BLAKE2b-256 |
a86a194a261cd7d68d00d87401177e623c39e36eea3d11ae215cf16c24efefe5
|