Views
No views yet
ACTION: open_app(WhatsApp) -> navigate_to_contact('Rahul') -> send_message('I will be late')1import requests
2
3API_URL = 'https://api-inference.huggingface.co/models/vishwajeet456/android-automation-ai'
4HEADERS = {'Authorization': 'Bearer YOUR_HF_TOKEN'}
5
6def get_android_action(command):
7 prompt = f'''Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
8
9### Instruction:
10You are an Android automation assistant. Convert the user's natural language command into the correct Android action.
11
12### Input:
13{command}
14
15### Response:
16'''
17 response = requests.post(API_URL, headers=HEADERS, json={'inputs': prompt, 'parameters': {'max_new_tokens': 150, 'temperature': 0.1}})
18 result = response.json()
19 if isinstance(result, list):
20 text = result[0]['generated_text']
21 return text.split('### Response:')[-1].strip()
22 return str(result)
23
24# Example
25print(get_android_action('Turn on flashlight'))
26# Output: ACTION: toggle_flashlight(state='on')