-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
47 lines (36 loc) · 1.11 KB
/
example.py
File metadata and controls
47 lines (36 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from qexec import configure, register_exec, call_llm, parse_and_execute
# First, let's define some example functions that simulate home automation
def control_lights(state: bool):
print(f"Lights turned {'ON' if state else 'OFF'}")
def toggle_lights():
print("Lights toggled")
def set_fan_speed(speed: float):
print(f"Fan speed set to {speed}%")
configure(
model="meta-llama/llama-4-scout:free",
api_key="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"
)
# 2. Register commands
register_exec(
"lights-on-ir",
control_lights,
description="Control the lights (ON/OFF)",
type="switch"
)
register_exec(
"lights-toggle-ir",
toggle_lights,
description="Toggle the lights",
type="button"
)
register_exec(
"fan-speed",
set_fan_speed,
description="Set the fan speed percentage",
type="range",
value_range=(0, 100)
)
response = call_llm("can you set the fan to 73 percent")
print("LLM Response:", response)
# Execute the commands
parse_and_execute(response)